/* Cachemiss: a circuit board. Matte black board, copper traces, chip packages,
   silkscreen labels, one LED colour per level of the memory hierarchy. */
:root {
  --bg: #0A0D0C;
  --chip: #15181A;
  --chip-hi: #1D2124;
  --edge: #2C3236;
  --copper: #D9A04A;
  --copper-dim: #7C6030;
  --silk: #EFECE0;
  --dim: #94A29A;
  --miss: #FF5247;
  --life: #7CFF6B;
  --l0: #7CFF6B; --l1: #3DE0D0; --l2: #5CA9FF; --l3: #B794FF; --l4: #FFB23E; --l5: #FF6BD6;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --head: "Chakra Petch", "IBM Plex Sans", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --matrix: "Doto", "JetBrains Mono", ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--silk); font-family: var(--sans); font-size: 16px; line-height: 1.5; padding: 0 16px 72px; min-height: 100vh; }
#world { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; }

.top { max-width: 760px; margin: 0 auto; padding: 18px 0 14px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--copper-dim); }
.brand { font-family: var(--matrix); font-weight: 900; font-size: 30px; letter-spacing: 0.04em; color: var(--silk); text-decoration: none; line-height: 1; }
.brand span { color: var(--miss); text-shadow: 0 0 14px rgba(255, 82, 71, 0.55); }
.tag { font-family: var(--mono); font-style: normal; font-weight: 400; font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; margin-left: 10px; padding: 2px 6px; border: 1px solid var(--copper-dim); color: var(--copper); vertical-align: middle; }

main { max-width: 760px; margin: 0 auto; padding-top: 26px; }
section, #d-play, #d-done { display: grid; gap: 16px; }
h1 { font-family: var(--head); font-weight: 700; font-size: clamp(26px, 5.4vw, 40px); line-height: 1.12; margin: 0; text-wrap: balance; text-shadow: 0 2px 22px rgba(0, 0, 0, 0.95), 0 0 3px rgba(0, 0, 0, 0.9); }
h2 { font-family: var(--head); font-weight: 600; font-size: 24px; margin: 0; letter-spacing: 0.01em; }
p { margin: 0; }
.silk { font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--copper); }
.fine { font-size: 13px; color: var(--dim); }
.rule { color: var(--dim); font-size: 14px; max-width: 62ch; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.95); }
.msg { min-height: 1.5em; color: var(--l4); font-family: var(--mono); font-size: 13.5px; }
.prompt { font-size: clamp(30px, 7vw, 50px); }

/* controls */
button, input, select, textarea { font: inherit; color: inherit; border-radius: 0; }
button { cursor: pointer; background: transparent; border: 1px solid var(--copper-dim); color: var(--silk); padding: 10px 16px; font-family: var(--head); font-weight: 600; font-size: 14px; letter-spacing: 0.06em; text-transform: uppercase; }
button:hover:not(:disabled) { border-color: var(--copper); color: var(--copper); }
button:disabled { opacity: 0.35; cursor: default; }
button.primary { background: var(--copper); border-color: var(--copper); color: #14100A; clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px); padding: 12px 22px; }
button.primary:hover:not(:disabled) { background: var(--silk); border-color: var(--silk); color: #14100A; }
button.ghost { border-color: var(--edge); color: var(--dim); padding: 6px 10px; font-family: var(--mono); font-weight: 400; font-size: 11px; }
input[type="text"], select, textarea { background: rgba(13, 17, 16, 0.9); border: 1px solid var(--copper-dim); padding: 11px 13px; min-width: 0; font-family: var(--mono); color: var(--silk); caret-color: var(--copper); }
input[type="text"]:focus, select:focus { outline: none; border-color: var(--copper); box-shadow: 0 0 0 1px var(--copper), 0 0 18px rgba(217, 160, 74, 0.25); }
input::placeholder { color: #5E6B64; }
button:focus-visible, a:focus-visible, textarea:focus-visible { outline: 2px solid var(--silk); outline-offset: 2px; }
button.primary:focus-visible { outline-offset: -5px; outline-color: #14100A; }
.field { display: grid; gap: 6px; max-width: 320px; }
.name-field { margin-bottom: 10px; }
.name-box { position: relative; display: block; }
.name-box input { width: 100%; padding-right: 38px; border-style: dashed; cursor: text; }
.name-box input:hover { border-color: var(--copper); }
.name-box input::placeholder { color: #8A968F; font-style: italic; }
.name-box input:focus::placeholder { color: #4E5852; }
.pencil { position: absolute; right: 12px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); fill: none; stroke: var(--copper); stroke-width: 1.4; stroke-linejoin: round; pointer-events: none; opacity: 0.8; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row.spread { justify-content: space-between; }
.row.big input { flex: 1 1 200px; font-size: 20px; padding: 15px; }
.row.big button { padding: 16px 26px; font-size: 16px; }
#code { width: 6.6em; text-transform: uppercase; letter-spacing: 0.25em; }

/* chip package: dark body, copper pins top and bottom, pin-1 dot */
.chip { position: relative; background: linear-gradient(rgba(29, 33, 36, 0.94), rgba(21, 24, 26, 0.95)); border: 1px solid var(--edge); border-radius: 5px; padding: 18px; display: grid; gap: 12px; align-content: start; margin-block: 7px; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 10px 30px rgba(0, 0, 0, 0.45); }
.chip::before, .chip::after { content: ""; position: absolute; left: 14px; right: 14px; height: 6px; background: repeating-linear-gradient(90deg, var(--copper) 0 7px, transparent 7px 17px); opacity: 0.8; }
.chip::before { top: -7px; }
.chip::after { bottom: -7px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); gap: 18px; }
.card { background-image: radial-gradient(circle at 14px 14px, #3A4146 0 4px, transparent 5px), linear-gradient(rgba(29, 33, 36, 0.94), rgba(21, 24, 26, 0.95)); padding-top: 30px; }

/* memory hierarchy */
.hier { position: relative; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(4px, 1.4vw, 12px); }
.hier::before { content: ""; position: absolute; left: 4%; right: 4%; top: 50%; height: 2px; background: var(--copper-dim); }
.lvl { --c: var(--dim); position: relative; display: grid; justify-items: center; gap: 3px; padding: 10px 2px 8px; background: rgba(16, 19, 20, 0.88); border: 1px solid var(--edge); border-radius: 4px; transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s; }
.lvl[data-l="0"] { --c: var(--l0); } .lvl[data-l="1"] { --c: var(--l1); } .lvl[data-l="2"] { --c: var(--l2); }
.lvl[data-l="3"] { --c: var(--l3); } .lvl[data-l="4"] { --c: var(--l4); } .lvl[data-l="5"] { --c: var(--l5); }
.lvl .led { width: 9px; height: 9px; border-radius: 50%; background: #2A3033; }
.lvl b { font-family: var(--head); font-weight: 700; font-size: clamp(13px, 3.4vw, 19px); letter-spacing: 0.04em; color: var(--dim); }
.lvl i { font-family: var(--mono); font-style: normal; font-size: clamp(8px, 2.1vw, 10.5px); color: #5E6B64; white-space: nowrap; }
.lvl.miss { border-color: rgba(255, 82, 71, 0.6); }
.lvl.miss .led { background: var(--miss); box-shadow: 0 0 10px var(--miss); }
.lvl.miss b { color: #7A4A46; text-decoration: line-through; }
.lvl.hit { border-color: var(--c); box-shadow: 0 0 0 1px var(--c), 0 0 26px -4px var(--c); transform: translateY(-3px); }
.lvl.hit .led { background: var(--c); box-shadow: 0 0 12px var(--c); }
.lvl.hit b { color: var(--c); }
.lvl.hit i { color: var(--silk); }
.hier.legend .lvl.hit { transform: none; box-shadow: none; }
.hier.compact .lvl { padding: 6px 2px 5px; }
.hier.compact .lvl i { display: none; }
.legend-note { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; color: var(--dim); margin-top: -8px; }

.badge { --c: var(--dim); display: inline-block; min-width: 3.6em; text-align: center; font-family: var(--head); font-weight: 700; font-size: 12px; letter-spacing: 0.06em; padding: 1px 7px; border: 1px solid var(--c); color: var(--c); border-radius: 3px; }
.badge.l0 { --c: var(--l0); } .badge.l1 { --c: var(--l1); } .badge.l2 { --c: var(--l2); } .badge.l3 { --c: var(--l3); } .badge.l4 { --c: var(--l4); } .badge.l5 { --c: var(--l5); }
.badge.none { --c: #5E6B64; }

/* reveal */
.found { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 18px; }
.found-where { font-family: var(--head); font-weight: 700; font-size: clamp(20px, 5vw, 30px); }
.found-bits { font-family: var(--mono); font-size: 13px; color: var(--dim); }
.found-bits b { font-family: var(--matrix); font-weight: 900; font-size: 40px; color: var(--silk); margin-right: 6px; line-height: 1; }
.readout { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px 16px; margin: 0; padding-top: 12px; border-top: 1px dashed var(--edge); }
.readout dt { font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--copper); }
.readout dd { margin: 3px 0 0; font-weight: 600; font-size: 17px; overflow-wrap: anywhere; }
.stamp { display: inline-block; font-family: var(--mono); font-weight: 600; font-size: 10.5px; letter-spacing: 0.14em; padding: 1px 6px; border: 2px solid var(--l4); color: var(--l4); transform: rotate(-4deg); margin-left: 8px; }
.tagchip { display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; padding: 1px 6px; border: 1px solid var(--life); color: var(--life); margin-left: 8px; }

/* Relay the moth */
.buddy { display: flex; align-items: center; gap: 14px; }
.moth { width: 58px; height: 44px; flex: none; filter: drop-shadow(0 0 10px rgba(217, 160, 74, 0.35)); }
.moth .wing path { fill: #C9B383; stroke: #6F5D3A; stroke-width: 1; }
.moth .wing circle { fill: #6F5D3A; }
.moth .body { fill: #EADFC2; }
.moth .ant { fill: none; stroke: #EADFC2; stroke-width: 1.2; stroke-linecap: round; }
.moth .wl { transform-origin: 30px 26px; animation: flap 2.6s ease-in-out infinite; }
.moth .wr { transform-origin: 34px 26px; animation: flap 2.6s ease-in-out infinite; }
@keyframes flap { 0%, 84%, 100% { transform: scaleX(1); } 88%, 96% { transform: scaleX(0.55); } 92% { transform: scaleX(0.9); } }
.say { position: relative; font-family: var(--mono); font-size: 13px; color: var(--silk); background: rgba(16, 19, 20, 0.88); border: 1px solid var(--edge); border-radius: 4px; padding: 9px 12px; max-width: 56ch; }
.buddy.small .moth { width: 44px; height: 33px; }
.buddy.excited .moth .wl, .buddy.excited .moth .wr { animation-duration: 0.35s; }

/* timers */
.ttl { display: flex; align-items: center; gap: 12px; min-height: 22px; }
.bar { flex: 1; height: 10px; border: 1px solid var(--copper-dim); background: rgba(13, 17, 16, 0.9); }
.bar-fill { height: 100%; width: 100%; background: linear-gradient(90deg, var(--miss), var(--l4) 45%, var(--copper)); transform-origin: left center; }
.ttl-text { font-family: var(--mono); font-size: 12.5px; color: var(--dim); }
.ttl-text.live::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--l4); box-shadow: 0 0 10px var(--l4); margin-right: 8px; animation: pulse 0.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.15; } }

/* seats: each player is a small package */
.seats { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.seat { position: relative; display: grid; gap: 4px; padding: 10px 12px; background: rgba(16, 19, 20, 0.88); border: 1px solid var(--edge); border-radius: 4px; min-width: 0; }
.seat-name { font-family: var(--head); font-weight: 600; font-size: 16px; overflow-wrap: anywhere; }
.seat-sub { font-family: var(--mono); font-size: 10.5px; color: var(--dim); }
.lives { display: inline-flex; gap: 5px; }
.life { width: 10px; height: 10px; border-radius: 50%; background: #2A3033; }
.life.on { background: var(--life); box-shadow: 0 0 8px var(--life); }
.seat.turn { border-color: var(--copper); box-shadow: 0 0 0 1px var(--copper), 0 0 28px -6px var(--copper); }
.seat.turn .seat-sub { color: var(--copper); }
.seat.out { opacity: 0.4; }
.seat.out .seat-name { text-decoration: line-through; }
.seat.off .seat-name::after { content: " (away)"; font-family: var(--mono); font-weight: 400; font-size: 11px; color: var(--dim); }
.settings { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.settings .field { max-width: none; }
.code { font-family: var(--matrix); font-weight: 900; letter-spacing: 0.18em; font-size: clamp(54px, 16vw, 104px); line-height: 1; color: var(--copper); text-shadow: 0 0 30px rgba(217, 160, 74, 0.35); }
.total { font-family: var(--matrix); font-weight: 900; font-size: clamp(60px, 16vw, 104px); line-height: 1; }
.total small { font-family: var(--mono); font-weight: 400; font-size: 14px; color: var(--dim); margin-left: 12px; }

.typing { min-height: 1.4em; font-family: var(--mono); font-size: 13px; color: var(--dim); overflow-wrap: anywhere; }
.banner { padding: 16px 18px; border: 2px solid var(--miss); color: var(--miss); background: rgba(255, 82, 71, 0.08); font-family: var(--head); font-weight: 700; font-size: clamp(20px, 5vw, 28px); letter-spacing: 0.03em; text-shadow: 0 0 18px rgba(255, 82, 71, 0.5); }
.shake { animation: shake 0.25s linear; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.last-line { font-family: var(--mono); font-size: 13.5px; overflow-wrap: anywhere; }
.last-line b { font-family: var(--head); font-size: 17px; }

.results, .log { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.log:empty { display: none; }
.results li, .log li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; align-items: center; padding: 9px 12px; background: rgba(16, 19, 20, 0.88); border: 1px solid var(--edge); border-radius: 4px; }
.results .q, .log .who { grid-column: 1 / -1; font-family: var(--mono); font-size: 11px; color: var(--dim); }
.results .a, .log .what { font-weight: 600; overflow-wrap: anywhere; }
.results .b, .log .bits { font-family: var(--mono); font-size: 12px; white-space: nowrap; color: var(--dim); }
.log li.fresh { border-color: var(--copper-dim); }
.log-title { margin-top: 6px; }
.share { width: 100%; font-family: var(--mono); font-size: 12.5px; background: rgba(13, 17, 16, 0.9); border: 1px solid var(--edge); padding: 10px; resize: vertical; }

@media (prefers-reduced-motion: reduce) {
  .moth .wl, .moth .wr, .ttl-text.live::before, .shake { animation: none; }
  .lvl { transition: none; }
}

/* where you are in the world */
.hud2 { position: fixed; left: max(16px, env(safe-area-inset-left, 0px)); bottom: 14px; display: flex; gap: 12px; align-items: baseline; font-family: var(--mono); font-size: 12px; color: var(--silk); pointer-events: none; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.95); }
@media (max-width: 700px) { .hud2.idle { display: none; } }   /* on phones the idle label covers the buttons */
.hud2 b { font-family: var(--head); font-weight: 700; font-size: 22px; letter-spacing: 0.1em; }
.flight { font-family: var(--mono); font-size: 15px; color: var(--silk); text-shadow: 0 1px 10px rgba(0, 0, 0, 0.95); }
.flight b { color: var(--copper); }
#d-reached { color: var(--copper); }

/* pressure: the holder's seat rattles as the TTL runs down */
body.hot .seat.turn { animation: jitter 0.2s linear infinite; }
body.critical .seat.turn { animation-duration: 0.09s; border-color: var(--miss); box-shadow: 0 0 0 1px var(--miss), 0 0 34px -4px var(--miss); }
body.critical .seat.turn .seat-sub, body.critical .ttl-text { color: var(--miss); }
body.critical .ttl-text.live::before { background: var(--miss); box-shadow: 0 0 12px var(--miss); animation-duration: 0.25s; }
@keyframes jitter { 0% { transform: translate(0, 0); } 25% { transform: translate(2px, -1px); } 50% { transform: translate(-2px, 1px); } 75% { transform: translate(1px, 2px); } 100% { transform: translate(0, 0); } }
@media (prefers-reduced-motion: reduce) { body.hot .seat.turn { animation: none; } }

/* party: an empty stage in the layout where the network is drawn on the canvas behind */
.arena { height: clamp(250px, 44vh, 430px); pointer-events: none; }

/* compact landing card, so the world stays visible under it */
.reveal { gap: 10px; padding: 14px 16px; }
.facts { font-family: var(--mono); font-size: 13px; color: var(--dim); overflow-wrap: anywhere; }
.facts b { color: var(--silk); font-family: var(--sans); font-size: 16px; font-weight: 600; }
.reveal .found-bits b { font-size: 34px; }
.reveal .buddy .say { padding: 6px 10px; font-size: 12.5px; }
@media (max-width: 600px) { .reveal .buddy .moth { display: none; } }

/* fixed shading over the world: dark behind the text at the top, vignette at the edges */
#shade { position: fixed; inset: 0; z-index: -1; pointer-events: none; background:
  linear-gradient(rgba(9, 12, 11, 0.82), rgba(9, 12, 11, 0) 50%),
  radial-gradient(ellipse at 50% 60%, rgba(0, 0, 0, 0) 35%, rgba(0, 0, 0, 0.55) 100%); }

/* lobby: the link is the point */
.invite { font-family: var(--mono); font-size: 15px; color: var(--silk); overflow-wrap: anywhere; user-select: all; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.95); }
.options { border: 1px solid var(--edge); background: rgba(16, 19, 20, 0.88); border-radius: 4px; padding: 10px 14px; }
.options summary { cursor: pointer; font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--copper); }
.options .settings { display: grid; gap: 12px; margin-top: 12px; }

/* ---------- lobby and party: everything on one screen ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
body.fit { padding-bottom: 0; height: 100dvh; overflow: hidden; display: flex; flex-direction: column; }
body.fit main { flex: 1; min-height: 0; width: 100%; padding-top: 12px; padding-bottom: 12px; display: flex; flex-direction: column; }
body.fit .top { width: 100%; padding: 12px 0 10px; }
body.fit .brand { font-size: 24px; }
section.fit:not([hidden]) { display: flex; flex-direction: column; gap: 10px; flex: 1; min-height: 0; }
section.fit .arena { flex: 1 1 auto; height: auto; min-height: 150px; }

.lobby-top { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 10px 20px; }
.lobby-actions { flex-wrap: wrap; }
#v-lobby .code { font-size: clamp(34px, 8vw, 52px); }
#v-lobby .msg:empty { display: none; }
#v-lobby .options { margin-top: auto; }

#p-play { display: grid; gap: 8px; }
#v-party .prompt { font-size: clamp(24px, 5.4vw, 40px); }
#v-party .rule { font-size: 13px; }
#v-party .row.big input { font-size: 18px; padding: 12px; }
.status-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; min-height: 1.6em; }
.status-line .msg, .status-line .typing { min-height: 0; }
.status-line .msg:empty, .status-line .typing:empty { display: none; }

.stage { position: relative; flex: 1 1 auto; min-height: 150px; display: flex; flex-direction: column; }
.stage .arena { flex: 1; min-height: 0; height: auto; }
.stage .banner { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; }

.over { display: grid; gap: 10px; padding: 12px 14px; }
.over h2 { font-size: clamp(18px, 4.4vw, 24px); }
.results.compact { grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); max-height: 34vh; overflow: auto; }
.results.compact li { padding: 6px 10px; }

/* the answer log: the latest few, one line each */
#v-party .log { gap: 4px; max-height: 6.6em; overflow: hidden; flex: none; }
#v-party .log li { grid-template-columns: auto minmax(0, 1fr) auto; padding: 4px 10px; font-size: 14px; }
#v-party .log .who { grid-column: auto; font-size: 11px; max-width: 12ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#v-party .log .what { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#v-party .log li:not(.fresh) { opacity: 0.7; }
@media (max-height: 700px) { #v-party .log li:nth-child(n+3) { display: none; } #v-party .rule { display: none; } }

/* ---------- open rooms ---------- */
.open-rooms { display: grid; gap: 8px; }
.room-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.room-list li { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 8px 12px; background: rgba(16, 19, 20, 0.88); border: 1px solid var(--edge); border-radius: 4px; }
.room-list .rn { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-list .rp { font-family: var(--mono); font-size: 12px; color: var(--dim); }
.room-list button { padding: 6px 12px; }
.room-list .empty { display: block; color: var(--dim); font-size: 13px; }
.seats-mini { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 4px; }
.seats-mini li { display: flex; justify-content: space-between; align-items: center; gap: 10px; font-size: 14px; }

/* ---------- chat ---------- */
.chat { position: fixed; right: 16px; bottom: 16px; z-index: 5; width: min(320px, calc(100vw - 32px)); display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.chat-toggle { background: rgba(16, 19, 20, 0.95); }
.chat-body { display: none; width: 100%; background: rgba(16, 19, 20, 0.95); border: 1px solid var(--edge); border-radius: 6px; padding: 8px; gap: 6px; flex-direction: column; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); }
.chat.open .chat-body { display: flex; }
.chat-log { list-style: none; margin: 0; padding: 0; max-height: 34vh; min-height: 60px; overflow-y: auto; font-size: 14px; display: grid; gap: 3px; align-content: start; overflow-wrap: anywhere; }
.chat-log .cn { color: var(--copper); cursor: pointer; font-weight: 600; }
.chat-log:empty::before { content: 'Nothing yet. Say hi.'; color: var(--dim); font-size: 13px; }
.reacts { display: flex; flex-wrap: wrap; gap: 4px; }
.reacts button { padding: 3px 7px; font-size: 15px; font-family: inherit; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; padding: 8px 10px; font-size: 14px; }
.chat-form button { padding: 8px 12px; }
@media (min-width: 1180px) {           /* wide screens: chat lives in the empty right margin */
  .chat { top: 80px; bottom: auto; width: calc((100vw - 760px) / 2 - 40px); max-width: 340px; }
}
.lobby-name { max-width: 260px; }
.lobby-name input { padding-top: 8px; padding-bottom: 8px; }

/* ---------- avatar picker ---------- */
.avatar-pick { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.avatar-pick .silk { width: 100%; }
.avatar-pick .devices, .avatar-pick .swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-pick .dev { width: 40px; height: 40px; padding: 7px; border-color: var(--edge); background: rgba(13, 17, 16, 0.9); color: var(--dim); }
.avatar-pick .dev svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linejoin: round; stroke-linecap: round; }
.avatar-pick .dev.on { border-color: var(--av); color: var(--av); box-shadow: 0 0 12px color-mix(in srgb, var(--av) 35%, transparent); }
.avatar-pick .sw { width: 22px; height: 22px; padding: 0; border-radius: 50%; border: 2px solid transparent; background: var(--sw); box-shadow: 0 0 8px color-mix(in srgb, var(--sw) 50%, transparent); }
.avatar-pick .sw.on { border-color: var(--silk); }
.avatar-pick.compact .dev { width: 32px; height: 32px; padding: 5px; }
.avatar-pick.compact .silk { width: auto; margin-right: 4px; }
.avatar-pick.compact .sw { width: 18px; height: 18px; }
