:root {
  --bg: #0b1033;
  --bg2: #121a4d;
  --panel: #18225e;
  --panel2: #202c73;
  --line: #2f3d8f;
  --text: #eef1ff;
  --muted: #9aa5d9;
  --gold: #ffcf4a;
  --gold2: #e2a400;
  --green: #2fd17a;
  --red: #ff5a5f;
  --amber: #ffa53a;
  --blue: #4f8cff;
  --cell: #1d2a86;
  --cell-hi: #2a3cb8;
  --radius: 10px;
  --font: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); }
body { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; border: 0; border-radius: 8px; padding: 8px 14px; background: var(--panel2); color: var(--text); }
button:hover { filter: brightness(1.15); }
button:disabled { opacity: .45; cursor: default; filter: none; }
button.primary { background: var(--gold); color: #1a1400; font-weight: 700; }
button.ok { background: var(--green); color: #002b14; font-weight: 700; }
button.bad { background: var(--red); color: #2b0003; font-weight: 700; }
button.ghost { background: transparent; border: 1px solid var(--line); }
button.small { padding: 4px 8px; font-size: 13px; }
input, select, textarea { font: inherit; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; }
a { color: var(--gold); }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.hidden { display: none !important; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; background: var(--panel2); font-size: 12px; color: var(--muted); }
.tag.gold { background: var(--gold); color: #221800; font-weight: 700; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; background: var(--red); }
.dot.on { background: var(--green); }

/* ---------- board ---------- */
.board { display: grid; grid-template-columns: minmax(160px, 1.6fr) repeat(var(--cols), 1fr); gap: 6px; width: 100%; }
.b-theme { background: var(--cell); border-radius: 8px; padding: 8px 12px; display: flex; align-items: center; font-weight: 600; text-transform: uppercase; letter-spacing: .02em; font-size: clamp(12px, 1.5vw, 24px); }
.b-cell { background: var(--cell); border-radius: 8px; display: flex; align-items: center; justify-content: center; color: var(--gold); font-weight: 800; font-size: clamp(14px, 2.4vw, 44px); min-height: 44px; user-select: none; }
.b-cell.used, .b-cell.empty { background: #121a52; color: transparent; }
.b-cell[data-pick] { cursor: pointer; }
.b-cell[data-pick]:hover { background: var(--cell-hi); }
.b-cell.flash { animation: flash .25s 6 alternate; }
@keyframes flash { from { background: var(--cell); } to { background: var(--gold); color: #000; } }

/* ---------- items ---------- */
.item-text { white-space: pre-wrap; text-align: center; line-height: 1.25; font-weight: 600; }
.txt-xl { font-size: clamp(28px, 6vw, 96px); }
.txt-l { font-size: clamp(24px, 4.2vw, 68px); }
.txt-m { font-size: clamp(20px, 3vw, 48px); }
.txt-s { font-size: clamp(16px, 2.2vw, 34px); }
.txt-xs { font-size: clamp(14px, 1.6vw, 26px); text-align: left; }
.item-image img, .item-video video { max-width: 100%; max-height: 100%; object-fit: contain; display: block; margin: auto; border-radius: 6px; }
.item-html iframe { width: 100%; height: 100%; border: 0; background: #fff; }

/* ---------- host ---------- */
.host { display: grid; grid-template-columns: 300px 1fr; grid-template-rows: auto 1fr; height: 100vh; }
.host header { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--bg2); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.host header h1 { margin: 0 8px 0 0; font-size: 20px; color: var(--gold); }
.host aside { border-right: 1px solid var(--line); overflow: auto; padding: 12px; background: #0e1440; }
.host main { overflow: auto; padding: 14px; }
.plist { display: flex; flex-direction: column; gap: 6px; }
.pl { background: var(--panel); border-radius: var(--radius); padding: 8px 10px; display: grid; grid-template-columns: auto 1fr auto; gap: 4px 8px; align-items: center; border: 2px solid transparent; }
.pl.chooser { border-color: var(--gold); }
.pl.answering { border-color: var(--green); box-shadow: 0 0 12px var(--green); }
.pl.wrong { opacity: .55; }
.pl .nm { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl .sc { font-weight: 800; font-size: 18px; color: var(--gold); cursor: pointer; }
.pl .sc.neg { color: var(--red); }
.pl .acts { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; }
.pl .sc input { width: 90px; }
.card { background: var(--panel); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.card h2, .card h3 { margin: 0 0 10px; }
.answer-box { background: #0f3b26; border: 1px solid var(--green); border-radius: var(--radius); padding: 12px; font-size: 20px; font-weight: 700; }
.answer-box .wrong { color: #ffb3b5; font-size: 15px; font-weight: 500; margin-top: 6px; }
.steps { display: flex; flex-direction: column; gap: 6px; }
.step { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 8px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.step.cur { border-color: var(--gold); }
.step.done { opacity: .6; }
.step img { max-height: 90px; max-width: 160px; border-radius: 4px; }
.step .media { background: var(--panel2); border-radius: 6px; padding: 4px 8px; font-size: 13px; }
.step .replic { color: var(--amber); font-style: italic; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.actions button { padding: 12px 18px; font-size: 16px; }
.status-line { font-size: 18px; margin: 6px 0; }
.qr svg { width: 180px; height: 180px; background: #fff; padding: 6px; border-radius: 8px; }
.packs { display: grid; gap: 8px; }
.pack-btn { text-align: left; padding: 12px; background: var(--panel2); }
.pack-btn.sel { outline: 2px solid var(--gold); }
.modal { position: fixed; inset: 0; background: #0009; display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal .card { width: min(520px, 94vw); max-height: 90vh; overflow: auto; }
.modal label { display: flex; justify-content: space-between; gap: 10px; align-items: center; margin: 8px 0; }
.modal label input[type=number] { width: 90px; }
.buzzlog { font-size: 13px; color: var(--muted); }
.final-list { display: grid; gap: 6px; }
.final-row { display: grid; grid-template-columns: 1fr 110px 2fr auto; gap: 8px; align-items: center; background: var(--bg2); padding: 8px; border-radius: 8px; }
.kbd { font-family: monospace; background: var(--bg2); border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; }

.tabs { gap: 6px; }
.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 10px; margin-top: 12px; }
.cat-card { display: grid; grid-template-columns: 96px 1fr; gap: 10px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 8px; }
.cat-card.sel { border-color: var(--gold); }
.cat-card img { width: 96px; height: 96px; object-fit: cover; border-radius: 8px; background: var(--panel); }
.cat-body { min-width: 0; }
.cat-body b { display: block; overflow: hidden; text-overflow: ellipsis; }
.cat-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; max-height: 44px; overflow: hidden; }
.cat-tags .tag { font-size: 11px; }

/* ---------- screen ---------- */
.screen { height: 100vh; display: grid; grid-template-rows: 1fr auto; overflow: hidden; }
.stage { position: relative; display: flex; align-items: center; justify-content: center; padding: 2.2vw; overflow: hidden; min-height: 0; }
.stage.open { box-shadow: inset 0 0 0 6px var(--green); }
.stage.pending { box-shadow: inset 0 0 0 6px #ffa53a55; }
.qview { width: 100%; height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2vh; min-height: 0; }
.qview .item { max-width: 100%; min-height: 0; }
.qview .item-image, .qview .item-video { flex: 1 1 0; display: flex; width: 100%; }
.qhead { position: absolute; top: 1.2vh; left: 2vw; right: 2vw; display: flex; justify-content: space-between; color: var(--muted); font-size: clamp(14px, 1.6vw, 26px); }
.qhead b { color: var(--gold); }
.big-banner { text-align: center; }
.big-banner .t1 { font-size: clamp(36px, 7vw, 120px); font-weight: 900; color: var(--gold); text-shadow: 0 4px 30px #ffcf4a55; }
.big-banner .t2 { font-size: clamp(20px, 3vw, 48px); margin-top: 2vh; }
.big-banner .t3 { font-size: clamp(16px, 2vw, 32px); margin-top: 1vh; color: var(--muted); }
.answering-bar { position: absolute; left: 50%; bottom: 2vh; transform: translateX(-50%); background: var(--green); color: #00240f; font-weight: 800; font-size: clamp(20px, 3vw, 48px); padding: 1vh 3vw; border-radius: 99px; box-shadow: 0 0 40px #2fd17a88; white-space: nowrap; }
.replic { position: absolute; bottom: 2vh; left: 3vw; right: 3vw; text-align: center; color: var(--amber); font-style: italic; font-size: clamp(16px, 2vw, 32px); }
.music-note { font-size: clamp(80px, 16vw, 260px); animation: pulse 1s infinite alternate; color: var(--gold); }
@keyframes pulse { from { transform: scale(1); opacity: .7; } to { transform: scale(1.12); opacity: 1; } }
.timerbar { position: absolute; top: 0; left: 0; height: 8px; background: var(--gold); transition: width .1s linear; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 1.2vw; width: 100%; }
.opt { background: var(--cell); border-radius: 12px; padding: 1vw; display: flex; gap: 1vw; align-items: center; min-height: 8vh; font-size: clamp(16px, 2.2vw, 36px); }
.opt .lt { color: var(--gold); font-weight: 900; }
.opt.right { background: var(--green); color: #002b14; }
.opt .item-image img { max-height: 18vh; }
.players-bar { display: flex; gap: 1vw; justify-content: center; padding: 1vh 1vw 1.4vh; background: var(--bg2); border-top: 1px solid var(--line); flex-wrap: wrap; }
.pcard { min-width: 9vw; text-align: center; padding: .6vh 1.2vw; border-radius: 10px; background: var(--panel); border: 3px solid transparent; transition: transform .15s; }
.pcard .n { font-size: clamp(13px, 1.4vw, 24px); font-weight: 600; white-space: nowrap; }
.pcard .s { font-size: clamp(16px, 2vw, 34px); font-weight: 800; color: var(--gold); }
.pcard .s.neg { color: var(--red); }
.pcard.chooser { border-color: var(--gold); }
.pcard.answering { border-color: var(--green); background: #14513a; transform: scale(1.08); }
.pcard.off { opacity: .45; }
.pcard .ok { color: var(--green); } .pcard .bad { color: var(--red); }
.lobby { display: grid; grid-template-columns: auto 1fr; gap: 4vw; align-items: center; }
.lobby .qr svg { width: 30vh; height: 30vh; }
.lobby h1 { font-size: clamp(30px, 5vw, 80px); margin: 0; color: var(--gold); }
.lobby .url { font-size: clamp(18px, 2.4vw, 40px); }
.round-intro h1 { font-size: clamp(30px, 6vw, 100px); color: var(--gold); text-align: center; margin: 0 0 3vh; }
.round-intro .themes { display: flex; flex-wrap: wrap; gap: 1vw; justify-content: center; }
.round-intro .themes div { background: var(--cell); padding: 1vh 1.6vw; border-radius: 10px; font-size: clamp(16px, 2vw, 32px); }
.final-themes { display: flex; flex-direction: column; gap: 1.2vh; width: min(900px, 90%); }
.final-themes div { background: var(--cell); padding: 1.6vh 2vw; border-radius: 12px; font-size: clamp(20px, 3vw, 48px); text-align: center; font-weight: 700; }
.final-themes div.removed { opacity: .25; text-decoration: line-through; }
.unlock { position: fixed; inset: 0; background: #000c; display: flex; align-items: center; justify-content: center; z-index: 99; font-size: 28px; cursor: pointer; text-align: center; }
.end-table { font-size: clamp(20px, 3vw, 48px); }
.end-table div { display: flex; justify-content: space-between; gap: 4vw; padding: .6vh 0; }
.end-table div:first-child { color: var(--gold); font-weight: 900; }
.flash-name { animation: pop .3s; }
@keyframes pop { from { transform: translateX(-50%) scale(.6); } to { transform: translateX(-50%) scale(1); } }

/* ---------- player ---------- */
.play { height: 100vh; height: 100dvh; min-height: 0 !important; }
.pview { height: auto; flex: 1 1 0; min-height: 30vh; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); position: relative; }
.pview .stage { padding: 10px; }
.pview .players-bar { padding: 4px; gap: 4px; }
.pview .pcard { min-width: 0; padding: 2px 8px; border-width: 2px; }
.pview .pcard .n { font-size: 12px; } .pview .pcard .s { font-size: 14px; }
.pview .unlock { position: absolute; font-size: 20px; }
.pview .qhead { font-size: 12px; top: 4px; }
.pview .answering-bar { font-size: 16px; padding: 4px 14px; }
.pview .lobby { grid-template-columns: 1fr; text-align: center; }
.pview .big-banner .t1 { font-size: 34px; } .pview .big-banner .t2 { font-size: 18px; }
.pview .txt-xl { font-size: 30px; } .pview .txt-l { font-size: 22px; } .pview .txt-m { font-size: 18px; } .pview .txt-s, .pview .txt-xs { font-size: 14px; }
.pview .board { grid-template-columns: minmax(80px, 1.4fr) repeat(var(--cols), 1fr); gap: 3px; }
.pview .b-theme { font-size: 10px; padding: 3px 5px; text-transform: none; }
.pview .b-cell { font-size: 13px; min-height: 26px; }
.pview .round-intro h1 { font-size: 28px; } .pview .round-intro .themes div { font-size: 13px; }
.pview .final-themes div { font-size: 16px; padding: 6px; }
.play .buzzer { flex: 0 0 auto; min-height: 20vh; }
@media (min-width: 900px) { .play { max-width: 1100px; } .pview { min-height: 55vh; } }

.play { display: flex; flex-direction: column; padding: 10px; gap: 10px; max-width: 1100px; margin: 0 auto; touch-action: manipulation; }
.play .top { display: flex; justify-content: space-between; align-items: center; }
.play .me { font-weight: 700; font-size: 18px; }
.play .myscore { font-size: 26px; font-weight: 900; color: var(--gold); }
.buzzer { flex: 1; min-height: 46vh; border-radius: 28px; font-size: 40px; font-weight: 900; color: #fff; background: #3a4170; display: flex; align-items: center; justify-content: center; text-align: center; user-select: none; -webkit-user-select: none; touch-action: none; transition: background .08s; padding: 10px; }
.buzzer.pending { background: #7a5a1f; }
.buzzer.open { background: var(--green); color: #002b14; box-shadow: 0 0 40px #2fd17a99; }
.buzzer.pressed { background: #1f8f53; }
.buzzer.won { background: var(--gold); color: #221800; }
.buzzer.lost { background: #44376b; }
.buzzer.blocked { background: var(--red); }
.play .status { text-align: center; color: var(--muted); min-height: 1.4em; }
.mini-scores { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; font-size: 15px; }
.ask { background: var(--panel); border: 2px solid var(--gold); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.ask input { font-size: 20px; padding: 10px; }
.ask button { padding: 12px; font-size: 18px; }
.join { margin: auto; display: flex; flex-direction: column; gap: 12px; width: 100%; max-width: 360px; text-align: center; }
.join input { font-size: 22px; padding: 12px; text-align: center; }
.join button { font-size: 20px; padding: 14px; }
.play .board { grid-template-columns: minmax(90px, 1.4fr) repeat(var(--cols), 1fr); gap: 4px; }
.play .b-theme { font-size: 11px; padding: 4px 6px; text-transform: none; }
.play .b-cell { font-size: 15px; min-height: 38px; }

.unlock-small { inset: auto 8px 8px auto !important; width: auto; height: auto; padding: 8px 14px; border-radius: 99px; font-size: 14px !important; background: var(--gold) !important; color: #221800; font-weight: 700; }
.host-view { height: 46vh; min-height: 260px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; margin-bottom: 12px; position: relative; }
.host-view .screen-wrap { height: 100%; display: grid; grid-template-rows: 1fr; }
.host-view .stage { padding: 12px; }
.host-view .txt-xl { font-size: 44px; } .host-view .txt-l { font-size: 32px; } .host-view .txt-m { font-size: 24px; } .host-view .txt-s, .host-view .txt-xs { font-size: 17px; }
.host-view .big-banner .t1 { font-size: 48px; } .host-view .big-banner .t2 { font-size: 22px; }
.host-view .answering-bar { font-size: 20px; }
.hv-tools { position: absolute; top: 6px; right: 8px; z-index: 5; display: flex; gap: 6px; }
.load-list { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }

/* ---------- index ---------- */
.index { max-width: 760px; margin: 0 auto; padding: 24px 16px; }
.index h1 { color: var(--gold); font-size: 40px; margin: 0 0 6px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 20px 0; }
.tile { display: block; background: var(--panel); border-radius: 14px; padding: 18px; text-decoration: none; color: var(--text); border: 1px solid var(--line); }
.tile b { display: block; font-size: 22px; color: var(--gold); margin-bottom: 6px; }

@media (max-width: 800px) {
  .host { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; height: auto; }
  .host aside { border-right: 0; border-bottom: 1px solid var(--line); }
  .final-row { grid-template-columns: 1fr 1fr; }
}

.cat-card.skel b, .cat-card.skel i { display:block; height:14px; border-radius:6px; background:var(--line, rgba(255,255,255,.12)); margin:6px 0; }
.cat-card.skel b { width:70%; height:18px; } .cat-card.skel i:last-child { width:45%; }
.cat-card.skel > div:first-child { background:var(--line, rgba(255,255,255,.08)); border-radius:8px; min-height:80px; }
.cat-card.skel { animation: skel 1.2s ease-in-out infinite alternate; }
@keyframes skel { from { opacity:.55 } to { opacity:1 } }
