/* ============================================================================
   Showdown.fun / weeekend.io — Neobrutalism edition
   Drop-in replacement for assets/app.css. Self-contained: design tokens are
   inlined so no extra <link> tags are needed.

   Design language: warm paper page, pure-black rules, hard offset shadows
   (zero blur), one yellow primary + indigo secondary, Inter + JetBrains Mono,
   lift-on-hover / sink-on-press. Adapted from the Neobrutalism Design System.
   ========================================================================== */

/* Self-hosted fonts — no external requests, works offline on Hostinger.
   Latin-subset variable woff2 (the app is English-only). */
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/inter-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("fonts/jetbrainsmono-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ----------------------------------------------------------------- tokens */
:root {
  /* brand */
  --yellow-100:#FFF6D1; --yellow-300:#FEE07A; --yellow-500:#FDC800; --yellow-700:#C79C00;
  --indigo-100:#E4DFFB; --indigo-300:#A899F1; --indigo-600:#432DD7; --indigo-800:#2B1C92;
  /* semantic hues */
  --green-100:#DCFCE7; --green-600:#16A34A; --green-800:#14532D;
  --amber-100:#FEF3C7; --amber-600:#D97706; --amber-800:#92400E;
  --red-100:#FEE2E2;   --red-600:#DC2626;   --red-800:#991B1B;
  /* neutrals */
  --ink-900:#1C293C; --ink-700:#3C4A61; --ink-500:#697689; --ink-300:#A8B1BF; --ink-200:#CBD1DA; --ink-100:#E6E9EE;
  --paper:#FBFBF9; --paper-sunk:#F1F0EA; --white:#FFFFFF; --black:#000000;

  /* semantic aliases (keeps the app's variable names working) */
  --bg:        var(--paper);
  --bg-2:      var(--paper-sunk);
  --surface:   var(--white);
  --surface-2: var(--paper-sunk);
  --line:      var(--black);
  --text:      var(--ink-900);
  --muted:     var(--ink-500);
  --violet:    var(--indigo-600);
  --pink:      var(--yellow-500);
  --cyan:      var(--indigo-600);
  --lime:      var(--green-600);
  --amber:     var(--amber-600);
  --danger:    var(--red-600);

  /* geometry */
  --radius:    8px;   /* cards  */
  --radius-sm: 4px;   /* controls */
  --radius-pill:999px;

  /* borders */
  --bw-thin:2px; --bw-thick:3px; --bw-heavy:4px;
  --border:        2px solid var(--black);
  --border-strong: 3px solid var(--black);

  /* hard offset shadows — zero blur, pure black */
  --shadow-xs:2px 2px 0 0 var(--black);
  --shadow-sm:3px 3px 0 0 var(--black);
  --shadow-md:4px 4px 0 0 var(--black);
  --shadow-lg:6px 6px 0 0 var(--black);
  --shadow-xl:8px 8px 0 0 var(--black);
  --shadow: var(--shadow-md);
  --focus-ring:0 0 0 3px var(--indigo-600);

  /* type */
  --font:      "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* motion */
  --ease-out:cubic-bezier(0.2,0.8,0.2,1);
  --dur-fast:120ms;
  --transition-control:
    transform var(--dur-fast) var(--ease-out),
    box-shadow var(--dur-fast) var(--ease-out),
    background-color var(--dur-fast) var(--ease-out);
}

* { box-sizing: border-box; }

/* The app toggles screens with the `hidden` attribute (#app-loading /
   #app-error / #app). Because .fullscreen-state and .app-grid set an explicit
   display, they would otherwise override the UA `display:none` for [hidden]
   and stack all three. Keep hidden meaning hidden. */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
}
body { min-height: 100vh; min-height: 100dvh; overflow-x: hidden; }

h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; font-weight: 800; letter-spacing: -0.02em; text-wrap: balance; }
p { margin: 0 0 .75rem; text-wrap: pretty; }
a { color: var(--indigo-600); font-weight: 600; text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 2px; }
a:hover { color: var(--indigo-800); text-decoration-color: var(--yellow-500); }

.muted { color: var(--muted); font-size: .9rem; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--yellow-500); color: var(--ink-900); font-weight: 700;
  padding: .6rem 1rem; border: var(--border-strong); border-top: none; border-left: none;
}
.skip-link:focus { left: 0; }

:focus-visible { outline: none; box-shadow: var(--focus-ring); }
::selection { background: var(--yellow-500); color: var(--ink-900); }

/* ---------------------------------------------------------------- backdrop */
/* The blurred "aurora" becomes flat neobrutalist confetti: solid shapes,
   black outlines, hard shadows, parked behind the content. */
.aurora { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
.aurora span { position: absolute; display: block; filter: none; opacity: 1; border: var(--border-strong); }
.aurora span:nth-child(1) {
  width: 190px; height: 190px; top: -46px; left: -46px;
  background: var(--yellow-500); border-radius: var(--radius);
  transform: rotate(-9deg); box-shadow: var(--shadow-lg);
}
.aurora span:nth-child(2) {
  width: 150px; height: 150px; bottom: -40px; right: -30px;
  background: var(--indigo-600); border-radius: 50%;
  box-shadow: var(--shadow-lg);
}
.aurora span:nth-child(3) {
  width: 120px; height: 120px; top: 34%; right: 8%;
  background: var(--green-600); border-radius: var(--radius);
  transform: rotate(12deg); box-shadow: var(--shadow-md); opacity: .9;
}
@media (max-width: 720px) { .aurora span:nth-child(3) { display: none; } }

/* ----------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 48px; padding: .7rem 1.2rem;
  border: var(--border); border-radius: var(--radius-sm);
  font: inherit; font-weight: 700; color: var(--ink-900);
  background: var(--white); cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition-control);
  text-decoration: none; text-align: center;
}
.btn:hover:not(:disabled) { transform: translate(-2px, -2px); box-shadow: var(--shadow-md); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: var(--shadow-xs); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }

.btn-primary   { background: var(--yellow-500); color: var(--ink-900); }
.btn-secondary { background: var(--indigo-600); color: var(--white); }
.btn-ghost     { background: var(--white); color: var(--ink-900); }
.btn-danger    { background: var(--red-600); color: var(--white); }
.btn-success   { background: var(--green-600); color: var(--ink-900); }
.btn-sm        { min-height: 38px; padding: .35rem .75rem; font-size: .85rem; box-shadow: var(--shadow-xs); }
.btn-sm:hover:not(:disabled) { box-shadow: var(--shadow-sm); }
.btn-block     { width: 100%; }
.btn-wide      { flex: 1 1 auto; }
.btn.is-busy   { pointer-events: none; opacity: .7; }

/* ------------------------------------------------------------------ inputs */
label {
  display: block; margin: .85rem 0 .3rem;
  font-family: var(--font-mono); font-size: .72rem; font-weight: 700; color: var(--ink-700);
  text-transform: uppercase; letter-spacing: .08em;
}

input[type="text"], input[type="number"], select, textarea {
  width: 100%; min-height: 48px; padding: .7rem .9rem;
  background: var(--white);
  border: var(--border); border-radius: var(--radius-sm);
  color: var(--text); font: inherit;
  transition: box-shadow var(--dur-fast) var(--ease-out);
}
input::placeholder { color: var(--ink-300); }
input:focus-visible, select:focus-visible, textarea:focus-visible { box-shadow: var(--focus-ring); }

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-900) 50%),
                    linear-gradient(135deg, var(--ink-900) 50%, transparent 50%);
  background-position: calc(100% - 18px) 55%, calc(100% - 12px) 55%;
  background-size: 6px 6px, 6px 6px; background-repeat: no-repeat;
  padding-right: 2.4rem;
}

.code-input {
  text-transform: uppercase; letter-spacing: .35em; font-weight: 800;
  font-size: 1.3rem; text-align: center; font-family: var(--font-mono);
}

input[type="range"] { width: 100%; accent-color: var(--indigo-600); min-height: 44px; }

.field-error { color: var(--red-800); font-weight: 600; font-size: .85rem; margin: .5rem 0 0; }

/* ----------------------------------------------------------------- landing */
.shell { max-width: 1000px; margin: 0 auto; padding: 2rem 1rem 3rem; }

.brand { text-align: center; margin-bottom: 2rem; }
.logo {
  display: inline-block;
  font-size: clamp(2.4rem, 9vw, 3.6rem); margin: 0; font-weight: 900;
  color: var(--ink-900); letter-spacing: -0.03em;
  padding: .1em .3em;
  background: var(--yellow-500);
  border: var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  transform: rotate(-2deg);
}
.logo span { color: var(--indigo-600); }
.tagline { color: var(--ink-700); max-width: 34rem; margin: 1.1rem auto 0; }

.card-stack { display: grid; gap: 1rem; }
@media (min-width: 720px) { .card-stack { grid-template-columns: 1fr 1fr; } }

.card {
  background: var(--white); border: var(--border-strong);
  border-radius: var(--radius); padding: 1.25rem;
  box-shadow: var(--shadow-md);
}
.card h2 { font-size: 1.15rem; }
.card .btn { width: 100%; margin-top: 1rem; }

.alert {
  border-radius: var(--radius-sm); padding: .9rem 1rem; margin-bottom: 1rem;
  border: var(--border); box-shadow: var(--shadow-xs);
  display: grid; gap: .25rem; font-size: .9rem; font-weight: 500;
}
.alert-error { background: var(--red-100); color: var(--red-800); }
.alert-info  { background: var(--indigo-100); color: var(--indigo-800); }
.alert-warn  { background: var(--amber-100); color: var(--amber-800); }

.games-preview { margin-top: 2.5rem; }
.cat-grid { display: grid; gap: 1rem; }
@media (min-width: 720px) { .cat-grid { grid-template-columns: repeat(2, 1fr); } }

.cat {
  background: var(--white); border: var(--border);
  border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow-sm);
}
.cat h3 { font-size: 1rem; margin-bottom: .15rem; }
.cat .cat-note { font-size: .8rem; color: var(--muted); margin-bottom: .6rem; }
.cat ul { list-style: none; margin: 0; padding: 0; display: grid; gap: .35rem; }
.cat li { display: flex; align-items: center; gap: .5rem; font-size: .9rem; }

.pill {
  font-family: var(--font-mono);
  font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  padding: .15rem .5rem; border-radius: var(--radius-pill); white-space: nowrap;
  border: var(--bw-thin) solid var(--black);
}
.pill-soon { background: var(--ink-100); color: var(--ink-700); }
.pill-live { background: var(--green-100); color: var(--green-800); }
.pill-18   { background: var(--amber-100); color: var(--amber-800); }

.foot { margin-top: 2.5rem; color: var(--muted); font-size: .8rem; text-align: center; }

.loading-line { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .45; } 50% { opacity: .9; } }

/* -------------------------------------------------------------- room shell */
.fullscreen-state {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1rem; padding: 2rem; text-align: center;
}

.spinner {
  width: 42px; height: 42px; border-radius: 50%;
  border: var(--bw-heavy) solid var(--ink-200); border-top-color: var(--indigo-600);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 2.4s; }
  * { scroll-behavior: auto !important; }
}

.app-grid {
  display: grid; grid-template-rows: auto 1fr auto;
  min-height: 100vh; min-height: 100dvh;
  max-width: 1240px; margin: 0 auto;
}
@media (min-width: 900px) {
  .app-grid {
    grid-template-columns: minmax(0, 1fr) 330px;
    grid-template-rows: auto 1fr;
    gap: 1rem; padding: 0 1rem 1rem;
  }
  .topbar { grid-column: 1 / -1; }
}

.topbar {
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  padding: .75rem 1rem;
  border-bottom: var(--border-strong);
  background: var(--yellow-500);
  position: sticky; top: 0; z-index: 20;
}
.logo-small { font-weight: 900; text-decoration: none; color: var(--ink-900); font-size: 1rem; letter-spacing: -0.02em; }
.logo-small span { color: var(--indigo-600); }

.room-code-label {
  font-family: var(--font-mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-700);
}
.room-code {
  font-family: var(--font-mono);
  font-size: 1.1rem; letter-spacing: .18em; font-weight: 700; color: var(--ink-900);
  background: var(--white); border: var(--bw-thin) solid var(--black);
  border-radius: var(--radius-sm); padding: .05rem .4rem;
}

.conn { display: flex; align-items: center; gap: .35rem; font-size: .75rem; font-weight: 600; color: var(--ink-700); }
.conn .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--green-600); border: 1.5px solid var(--black); }
.conn[data-state="slow"] .dot { background: var(--amber-600); }
.conn[data-state="down"] .dot { background: var(--red-600); }
.conn[data-state="down"] { color: var(--red-800); }

.stage { padding: 1rem; min-width: 0; }
.sidebar { padding: 0 1rem 1rem; display: grid; gap: .75rem; align-content: start; }
@media (min-width: 900px) { .sidebar { padding: 0; position: sticky; top: 72px; } }

.panel {
  background: var(--white); border: var(--border);
  border-radius: var(--radius); padding: .9rem; box-shadow: var(--shadow-sm);
}
.panel-h {
  font-family: var(--font-mono);
  font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
  color: var(--ink-700); margin-bottom: .6rem;
  display: flex; justify-content: space-between; align-items: center;
}
.count { color: var(--ink-900); font-weight: 800; }

/* -------------------------------------------------------------- player list */
.player-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.player-row {
  display: flex; align-items: center; gap: .55rem;
  padding: .5rem .6rem; border-radius: var(--radius-sm);
  background: var(--paper-sunk); border: var(--bw-thin) solid var(--black);
  font-size: .92rem; font-weight: 500;
}
.player-row.is-me { background: var(--indigo-100); box-shadow: var(--shadow-xs); }
.player-row.is-off { opacity: .5; }
.avatar {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: .78rem; font-weight: 800; color: var(--white);
  border: var(--bw-thin) solid var(--black);
}
.player-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge {
  font-family: var(--font-mono);
  font-size: .6rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
  padding: .12rem .4rem; border-radius: var(--radius-pill); border: 1.5px solid var(--black);
}
.badge-host  { background: var(--amber-100); color: var(--amber-800); }
.badge-ready { background: var(--green-100); color: var(--green-800); }
.badge-off   { background: var(--ink-100); color: var(--ink-700); }
.kick-btn {
  background: none; border: none; color: var(--ink-500); cursor: pointer;
  font-size: 1.05rem; line-height: 1; padding: .25rem .35rem; border-radius: var(--radius-sm);
}
.kick-btn:hover { color: var(--red-600); background: var(--red-100); }

/* --------------------------------------------------------------------- chat */
.panel-chat { display: flex; flex-direction: column; }
.chat-log {
  max-height: 240px; min-height: 90px; overflow-y: auto;
  display: flex; flex-direction: column; gap: .3rem;
  font-size: .87rem; padding-right: .2rem;
}
.chat-msg { word-break: break-word; }
.chat-msg .who { font-weight: 800; color: var(--indigo-600); }
.chat-sys { color: var(--muted); font-style: italic; font-size: .82rem; }
.empty-note { color: var(--muted); font-size: .85rem; font-style: italic; }
.chat-form { display: flex; gap: .4rem; margin-top: .6rem; }
.chat-form input { min-height: 42px; }

/* -------------------------------------------------------------------- lobby */
.game-picker { display: grid; gap: 1rem; }
.picker-cat h3 {
  font-family: var(--font-mono);
  font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-700); font-weight: 700;
}
.picker-note { font-size: .78rem; color: var(--muted); margin: -.3rem 0 .55rem; }
.game-tabs { display: flex; gap: .4rem; flex-wrap: wrap; margin-bottom: .8rem; }
.game-tab {
  flex: 1 1 auto; min-height: 40px; padding: .4rem .7rem;
  font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  background: var(--white); color: var(--ink-700);
  border: var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow-xs);
  transition: var(--transition-control);
}
.game-tab:hover { transform: translate(-1px,-1px); box-shadow: var(--shadow-sm); }
.game-tab.is-active { background: var(--yellow-500); color: var(--ink-900); box-shadow: var(--shadow-sm); }
.game-tab .tab-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--indigo-600); border: 1px solid var(--black); }
:root[data-theme="dark"] .game-tab.is-active { color: #17141F; }

.game-grid { display: grid; gap: .6rem; grid-template-columns: 1fr; }
@media (min-width: 560px) { .game-grid { grid-template-columns: 1fr 1fr; } }

.game-tile {
  display: flex; flex-direction: column; gap: .25rem; text-align: left;
  padding: .8rem; border-radius: var(--radius-sm);
  border: var(--border); background: var(--white);
  color: var(--text); font: inherit; cursor: pointer; width: 100%;
  box-shadow: var(--shadow-xs); transition: var(--transition-control);
}
.game-tile:hover:not(:disabled) { transform: translate(-2px,-2px); box-shadow: var(--shadow-sm); }
.game-tile[aria-pressed="true"] {
  background: var(--yellow-300); box-shadow: var(--shadow-sm);
}
.game-tile:disabled { cursor: not-allowed; opacity: .55; box-shadow: none; }
.game-tile .t-title { font-weight: 800; display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.game-tile .t-blurb { font-size: .8rem; color: var(--muted); }

.host-controls {
  display: flex; gap: .4rem; margin-left: auto;
}

/* -------------------------------------------------------------- game screens */
.game-head { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: 1rem; }
.game-title { font-size: 1.25rem; margin: 0; }
.game-meta { font-family: var(--font-mono); font-size: .78rem; color: var(--ink-700); }

.timer { margin-left: auto; display: flex; align-items: center; gap: .5rem; }
.timer-num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.1rem; min-width: 2.2ch; text-align: right; }
.timer-bar { width: 110px; height: 12px; border-radius: var(--radius-pill); background: var(--white); border: var(--bw-thin) solid var(--black); overflow: hidden; }
.timer-fill { height: 100%; background: var(--green-600); transition: width .9s linear; }
.timer.is-low .timer-fill { background: var(--red-600); }
.timer.is-low .timer-num { color: var(--red-600); }

.board {
  background: var(--white); border: var(--border-strong);
  border-radius: var(--radius); padding: 1.1rem; margin-bottom: 1rem;
  box-shadow: var(--shadow-md);
}

.q-prompt { font-size: 1.2rem; font-weight: 800; margin-bottom: 1rem; }

.answers { display: grid; gap: .55rem; }
@media (min-width: 620px) { .answers { grid-template-columns: 1fr 1fr; } }
.answer-btn {
  display: flex; align-items: center; gap: .6rem; text-align: left;
  min-height: 56px; padding: .75rem .9rem;
  border-radius: var(--radius-sm); border: var(--border);
  background: var(--white); color: var(--text); font: inherit; font-weight: 600;
  cursor: pointer; width: 100%;
  box-shadow: var(--shadow-xs); transition: var(--transition-control);
}
.answer-btn:hover:not(:disabled) { transform: translate(-2px,-2px); box-shadow: var(--shadow-sm); }
.answer-btn .key {
  width: 28px; height: 28px; flex: none; border-radius: var(--radius-sm);
  display: grid; place-items: center; font-weight: 800; font-size: .8rem;
  background: var(--yellow-500); border: var(--bw-thin) solid var(--black);
}
.answer-btn.is-picked { background: var(--indigo-100); box-shadow: var(--shadow-sm); }
.answer-btn.is-right  { background: var(--green-100); border-color: var(--green-600); box-shadow: 3px 3px 0 0 var(--green-600); }
.answer-btn.is-wrong  { background: var(--red-100); border-color: var(--red-600); box-shadow: 3px 3px 0 0 var(--red-600); }
.answer-btn:disabled { cursor: default; }
.answer-btn.is-right:disabled, .answer-btn.is-wrong:disabled, .answer-btn.is-picked:disabled { opacity: 1; }
.answer-btn .tally { margin-left: auto; font-family: var(--font-mono); font-size: .78rem; color: var(--ink-700); }

.reveal-fact {
  margin-top: 1rem; padding: .75rem .9rem; border-radius: var(--radius-sm);
  background: var(--indigo-100); border: var(--border);
  font-size: .88rem; box-shadow: var(--shadow-xs);
}
.gain { color: var(--green-800); font-weight: 800; }

.scoreboard { display: grid; gap: .35rem; }
.score-row {
  display: flex; align-items: center; gap: .6rem;
  padding: .5rem .6rem; border-radius: var(--radius-sm);
  background: var(--paper-sunk); border: var(--bw-thin) solid var(--black);
  font-size: .92rem; font-weight: 500;
}
.score-row .rank { width: 1.6rem; color: var(--ink-500); font-weight: 800; font-family: var(--font-mono); }
.score-row .pts { margin-left: auto; font-weight: 800; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }
.score-row.top { background: var(--yellow-300); box-shadow: var(--shadow-xs); }

/* --------------------------------------------------------------- who am i? */
.char-grid { display: grid; gap: .7rem; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.char-card {
  border: var(--border); border-radius: var(--radius);
  background: var(--white); padding: .7rem; text-align: center;
  box-shadow: var(--shadow-xs);
}
.char-card.is-me { background: var(--indigo-100); box-shadow: var(--shadow-sm); }
.char-card.is-turn { box-shadow: var(--shadow-md); border-color: var(--indigo-600); }
.char-card img { width: 88px; height: 88px; border-radius: var(--radius-sm); display: block; margin: 0 auto .5rem; border: var(--bw-thin) solid var(--black); }
.char-mystery {
  width: 88px; height: 88px; border-radius: var(--radius-sm); margin: 0 auto .5rem;
  display: grid; place-items: center; font-size: 2.2rem; font-weight: 900;
  border: var(--bw-thin) solid var(--black);
  background: repeating-linear-gradient(45deg, var(--indigo-100), var(--indigo-100) 8px, var(--white) 8px, var(--white) 16px);
  color: var(--indigo-600);
}
.char-who { font-family: var(--font-mono); font-size: .7rem; color: var(--ink-500); text-transform: uppercase; letter-spacing: .05em; }
.char-name { font-weight: 800; font-size: .92rem; word-break: break-word; }
.char-sub { font-size: .74rem; color: var(--muted); }
.char-solved { color: var(--green-800); font-size: .74rem; font-weight: 800; }

.turn-banner {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .75rem .9rem; border-radius: var(--radius-sm); margin-bottom: 1rem;
  background: var(--indigo-100); border: var(--border); box-shadow: var(--shadow-xs);
}
.turn-banner.is-mine { background: var(--green-100); }

.guess-form { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: 1rem; }
.guess-form input { flex: 1 1 180px; }

.event-log { display: grid; gap: .3rem; font-size: .84rem; color: var(--ink-700); margin-top: 1rem; }
.event-log div { padding: .35rem .55rem; background: var(--paper-sunk); border: 1.5px solid var(--black); border-radius: var(--radius-sm); }

/* ------------------------------------------------------- chameleon (reveal) */
.big-card { text-align: center; }
.role-tag {
  display: inline-block; font-family: var(--font-mono);
  font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-700); margin-bottom: .4rem;
}
.big-card.is-cham { background: var(--amber-100); border-color: var(--amber-600); }
.big-card.is-mafia { background: var(--red-100); border-color: var(--red-600); }
.big-card.is-sheriff { background: var(--indigo-100); border-color: var(--indigo-600); }
.big-card.is-villager { background: var(--green-100); border-color: var(--green-600); }

/* mafia end-of-game role reveal */
.role-reveal { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.role-reveal li {
  display: flex; justify-content: space-between; align-items: center; gap: .5rem;
  padding: .5rem .7rem; font-weight: 700;
  background: var(--paper-sunk); border: var(--bw-thin) solid var(--black); border-radius: var(--radius-sm);
}
.role-reveal li.rr-mafia { background: var(--red-100); }
.role-reveal li.rr-sheriff { background: var(--indigo-100); }
.role-reveal li.rr-villager { background: var(--green-100); }
.narrator-guide ol { margin: 0 0 .5rem; padding-left: 1.2rem; display: grid; gap: .4rem; font-size: .9rem; }
.big-word {
  font-size: clamp(2rem, 9vw, 3.2rem); font-weight: 900; letter-spacing: -0.02em;
  padding: .4rem 0; text-wrap: balance;
}

/* ------------------------------------------------------- collapsible panels */
details.collapsible {
  background: var(--white); border: var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); margin-top: 1rem; overflow: hidden;
}
details.collapsible > summary {
  cursor: pointer; list-style: none; padding: .7rem .9rem;
  font-family: var(--font-mono); font-size: .72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--ink-700);
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
}
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::after {
  content: "\25BE"; color: var(--ink-500);
  transition: transform var(--dur-fast) var(--ease-out);
}
details.collapsible[open] > summary::after { transform: rotate(180deg); }
details.collapsible > summary:hover { background: var(--paper-sunk); }
details.collapsible > .collapse-body { padding: 0 .9rem .9rem; }

/* -------------------------------------------------------------------- cards */
.felt {
  background: var(--green-100);
  border: var(--border-strong); border-radius: var(--radius);
  padding: 1.1rem; margin-bottom: 1rem; box-shadow: var(--shadow-md);
}

.hand { display: flex; gap: .4rem; flex-wrap: wrap; }
.pcard {
  width: 46px; height: 64px; border-radius: var(--radius-sm); flex: none;
  background: var(--white); color: var(--ink-900);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 800; line-height: 1;
  border: var(--bw-thin) solid var(--black); box-shadow: var(--shadow-xs);
}
.pcard .r { font-size: 1.05rem; }
.pcard .s { font-size: .95rem; }
.pcard.red { color: var(--red-600); }
.pcard.back {
  background: repeating-linear-gradient(45deg, var(--indigo-600), var(--indigo-600) 6px, var(--indigo-800) 6px, var(--indigo-800) 12px);
  color: transparent; border: var(--bw-thin) solid var(--black);
}
.pcard.slot { background: var(--paper-sunk); border: var(--bw-thin) dashed var(--black); box-shadow: none; }
.pcard.sm { width: 36px; height: 50px; }
.pcard.sm .r { font-size: .85rem; }
.pcard.sm .s { font-size: .75rem; }

.seat-row {
  display: flex; align-items: center; gap: .6rem; flex-wrap: wrap;
  padding: .6rem; border-radius: var(--radius-sm);
  background: var(--white); margin-bottom: .45rem;
  border: var(--bw-thin) solid var(--black);
}
.seat-row.is-turn { background: var(--indigo-100); box-shadow: var(--shadow-sm); }
.seat-row.is-me { background: var(--yellow-100); }
.seat-row.is-folded { opacity: .45; }
.seat-info { display: grid; min-width: 120px; }
.seat-name { font-weight: 800; font-size: .92rem; }
.seat-sub { font-family: var(--font-mono); font-size: .74rem; color: var(--ink-700); }
.seat-tag {
  font-family: var(--font-mono);
  font-size: .64rem; font-weight: 700; text-transform: uppercase;
  padding: .12rem .45rem; border-radius: var(--radius-pill); border: 1.5px solid var(--black);
  background: var(--ink-100); color: var(--ink-700);
}
.seat-tag.win  { background: var(--green-100); color: var(--green-800); }
.seat-tag.lose { background: var(--red-100); color: var(--red-800); }
.seat-tag.push { background: var(--amber-100); color: var(--amber-800); }

.pot-line { display: flex; gap: 1rem; flex-wrap: wrap; align-items: baseline; margin-bottom: .8rem; font-size: .9rem; }
.pot-line strong { font-size: 1.15rem; font-family: var(--font-mono); }

.chip-row { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0; }
.chip-btn {
  min-height: 44px; padding: .4rem .85rem; border-radius: var(--radius-pill);
  border: var(--border); background: var(--white);
  color: var(--text); font: inherit; font-weight: 800; cursor: pointer;
  box-shadow: var(--shadow-xs); transition: var(--transition-control);
}
.chip-btn:hover:not(:disabled) { transform: translate(-1px,-1px); box-shadow: var(--shadow-sm); }
.chip-btn:active:not(:disabled) { transform: translate(1px,1px); box-shadow: none; }
.chip-btn:disabled { opacity: .4; cursor: not-allowed; box-shadow: none; }

.action-row { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; }
.action-row .btn { flex: 1 1 100px; }

.raise-box {
  display: grid; gap: .4rem; margin-top: .8rem; padding: .8rem;
  border: var(--border); border-radius: var(--radius-sm);
  background: var(--paper-sunk);
}
.raise-value { font-weight: 800; font-variant-numeric: tabular-nums; font-family: var(--font-mono); }

/* -------------------------------------------------------------------- party */
.safety-note {
  font-size: .8rem; color: var(--ink-700); margin-top: 1rem;
  border-top: var(--bw-thin) solid var(--black); padding-top: .7rem;
  display: grid; gap: .25rem;
}

.vote-pair { display: grid; gap: .6rem; }
@media (min-width: 620px) { .vote-pair { grid-template-columns: 1fr 1fr; } }
.vote-card {
  padding: 1.1rem; min-height: 110px; border-radius: var(--radius);
  border: var(--border-strong); background: var(--white);
  color: var(--text); font: inherit; font-size: 1rem; font-weight: 700;
  cursor: pointer; text-align: left; display: flex; flex-direction: column; gap: .5rem;
  box-shadow: var(--shadow-sm); transition: var(--transition-control);
}
.vote-card:hover:not(:disabled) { transform: translate(-2px,-2px); box-shadow: var(--shadow-md); }
.vote-card.is-picked { background: var(--yellow-300); box-shadow: var(--shadow-md); }
.vote-card .vote-count { margin-top: auto; font-family: var(--font-mono); font-size: .82rem; color: var(--ink-700); font-weight: 700; }
.vote-card:disabled { cursor: default; }

.wheel-wrap { display: grid; place-items: center; gap: 1rem; padding: 1rem 0; }
.wheel {
  width: min(240px, 70vw); aspect-ratio: 1; border-radius: 50%;
  background: conic-gradient(
    var(--yellow-500) 0 45deg, var(--indigo-600) 45deg 90deg, var(--green-600) 90deg 135deg,
    var(--red-600) 135deg 180deg, var(--amber-600) 180deg 225deg, var(--yellow-500) 225deg 270deg,
    var(--indigo-600) 270deg 315deg, var(--green-600) 315deg 360deg);
  border: var(--bw-heavy) solid var(--black);
  box-shadow: var(--shadow-lg);
}
.wheel.is-spinning { animation: spin 0.55s linear infinite; }
.challenge-card {
  font-size: 1.15rem; font-weight: 800; text-align: center;
  padding: 1.2rem; border-radius: var(--radius);
  background: var(--yellow-300); border: var(--border-strong); box-shadow: var(--shadow-md);
}

.result-list { display: grid; gap: .35rem; margin-top: .8rem; }
.result-row {
  padding: .5rem .7rem; border-radius: var(--radius-sm);
  background: var(--green-100); border: var(--bw-thin) solid var(--black);
  font-size: .88rem; font-weight: 500;
}

/* -------------------------------------------------------------------- misc */
.empty-state {
  text-align: center; padding: 2.5rem 1rem; color: var(--muted);
  border: var(--bw-thick) dashed var(--black); border-radius: var(--radius);
  background: var(--paper-sunk);
}
.empty-state h3 { color: var(--ink-900); }

.toast {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%);
  background: var(--ink-900); border: var(--bw-thick) solid var(--black); color: var(--white);
  padding: .7rem 1.1rem; border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  z-index: 60; font-size: .9rem; font-weight: 600; max-width: calc(100vw - 2rem); text-align: center;
}
.toast[data-kind="error"] { background: var(--red-600); }

.notice {
  font-size: .85rem; color: var(--ink-700); margin-top: 1rem;
  padding: .65rem .8rem; border-radius: var(--radius-sm);
  background: var(--paper-sunk); border: var(--bw-thin) solid var(--black);
}

.waiting-dots::after {
  content: '…'; display: inline-block; width: 1.2em; text-align: left;
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots { 0% { content: ''; } 25% { content: '.'; } 50% { content: '..'; } 75% { content: '…'; } }

/* =====================================================================
   THEME TOGGLE — the little sun/moon button in the topbar / landing.
   ===================================================================== */
.theme-toggle {
  min-height: 38px; min-width: 38px;
  display: inline-grid; place-items: center;
  padding: .3rem .5rem; cursor: pointer;
  font-size: 1rem; line-height: 1;
  background: var(--white); color: var(--ink-900);
  border: var(--border); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xs); transition: var(--transition-control);
}
.theme-toggle:hover { transform: translate(-2px,-2px); box-shadow: var(--shadow-sm); }
.theme-toggle:active { transform: translate(2px,2px); box-shadow: none; }
.theme-toggle::after {
  content: ""; width: 20px; height: 20px; background-color: currentColor;
  -webkit-mask: url("icons/dark_mode.svg") center / contain no-repeat;
  mask: url("icons/dark_mode.svg") center / contain no-repeat;
}
:root[data-theme="dark"] .theme-toggle::after {
  -webkit-mask-image: url("icons/light_mode.svg");
  mask-image: url("icons/light_mode.svg");
}
.theme-toggle-fixed { position: fixed; top: 1rem; right: 1rem; z-index: 50; }

/* =====================================================================
   FLOATING ROOM CHAT — a launcher that opens a chat panel, with an
   unread badge and transient message bubbles while it's closed.
   ===================================================================== */
.chat-widget {
  position: fixed; right: 1rem; bottom: 1rem; z-index: 70;
  display: flex; flex-direction: column; align-items: flex-end; gap: .6rem;
}

/* launcher button */
.chat-fab {
  position: relative; width: 58px; height: 58px; flex: none;
  display: grid; place-items: center; cursor: pointer;
  background: var(--indigo-600); color: #fff;
  border: var(--border-strong); border-radius: 50%;
  box-shadow: var(--shadow-md); transition: var(--transition-control);
}
.chat-fab:hover { transform: translate(-2px,-2px); box-shadow: var(--shadow-lg); }
.chat-fab:active { transform: translate(2px,2px); box-shadow: var(--shadow-sm); }
.chat-fab-icon::before {
  content: ""; display: block; width: 24px; height: 24px; background-color: currentColor;
  -webkit-mask: url("icons/chat.svg") center / contain no-repeat;
  mask: url("icons/chat.svg") center / contain no-repeat;
}
/* the open state swaps back to a text glyph, so it must drop the mask */
.chat-widget[data-open="true"] .chat-fab-icon::before {
  content: "✕"; color: #fff; font-weight: 900; font-size: 1.25rem;
  width: auto; height: auto; background-color: transparent;
  -webkit-mask: none; mask: none;
}

.chat-unread {
  position: absolute; top: -6px; right: -6px;
  min-width: 22px; height: 22px; padding: 0 5px;
  display: grid; place-items: center;
  background: var(--red-600); color: #fff;
  font-family: var(--font-mono); font-size: .72rem; font-weight: 700;
  border: var(--bw-thin) solid var(--black); border-radius: var(--radius-pill);
}

/* the panel */
.chat-panel {
  width: min(360px, calc(100vw - 2rem)); max-height: min(70vh, 560px);
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--white); border: var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  animation: chatpop .14s var(--ease-out);
}
@keyframes chatpop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.chat-panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: .65rem .9rem; background: var(--yellow-500);
  border-bottom: var(--border-strong);
}
.chat-panel-head .panel-h { margin: 0; color: var(--ink-900); }
.chat-close {
  background: none; border: none; cursor: pointer; color: var(--ink-900);
  font-size: 1.3rem; line-height: 1; padding: .05rem .35rem; border-radius: var(--radius-sm);
}
.chat-close:hover { background: rgba(0,0,0,.14); }
.chat-panel .chat-log { max-height: none; flex: 1 1 auto; min-height: 130px; padding: .8rem .9rem; }
.chat-panel .chat-form { margin: 0; padding: .7rem .9rem; border-top: var(--bw-thin) solid var(--black); background: var(--paper-sunk); }

/* transient bubbles shown while the panel is closed */
.chat-bubbles { display: flex; flex-direction: column; align-items: flex-end; gap: .4rem; max-width: min(320px, calc(100vw - 2rem)); }
.chat-bubble {
  background: var(--white); border: var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: .5rem .7rem; font-size: .85rem; max-width: 100%;
  animation: bubblein .16s var(--ease-out);
}
.chat-bubble.is-leaving { animation: bubbleout .3s var(--ease-out) forwards; }
.chat-bubble .who { font-weight: 800; color: var(--indigo-600); margin-right: .25rem; }
.chat-bubble .txt { word-break: break-word; }
@keyframes bubblein  { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
@keyframes bubbleout { to { opacity: 0; transform: translateX(12px); } }
@media (prefers-reduced-motion: reduce) { .chat-panel, .chat-bubble { animation: none; } }

/* dark-mode fixups for the widget (bright head + indigo accents) */
:root[data-theme="dark"] .chat-panel-head { background: var(--paper-sunk); }
:root[data-theme="dark"] .chat-close:hover { background: rgba(255,255,255,.14); }
:root[data-theme="dark"] .chat-bubble .who { color: var(--indigo-300); }

/* =====================================================================
   DARK MODE — opt-in via <html data-theme="dark">. Paper stays the
   default (no attribute = light). The neobrutalist language is kept:
   hard offset shadows and thick outlines, only now the "ink" that draws
   them is light so they read on a dark surface. Brand fills stay vivid;
   text sitting ON a bright fill is pinned dark for contrast (WCAG AA).
   ===================================================================== */
:root[data-theme="dark"] {
  /* surfaces & neutrals flipped */
  --paper:#15131D; --paper-sunk:#1E1B29; --white:#252130;
  --black:#EAE8F2;                 /* borders + offset shadows go light */
  --ink-900:#F3F1FA; --ink-700:#C7C3D6; --ink-500:#948FA6;
  --ink-300:#6E6982; --ink-200:#3A3550; --ink-100:#2C2840;

  /* soft chip backgrounds (-100) darken; their text (-800) lightens */
  --yellow-100:#3C3305;
  --indigo-100:#242056; --indigo-800:#C7BCF6;
  --green-100:#123A22;  --green-800:#7CE3A2;
  --amber-100:#402B08;  --amber-800:#F3C271;
  --red-100:#401616;    --red-800:#F5A3A3;

  /* re-point the semantic aliases (explicit, no reliance on var() chaining) */
  --bg:var(--paper); --bg-2:var(--paper-sunk);
  --surface:var(--white); --surface-2:var(--paper-sunk);
  --line:var(--black); --text:var(--ink-900); --muted:var(--ink-500);
  --violet:var(--indigo-600); --pink:var(--yellow-500);
  --cyan:var(--indigo-600); --lime:var(--green-600);
  --amber:var(--amber-600); --danger:var(--red-600);

  /* keep focus rings and links visible on a dark ground */
  --focus-ring:0 0 0 3px var(--indigo-300);
}

/* links & inline accents need a brighter indigo on dark */
:root[data-theme="dark"] a { color: var(--indigo-300); }
:root[data-theme="dark"] a:hover { color: var(--indigo-800); }
:root[data-theme="dark"] .chat-msg .who,
:root[data-theme="dark"] .logo-small span,
:root[data-theme="dark"] .char-mystery { color: var(--indigo-300); }
:root[data-theme="dark"] ::selection { color: #17141F; }
:root[data-theme="dark"] .spinner { border-top-color: var(--indigo-300); }

/* the topbar is bright yellow in light mode; go dark so its mixed
   contents (labels + the code chip) all read without per-child fixes */
:root[data-theme="dark"] .topbar { background: var(--paper-sunk); }

/* these draw text on a saturated fill and must stay light (they use
   --white, which we flipped to a dark surface for panels/cards) */
:root[data-theme="dark"] .btn-secondary,
:root[data-theme="dark"] .btn-danger,
:root[data-theme="dark"] .avatar { color: #F7F5FC; }

/* text sitting on a bright fill stays dark for contrast */
:root[data-theme="dark"] .btn-primary,
:root[data-theme="dark"] .btn-success,
:root[data-theme="dark"] .logo,
:root[data-theme="dark"] .skip-link,
:root[data-theme="dark"] .answer-btn .key,
:root[data-theme="dark"] .game-tile[aria-pressed="true"],
:root[data-theme="dark"] .game-tile[aria-pressed="true"] .t-blurb,
:root[data-theme="dark"] .score-row.top,
:root[data-theme="dark"] .score-row.top .rank,
:root[data-theme="dark"] .score-row.top .pts,
:root[data-theme="dark"] .vote-card.is-picked,
:root[data-theme="dark"] .vote-card.is-picked .vote-count,
:root[data-theme="dark"] .challenge-card { color: #17141F; }

/* playing cards stay light-faced (a dark card reads as face-down) */
:root[data-theme="dark"] .pcard:not(.back):not(.slot) { background: #F4F3ED; color: #17151F; }
:root[data-theme="dark"] .pcard.red { color: var(--red-600); }

/* the toast stays a dark pill in both themes */
:root[data-theme="dark"] .toast { background: #0E0C16; color: #F5F3FB; }
:root[data-theme="dark"] .toast[data-kind="error"] { background: var(--red-600); color: #fff; }

/* ==================================================================== v4:
   top bar controls, dialogs, splash, leaderboard, settings, FU cards */

.room-code-btn {
  margin-left: auto; display: flex; align-items: baseline; gap: .4rem;
  background: none; border: none; padding: 0; cursor: pointer; font: inherit; color: inherit;
}
.room-code-btn .room-code { transition: var(--transition-control); }
.room-code-btn:hover .room-code { transform: translate(-1px, -1px); box-shadow: var(--shadow-sm); }
.icon-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: var(--border); border-radius: var(--radius-sm); background: var(--white);
  box-shadow: var(--shadow-xs); cursor: pointer; font: inherit; font-size: 1.05rem; line-height: 1;
  transition: var(--transition-control);
}
.icon-btn:hover { transform: translate(-2px,-2px); box-shadow: var(--shadow-sm); }
.icon-btn:active { transform: translate(2px,2px); box-shadow: none; }
.icon-btn .mini-count {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: var(--radius-pill); background: var(--red-600); color: var(--white);
  border: 1.5px solid var(--black); font-family: var(--font-mono); font-size: .65rem; font-weight: 700;
  display: grid; place-items: center;
}
.icon-btn { position: relative; }

/* dialogs */
.dlg {
  border: var(--border-strong); border-radius: var(--radius); padding: 0;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-xl);
  width: min(520px, calc(100vw - 2rem));
}
.dlg::backdrop { background: rgba(28, 41, 60, .55); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: .9rem 1rem; border-bottom: var(--border); background: var(--yellow-500); }
.dlg-title { margin: 0; font-size: 1.05rem; }
.dlg-close { background: none; border: none; font-size: 1.5rem; line-height: 1; cursor: pointer; color: inherit; padding: .1rem .4rem; }
.dlg-body { padding: 1rem; display: grid; gap: .75rem; font-size: .95rem; }
.dlg-body p { margin: 0; }
.dlg-body h3 { margin: 0; font-size: 1rem; }
.dlg-foot { padding: .75rem 1rem; border-top: var(--border); display: flex; justify-content: flex-end; }

/* leaderboard table */
.board-table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.board-table th { font-family: var(--font-mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-700); text-align: left; padding: .3rem .4rem; }
.board-table td { padding: .45rem .4rem; border-top: var(--bw-thin) solid var(--ink-200); }
.board-table td.num { text-align: right; font-family: var(--font-mono); font-weight: 700; }
.board-table tr.is-me td { background: var(--indigo-100); }
.board-table .rank { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--black); font-size: .72rem; font-weight: 800; background: var(--white); }
.board-table tr:first-child .rank { background: var(--yellow-500); }

/* lobby settings strip */
.settings-strip { display: grid; gap: .5rem; margin: 1rem 0 .75rem; }
.toggle-row {
  display: flex; align-items: center; gap: .75rem; padding: .6rem .75rem;
  border: var(--bw-thin) solid var(--black); border-radius: var(--radius-sm); background: var(--paper-sunk);
}
.toggle-row .toggle-text { flex: 1; min-width: 0; }
.toggle-row .toggle-text strong { display: block; font-size: .92rem; }
.toggle-row .toggle-text span { font-size: .78rem; color: var(--muted); }
.toggle-row input[type="checkbox"] {
  appearance: none; -webkit-appearance: none; width: 44px; height: 26px; flex: none; margin: 0;
  border: var(--border); border-radius: var(--radius-pill); background: var(--white); position: relative; cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-out);
}
.toggle-row input[type="checkbox"]::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--black); transition: transform var(--dur-fast) var(--ease-out);
}
.toggle-row input[type="checkbox"]:checked { background: var(--green-600); }
.toggle-row input[type="checkbox"]:checked::after { transform: translateX(18px); }
.toggle-row input[type="checkbox"]:disabled { cursor: default; opacity: .7; }

/* lobby button row (base .host-controls pushes itself right) */
.lobby-actions { margin-left: 0; margin-top: .25rem; }
.lobby-actions .btn-wide { flex: 1; }

/* game tile trim */
.game-tile .t-meta { display: flex; gap: .4rem; align-items: center; font-size: .72rem; color: var(--muted); }

/* FU buttons and badges in the roster */
.fu-btn {
  font-family: var(--font-mono); font-weight: 800; font-size: .68rem; letter-spacing: .04em;
  padding: .2rem .5rem; border: var(--bw-thin) solid var(--black); border-radius: var(--radius-sm);
  background: var(--red-600); color: var(--white); cursor: pointer; box-shadow: var(--shadow-xs);
  transition: var(--transition-control);
}
.fu-btn:hover:not(:disabled) { transform: translate(-1px,-1px); box-shadow: var(--shadow-sm); }
.fu-btn:disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.badge-fu { background: var(--red-100); color: var(--red-800); }
.badge-scr { background: var(--indigo-100); color: var(--indigo-800); }

/* splash overlays */
.splash {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 1.5rem;
  background: rgba(28, 41, 60, .78); animation: splash-in 240ms var(--ease-out);
}
.splash-card {
  position: relative; text-align: center; padding: 2rem 1.75rem; max-width: 420px; width: 100%;
  background: var(--surface); color: var(--text); border: var(--border-strong); border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
}
.splash-card h2 { margin: 0 0 .5rem; font-size: 1.6rem; letter-spacing: -0.02em; }
.splash-card p { margin: 0; color: var(--muted); }
.splash[data-kind="win"] .splash-card { background: var(--yellow-500); color: var(--ink-900); }
.splash[data-kind="win"] .splash-card p { color: var(--ink-700); }
.splash[data-kind="fu"] .splash-card { background: var(--red-600); color: var(--white); }
.splash[data-kind="fu"] .splash-card p { color: var(--red-100); }
@keyframes splash-in { from { opacity: 0; } to { opacity: 1; } }

.fu-card {
  width: 120px; height: 170px; margin: 0 auto 1rem; border: var(--border-strong); border-radius: var(--radius);
  background: var(--red-600); color: var(--white); display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 900; font-size: 2.4rem; letter-spacing: -0.04em;
  box-shadow: var(--shadow-lg); animation: card-flip 900ms var(--ease-out) both;
}
@keyframes card-flip {
  0%   { transform: translateY(-140vh) rotate(-30deg) rotateY(180deg); opacity: 0; }
  60%  { transform: translateY(8px) rotate(4deg) rotateY(0deg); opacity: 1; }
  80%  { transform: translateY(-6px) rotate(-2deg); }
  100% { transform: translateY(0) rotate(0); }
}

.confetti { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.confetti span {
  position: absolute; top: -12px; width: 10px; height: 14px; border: 1.5px solid var(--black);
  animation: confetti-fall 1.8s linear infinite;
}
.confetti span:nth-child(odd)  { background: var(--indigo-600); }
.confetti span:nth-child(even) { background: var(--green-600); }
.confetti span:nth-child(3n)   { background: var(--white); }
@keyframes confetti-fall {
  to { transform: translateY(260px) rotate(540deg); opacity: 0; }
}

/* phones: players strip under the top bar, lobby breathing room */
@media (max-width: 899px) {
  .app-grid { grid-template-rows: auto auto 1fr; }
  /* Without an explicit column the implicit one sizes to max-content, so the
     widest child (the category tab row) widens the whole page sideways. */
  .app-grid { grid-template-columns: minmax(0, 1fr); }
  .sidebar, .sidebar .panel, .player-list { min-width: 0; }
  .topbar  { grid-row: 1; }
  .sidebar { grid-row: 2; padding: .6rem 1rem 0; }
  .stage   { grid-row: 3; }
  .sidebar .panel { padding: .5rem .6rem; }
  .sidebar .panel-h { margin-bottom: .4rem; }
  .player-list { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .2rem; scrollbar-width: thin; }
  .player-row { flex: none; padding: .35rem .5rem; }
  .player-row .player-name { max-width: 6.5rem; font-size: .8rem; }
  .player-row .badge-ready, .player-row .badge-off { display: none; }

  /* top bar must stay one row at 375px */
  .topbar { padding: .6rem .75rem; }
  .room-code-btn .room-code-label { display: none; }
  .room-code-btn .room-code { font-size: .9rem; letter-spacing: .12em; padding: .15rem .45rem; }
  .icon-btn, .theme-toggle {
    width: 34px; height: 34px; min-width: 34px; min-height: 34px; padding: 0;
  }
  /* only the dot fits next to the controls; the word stays for screen readers */
  .conn #conn-text {
    position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .splash, .fu-card, .confetti span { animation: none; }
}

.flag-wrap { display: grid; place-items: center; margin-bottom: 1rem; }
.flag-img { width: min(100%, 360px); aspect-ratio: 4 / 3; object-fit: contain; border: var(--border-strong); border-radius: var(--radius-sm); box-shadow: var(--shadow-md); background: var(--white); }

/* travle */
.tv-route { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; margin-bottom: .5rem; }
.tv-end { display: flex; align-items: center; gap: .5rem; font-size: 1.05rem; }
.tv-flag { width: 48px; aspect-ratio: 4 / 3; object-fit: cover; border: var(--bw-thin) solid var(--black); border-radius: 3px; }
.tv-arrow { font-size: 1.4rem; font-weight: 900; }
.tv-left { align-self: center; font-family: var(--font-mono); font-size: .8rem; color: var(--ink-700); }
.tv-chips { display: flex; gap: .4rem; flex-wrap: wrap; margin: .6rem 0 .2rem; }
.tv-chip {
  padding: .3rem .6rem; border: var(--bw-thin) solid var(--black); border-radius: var(--radius-pill);
  font-size: .85rem; font-weight: 700; background: var(--paper-sunk);
}
.tv-chip.is-green { background: var(--green-100); color: var(--green-800); }
.tv-chip.is-amber { background: var(--amber-100); color: var(--amber-800); }
.tv-chip.is-red   { background: var(--red-100); color: var(--red-800); }
.tv-chip.is-path  { background: var(--yellow-300); }

/* Material Symbols as mask images: one file, paints with currentColor,
   so light and dark themes need no second asset. */
.mi {
  display: inline-block; width: 20px; height: 20px; flex: none;
  background-color: currentColor;
  -webkit-mask: var(--mi) center / contain no-repeat;
  mask: var(--mi) center / contain no-repeat;
}
.mi-info  { --mi: url("icons/info.svg"); }
.mi-board { --mi: url("icons/trophy.svg"); }
.mi-chat  { --mi: url("icons/chat.svg"); width: 24px; height: 24px; }
