:root {
  --bg: #0f1226; --panel: #1a1e3a; --panel2: #232850; --text: #f4f5ff; --muted: #a9addb; --line: #2f3566;
  --green: #00a86b; --gold: #ffb612; --red: #e5484d; --blue: #3b6cff; --purple: #8e5cff;
  --ok: #2ecc71; --bad: #e74c3c; --radius: 16px;
  --font: 'Baloo 2', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); -webkit-tap-highlight-color: transparent; }
body { min-height: 100vh; }
a { color: var(--gold); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; border: 0; border-radius: 12px; padding: .7em 1.1em; font-weight: 700; color: #fff; background: var(--blue); transition: transform .08s, filter .15s; }
button:hover { filter: brightness(1.1); }
button:active { transform: scale(.97); }
button:focus-visible, .gamecard:focus-visible { outline: 4px solid var(--gold); outline-offset: 3px; }
button:disabled { opacity: .45; cursor: default; transform: none; }
button.ghost { background: transparent; border: 2px solid var(--line); color: var(--text); }
button.gold { background: var(--gold); color: #1a1300; }
button.green { background: var(--green); }
input, select, textarea { width: 100%; padding: .75em .9em; border-radius: 12px; border: 2px solid var(--line); background: #0b0e20; color: var(--text); font-size: 1.05rem; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); }
label { display: block; margin: .6em 0 .25em; color: var(--muted); font-size: .95rem; }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.flag { height: 6px; background: linear-gradient(90deg, var(--red) 0 25%, var(--blue) 25% 50%, var(--green) 50% 75%, var(--gold) 75%); }
.brand { font-weight: 800; font-size: 1.5rem; letter-spacing: .5px; text-decoration: none; color: var(--text); }
.brand b { color: var(--gold); }
.pill { display: inline-block; padding: .15em .7em; border-radius: 99px; background: var(--panel2); color: var(--muted); font-size: .85rem; }
.pill.gold { background: var(--gold); color: #1a1300; }
.pill.red { background: var(--red); color: #fff; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #000d; color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 99; max-width: 90vw; text-align: center; }

/* ---- blocks (shared by TV + phone) ---- */
.blocks { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.b-h { font-size: 1.8em; font-weight: 800; margin: 0; text-align: center; }
.b-p { margin: 0; text-align: center; color: var(--muted); font-size: 1.1em; white-space: pre-line; }
.b-big { font-size: 2.2em; font-weight: 800; text-align: center; line-height: 1.15; white-space: pre-line; }
.b-big.small { font-size: 1.5em; }
.b-note { background: var(--panel2); border-left: 5px solid var(--gold); padding: 10px 14px; border-radius: 10px; white-space: pre-line; }
.b-round { text-align: center; color: var(--gold); font-weight: 700; letter-spacing: 1px; text-transform: uppercase; font-size: .9em; }
.b-answer { text-align: center; font-size: 2em; font-weight: 800; color: var(--ok); }
.b-letter { text-align: center; font-size: 5em; font-weight: 800; color: var(--gold); line-height: 1; }
.b-result { text-align: center; font-size: 1.8em; font-weight: 800; padding: 16px; border-radius: var(--radius); }
.b-result.ok { background: #1e7d4a; } .b-result.bad { background: #8e2b2b; }
.b-card { background: linear-gradient(135deg, var(--purple), var(--blue)); border-radius: 20px; padding: 26px 20px; text-align: center; font-size: 1.4em; font-weight: 700; box-shadow: 0 10px 30px #0006; white-space: pre-line; }
.b-card small { display: block; font-size: .65em; letter-spacing: 2px; opacity: .8; margin-bottom: 6px; }
.b-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.b-options div { background: var(--panel2); padding: 14px 16px; border-radius: 14px; font-size: 1.25em; font-weight: 700; border-left: 8px solid var(--c, var(--blue)); }
.b-options b { color: var(--muted); margin-right: .5em; }
.choices { display: grid; gap: 10px; }
.choices.big button { min-height: 72px; font-size: 1.25em; }
.choices button { width: 100%; text-align: left; padding: 14px 16px; font-size: 1.1em; background: var(--c, var(--panel2)); border: 2px solid transparent; }
.choices button.sel { border-color: var(--gold); box-shadow: 0 0 0 3px #ffb61255; }
.choices button small { display: block; opacity: .75; font-weight: 500; font-size: .8em; }
.btnrow { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.btnrow button { flex: 1 1 140px; min-height: 60px; font-size: 1.15em; }
.controls { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.controls button { background: var(--panel2); border: 2px solid var(--line); font-size: .95em; padding: .55em .9em; }
.inputrow { display: flex; gap: 8px; } .inputrow input { flex: 1; } .inputrow button { flex: 0 0 auto; }
.b-timer { height: 10px; background: var(--panel2); border-radius: 99px; overflow: hidden; position: relative; }
.b-timer i { position: absolute; inset: 0 auto 0 0; background: linear-gradient(90deg, var(--green), var(--gold), var(--red)); }
.b-timer span { position: absolute; right: 0; top: -1.6em; font-weight: 800; color: var(--gold); }
.waiting { text-align: center; color: var(--muted); }
.waiting .av { font-size: 1.8em; letter-spacing: 4px; }
.scores { display: grid; gap: 6px; }
.scores div { display: flex; align-items: center; gap: 10px; background: var(--panel2); padding: 8px 12px; border-radius: 10px; }
.scores div b { margin-left: auto; color: var(--gold); }
.scores .rank { width: 1.5em; color: var(--muted); }
.bars { display: grid; gap: 8px; }
.bar { position: relative; background: var(--panel2); border-radius: 10px; padding: 10px 14px; overflow: hidden; font-weight: 700; }
.bar i { position: absolute; inset: 0 auto 0 0; background: var(--c, #3b6cff55); opacity: .35; }
.bar.hl { outline: 3px solid var(--ok); }
.bar span { position: relative; } .bar em { position: relative; float: right; font-style: normal; color: var(--gold); }
.bar small { position: relative; display: block; color: var(--muted); font-weight: 500; }
.list { display: grid; gap: 6px; }
.list div { background: var(--panel2); padding: 10px 14px; border-radius: 10px; font-weight: 600; }
.list div.hl { outline: 3px solid var(--gold); }
.list small { display: block; color: var(--muted); font-weight: 500; }
.versus { display: grid; grid-template-columns: 1fr auto 1fr; gap: 10px; align-items: stretch; }
.versus > div { border-radius: 16px; padding: 18px; font-size: 1.3em; font-weight: 800; text-align: center; display: flex; flex-direction: column; justify-content: center; }
.versus .a { background: #c0392b; } .versus .b { background: #2471a3; }
.versus .or { align-self: center; color: var(--muted); font-weight: 800; }
.versus.small > div { font-size: 1em; padding: 10px; }
.versus small { font-size: .65em; font-weight: 600; opacity: .9; }
.grid { display: grid; margin: 0 auto; position: relative; border-radius: 12px; width: 100%; }
.grid .cell { aspect-ratio: 1; display: flex; align-items: center; justify-content: center; border-radius: 6px; font-size: clamp(12px, 4vw, 34px); color: #111; position: relative; user-select: none; padding: 0; min-width: 0; font-weight: 800; }
.grid .cell.click { cursor: pointer; box-shadow: inset 0 0 0 3px #ffb612aa; }
.grid .cell.round { border-radius: 50%; }
.grid .cell sub { position: absolute; left: 3px; top: 1px; font-size: 9px; color: #0008; font-weight: 600; }
.grid.dots .cell { border-radius: 2px; }
.grid svg.lines { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.gridhead { display: grid; grid-template-columns: repeat(5, 1fr); text-align: center; font-weight: 800; color: var(--gold); font-size: 1.4em; }
.cards { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pcard { width: 80px; height: 112px; background: #fff; color: #111; border-radius: 10px; display: flex; flex-direction: column; justify-content: space-between; padding: 6px 8px; font-weight: 800; font-size: 1.4em; box-shadow: 0 6px 16px #0007; }
.pcard.red { color: #c0392b; } .pcard .mid { text-align: center; font-size: 1.6em; }
.pcard.back { background: repeating-linear-gradient(45deg, #8e5cff, #8e5cff 8px, #3b6cff 8px, #3b6cff 16px); }
.dice { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; font-size: 3.4em; line-height: 1; }
.buzzer { width: min(80vw, 340px); aspect-ratio: 1; margin: 10px auto; border-radius: 50%; font-size: 2em; box-shadow: 0 14px 0 #0006, 0 20px 40px #0008; }
.buzzer:active { transform: translateY(8px); box-shadow: 0 6px 0 #0006; }
.flash { border-radius: 20px; padding: 60px 20px; text-align: center; font-size: 3em; font-weight: 800; }
.secret { background: var(--panel2); border: 3px dashed var(--gold); border-radius: 16px; padding: 22px; text-align: center; font-size: 1.3em; font-weight: 700; user-select: none; white-space: pre-line; }
.secret.hidden { color: var(--muted); font-weight: 500; }
.feed { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.feed.inline { flex-direction: row; flex-wrap: wrap; justify-content: center; gap: 8px; font-size: 1.2em; }
.table { overflow-x: auto; } .table table { width: 100%; border-collapse: collapse; } .table td, .table th { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; } .table s { color: var(--bad); }
.keyboard { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.keyboard button { padding: 12px 0; font-size: 1.2em; background: var(--panel2); }
.keyboard button.wrong { background: #5b2020; } .keyboard button.used { background: #1e5d3a; }
.drawwrap { background: #fff; border-radius: 14px; overflow: hidden; touch-action: none; }
.drawwrap canvas { width: 100%; display: block; touch-action: none; }
.palette { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.palette button { width: 38px; height: 38px; padding: 0; border-radius: 50%; border: 3px solid #fff3; }
.palette button.sel { border-color: var(--gold); }
.eq { display: flex; gap: 6px; justify-content: center; align-items: flex-end; height: 70px; }
.eq i { width: 14px; background: var(--gold); border-radius: 4px; animation: eq 1s infinite ease-in-out; }
@keyframes eq { 0%, 100% { height: 15%; } 50% { height: 100%; } }
.avatarbig { text-align: center; font-size: 4.5em; line-height: 1; }
.form { display: grid; gap: 4px; }
.form button { margin-top: 10px; min-height: 56px; }

/* ---- game picker ---- */
.tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 6px; }
.tabs button { flex: 0 0 auto; background: var(--panel2); border: 2px solid transparent; font-weight: 700; }
.tabs button.on { border-color: var(--gold); background: #2f2a10; }
.gamegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.gamecard { background: var(--panel2); border-radius: 16px; padding: 14px; text-align: left; color: var(--text); display: flex; flex-direction: column; gap: 4px; position: relative; border: 2px solid transparent; }
.gamecard:hover { border-color: var(--line); }
.gamecard .em { font-size: 2em; }
.gamecard .nm { font-weight: 800; font-size: 1.08em; line-height: 1.15; }
.gamecard .ds { font-size: .82em; color: var(--muted); font-weight: 500; line-height: 1.3; }
.gamecard .tag { position: absolute; top: 10px; right: 10px; }
.gamecard.locked { opacity: .65; }

/* ---- host TV screen ---- */
.tv { font-size: clamp(16px, 1.6vw, 28px); }
.tv .blocks { max-width: 1400px; margin: 0 auto; }
.tv .grid { max-width: min(78vh, 900px); }
.tv .choices button { font-size: 1em; }
.hostbar { display: flex; align-items: center; gap: 14px; padding: 10px 18px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.roomcode { font-size: 2em; font-weight: 800; letter-spacing: 6px; color: var(--gold); line-height: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--panel2); padding: 4px 10px; border-radius: 99px; font-weight: 700; font-size: .9em; }
.chip.off { opacity: .4; }
.chip button { background: none; padding: 0 0 0 6px; color: var(--muted); }
.joinbox { display: grid; grid-template-columns: auto 1fr; gap: 24px; align-items: center; }
.joinbox img { width: min(32vh, 280px); background: #fff; border-radius: 16px; padding: 10px; }
.miniqr { width: 64px; height: 64px; background: #fff; border-radius: 8px; padding: 3px; }

/* ---- phone ---- */
.phone { max-width: 560px; margin: 0 auto; padding: 12px 14px 40px; }
.phonebar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.phonebar .av { font-size: 1.8em; }

/* ---- landing ---- */
.hero { text-align: center; padding: 50px 16px 30px; }
.hero h1 { font-size: clamp(2.2rem, 6vw, 4rem); margin: 0; line-height: 1.05; }
.hero h1 span { color: var(--gold); }
.hero p { color: var(--muted); font-size: 1.25rem; max-width: 720px; margin: 14px auto 24px; }
.hero .row { justify-content: center; }
.hero button { font-size: 1.25rem; padding: .8em 1.6em; }
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.steps .panel b { font-size: 2em; display: block; }
.prices { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.price { text-align: center; }
.price .amt { font-size: 2.6em; font-weight: 800; color: var(--gold); }
.price ul { text-align: left; padding-left: 1.2em; color: var(--muted); }
.price.best { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
section { margin: 40px 0; }
section h2 { font-size: 2rem; margin: 0 0 14px; }
details { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin-bottom: 8px; }
summary { font-weight: 700; cursor: pointer; }

/* ---- builder ---- */
.qrow { background: var(--panel2); border-radius: 14px; padding: 12px; display: grid; gap: 8px; }
.qrow .wr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
@media (max-width: 640px) {
  .joinbox { grid-template-columns: 1fr; text-align: center; } .joinbox img { margin: 0 auto; }
  .qrow .wr { grid-template-columns: 1fr; }
  .b-big { font-size: 1.7em; } .b-letter { font-size: 4em; }
  .pcard { width: 62px; height: 88px; font-size: 1.1em; }
  .keyboard { grid-template-columns: repeat(6, 1fr); }
}
/* Keep game boards and drawings inside the TV viewport. */
.tv .grid { max-width: min(62vh, 900px); }
.tv .blocks > canvas { width: auto !important; max-width: 100% !important; max-height: 62vh; }
.tv .b-h { font-size: 1.4em; }
.grid .cell.shrink { transform: scale(.42); }
.grid .cell.shrink.click { transform: scale(.6); }
