:root {
  --bg: #0d1326;
  --bg2: #151d38;
  --card: #1b2547;
  --line: #2c3a6b;
  --text: #eef1ff;
  --muted: #9aa6d1;
  --accent: #7cf3c4;
  --o0: #e5484d;
  --o1: #3e63dd;
  --o2: #f0a020;
  --o3: #2f9e64;
  --gold: #ffd24d;
  --silver: #c9d1e6;
  --bronze: #e39b62;
  --radius: 18px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 700px at 10% -10%, #24306a 0%, transparent 60%),
              radial-gradient(900px 600px at 110% 110%, #1d4a5a 0%, transparent 55%), var(--bg);
  color: var(--text);
  line-height: 1.35;
}
a { color: var(--accent); }
button { font: inherit; cursor: pointer; }
.warn { background: #5a1f2a; border: 1px solid #a33a4c; color: #ffd8de; padding: .6em .9em; border-radius: 10px; }
.warn.fixed { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 99; }
.muted { color: var(--muted); }
.eyebrow { text-transform: uppercase; letter-spacing: .14em; font-size: .8rem; color: var(--accent); margin: 0 0 .3em; font-weight: 700; }
.brand { font-weight: 800; font-size: 1.3rem; letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.primary {
  background: var(--accent); color: #062a1e; border: 0; border-radius: 14px;
  padding: .9em 1.4em; font-weight: 800; font-size: 1.05rem; width: 100%;
}
.primary:hover { filter: brightness(1.07); }
body.offline::after {
  content: "Spojenie so serverom sa prerušilo…"; position: fixed; bottom: 10px; left: 50%; transform: translateX(-50%);
  background: #5a1f2a; padding: .4em .9em; border-radius: 8px; font-size: .9rem;
}

/* ============ SETUP ============ */
.setup-card, .join-card {
  max-width: 760px; margin: 5vh auto; padding: 2rem; background: color-mix(in srgb, var(--card) 85%, transparent);
  border: 1px solid var(--line); border-radius: 24px;
}
.setup-card h1 { margin: 0 0 .2em; font-size: 2.2rem; }
.lead { color: var(--muted); margin-top: 0; }
fieldset { border: 0; padding: 0; margin: 1.4rem 0; }
legend { font-weight: 700; margin-bottom: .6rem; }
.topic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: .6rem; }
.topic { display: flex; gap: .6rem; align-items: flex-start; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; cursor: pointer; }
.topic:has(input:checked) { border-color: var(--accent); background: #17304a; }
.topic input { margin-top: .2rem; accent-color: var(--accent); width: 18px; height: 18px; }
.topic small { display: block; color: var(--muted); font-size: .8rem; }
.small-links { font-size: .85rem; }
.row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.4rem; }
.row label { flex: 1 1 200px; display: flex; flex-direction: column; gap: .35rem; font-weight: 600; }
select, input[type=password], input[name=name], input[name=g] {
  font: inherit; padding: .7em .8em; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--text);
}
.foot { margin-top: 1.4rem; font-size: .9rem; }

/* ============ JOIN (mobil) ============ */
.join-card { margin: 8vh 1rem; max-width: 440px; }
@media (min-width: 480px) { .join-card { margin: 10vh auto; } }
.join-card form { display: flex; flex-direction: column; gap: 1rem; margin-top: 1.2rem; }
.join-card label { display: flex; flex-direction: column; gap: .4rem; font-weight: 600; }
.join-card input { font-size: 1.4rem; text-align: center; }

/* ============ TABUĽA ============ */
body.board { overflow: hidden; }
.board-wrap { height: 100vh; display: flex; flex-direction: column; padding: 14px 18px 8px; gap: 12px; }
.topbar { display: flex; align-items: center; gap: 1.5rem; }
.topbar .brand { font-size: 1.5rem; }
.mini-join { margin-left: auto; display: flex; align-items: center; gap: 1rem; background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 14px 6px 6px; }
.mini-join small { display: block; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; }
.mini-join strong { font-size: 1.05rem; }
.mini-qr { width: 64px; height: 64px; }
.mini-qr svg { width: 100%; height: 100%; display: block; border-radius: 6px; }
.mini-pin strong { font-size: 1.6rem; letter-spacing: .08em; color: var(--accent); }
body:has(.phase-lobby) .mini-join { visibility: hidden; }
.tools { display: flex; gap: .5rem; }
.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: .45em .8em; }
.ghost:hover { color: var(--text); border-color: var(--muted); }
body.board:not(.is-host) .tools .ghost:not([data-fullscreen]) { display: none; }
.keys { margin: 0; text-align: center; color: #5c6894; font-size: .8rem; }

.board-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr clamp(260px, 24vw, 380px); gap: 16px; }
.stage { background: color-mix(in srgb, var(--card) 70%, transparent); border: 1px solid var(--line); border-radius: 24px; padding: clamp(16px, 2.2vw, 36px); display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

/* lobby */
.lobby { flex: 1; display: grid; grid-template-columns: minmax(0, 46%) 1fr; gap: 3vw; align-items: center; }
.lobby-qr { background: #fff; border-radius: 20px; padding: 10px; aspect-ratio: 1; max-height: 68vh; justify-self: center; width: 100%; max-width: 68vh; }
.lobby-qr svg { width: 100%; height: 100%; display: block; }
.lobby h1 { font-size: clamp(2rem, 3.6vw, 3.6rem); margin: 0 0 .2em; line-height: 1.05; }
.join-url { font-size: clamp(1.1rem, 1.7vw, 1.8rem); font-weight: 700; color: var(--accent); word-break: break-all; margin: 0 0 1.2em; }
.pin-label { margin: 0; color: var(--muted); text-transform: uppercase; letter-spacing: .14em; font-size: .9rem; }
.pin { font-size: clamp(3rem, 7vw, 7rem); font-weight: 900; letter-spacing: .1em; margin: 0; line-height: 1; }
.meta { font-size: 1.2rem; margin: 1em 0 .2em; }
.topics { color: var(--muted); margin: 0 0 1.2em; }

/* otázka */
.q-head { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-weight: 700; font-size: clamp(.9rem, 1.2vw, 1.2rem); }
.q-topic { background: var(--bg2); border: 1px solid var(--line); padding: .25em .8em; border-radius: 99px; }
.q-text { font-size: clamp(1.6rem, 3.1vw, 3.3rem); line-height: 1.15; margin: .5em 0 .4em; text-wrap: balance; }
.q-mid { display: flex; align-items: center; gap: 2rem; margin-bottom: 1rem; }
.timer.big { flex: 1; display: flex; align-items: center; gap: 1rem; }
.timer.big .timer-num { font-size: clamp(2.4rem, 4vw, 4.2rem); font-weight: 900; min-width: 2ch; text-align: center; font-variant-numeric: tabular-nums; }
.timer-bar { flex: 1; height: 14px; background: var(--bg2); border-radius: 99px; overflow: hidden; }
.timer-bar i { display: block; height: 100%; width: 100%; background: var(--accent); border-radius: 99px; transition: width .15s linear; }
.timer.low .timer-bar i { background: var(--o0); }
.timer.low .timer-num { color: #ff8b8f; }
.answered { text-align: center; }
.answered span { display: block; font-size: clamp(1.6rem, 2.6vw, 2.8rem); font-weight: 900; font-variant-numeric: tabular-nums; }
.answered small { color: var(--muted); }

.opts { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.opt { position: relative; display: flex; align-items: center; gap: 1rem; padding: 1rem 1.3rem; border-radius: var(--radius); font-size: clamp(1.1rem, 2vw, 2.1rem); font-weight: 700; overflow: hidden; min-height: 0; }
.opt b { flex: none; width: 2.1em; height: 2.1em; display: grid; place-items: center; border-radius: 12px; background: rgba(0, 0, 0, .22); font-size: .9em; }
.opt span { position: relative; z-index: 1; }
.o0 { background: var(--o0); } .o1 { background: var(--o1); } .o2 { background: var(--o2); color: #2a1a00; } .o3 { background: var(--o3); }
.revealed .opt.wrong { opacity: .28; filter: saturate(.4); }
.revealed .opt.correct { outline: 5px solid #fff; outline-offset: -5px; box-shadow: 0 0 40px rgba(255, 255, 255, .25); }
.cnt { margin-left: auto; font-style: normal; font-size: .9em; position: relative; z-index: 1; font-variant-numeric: tabular-nums; }
.revealed .opt::after { content: ""; position: absolute; left: 0; bottom: 0; height: 8px; width: var(--bar, 0); background: rgba(255, 255, 255, .5); }
.explain { font-size: clamp(1rem, 1.5vw, 1.5rem); margin: 1rem 0 0; color: #cfd6f5; }
.explain strong { color: var(--accent); }

.host-row { display: flex; justify-content: flex-end; margin-top: 1rem; }
.host-btn { background: var(--accent); color: #062a1e; border: 0; border-radius: 14px; padding: .75em 1.5em; font-weight: 800; font-size: clamp(1rem, 1.3vw, 1.3rem); text-decoration: none; }
.host-btn:hover { filter: brightness(1.08); }
.lobby .host-row { justify-content: flex-start; }
.lobby .host-btn { font-size: 1.5rem; padding: .8em 2em; }

/* final */
.final { flex: 1; display: flex; flex-direction: column; align-items: center; text-align: center; }
.final h1 { font-size: clamp(2.4rem, 4vw, 4rem); margin: 0; }
.podium { flex: 1; display: flex; align-items: flex-end; justify-content: center; gap: 2vw; width: 100%; padding-top: 2vh; }
.pod { width: min(28%, 280px); display: flex; flex-direction: column; align-items: center; }
.pod-name { font-size: clamp(1.2rem, 2.2vw, 2.4rem); font-weight: 800; word-break: break-word; }
.pod-score { color: var(--muted); font-size: clamp(1rem, 1.4vw, 1.4rem); margin-bottom: .4em; }
.pod-block { width: 100%; border-radius: 16px 16px 0 0; display: grid; place-items: center; font-size: clamp(2rem, 4vw, 4.2rem); font-weight: 900; color: #1a1400; animation: rise .9s cubic-bezier(.2, .9, .3, 1.2) both; }
.p1 .pod-block { height: 42vh; background: linear-gradient(var(--gold), #e0a800); animation-delay: .9s; }
.p2 .pod-block { height: 30vh; background: linear-gradient(var(--silver), #98a3bf); animation-delay: .45s; }
.p3 .pod-block { height: 21vh; background: linear-gradient(var(--bronze), #b8713c); }
@keyframes rise { from { transform: scaleY(0); transform-origin: bottom; } to { transform: scaleY(1); transform-origin: bottom; } }

/* bočný panel – poradie */
.side { background: color-mix(in srgb, var(--card) 70%, transparent); border: 1px solid var(--line); border-radius: 24px; padding: 18px; overflow: hidden; display: flex; flex-direction: column; }
.side h3 { margin: 0 0 .6rem; font-size: 1.4rem; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.badge { font-size: .8rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 99px; padding: .2em .7em; color: var(--muted); font-weight: 600; }
.hint, .empty, .more { color: var(--muted); font-size: .85rem; margin: 0 0 .6rem; }
.chips { list-style: none; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: .45rem; overflow: auto; }
.chips li { background: var(--bg2); border: 1px solid var(--line); border-radius: 99px; padding: .35em .5em .35em .9em; font-weight: 700; font-size: 1.05rem; animation: pop .35s ease both; display: flex; align-items: center; gap: .2em; }
.kick { background: none; border: 0; color: var(--muted); font-size: 1.1rem; line-height: 1; padding: 0 .3em; opacity: .5; }
.kick:hover { opacity: 1; color: #ff8b8f; }
body:not(.is-host) .kick { display: none; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: none; opacity: 1; } }
ol.lb { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 6px; overflow: hidden; }
ol.lb li { display: flex; align-items: center; gap: .6rem; padding: .5em .7em; background: var(--bg2); border-radius: 12px; font-size: clamp(.95rem, 1.15vw, 1.2rem); }
ol.lb .rk { width: 2.2ch; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
ol.lb .nm { flex: 1; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
ol.lb .sc { font-weight: 800; font-variant-numeric: tabular-nums; }
ol.lb i { font-style: normal; font-size: .75em; font-weight: 700; }
ol.lb .up { color: var(--accent); } ol.lb .down { color: #ff8b8f; }
ol.lb .r1 { background: linear-gradient(90deg, rgba(255, 210, 77, .35), var(--bg2)); } ol.lb .r1 .rk { color: var(--gold); }
ol.lb .r2 { background: linear-gradient(90deg, rgba(201, 209, 230, .25), var(--bg2)); } ol.lb .r2 .rk { color: var(--silver); }
ol.lb .r3 { background: linear-gradient(90deg, rgba(227, 155, 98, .28), var(--bg2)); } ol.lb .r3 .rk { color: var(--bronze); }

@media (max-width: 900px) {
  body.board { overflow: auto; }
  .board-wrap { height: auto; }
  .board-main { grid-template-columns: 1fr; }
  .lobby { grid-template-columns: 1fr; }
  .mini-join { display: none; }
}

/* ============ MOBIL HRÁČA ============ */
body.play { min-height: 100dvh; }
.play-wrap { min-height: 100dvh; display: flex; }
.pstage { flex: 1; display: flex; flex-direction: column; padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); gap: 12px; }
.p-head { display: flex; align-items: center; gap: 1rem; color: var(--muted); font-weight: 700; }
.p-head > span { white-space: nowrap; }
.timer.small { flex: 1; display: flex; align-items: center; gap: .6rem; }
.timer.small .timer-num { font-weight: 900; color: var(--text); font-size: 1.3rem; min-width: 2ch; text-align: right; }
.timer.small .timer-bar { height: 10px; }
.p-q { font-size: clamp(1.2rem, 5.2vw, 1.8rem); line-height: 1.2; margin: .2em 0; }
.p-opts { flex: 1; display: grid; grid-template-rows: repeat(4, 1fr); gap: 10px; }
.p-opts.n2 { grid-template-rows: repeat(2, 1fr); }
.p-opt { border: 0; border-radius: 16px; color: #fff; display: flex; align-items: center; gap: .8rem; text-align: left; padding: .8rem 1rem; font-size: clamp(1rem, 4.4vw, 1.35rem); font-weight: 700; min-height: 64px; transition: transform .08s; }
.p-opt.o2 { color: #2a1a00; }
.p-opt b { flex: none; width: 2em; height: 2em; display: grid; place-items: center; background: rgba(0, 0, 0, .22); border-radius: 10px; }
.p-opt:active { transform: scale(.97); }
.p-opt:disabled { opacity: .45; }
.center { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: .3rem; padding: 1rem; }
.center h1 { margin: .1em 0; font-size: 2.2rem; }
.center h2 { margin: .1em 0; }
.big-emoji { font-size: 4.5rem; line-height: 1; }
.chosen { display: flex; align-items: center; gap: .6rem; padding: .6rem 1rem; border-radius: 14px; font-weight: 700; margin: .8rem 0; }
.chosen b { background: rgba(0, 0, 0, .22); border-radius: 8px; padding: .1em .5em; }
.result.good h1 { color: var(--accent); }
.result.bad h1 { color: #ff8b8f; }
.plus { font-size: 1.8rem; font-weight: 900; margin: .2em 0; }
.my-rank { display: flex; gap: 1rem; margin-top: 1.2rem; }
.my-rank span { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: .6rem 1rem; font-size: 1.3rem; font-weight: 800; }
.mini-top { list-style: none; padding: 0; margin: 1.2rem 0 .4rem; color: var(--muted); }
.p-foot { display: flex; justify-content: space-between; color: var(--muted); font-weight: 700; border-top: 1px solid var(--line); padding-top: 10px; }
.pulse { width: 18px; height: 18px; border-radius: 50%; background: var(--accent); margin-top: 1.5rem; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { transform: scale(.7); opacity: .5; } 50% { transform: scale(1.3); opacity: 1; } }
body:has(.phase-final) .tools [hx-post] { display: none; }
