:root {
  --bg: #0b1033; --panel: #141a46; --line: #262e66; --text: #f3f4fb; --muted: #9aa1c9;
  --board: #0f1fa8; --board-2: #0a1680; --gold: #f6c344; --accent: #e8772e;
  --good: #2fa866; --bad: #d1493f; --live: #ffd24a;
  --font: "IBM Plex Sans", system-ui, sans-serif; --display: "Barlow Condensed", "Arial Narrow", sans-serif;
  --clue: "Libre Baskerville", Georgia, serif; --mono: "IBM Plex Mono", ui-monospace, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 var(--font); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; transition: box-shadow .08s; }
#app { max-width: 560px; margin: 0 auto; padding: max(14px, env(safe-area-inset-top)) 16px max(18px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
h1, h2 { font-family: var(--display); letter-spacing: .02em; margin: 0; text-transform: uppercase; }
h1 { font-size: 40px; } h2 { font-size: 20px; }
.brand span { color: var(--gold); }
p { margin: 0; }
.muted { color: var(--muted); } .small { font-size: 13px; } .mono { font-family: var(--mono); } .center { text-align: center; }
.err { color: #ff8c84; min-height: 1.2em; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.card.warn { border-color: var(--accent); }
details.card summary { cursor: pointer; font-family: var(--display); text-transform: uppercase; font-size: 18px; letter-spacing: .03em; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
label.row { flex-direction: row; align-items: center; }
input, select { font: inherit; color: var(--text); background: #0d1238; border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; width: 100%; min-width: 0; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--gold); }
.codein { text-transform: uppercase; font-family: var(--mono); letter-spacing: .3em; font-size: 20px; }
button, .btn { font: 600 16px var(--font); color: var(--text); background: #222a63; border: 1px solid #333c80; border-radius: 12px; padding: 12px 14px; cursor: pointer; text-decoration: none; text-align: center; touch-action: manipulation; }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--gold); color: #1a1400; border-color: var(--gold); }
button.good { background: var(--good); border-color: var(--good); } button.bad { background: var(--bad); border-color: var(--bad); }
button.ghost { background: transparent; border-color: var(--line); color: var(--muted); }
button.big { padding: 18px; font-size: 19px; flex: 1; }
button.link, a.link { background: none; border: 0; padding: 6px 0; color: var(--muted); text-decoration: underline; font-weight: 500; font-size: 14px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > input { flex: 1; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.center { justify-content: center; }
.chip { border-radius: 999px; padding: 8px 14px; background: #1b2257; border: 1px solid var(--line); font-weight: 500; font-size: 15px; }
.chip.on { background: var(--gold); color: #1a1400; border-color: var(--gold); }
.code { font: 600 34px var(--mono); letter-spacing: .25em; color: var(--gold); }
.status { text-align: center; font-size: 19px; font-weight: 600; padding: 6px 0; }
.status.live { color: var(--live); }
footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 6px; }
.offline { position: fixed; top: 0; left: 0; right: 0; background: var(--accent); color: #fff; text-align: center; padding: 6px; font-weight: 600; z-index: 10; }
.side { padding: 4px 0; border-top: 1px solid var(--line); }
.side:first-child { border-top: 0; }
.adj .row button { padding: 6px 14px; }

/* player header */
header.me { display: flex; justify-content: space-between; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; }
header.me .n { font-weight: 600; font-size: 18px; }
header.me .s { font: 700 30px var(--display); color: var(--gold); }
.neg { color: #ff8c84 !important; }

/* the buzzer pad */
.pad { width: 100%; min-height: 42dvh; border-radius: 22px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 18px;
  border: 3px solid #2b336f; background: #161c4a; color: var(--muted); user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; transition: background .05s; }
.pad .big { font: 800 clamp(34px, 11vw, 58px)/1 var(--display); text-transform: uppercase; letter-spacing: .02em; }
.pad .sub { font-size: 14px; text-align: center; max-width: 30ch; }
.pad.live { background: var(--live); border-color: #fff3b8; color: #2a1d00; box-shadow: 0 0 60px rgba(255,210,74,.7); }
.pad.early { background: var(--bad); border-color: #ff9b93; color: #fff; }
.pad.sent { background: #3b3416; border-color: var(--gold); color: var(--gold); }
.pad.won { background: var(--good); border-color: #9ef0c0; color: #fff; }
.pad.lost, .pad.out { background: #1a1d36; color: var(--muted); }
body.lit { box-shadow: inset 0 0 0 10px var(--live); }

/* clue / answer screens (phone + host sizes) */
.screen { background: var(--board); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: inset 0 0 0 2px #2840d8; }
.screen .meta { display: flex; justify-content: space-between; gap: 10px; font: 600 15px var(--display); text-transform: uppercase; letter-spacing: .05em; color: #c9d0ff; }
.cluetext { font: 700 18px/1.45 var(--clue); text-transform: uppercase; text-shadow: 2px 2px 0 #000a; }
.cluetext.small { font-size: 14px; opacity: .85; }
.answer { font: 800 28px var(--display); color: var(--gold); text-align: center; text-transform: uppercase; }
.hostanswer { background: #2a2208; border: 1px dashed var(--gold); border-radius: 12px; padding: 10px 12px; font-size: 18px; font-weight: 600; }
.ddword { font: 800 clamp(30px, 9vw, 60px)/1.05 var(--display); text-transform: uppercase; color: var(--gold); text-align: center; }
.outcomes { display: flex; flex-wrap: wrap; gap: 8px 14px; justify-content: center; font-size: 14px; }
.outcomes .ok { color: #8ff0b6; } .outcomes .no { color: #ff9b93; }
.timer { height: 10px; background: #1b2257; border-radius: 99px; overflow: hidden; }
.timer i { display: block; height: 100%; background: var(--gold); width: 100%; }
.clueimg { max-width: 100%; max-height: 40vh; object-fit: contain; border-radius: 10px; align-self: center; }

/* board grid */
.board { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 4px; background: #000; padding: 4px; border-radius: 10px; }
.board .cat { background: var(--board); color: #fff; font: 700 11px/1.1 var(--display); text-transform: uppercase; text-align: center; padding: 6px 2px; display: flex; align-items: center; justify-content: center; min-height: 46px; word-break: break-word; }
.board .cell { background: var(--board); color: var(--gold); font: 800 18px var(--display); border: 0; border-radius: 0; padding: 12px 0; text-shadow: 2px 2px 0 #000; display: flex; align-items: center; justify-content: center; }
.board .cell:disabled, .board .cell.used { background: var(--board-2); opacity: 1; }

/* ---------- TV ---------- */
body[data-role=tv] { overflow: hidden; }
body[data-role=tv] #app { max-width: none; height: 100dvh; padding: 2vh 2.5vw; gap: 1.6vh; }
body[data-role=tv] .tvgame { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 1.6vh; }
.tvhead { display: flex; justify-content: space-between; font: 700 3.2vh var(--display); text-transform: uppercase; letter-spacing: .04em; color: #c9d0ff; }
body[data-role=tv] .board { flex: 1; gap: .5vw; padding: .5vw; grid-template-rows: auto repeat(5, 1fr); }
body[data-role=tv] .board .cat { font-size: clamp(14px, 2.6vh, 34px); min-height: 11vh; padding: 1vh .6vw; }
body[data-role=tv] .board .cell { font-size: 7vh; }
body[data-role=tv] .screen { flex: 1; padding: 4vh 5vw; justify-content: center; gap: 3vh; border-radius: 1.5vw; }
body[data-role=tv] .screen .meta { font-size: 3.2vh; }
body[data-role=tv] .cluetext { font-size: clamp(24px, 7vh, 96px); text-align: center; line-height: 1.35; }
body[data-role=tv] .cluetext.small { font-size: 3.4vh; }
body[data-role=tv] .answer { font-size: 9vh; }
body[data-role=tv] .ddword { font-size: 13vh; }
body[data-role=tv] .outcomes { font-size: 3vh; }
body[data-role=tv] .chip { font-size: 2.8vh; padding: 1vh 1.6vw; }
body[data-role=tv] .timer { height: 2vh; }
body[data-role=tv] .clueimg { max-height: 45vh; }
.banner { text-align: center; font: 800 7vh var(--display); text-transform: uppercase; background: var(--panel); border-radius: 1.2vw; padding: 1.2vh; border: 2px solid var(--line); }
.banner.hot { background: var(--good); border-color: #9ef0c0; }
.banner small { font-size: .5em; opacity: .9; }
.enter { animation: pop .35s ease-out; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.scores { display: flex; gap: .8vw; justify-content: center; flex-wrap: wrap; }
.pod { background: var(--panel); border: 2px solid var(--line); border-radius: 1vw; padding: 1vh 1.4vw; text-align: center; min-width: 11vw; }
.pod .n { font: 700 2.8vh var(--display); text-transform: uppercase; letter-spacing: .03em; }
.pod .m { font-size: 1.6vh; color: var(--muted); max-width: 18vw; }
.pod .s { font: 800 4.2vh var(--display); color: var(--gold); }
.pod.off { opacity: .5; }
.reveals { display: flex; gap: 1vw; flex-wrap: wrap; justify-content: center; }
.reveal { background: var(--panel); border: 2px solid var(--line); border-radius: 1vw; padding: 1.5vh 1.5vw; min-width: 18vw; text-align: center; }
.reveal .n { font: 700 3vh var(--display); text-transform: uppercase; }
.reveal .resp { font: 700 3.4vh var(--clue); margin: 1vh 0; }
.reveal .w { font: 800 4vh var(--display); }
.reveal.ok { border-color: var(--good); } .reveal.ok .w { color: #8ff0b6; }
.reveal.no { border-color: var(--bad); } .reveal.no .w { color: #ff9b93; }
.podium { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3vh; }
.podium .winner { font: 800 12vh var(--display); color: var(--gold); text-transform: uppercase; }
.podium ol { margin: 0; padding: 0; list-style: none; width: min(70vw, 900px); font-size: 4vh; }
.podium li { display: flex; justify-content: space-between; padding: .8vh 0; border-bottom: 1px solid var(--line); }
.podium li small { color: var(--muted); font-size: .55em; }
.fastest { font-size: 2.6vh; color: #c9d0ff; }
.tvlobby { flex: 1; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr); gap: 4vw; align-items: center; }
.joinbox { display: flex; flex-direction: column; align-items: center; gap: 2vh; }
.joinbox h1 { font-size: 9vh; }
.qr { width: min(42vh, 32vw); aspect-ratio: 1; background: #fff; border-radius: 1vw; padding: 1vh; }
.qr svg { width: 100%; height: 100%; display: block; }
.how { font-size: 3.2vh; } .how b { color: var(--gold); }
.joined h2 { font-size: 5vh; margin-bottom: 2vh; }
.sides { display: flex; flex-wrap: wrap; gap: 1vw; }
.sidecard { background: var(--panel); border: 2px solid var(--line); border-radius: 1vw; padding: 1.2vh 1.4vw; }
.sidecard .n { font: 700 3.4vh var(--display); text-transform: uppercase; }
.sidecard .m { font-size: 2vh; color: var(--muted); }
.sidecard.team { border-color: var(--accent); }
.unmute { position: fixed; right: 2vw; bottom: 2vh; z-index: 5; background: var(--accent); border-color: var(--accent); }
.tvjoin { max-width: 480px; margin: 10vh auto; display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 700px) { body[data-role=tv] #app { height: auto; } body[data-role=tv] { overflow: auto; } .tvlobby { grid-template-columns: 1fr; } }
