/* Playfield — dark-first arcade table: ink ground with a faint board-grid,
   coral X / aqua O as the two player colours, amber for primary actions. */
:root {
  --bg: #0d0f16;
  --bg-grid: rgba(150, 160, 210, .055);
  --panel: #151824;
  --panel-2: #1c2030;
  --panel-3: #252a3d;
  --line: #2a2f44;
  --fg: #eceef6;
  --muted: #9298b2;
  --faint: #636a87;
  --x: #ff6b7a;
  --o: #46d4d0;
  --amber: #ffc24b;
  --p2: #a98bff;
  --p3: #8fd35b;
  --on-amber: #1b1406;
  --accent: var(--amber);          /* whose turn it is / what you can click */
  --pink: #f472b6;
  --seat0: var(--x); --seat1: var(--o); --seat2: var(--p2); --seat3: var(--p3); --seat4: var(--amber); --seat5: var(--pink);
  --good: #5fd68a;
  --bad: #ff7a6b;
  --shadow: 0 18px 50px -20px rgba(0, 0, 0, .7);
  --font: ui-rounded, "SF Pro Rounded", system-ui, -apple-system, "Segoe UI Variable Text", "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --r: 14px;
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f4f8; --bg-grid: rgba(40, 50, 110, .06); --panel: #ffffff; --panel-2: #f1f2f7; --panel-3: #e5e7f0;
    --line: #dcdfea; --fg: #151826; --muted: #5a6080; --faint: #8d93ad; --x: #e5435a; --o: #0f9e9a;
    --amber: #ffbf3a; --on-amber: #1b1406; --good: #1f9d55; --bad: #d64534; --p2: #7a5af0; --p3: #4f9a1f;
    --shadow: 0 18px 40px -22px rgba(30, 40, 90, .35); color-scheme: light;
  }
}
:root[data-theme="light"] {
  --bg: #f3f4f8; --bg-grid: rgba(40, 50, 110, .06); --panel: #ffffff; --panel-2: #f1f2f7; --panel-3: #e5e7f0;
  --line: #dcdfea; --fg: #151826; --muted: #5a6080; --faint: #8d93ad; --x: #e5435a; --o: #0f9e9a;
  --amber: #ffbf3a; --on-amber: #1b1406; --good: #1f9d55; --bad: #d64534; --p2: #7a5af0; --p3: #4f9a1f;
  --shadow: 0 18px 40px -22px rgba(30, 40, 90, .35); color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; font: 15px/1.55 var(--font); color: var(--fg); background-color: var(--bg);
  background-image: linear-gradient(var(--bg-grid) 1px, transparent 1px), linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 44px 44px; background-position: -1px -1px;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
svg { display: block; }
button, input, select { font: inherit; color: inherit; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.app {
  max-width: 1180px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; gap: 28px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(14px, env(safe-area-inset-top, 0px)) max(18px, env(safe-area-inset-bottom, 0px));
}

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--fg); text-decoration: none; font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.brand svg { width: 32px; height: 32px; }
.brand-tile { fill: var(--panel-2); stroke: var(--line); }
.brand-x { stroke: var(--x); stroke-width: 3; stroke-linecap: round; fill: none; }
.brand-o { stroke: var(--o); stroke-width: 3; fill: none; }
.topbar-right { display: flex; align-items: center; gap: 8px; min-width: 0; }
.stat { display: inline-flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--muted); padding: 6px 10px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); white-space: nowrap; }
.stat b { color: var(--fg); font-weight: 650; font-variant-numeric: tabular-nums; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); }
.online-live .dot { background: var(--good); box-shadow: 0 0 0 3px color-mix(in srgb, var(--good) 25%, transparent); }
#ping.good { color: var(--good); } #ping.ok { color: var(--amber); } #ping.bad { color: var(--bad); }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 4px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); cursor: pointer; max-width: 190px; min-width: 0; }
.chip:hover { border-color: var(--faint); }
.chip > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .88rem; }
.avatar { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; font-size: .8rem; color: var(--on-amber); background: var(--amber); }
.icon-btn { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); cursor: pointer; flex: none; }
.icon-btn svg { width: 18px; height: 18px; fill: var(--muted); }
.icon-btn:hover svg { fill: var(--fg); }
.lang-btn { font: 700 .74rem/1 var(--mono); letter-spacing: .04em; color: var(--muted); }
.lang-btn:hover { color: var(--fg); }

.banner { padding: 10px 14px; border-radius: 10px; background: color-mix(in srgb, var(--amber) 14%, var(--panel)); border: 1px solid color-mix(in srgb, var(--amber) 40%, var(--line)); font-size: .9rem; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 16px; border-radius: 11px; border: 1px solid var(--line); background: var(--panel-2); font-weight: 650; cursor: pointer; transition: transform .12s ease, background-color .15s, border-color .15s; white-space: nowrap; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn:hover:not(:disabled) { border-color: var(--faint); background: var(--panel-3); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--amber); color: var(--on-amber); border-color: transparent; }
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--amber) 88%, #fff); border-color: transparent; }
.btn.primary svg { fill: currentColor; stroke: none; }
.btn.ghost { background: transparent; }
.btn.big { padding: 13px 22px; font-size: 1.02rem; border-radius: 13px; }
.btn.busy { pointer-events: none; opacity: .75; }

/* ---------- lobby ---------- */
.lobby { display: flex; flex-direction: column; gap: 22px; flex: 1; }
.home { display: flex; flex-direction: column; gap: 26px; padding-top: 8px; }
.hero { display: flex; flex-direction: column; gap: 14px; }
.eyebrow { margin: 0; font: 600 .72rem/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.hero h1 { margin: 0; font-size: clamp(2rem, 4.6vw, 3.2rem); line-height: 1.04; letter-spacing: -.045em; font-weight: 850; text-wrap: balance; }
.hero h1 .dim { color: var(--muted); }
.lede { margin: 0; color: var(--muted); max-width: 60ch; font-size: 1.02rem; }
.game-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
.gtile { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-radius: 18px; border: 1px solid var(--line); background: var(--panel); box-shadow: var(--shadow);
  transition: transform .15s, border-color .15s; }
.gtile:hover { transform: translateY(-3px); border-color: var(--amber); }
.gtile.soon { opacity: .55; border-style: dashed; box-shadow: none; } .gtile.soon:hover { transform: none; border-color: var(--line); }
.gt-top { display: flex; align-items: center; gap: 12px; }
.gt-top h3 { margin: 0; font-size: 1.08rem; letter-spacing: -.01em; }
.gt-top small, .gh-meta { color: var(--muted); font-size: .8rem; }
.gt-hint { margin: 0; color: var(--muted); font-size: .92rem; line-height: 1.45; flex: 1; }
.gt-foot { display: flex; align-items: center; gap: 8px; }
.gt-count { margin-right: auto; font: 600 .74rem/1 var(--mono); color: var(--faint); }
.gt-count.on { color: var(--good, #4ade80); }
.btn.danger { background: color-mix(in srgb, var(--bad) 20%, var(--panel-2)); border-color: var(--bad); color: var(--bad); }
.btn.small { padding: 7px 12px; font-size: .86rem; border-radius: 10px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.gi { width: 40px; height: 40px; flex: none; border-radius: 10px; background: var(--panel-2); display: grid; place-items: center; }
.gi svg { width: 26px; height: 26px; }
.gi.big { width: 52px; height: 52px; border-radius: 14px; } .gi.big svg { width: 34px; height: 34px; }
.game-page { display: flex; flex-direction: column; gap: 18px; }
.crumbs { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.game-tabs { display: flex; gap: 6px; overflow-x: auto; padding: 2px; flex: 1; min-width: 0; scrollbar-width: thin; }
.gtab { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px 4px 4px; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); text-decoration: none; font-size: .82rem; white-space: nowrap; }
.gtab .gi { width: 26px; height: 26px; border-radius: 50%; } .gtab .gi svg { width: 17px; height: 17px; }
.gtab[aria-selected="true"] { border-color: var(--amber); color: var(--fg); }
.gtab:hover { color: var(--fg); }
@media (max-width: 720px) { .gtab-name { display: none; } .gtab { padding: 4px; } }
.game-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding: 18px; border-radius: 18px; background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); }
.gh-text { flex: 1; min-width: 220px; display: flex; flex-direction: column; gap: 4px; }
.gh-text h2 { margin: 0; font-size: 1.5rem; letter-spacing: -.03em; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; }
.rules-dlg { max-width: min(680px, calc(100vw - 24px)); width: 100%; padding: 0; }
.rules-box { display: flex; flex-direction: column; gap: 14px; padding: 20px; max-height: min(86vh, 800px); }
.rules-top { display: flex; gap: 14px; align-items: center; } .rules-top h3 { margin: 0 0 4px; } .rules-top .dlg-sub { margin: 0; }
.rules-body { overflow-y: auto; display: grid; gap: 14px; padding-right: 6px; }
.rules-body h4 { margin: 0 0 6px; font: 700 .72rem/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--amber); }
.rules-body ul { margin: 0; padding-left: 1.1em; display: grid; gap: 5px; font-size: .94rem; line-height: 1.45; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: confetti-fall 2.4s ease-in forwards; }
@keyframes confetti-fall { to { transform: translate(var(--dx), 105vh) rotate(var(--rot)); opacity: .9; } }
@media (prefers-reduced-motion: reduce) { .gtile { transition: none; } .confetti { display: none; } }

.rooms { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 18px; box-shadow: var(--shadow); min-width: 0; display: flex; flex-direction: column; gap: 14px; }
.rooms-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.rooms-head h2 { margin: 0; font-size: 1.1rem; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.count { font: 600 .75rem/1 var(--mono); padding: 4px 7px; border-radius: 999px; background: var(--panel-3); color: var(--muted); }
.search { display: flex; align-items: center; gap: 8px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); flex: 1 1 180px; max-width: 260px; }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--faint); stroke-width: 2; flex: none; }
.search input { border: 0; background: transparent; padding: 8px 0; outline: none; width: 100%; min-width: 0; }
.room-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.room-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto auto; align-items: center; gap: 12px; padding: 10px 10px 10px 12px; border-radius: 12px; background: var(--panel-2); border: 1px solid transparent; transition: border-color .15s; }
.room-row:hover { border-color: var(--line); }
.room-row.new { animation: rowIn .35s ease-out; }
.room-row .gi { width: 38px; height: 38px; border-radius: 10px; background: var(--panel-3); display: grid; place-items: center; }
.room-row .gi svg { width: 22px; height: 22px; }
.room-row .nm { min-width: 0; }
.room-row .nm b { display: flex; align-items: center; gap: 6px; font-size: .95rem; overflow: hidden; white-space: nowrap; }
.room-row .nm b span { overflow: hidden; text-overflow: ellipsis; }
.room-row .nm b svg { width: 14px; height: 14px; flex: none; fill: var(--muted); }
.room-row .nm small { color: var(--muted); font-size: .8rem; }
.badge { font: 700 .64rem/1 var(--mono); letter-spacing: .06em; padding: 3px 5px; border-radius: 5px; background: var(--panel-3); color: var(--muted); text-transform: uppercase; flex: none; }
.seats { display: flex; gap: 4px; }
.seats i { width: 9px; height: 9px; border-radius: 3px; background: var(--panel-3); border: 1px solid var(--line); }
.seats i.on { background: var(--good); border-color: transparent; }
.room-row .btn { padding: 7px 14px; font-size: .88rem; }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.empty svg { width: 54px; height: 54px; fill: none; stroke: var(--line); stroke-width: 2; }
.empty p { margin: 0; max-width: 34ch; }
.empty b { color: var(--fg); }
@keyframes rowIn { from { opacity: .3; transform: translateY(-4px); } to { opacity: 1; transform: none; } }

/* ---------- room ---------- */
.room { display: flex; flex-direction: column; gap: 22px; flex: 1; }
.room-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "leave title invite"; align-items: center; gap: 14px; }
#leave-btn { grid-area: leave; justify-self: start; } .room-title { grid-area: title; } .room-btns { grid-area: invite; justify-self: end; display: flex; gap: 8px; }
.room-title { min-width: 0; text-align: center; }
.room-title h2 { margin: 0; font-size: 1.35rem; letter-spacing: -.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-meta { color: var(--muted); font-size: .85rem; }
.lock-tag { margin-left: 4px; }
.room-body { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.side-extra:empty { display: none; }
.room.wide .board-host { width: min(680px, 100%, max(380px, calc(100dvh - 260px))); }
.room.wide .timer { width: min(680px, 100%); }
.room-meta .opt { margin-left: 4px; }
.players { display: flex; flex-direction: column; gap: 10px; }
.player { --c: var(--muted); display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r); background: var(--panel); border: 1px solid var(--line); position: relative; transition: border-color .2s, box-shadow .2s; }
.player.x, .player.p0 { --c: var(--seat0); } .player.o, .player.p1 { --c: var(--seat1); } .player.p2 { --c: var(--seat2); } .player.p3 { --c: var(--seat3); } .player.p4 { --c: var(--seat4); } .player.p5 { --c: var(--seat5); }
.player.gone { opacity: .55; }
.player.active { border-color: var(--c); box-shadow: 0 0 0 1px var(--c) inset, 0 10px 30px -18px var(--c); }
.player .sym { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; font-weight: 900; font-size: 1.3rem; color: var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); }
.player .pn { min-width: 0; }
.player .pn b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .pn small { color: var(--muted); font-size: .78rem; display: flex; gap: 6px; flex-wrap: wrap; }
.player.empty-seat .pn b { color: var(--faint); font-weight: 500; }
.tag { font: 600 .66rem/1 var(--mono); text-transform: uppercase; letter-spacing: .08em; padding: 3px 6px; border-radius: 6px; background: var(--panel-3); color: var(--muted); }
.tag.you { background: var(--amber); color: var(--on-amber); }
.tag.warn { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }
.tag.bot { background: color-mix(in srgb, var(--p2) 22%, transparent); color: var(--p2); }
.player.bot { border-style: dashed; }
.pinfo { font-size: .75rem; color: var(--muted); }
.tag.ready { background: color-mix(in srgb, var(--good) 20%, transparent); color: var(--good); }
.player .score { font: 800 1.5rem/1 var(--mono); font-variant-numeric: tabular-nums; }

.stage { display: flex; flex-direction: column; align-items: center; gap: 14px; min-width: 0; }
.status { font-size: clamp(1.2rem, 3vw, 1.6rem); font-weight: 800; letter-spacing: -.02em; text-align: center; min-height: 1.5em; text-wrap: balance; }
.status.mine { color: var(--amber); }
.status .sub { display: block; font-size: .9rem; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.timer { width: min(440px, 100%); height: 5px; border-radius: 99px; background: var(--panel-3); overflow: hidden; }
.timer i { display: block; height: 100%; width: 100%; background: var(--muted); border-radius: inherit; transform-origin: left; }
.timer.mine i { background: var(--amber); }
.timer.low i { background: var(--bad); }
.timer.idle i { transform: scaleX(0); }
.board-host { width: min(440px, 100%); }
.notice { margin: 0; color: var(--muted); font-size: .9rem; }
.room-actions { display: flex; gap: 10px; min-height: 42px; }

/* ---------- dialogs ---------- */
dialog { border: 1px solid var(--line); border-radius: 18px; background: var(--panel); color: var(--fg); padding: 0; width: min(420px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(5, 6, 12, .6); backdrop-filter: blur(3px); }
dialog[open] { animation: dlgIn .18s ease-out; }
dialog form { display: flex; flex-direction: column; gap: 14px; padding: 22px; }
dialog h3 { margin: 0; font-size: 1.2rem; letter-spacing: -.01em; }
.dlg-sub { margin: -8px 0 0; color: var(--muted); font-size: .9rem; overflow-wrap: anywhere; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-weight: 600; font-size: .88rem; }
.field em { color: var(--muted); font-style: normal; font-weight: 400; }
.field input, .field select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); outline: none; width: 100%; }
.field input:focus, .field select:focus { border-color: var(--amber); }
.field input[aria-invalid="true"] { border-color: var(--bad); }
.hint { color: var(--faint); font-size: .76rem; }
.form-err { margin: 0; min-height: 1.2em; color: var(--bad); font-size: .87rem; }
.copy-buf { position: fixed; left: -9999px; top: 0; opacity: 0; }
.invite-input { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); font: 500 .9rem/1.3 var(--mono); }
.opt-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.opt-grid:empty { display: none; }
.wide-field { grid-column: 1 / -1; }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.lobby-tools:empty { display: none; }
.lobby-tools { display: flex; flex-wrap: wrap; gap: 10px; }
.players.many { gap: 6px; }
.players.many .player { padding: 8px 10px; }
.players.many .player .sym { width: 34px; height: 34px; font-size: 1rem; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; }
@keyframes dlgIn { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }

/* ---------- gate (bot check) ---------- */
.gate { position: fixed; inset: 0; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(4px); z-index: 50; transition: opacity .25s; padding: 16px; }
.gate.done { opacity: 0; pointer-events: none; }
.gate-card { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px 26px; display: flex; flex-direction: column; align-items: center; gap: 12px; box-shadow: var(--shadow); min-width: min(280px, 100%); }
.gate-card p { margin: 0; font-weight: 600; text-align: center; }
.gate-progress { width: 200px; max-width: 100%; height: 4px; border-radius: 9px; background: var(--panel-3); overflow: hidden; }
.gate-progress i { display: block; height: 100%; width: 0; background: var(--amber); transition: width .2s; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--panel-3); border-top-color: var(--amber); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- toasts ---------- */
.toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: max(16px, env(safe-area-inset-bottom, 0px)); display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(440px, calc(100vw - 32px)); pointer-events: none; }
.toast { pointer-events: auto; padding: 11px 16px; border-radius: 12px; background: var(--panel-3); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: .92rem; animation: toastIn .2s ease-out; max-width: 100%; overflow-wrap: anywhere; }
.toast.error { border-color: color-mix(in srgb, var(--bad) 55%, var(--line)); }
.toast.ok { border-color: color-mix(in srgb, var(--good) 55%, var(--line)); }
.toast.out { opacity: 0; transition: opacity .25s; }
@keyframes toastIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.foot a { color: inherit; }
.foot-links { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px; }
.foot a:hover, .linkbtn:hover { color: var(--fg); }
.foot { display: flex; justify-content: space-between; align-items: center; gap: 10px 16px; flex-wrap: wrap; color: var(--faint); font-size: .8rem; border-top: 1px solid var(--line); padding-top: 14px; }
.foot-kind { flex-basis: 100%; }
.linkbtn { all: unset; cursor: pointer; color: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, currentColor 45%, transparent); }
.linkbtn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; border-radius: 3px; }

/* "Built by AI" badge in the footer and the first-visit notice */
.ai-badge { display: inline-flex; align-items: center; gap: 9px; padding: 6px 13px 6px 8px; border-radius: 999px; cursor: pointer; color: var(--fg); font: inherit; font-size: .8rem;
  border: 1px solid transparent; background: linear-gradient(var(--panel), var(--panel)) padding-box, linear-gradient(120deg, #5b8cff, #b06bff, #ff6b9d, #5b8cff) border-box; background-size: 100% 100%, 300% 100%; animation: aiBorder 6s linear infinite; }
.ai-badge:hover { transform: translateY(-1px); }
.ai-badge svg { width: 22px; height: 22px; padding: 3px; border-radius: 50%; background: linear-gradient(135deg, #5b8cff, #b06bff); fill: none; stroke: #fff; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; box-sizing: content-box; width: 16px; height: 16px; }
.ai-badge svg .f { fill: #fff; stroke: none; }
.ai-badge em { font-style: normal; color: var(--muted); }
.ai-badge b { font-weight: 700; }
@keyframes aiBorder { to { background-position: 0 0, 300% 0; } }

.ai-dlg { width: min(520px, calc(100vw - 24px)); }
.ai-dlg::backdrop { background: rgba(8, 8, 20, .72); backdrop-filter: blur(5px); }
.ai-box { display: flex; flex-direction: column; gap: 14px; padding: 0 24px 22px; max-height: min(92vh, 760px); overflow-y: auto; }
.ai-box h3 { font-size: 1.45rem; line-height: 1.15; text-align: center; margin: 0; background: linear-gradient(100deg, #7da2ff, #c58bff 55%, #ff7fae); -webkit-background-clip: text; background-clip: text; color: transparent; }
.ai-lead { margin: 0; text-align: center; color: var(--muted); line-height: 1.5; }
.ai-art { margin: 0 -24px; padding: 22px 0 0; background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, #6a7bff 38%, transparent), transparent 70%), repeating-linear-gradient(0deg, transparent 0 11px, color-mix(in srgb, var(--fg) 5%, transparent) 11px 12px); border-radius: 18px 18px 0 0; }
.ai-robot { display: block; width: min(240px, 70%); height: auto; margin: 0 auto; overflow: visible; }
.ai-bot { animation: aiFloat 3.2s ease-in-out infinite; transform-origin: 120px 80px; }
.ai-ant { stroke: #9aa7ff; stroke-width: 3; stroke-linecap: round; }
.ai-bulb { fill: #ffd166; animation: aiPulse 1.6s ease-in-out infinite; transform-origin: 120px 26px; }
.ai-ear { fill: #7c6bff; }
.ai-face { fill: #0f1230; }
.ai-eye { fill: #5ef2e0; animation: aiBlink 4.5s infinite; transform-origin: center; transform-box: fill-box; }
.ai-mouth { fill: none; stroke: #5ef2e0; stroke-width: 3; stroke-linecap: round; }
.ai-stars path, .ai-stars circle { fill: #c9b8ff; opacity: .85; animation: aiTwinkle 2.4s ease-in-out infinite; }
.ai-stars path:nth-child(2) { animation-delay: .7s; } .ai-stars path:nth-child(3) { animation-delay: 1.4s; }
.ai-bug-body { fill: #ff6b7a; } .ai-bug-legs { stroke: #ff6b7a; stroke-width: 1.6; stroke-linecap: round; fill: none; }
.ai-bug { animation: aiCrawl 5s ease-in-out infinite; }
@keyframes aiFloat { 50% { transform: translateY(-5px); } }
@keyframes aiPulse { 50% { transform: scale(1.35); opacity: .7; } }
@keyframes aiBlink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes aiTwinkle { 50% { opacity: .25; } }
@keyframes aiCrawl { 0%, 100% { transform: translate(176px, 110px); } 50% { transform: translate(150px, 112px); } }
.ai-chips { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.ai-chips li { display: grid; gap: 2px; padding: 10px 14px 10px 16px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); border-left: 4px solid var(--c); }
.ai-chips b { font-size: .95rem; } .ai-chips span { color: var(--muted); font-size: .86rem; line-height: 1.4; }
.chip-a { --c: #ff6b7a; } .chip-b { --c: #ffc24b; } .chip-c { --c: #46d4d0; }
.ai-consent { margin: 0; font-size: .82rem; color: var(--muted); text-align: center; line-height: 1.5; }
.ai-consent .linkbtn { color: var(--fg); }
.ai-dlg .dlg-actions { justify-content: center; }
.ai-dlg .btn.primary { padding: 12px 26px; font-size: 1rem; }

.legal-tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.legal-tab { all: unset; cursor: pointer; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); font-size: .86rem; font-weight: 650; color: var(--muted); }
.legal-tab[aria-selected="true"] { background: var(--amber); border-color: var(--amber); color: var(--on-amber); }
.legal-tab:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
.legal-body section { display: grid; gap: 6px; }
.legal-body p { margin: 0; font-size: .92rem; line-height: 1.55; overflow-wrap: anywhere; }
.legal-dlg { max-width: min(760px, calc(100vw - 24px)); }
@media (max-width: 520px), (max-height: 700px) { .ai-art { padding-top: 12px; } .ai-robot { width: 128px; } .ai-box { gap: 11px; padding: 0 18px 18px; } .ai-art { margin: 0 -18px; } .ai-box h3 { font-size: 1.25rem; } .ai-chips li { padding: 8px 12px 8px 14px; } }
@media (prefers-reduced-motion: reduce) { .ai-badge, .ai-bot, .ai-bulb, .ai-eye, .ai-bug, .ai-stars * { animation: none; } }

.show-sm { display: none; }
@media (max-width: 860px) {
  .room-body { grid-template-columns: minmax(0, 1fr); }
  .players { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .side { order: 0; }
  .room.wide .side { order: 2; }
  .room.wide .room-body { gap: 18px; }
}
@media (max-width: 560px) {
  .hide-sm { display: none; }
  .show-sm { display: inline; }
  .app { gap: 20px; }
  .players { gap: 8px; }
  .player { grid-template-columns: 34px minmax(0, 1fr) auto; padding: 9px; gap: 8px; }
  .player .sym { width: 34px; height: 34px; font-size: 1.05rem; border-radius: 9px; }
  .player .score { font-size: 1.2rem; }
  .room-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .room-row .seats { display: none; }
  .room-row .gi { width: 34px; height: 34px; }
  .room-head { gap: 8px 10px; grid-template-areas: "leave . invite" "title title title"; }
  .actions .btn { flex: 1 1 0; padding-inline: 12px; }
  .room-head .btn { padding: 8px 11px; }
  .stat#online { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media (max-width: 900px) { .room-head { gap: 8px 10px; grid-template-areas: "leave . invite" "title title title"; } }
.room-title h2 { display: flex; align-items: center; justify-content: center; gap: 6px; }
.room-title h2 #room-name { overflow: hidden; text-overflow: ellipsis; }
.rename { flex: none; display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; border: 1px solid var(--line, #3a3f4b); background: transparent; color: var(--muted); cursor: pointer; }
.rename:hover, .rename:focus-visible { color: var(--text); background: var(--panel-2); }
.rename svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
a.btn:not(.primary) { color: var(--fg); }
