/* ============================================================
   Blurred Guess — responsive, mobile-first dark theme
   ============================================================ */

:root {
  --bg:        #14141e;
  --bg-2:      #1a1a2e;
  --panel:     #232340;
  --panel-2:   #2c2c4f;
  --line:      #383862;
  --text:      #e8e8f5;
  --muted:     #9a9ac0;
  --accent:    #64f0a0;
  --accent-2:  #4ad4ff;
  --danger:    #ff5d73;
  --warn:      #ffd24a;
  --gold:      #ffd24a;
  --silver:    #cfd6e6;
  --bronze:    #e0975a;
  --radius:    16px;
  --shadow:    0 10px 30px rgba(0, 0, 0, 0.35);
  --font:      system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 50% -10%, #25254a 0%, transparent 60%),
    var(--bg);
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

#app {
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 18px 40px;
  min-height: 100dvh;
}

/* The front page (menu) may grow wide on big screens to lay games out as a
   tile grid — capped at ~2/3 of a 4K width so it never stretches edge-to-edge.
   Other views (lobby/game/results) stay phone-narrow via the default above. */
#app:has(#view-menu.view-active) { max-width: min(2560px, 94vw); }
/* Single-column reading blocks stay centred at a comfortable width even when
   the container is wide; only the game/room tile grids span the full area. */
#view-menu .brand,
#view-menu .field { max-width: 620px; margin-left: auto; margin-right: auto; }

/* ---------------- view switching ---------------- */
.view { display: none; animation: fade 0.25s ease; }
.view-active { display: block; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.hidden { display: none !important; }

/* ---------------- connection pill ---------------- */
.conn-status {
  position: fixed;
  top: 10px; right: 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 999px;
  z-index: 50;
  transition: background 0.2s, color 0.2s;
}
.conn-online   { background: rgba(100, 240, 160, 0.18); color: var(--accent); }
.conn-offline  { background: rgba(255, 93, 115, 0.18); color: var(--danger); }
.conn-connecting { background: rgba(255, 210, 74, 0.18); color: var(--warn); }

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 15px 18px;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease, background 0.15s;
  color: #10101a;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-ghost:disabled:hover { color: var(--muted); border-color: var(--line); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); }
.btn-primary:hover { filter: brightness(1.06); }
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }
.btn-icon {
  flex: 0 0 auto;
  width: 50px;
  font-size: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
}
.btn-icon:active { transform: scale(0.95); }

/* ---------------- brand / menu ---------------- */
.brand { text-align: center; margin: 14px 0 26px; }
.brand-logo {
  width: 92px; height: 92px;
  margin: 0 auto 14px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 35%, #2f2f5c, #1c1c34);
  box-shadow: var(--shadow), inset 0 0 0 2px var(--line);
}
.brand-logo .face { font-size: 52px; line-height: 1; filter: saturate(1.2); }
.brand h1 { font-size: 30px; letter-spacing: -0.02em; }
.tagline { color: var(--muted); margin-top: 8px; font-size: 14px; line-height: 1.5; }

.field { margin-bottom: 22px; }
.field label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 8px;
}
.name-row { display: flex; gap: 10px; }
input[type="text"] {
  flex: 1 1 auto;
  width: 100%;
  padding: 14px 16px;
  font-size: 16px;
  font-family: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(100, 240, 160, 0.15);
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 12px;
}

/* Responsive tile grid: one column on a phone, filling into multiple columns
   as the container widens on desktop/TV. */
.game-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}
.loading { color: var(--muted); padding: 20px; text-align: center; grid-column: 1 / -1; }
.game-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.game-card:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: 0 10px 28px rgba(0,0,0,0.28); }
/* Header: big icon on the left, title + tagline stacked to its right. */
.game-card-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}
.game-icon {
  flex: 0 0 auto;
  font-size: 64px;
  line-height: 1;
  filter: saturate(1.15) drop-shadow(0 2px 6px rgba(0,0,0,0.25));
}
/* SVG icons (e.g. the maze) render at the same footprint, tinted via currentColor. */
.game-icon-svg { color: var(--accent-2); width: 62px; height: 62px; }
.game-icon-svg svg { display: block; width: 100%; height: 100%; }
.game-headings { min-width: 0; }
.game-headings .tagline-sm { margin-bottom: 0; }
.game-card h3 { font-size: 18px; margin-bottom: 4px; }
/* desc absorbs slack so the action row lines up across tiles of unequal text. */
.game-card .desc { color: var(--muted); font-size: 13.5px; line-height: 1.5; margin-bottom: 14px; flex: 1 1 auto; }
.game-card .meta {
  display: flex; align-items: center; gap: 10px;
  font-size: 12px; color: var(--muted); margin-bottom: 14px;
}
.badge {
  font-size: 11px; font-weight: 700;
  padding: 3px 8px; border-radius: 999px;
  background: rgba(100, 240, 160, 0.15); color: var(--accent);
}
.badge.off { background: rgba(255, 93, 115, 0.15); color: var(--danger); }
.badge.badge-tv { background: rgba(74, 212, 255, 0.15); color: var(--accent-2); }

/* ---------------- open-rooms list ---------------- */
/* Same responsive tiling as the game grid so a wide menu stays coherent. */
.room-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
  margin-bottom: 8px;
}
.room-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
}
.room-info { flex: 1; min-width: 0; }
.room-code-tag {
  font-weight: 800; letter-spacing: 0.12em; color: var(--accent);
  font-size: 15px;
}
.room-sub { display: block; font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.btn-join {
  flex: 0 0 auto;
  padding: 9px 18px;
  font-size: 14px; font-weight: 700; font-family: inherit;
  color: #10101a;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border: none; border-radius: 10px; cursor: pointer;
  transition: transform 0.08s, filter 0.15s;
}
.btn-join:hover:not(:disabled) { filter: brightness(1.06); }
.btn-join:active:not(:disabled) { transform: scale(0.96); }
.btn-join:disabled { opacity: 0.5; cursor: default; background: var(--panel-2); color: var(--muted); }

/* ---------------- lobby ---------------- */
.lobby-head, .game-head, .results-head { margin-bottom: 18px; }
.lobby-head { display: flex; align-items: center; justify-content: space-between; }
.lobby-head h2 { font-size: 22px; }
.room-pill {
  font-size: 13px; color: var(--muted);
  background: var(--panel); border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 999px;
}
.room-pill span { color: var(--accent); font-weight: 800; letter-spacing: 0.1em; }
.lobby-hint { color: var(--muted); font-size: 14px; margin-bottom: 16px; }
.countdown {
  text-align: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--warn);
  margin-bottom: 16px;
  animation: pulse 1s ease-in-out infinite;
}
.countdown span { font-size: 26px; }
@keyframes pulse { 50% { opacity: 0.55; } }

.player-list { list-style: none; display: grid; gap: 10px; margin-bottom: 22px; }
.player-list li {
  display: flex; align-items: center; gap: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 16px;
  font-size: 15px;
}
.player-list li.me { border-color: var(--accent); }
.player-list .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 16px; font-weight: 800; color: #10101a;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
.player-list .pname { flex: 1; font-weight: 600; }
.player-list .pstate { font-size: 12px; color: var(--muted); }
.player-list li.eliminated { opacity: 0.5; }
.player-list li.eliminated .pstate { color: var(--danger); }
.player-list .pname-rename { width: auto; font-size: 15px; padding: 4px 8px; border-radius: 10px; opacity: 0.75; }
.player-list .pname-rename:hover { opacity: 1; border-color: var(--accent); }

/* ---- rename dialog (modal) ---- */
.modal-overlay {
  position: fixed; inset: 0; z-index: 80; display: flex; align-items: center; justify-content: center;
  background: rgba(6,6,12,0.66); backdrop-filter: blur(3px); padding: 20px;
}
.modal-overlay.hidden { display: none; }
.modal-box {
  width: 100%; max-width: 360px; background: var(--panel); border: 1px solid var(--line);
  border-radius: 16px; padding: 22px; box-shadow: var(--shadow); animation: slideUp 0.2s ease;
}
.modal-box h3 { font-size: 18px; margin-bottom: 14px; }
.modal-box input {
  width: 100%; margin-bottom: 16px; padding: 12px 14px; font-size: 16px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; color: var(--text);
}
.modal-box input:focus { outline: none; border-color: var(--accent); }
.modal-actions { display: flex; gap: 10px; }
.modal-actions .btn { flex: 1; }
.tag-you {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  background: var(--accent); color: #10101a;
  padding: 2px 6px; border-radius: 6px;
}
.tag-host {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  background: rgba(255, 210, 74, 0.18); color: var(--gold, #ffd24a);
  border: 1px solid rgba(255, 210, 74, 0.5);
  padding: 2px 7px; border-radius: 6px; white-space: nowrap;
}

/* ---------------- game ---------------- */
.game-head { display: flex; align-items: center; gap: 12px; }
.round-badge, .alive-badge {
  font-size: 13px; font-weight: 700;
  background: var(--panel); border: 1px solid var(--line);
  padding: 8px 12px; border-radius: 999px; white-space: nowrap;
}
.round-badge span, .alive-badge span { color: var(--accent); }
.timer {
  flex: 1;
  height: 10px;
  background: var(--panel);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.timer-bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.45s linear, background 0.3s;
}
.timer-bar.low { background: linear-gradient(90deg, var(--danger), var(--warn)); }

.stage { margin-bottom: 18px; }
.image-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-2);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}
/* The blurred-guess image (id may vary by view module, so match by container). */
.image-frame img {
  width: 100%; height: 100%;
  object-fit: cover; display: block;
  /* Server sends small PNGs for blurred frames; let the browser scale them up
     smoothly (this IS the blur — a tiny source stretched to fill reads as blur).
     Never pixelate. */
  image-rendering: auto;
}
.game-overlay {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  text-align: center;
  padding: 20px;
  font-size: 22px; font-weight: 800;
  background: rgba(12, 12, 22, 0.82);
  backdrop-filter: blur(3px);
}
.game-overlay.eliminated { color: var(--danger); }
.game-overlay.safe { color: var(--accent); }
.game-overlay small { display: block; font-size: 14px; font-weight: 500; color: var(--muted); margin-top: 8px; }

.word-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
}
.word-btn {
  padding: 16px 10px;
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  cursor: pointer;
  text-transform: capitalize;
  transition: transform 0.08s, border-color 0.12s, background 0.12s;
}
.word-btn:hover:not(:disabled) { border-color: var(--accent); background: var(--panel-2); }
.word-btn:active:not(:disabled) { transform: scale(0.97); }
.word-btn:disabled { opacity: 0.55; cursor: default; }
.word-btn.chosen { border-color: var(--accent-2); background: rgba(74, 212, 255, 0.16); }
.word-btn.correct { border-color: var(--accent); background: rgba(100, 240, 160, 0.2); }
.word-btn.wrong { border-color: var(--danger); background: rgba(255, 93, 115, 0.2); }

.guess-status { text-align: center; min-height: 22px; color: var(--muted); font-size: 14px; }

/* ---------------- round summary toast ---------------- */
.round-summary {
  position: fixed;
  left: 50%; bottom: 24px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 28px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
  z-index: 40;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translate(-50%, 20px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }
.round-summary h4 { font-size: 14px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: 0.05em; }
.round-summary .answer { font-size: 20px; font-weight: 800; color: var(--accent); margin-bottom: 12px; text-transform: capitalize; }
.rs-row { display: flex; align-items: center; gap: 10px; font-size: 14px; padding: 5px 0; }
.rs-row .rank { width: 22px; color: var(--muted); font-weight: 700; }
.rs-row .nm { flex: 1; }
.rs-row .tm { color: var(--accent); font-weight: 700; font-size: 18px; font-variant-numeric: tabular-nums; }
.rs-row.out .nm { color: var(--danger); }

/* ---------------- results / leaderboard ---------------- */
.results-head { text-align: center; }
.results-head h2 { font-size: 26px; }
/* "Back to menu" / "Leave" shouldn't sit flush against the button above them. */
#results-menu, #leave-lobby { margin-top: 12px; }
.results-body { display: flex; gap: 32px; align-items: flex-start; }
.results-body .leaderboard { flex: 1 1 0; min-width: 0; }
.results-qr-col { flex: 0 0 auto; text-align: center; padding: 16px; background: var(--panel); border: 1px solid var(--line); border-radius: 16px; }
.results-qr-col.hidden { display: none; }
.leaderboard { list-style: none; display: grid; gap: 10px; margin: 22px 0; }
.lb-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.lb-row.me { border-color: var(--accent); }
.lb-row .rank {
  width: 40px; height: 34px; flex: 0 0 auto;
  display: grid; place-items: center;
  border-radius: 10px;
  font-weight: 800; font-size: 13px; letter-spacing: -0.03em;
  background: var(--panel-2); color: var(--muted);
}
.lb-row.r1 .rank { background: var(--gold); color: #2a2200; }
.lb-row.r2 .rank { background: var(--silver); color: #1a1a1a; }
.lb-row.r3 .rank { background: var(--bronze); color: #2a1500; }
.lb-row .nm { flex: 1; font-weight: 700; font-size: 19px; }
.lb-row .nm small { display: block; font-weight: 500; font-size: 12px; color: var(--muted); }
.lb-row .nm small.out { color: var(--danger); }
/* The reaction-time average is the headline stat here — make it prominent. */
.lb-row .nm small.lb-avg { font-size: 17px; font-weight: 700; color: var(--accent); margin-top: 2px; }
/* Snaker length — the key stat; keep it clearly readable under the name. */
.lb-row .nm small.lb-len { font-size: 16px; font-weight: 700; color: var(--accent-2); margin-top: 3px; }
.lb-row .score { font-weight: 800; font-variant-numeric: tabular-nums; color: var(--accent); }

/* ---------------- menu extras (cards, watch, rooms) ---------------- */
.game-card.off { opacity: 0.6; }
.tagline-sm { color: var(--accent-2); font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.card-actions { display: flex; gap: 10px; }
.card-actions .btn { width: auto; flex: 1; }
.card-actions .btn-ghost { flex: 0 0 auto; padding-left: 14px; padding-right: 14px; }
.room-actions { display: flex; gap: 8px; flex: 0 0 auto; }
.btn-watch {
  padding: 9px 12px; font-size: 15px; font-family: inherit;
  background: var(--panel-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px; cursor: pointer;
}
.btn-watch:hover { border-color: var(--accent-2); }

/* ---------------- share box + team tags ---------------- */
.share-box { margin-bottom: 14px; }
.share-row { display: flex; gap: 10px; }
.share-btn { width: auto; flex: 1; font-size: 14px; padding: 12px; }
.tag-team {
  font-size: 10px; font-weight: 800; text-transform: uppercase;
  padding: 2px 6px; border-radius: 6px; background: var(--panel-2); color: var(--muted);
}
.team-left  .tag-team, .lb-row.team-left  .rank { background: var(--accent); color: #08160e; }
.team-right .tag-team, .lb-row.team-right .rank { background: var(--accent-2); color: #06121a; }
.player-list li.team-left  { border-left: 4px solid var(--accent); }
.player-list li.team-right { border-left: 4px solid var(--accent-2); }
.muted { color: var(--muted); }

/* ---------------- TV / observer mode ---------------- */
.tv-lobby-banner {
  text-align: center; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px; margin-bottom: 18px;
}
.tv-join-hint { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: 0.08em; }
.tv-qr { display: block; margin: 12px auto; background: #fff; border-radius: 12px; padding: 10px; box-shadow: var(--shadow); width: min(280px, 60vw); height: auto; image-rendering: pixelated; }
.tv-join-url { font-size: 22px; font-weight: 800; color: var(--accent-2); margin: 4px 0 14px; }
.tv-room-big { font-size: 64px; font-weight: 900; letter-spacing: 0.16em; color: var(--accent); line-height: 1; }

.tv-options { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 14px 0; }
.tv-chip {
  padding: 8px 14px; font-size: 16px; font-weight: 700; text-transform: capitalize;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
}
.tv-chip.correct { border-color: var(--accent); background: rgba(100,240,160,0.2); color: var(--text); }
.tv-chip.wrong { border-color: var(--danger); background: rgba(255,93,115,0.15); }

.tv-scoreboard { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 18px; }
.tv-scoreboard h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 8px; }
.tvb-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 17px; border-bottom: 1px solid rgba(255,255,255,0.04); }
.tvb-row:last-child { border-bottom: none; }
.tvb-name { font-weight: 600; }
.tvb-score { font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }

/* TV lobby: players (left) + QR (right) share one box; stack when narrow. */
.tv-col-title { display: none; }
body.tv-mode .lobby-body {
  display: flex; flex-wrap: wrap; gap: 28px; align-items: flex-start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow); margin-bottom: 18px;
}
body.tv-mode .lobby-col { flex: 1 1 300px; min-width: 0; }
body.tv-mode .lobby-body .player-list { margin: 0; }
body.tv-mode .lobby-body .player-list li { background: var(--panel-2); }
body.tv-mode .tv-col-title { display: block; font-size: 13px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 12px; }
body.tv-mode #tv-lobby-banner { background: none; border: none; padding: 0; margin: 0; box-shadow: none; }
body.tv-mode #tv-lobby-banner .tv-room-big { font-size: 46px; }

/* On a big screen, give the app room to breathe and enlarge the stage. */
body.tv-mode #app { max-width: 1120px; }
body.tv-mode .stage { margin-bottom: 22px; }
body.tv-mode #conn-status { font-size: 14px; }
@media (min-width: 900px) {
  /* two-column layout only for Blurred (image + scoreboard); other games manage their own */
  body.tv-mode #view-game .game-blurred {
    display: grid; grid-template-columns: 1.4fr 1fr; gap: 24px; align-items: start;
  }
  body.tv-mode #view-game .game-blurred .game-head { grid-column: 1 / -1; }
  body.tv-mode #view-game .game-blurred .tv-options { grid-column: 1 / -1; }
}

/* ---------------- Reaction Rush ---------------- */
.rx-pad {
  width: 100%; min-height: 48vh; margin: 8px 0 14px;
  border: none; border-radius: var(--radius);
  font-family: inherit; font-size: 34px; font-weight: 900; color: #08160e;
  cursor: pointer; letter-spacing: 0.02em;
  transition: background 0.06s, transform 0.05s;
  box-shadow: var(--shadow);
}
.rx-pad:active { transform: scale(0.995); }
.rx-idle   { background: var(--panel-2); color: var(--muted); }
.rx-arming { background: linear-gradient(160deg, #ff5d73, #c8283c); color: #fff; }
.rx-go     { background: linear-gradient(160deg, #64f0a0, #2fd07f); color: #08160e; animation: rxpulse 0.5s ease infinite alternate; }
.rx-wait   { background: var(--panel-2); color: var(--warn); }
.rx-done   { background: linear-gradient(160deg, #4ad4ff, #2f9fd0); color: #06121a; }
.rx-out    { background: linear-gradient(160deg, #ffd24a, #e0975a); color: #2a1500; }
@keyframes rxpulse { from { filter: brightness(1); } to { filter: brightness(1.15); } }

.rx-stage { display: grid; place-items: center; margin: 10px 0 18px; }
.rx-light {
  width: min(60vw, 320px); aspect-ratio: 1/1; border-radius: 50%;
  box-shadow: inset 0 0 0 8px rgba(0,0,0,0.25), var(--shadow);
  transition: background 0.08s, box-shadow 0.2s;
}
.rx-light.rx-idle { background: radial-gradient(circle at 40% 35%, #3a3a5c, #222240); }
.rx-light.rx-red   { background: radial-gradient(circle at 40% 35%, #ff8090, #c8283c); box-shadow: inset 0 0 0 8px rgba(0,0,0,0.25), 0 0 60px rgba(255,93,115,0.6); }
.rx-light.rx-green { background: radial-gradient(circle at 40% 35%, #9dffce, #2fd07f); box-shadow: inset 0 0 0 8px rgba(0,0,0,0.2), 0 0 80px rgba(100,240,160,0.75); }
.rx-light-label { margin-top: 16px; font-size: 30px; font-weight: 900; color: var(--text); }

.rx-feed { display: grid; gap: 6px; margin-bottom: 14px; min-height: 40px; }
.rx-feed-row { display: flex; justify-content: space-between; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 14px; font-size: 16px; animation: slideUp 0.2s ease; }
.rx-feed-row.out { opacity: 0.75; }
.rx-nm { font-weight: 700; }
.rx-ms { color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; }
.rx-jump { color: var(--warn); font-weight: 700; }

/* ---------------- Tug of War ---------------- */
.tug-rope {
  position: relative; width: 100%; height: 120px; margin: 12px 0 16px;
  border-radius: var(--radius); overflow: hidden; display: flex;
  border: 1px solid var(--line); box-shadow: var(--shadow);
}
.tug-rope-tv { height: 220px; }
.tug-zone { flex: 1; display: grid; place-items: center; padding: 10px; }
.tug-zone-left  { background: linear-gradient(90deg, rgba(100,240,160,0.28), rgba(100,240,160,0.06)); }
.tug-zone-right { background: linear-gradient(90deg, rgba(74,212,255,0.06), rgba(74,212,255,0.28)); }
.tug-side-label { font-size: 40px; }
.tug-center { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,0.35); transform: translateX(-1px); }
.tug-marker {
  position: absolute; top: 50%; left: 50%;
  width: 34px; height: 34px; border-radius: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 40% 35%, #fff, #c9c9e6);
  box-shadow: 0 0 0 4px rgba(0,0,0,0.25), 0 6px 16px rgba(0,0,0,0.4);
  transition: left 0.1s linear; z-index: 3;
}
.tug-rope-tv .tug-marker { width: 54px; height: 54px; }
.tug-names { display: grid; gap: 4px; font-weight: 700; font-size: 16px; text-align: center; z-index: 2; }

/* On a TV, the rope fills the screen: wide, tall, big marker + names. */
body.tug-tv.tv-mode #app { max-width: 100%; padding: 8px 10px; }
body.tug-tv.tv-mode #view-game .game-head { margin: 2px 0 8px; }
body.tug-tv .tug-rope-tv { height: min(62vh, 720px); margin: 16px 0 20px; }
body.tug-tv .tug-rope-tv .tug-marker { width: min(11vh, 130px); height: min(11vh, 130px); box-shadow: 0 0 0 6px rgba(0,0,0,0.25), 0 10px 26px rgba(0,0,0,0.45); }
body.tug-tv .tug-names { gap: 8px; font-size: clamp(22px, 3.4vh, 48px); }
body.tug-tv .tug-status-big { font-size: clamp(26px, 4vh, 56px); min-height: 46px; }
body.tug-tv .tug-banner { font-size: clamp(28px, 4.4vh, 60px); padding: 22px; }

.tug-mash {
  width: 100%; min-height: 40vh; margin-bottom: 12px;
  border: none; border-radius: var(--radius);
  font-family: inherit; font-size: 40px; font-weight: 900; color: #08160e;
  cursor: pointer; box-shadow: var(--shadow); transition: transform 0.04s, filter 0.1s;
  background: var(--panel-2);
}
.tug-mash.armed:active { transform: scale(0.98); filter: brightness(1.1); }
.tug-mash:disabled { opacity: 0.6; }
.tug-mash.team-left  { background: linear-gradient(160deg, #64f0a0, #2fd07f); color: #08160e; }
.tug-mash.team-right { background: linear-gradient(160deg, #4ad4ff, #2f9fd0); color: #06121a; }

.tug-banner {
  text-align: center; font-size: 24px; font-weight: 900; padding: 16px; border-radius: var(--radius);
  margin-bottom: 12px; animation: slideUp 0.25s ease;
}
.tug-banner.team-left  { background: rgba(100,240,160,0.22); color: var(--accent); }
.tug-banner.team-right { background: rgba(74,212,255,0.22); color: var(--accent-2); }
.tug-banner.tug-tie    { background: rgba(255,255,255,0.10); color: var(--muted); }
.tug-status-big { font-size: 22px; font-weight: 800; color: var(--warn); min-height: 30px; }

.winner-banner {
  text-align: center; font-size: 26px; font-weight: 900; padding: 18px;
  border-radius: var(--radius); margin-bottom: 16px; animation: slideUp 0.25s ease;
}
.winner-banner.team-left  { background: rgba(100,240,160,0.22); color: var(--accent); }
.winner-banner.team-right { background: rgba(74,212,255,0.22); color: var(--accent-2); }

/* ---------------- Labyrinth ---------------- */
.lab-canvas {
  display: block; margin: 4px auto 12px; max-width: 100%; height: auto;
  background: #0e0e18; border-radius: 12px; border: 1px solid var(--line);
  image-rendering: auto; touch-action: none;
}
/* TV: stretch the maze to fill the screen; standings as a strip beneath it. */
.lab-stage-tv { display: flex; flex-direction: column; gap: 14px; }
.lab-canvas-tv { display: block; width: 100%; max-width: 100%; height: auto; max-height: 76vh; object-fit: contain; margin: 0 auto; }
.lab-board { width: 100%; }
/* On a TV, let the maze fill the whole screen (JS sizes the canvas to fit). */
body.lab-tv.tv-mode #app { max-width: 100%; padding: 6px; }
body.lab-tv.tv-mode #view-game .game-head { margin: 2px 0 6px; }
body.lab-tv .lab-stage-tv { gap: 8px; }
body.lab-tv .lab-canvas-tv { width: auto; height: auto; max-width: none; max-height: none; }
.lab-board h4 { display: inline-block; margin: 0 16px 0 0; vertical-align: middle; }
.lab-board .tvb-row { display: inline-flex; margin: 0 16px 4px 0; padding: 4px 0; border: none; font-size: 20px; }

.lab-dpad {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  gap: 12px; width: min(440px, 96%); height: min(66vh, 580px); margin: 10px auto 0;
  touch-action: none; transition: opacity 0.15s;
}
.lab-dpad-off { opacity: 0.4; filter: grayscale(0.5); pointer-events: none; }
/* Forfeit (give up this maze) + Leave (quit the game) controls on the phone. */
.lab-forfeit { display: block; width: 100%; max-width: 440px; margin: 14px auto 0; }
.lab-leave { display: block; width: 100%; max-width: 440px; margin: 10px auto 0; opacity: 0.75; font-size: 14px; }
.lab-standings { margin: 8px auto 0; max-width: 460px; }
.lab-standings .tvb-row { font-size: 18px; }
.lab-btn {
  font-size: 44px; font-weight: 800; font-family: inherit; border: none; border-radius: 18px;
  background: var(--panel-2); color: var(--text); cursor: pointer;
  touch-action: none; -webkit-user-select: none; user-select: none;
  box-shadow: var(--shadow); transition: background 0.04s, transform 0.04s;
}
.lab-btn:active { background: linear-gradient(160deg, var(--accent), var(--accent-2)); color: #08160e; transform: scale(0.94); }
.lab-up    { grid-column: 2; grid-row: 1; }
.lab-left  { grid-column: 1; grid-row: 2; }
.lab-right { grid-column: 3; grid-row: 2; }
.lab-down  { grid-column: 2; grid-row: 3; }

/* boost indicator on the phone D-pad */
.lab-dpad.lab-boosted { filter: drop-shadow(0 0 20px rgba(255, 210, 74, 0.95)); }
.lab-dpad.lab-boosted .lab-btn { background: linear-gradient(160deg, #ffd24a, #ff9d5c); color: #2a1500; }

/* Countdown / GO overlay (both phone and TV) — centred on the whole screen */
.lab-overlay { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; z-index: 60; text-align: center; }
.lab-count-sub { display: block; font-size: 20px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }
.lab-count-big { display: block; font-size: clamp(72px, 22vw, 280px); font-weight: 900; color: var(--accent); line-height: 1; text-shadow: 0 8px 40px rgba(0,0,0,0.6); animation: labpop 0.3s ease; }
.lab-go { color: var(--accent-2); }
@keyframes labpop { from { transform: scale(0.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---------------- Snaker ---------------- */
/* The field fills the whole screen on a TV — break out of the tv-mode app cap. */
body.snk-tv.tv-mode #app { max-width: 100%; padding: 6px; }
body.snk-tv.tv-mode #view-game .game-head { margin: 2px 0 6px; }
.snk-stage-tv { position: relative; width: fit-content; margin: 0 auto; }
.snk-canvas-tv { display: block; border-radius: 12px; box-shadow: var(--shadow); background: #0b0b14; }
.snk-hud {
  position: absolute; top: 12px; left: 12px; min-width: 140px;
  background: rgba(10,10,20,0.62); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; font-size: 15px; backdrop-filter: blur(3px);
}
.snk-hud-alive { font-weight: 800; margin-bottom: 6px; color: var(--accent); }
.snk-hud-row { display: flex; align-items: center; gap: 7px; font-weight: 600; padding: 1px 0; }
.snk-hud-row b { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); }
.snk-chip { width: 12px; height: 12px; border-radius: 50%; flex: 0 0 auto; box-shadow: 0 0 6px rgba(0,0,0,0.4); }

/* The steering pad fills the whole screen (both orientations) — break the app cap. */
body.snk-play #app { max-width: 100%; padding: 6px; }
body.snk-play .snk-status { margin: 2px 0; font-size: 13px; min-height: 18px; }
/* phone: circular steering pad — as big as the smaller screen dimension allows */
.snk-status { text-align: center; min-height: 22px; }
.snk-pad {
  position: relative; width: min(90vmin, 900px); aspect-ratio: 1; margin: 6px auto 0;
  border-radius: 50%; touch-action: none; user-select: none;
  background: radial-gradient(circle at 50% 45%, #23233c, #14141f 70%);
  border: 2px solid var(--line); box-shadow: inset 0 4px 24px rgba(0,0,0,0.5), var(--shadow);
  transition: box-shadow 0.12s;
}
.snk-pad-run { box-shadow: inset 0 4px 24px rgba(0,0,0,0.5), 0 0 30px rgba(255,210,74,0.6); }
.snk-ring { position: absolute; inset: 12%; border-radius: 50%; border: 2px dashed rgba(255,255,255,0.12); }
.snk-center {
  position: absolute; left: 50%; top: 50%; width: 30%; aspect-ratio: 1; transform: translate(-50%,-50%);
  border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle, rgba(255,210,74,0.28), rgba(255,210,74,0.05) 70%);
  border: 2px solid rgba(255,210,74,0.7); color: #ffd24a; font-weight: 900; font-size: 15px; letter-spacing: 0.06em;
}
.snk-knob {
  position: absolute; left: 50%; top: 50%; width: 22%; aspect-ratio: 1; transform: translate(-50%,-50%);
  border-radius: 50%; background: linear-gradient(160deg, var(--accent-2), #2a86c0);
  border: 2px solid rgba(255,255,255,0.85); box-shadow: 0 4px 16px rgba(0,0,0,0.5); pointer-events: none;
}
.snk-knob-run { background: linear-gradient(160deg, #ffd24a, #ff9d5c); }
.snk-dead { text-align: center; margin-top: 26px; }
.snk-dead-big { font-size: 30px; font-weight: 900; }
.snk-dead-sub { color: var(--muted); margin-top: 8px; }
/* Winner announcement panel — readable over the busy field. */
.snk-win-box {
  display: inline-flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 26px 54px; border-radius: 26px;
  background: rgba(8,8,16,0.82); border: 2px solid rgba(255,210,74,0.6);
  box-shadow: 0 16px 70px rgba(0,0,0,0.75), 0 0 60px rgba(255,210,74,0.25);
}

/* ---------------- Memefall ---------------- */
.mf-stage { position: relative; margin-bottom: 12px; }
.mf-canvas {
  display: block; width: 100%; height: auto; border-radius: 14px;
  border: 1px solid var(--line); box-shadow: var(--shadow); touch-action: none;
}
body.tv-mode .mf-canvas { max-height: 72vh; }
/* On a TV, fill the whole screen (JS sizes the canvas to fit W and H). */
body.mf-tv.tv-mode #app { max-width: 100%; padding: 6px; }
body.mf-tv.tv-mode #view-game .game-head { margin: 2px 0 6px; }
body.mf-tv .mf-stage { width: fit-content; margin: 0 auto 6px; }
body.mf-tv .mf-canvas { width: auto; height: auto; max-height: none; }

.mf-answered-bar {
  text-align: center; font-size: 15px; font-weight: 700; color: var(--muted);
  margin-bottom: 10px;
}

/* 2×2 grid sized by whichever dimension is more constrained: width or height. */
.mf-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: repeat(2, 1fr);
  gap: 8px;
  /* Square grid that fits both the available width AND the remaining viewport height.
     190px ≈ game-head + status + winners + app padding. */
  height: min(calc(100vw - 36px), calc(100dvh - 190px));
  margin-bottom: 10px;
}
.mf-opt {
  min-height: 0; min-width: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 6px; background: #f0f2ff; border: 2px solid var(--line);
  border-radius: 14px; cursor: pointer;
  transition: border-color 0.1s, background 0.1s, transform 0.06s;
  font-family: inherit; overflow: hidden;
}
.mf-opt:hover:not(:disabled) { border-color: var(--accent); background: #e0e6ff; }
.mf-opt:active:not(:disabled) { transform: scale(0.97); }
.mf-opt:disabled { cursor: default; }
.mf-opt.chosen  { border-color: var(--accent-2); background: #cdf0fc; }
.mf-opt.correct { border-color: var(--accent);   background: #c8f5dc; }
.mf-opt.wrong   { border-color: var(--danger);   background: #fdd8dc; opacity: 0.75; }
.mf-opt-img { width: 100%; height: 100%; object-fit: contain; display: block; }

.mf-toast-img {
  display: block; margin: 8px auto 4px; width: 72px; height: 72px; object-fit: contain;
}

.mf-board { margin-top: 10px; }

/* Winner strip: small meme icon + winner name per round */
.mf-winners {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; justify-content: center; align-items: flex-start;
}
.mf-winner-pill {
  display: inline-flex; flex-direction: column; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 700; color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
  padding: 8px 10px; border-radius: 16px;
}
.mf-winner-pill.muted { color: var(--muted); }
.mf-winner-name { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mf-winner-icon {
  width: 52px; height: 52px; object-fit: contain;
  border-radius: 12px; background: #eef0ff; flex-shrink: 0;
}
/* On a TV the (up to 5) pills spread across the bottom strip and scale with the window. */
body.mf-tv .mf-winners { gap: 14px; margin: 12px 0 8px; flex-wrap: nowrap; width: 100%; }
body.mf-tv .mf-winner-pill { flex: 1 1 0; min-width: 0; max-width: 300px; font-size: clamp(15px, 1.5vw, 26px); padding: 10px; gap: 8px; border-radius: 18px; }
body.mf-tv .mf-winner-icon { width: auto; height: clamp(48px, 10vh, 120px); max-width: 100%; border-radius: 14px; }

/* ---------------- responsive niceties ---------------- */
@media (min-width: 480px) {
  .word-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-height: 680px) {
  .brand { margin: 6px 0 18px; }
  .brand-logo { width: 72px; height: 72px; }
  .brand-logo .face { font-size: 40px; }
}
