:root {
  --bg: #0b1020;
  --bg-2: #141b33;
  --line: #27305a;
  --text: #f4f1e8;
  --muted: #a9b0cc;
  --gold: #f5c542;
  --ok: #3fb37f;
  --bad: #ef6461;
  --opt-a: #ef6461;
  --opt-b: #4c9be8;
  --opt-c: #f2b134;
  --opt-d: #3fb37f;
  --on-opt: #0b1020;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.35;
}

button, input { font: inherit; }

button {
  cursor: pointer;
  border: 0;
  border-radius: 10px;
}

button:focus-visible, input:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

.opt-a { --c: var(--opt-a); }
.opt-b { --c: var(--opt-b); }
.opt-c { --c: var(--opt-c); }
.opt-d { --c: var(--opt-d); }

.letter {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 1.8em;
  height: 1.8em;
  border-radius: 8px;
  background: var(--c);
  color: var(--on-opt);
  font-weight: 800;
}

.offline {
  position: fixed;
  left: 50%;
  top: 12px;
  transform: translateX(-50%);
  background: var(--bad);
  color: var(--on-opt);
  padding: 6px 14px;
  border-radius: 8px;
  font-weight: 700;
  z-index: 50;
}

/* ---- odpočet ---------------------------------------------------------- */

.countdown {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cd-track {
  flex: 1;
  height: 12px;
  border-radius: 6px;
  background: var(--line);
  overflow: hidden;
}

.cd-fill {
  height: 100%;
  background: var(--gold);
  transform-origin: left;
  transition: transform 0.1s linear;
}

.cd-low .cd-fill { background: var(--bad); }

.cd-secs {
  min-width: 3.5ch;
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

/* ===================================================================== */
/* TV                                                                     */
/* ===================================================================== */

body.tv {
  height: 100vh;
  overflow: hidden;
  font-size: clamp(16px, 1.6vw, 34px);
  background:
    radial-gradient(circle at 15% 10%, rgba(245, 197, 66, 0.12), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(76, 155, 232, 0.12), transparent 45%),
    var(--bg);
}

.tv-stage {
  height: 100vh;
  padding: 3.5vh 4vw;
  display: flex;
  flex-direction: column;
  gap: 3vh;
}

.tv-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  color: var(--muted);
  font-size: 1em;
}

.tv-top strong { color: var(--gold); }

.tv-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 3vh;
}

.tv-title {
  margin: 0;
  font-size: 3.4em;
  line-height: 1.05;
  color: var(--gold);
  letter-spacing: -0.02em;
}

.tv-sub { margin: 0; font-size: 1.4em; color: var(--muted); }

.tv-lobby {
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5vw;
  align-items: center;
}

.tv-qr {
  width: min(38vh, 30vw);
  aspect-ratio: 1;
  background: #fff;
  border-radius: var(--radius);
  padding: 1vh;
}

.tv-qr img { width: 100%; height: 100%; display: block; }

.tv-url { margin-top: 1.5vh; text-align: center; color: var(--muted); font-size: 0.9em; word-break: break-all; }

.tv-teams {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  margin-top: 2vh;
}

.tv-chip {
  padding: 0.3em 0.8em;
  border-radius: 8px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-weight: 600;
  animation: pop 0.4s ease-out;
}

@keyframes pop {
  from { transform: scale(0.6); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.tv-round-no { font-size: 1.6em; color: var(--muted); margin: 0; }

.tv-question {
  margin: 0;
  font-size: 2.4em;
  line-height: 1.15;
  text-align: center;
  max-width: 28ch;
  align-self: center;
}

.tv-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2vh 2vw;
  flex: 1;
  align-content: center;
}

.tv-opt {
  display: flex;
  align-items: center;
  gap: 0.8em;
  padding: 2.2vh 1.4vw;
  border-radius: var(--radius);
  background: var(--bg-2);
  border: 3px solid var(--c);
  font-size: 1.5em;
  font-weight: 600;
  position: relative;
  transition: opacity 0.3s;
}

.tv-opt .opt-text { flex: 1; text-align: left; }

.tv-opt .opt-count {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.8em;
}

.tv-opt.is-wrong { opacity: 0.35; }

.tv-opt.is-correct {
  background: var(--c);
  color: var(--on-opt);
  box-shadow: 0 0 0 6px rgba(245, 197, 66, 0.35);
}

.tv-opt.is-correct .letter { background: var(--on-opt); color: var(--c); }
.tv-opt.is-correct .opt-count { color: var(--on-opt); }

.tv-badge {
  font-size: 0.7em;
  font-weight: 800;
  padding: 0.15em 0.5em;
  border-radius: 6px;
  background: var(--on-opt);
  color: var(--gold);
}

.tv-bottom {
  display: flex;
  align-items: center;
  gap: 3vw;
  font-size: 1.1em;
}

.tv-bottom .countdown { flex: 1; }

.tv-answered { color: var(--muted); white-space: nowrap; }
.tv-answered strong { color: var(--text); }

.tv-locked { color: var(--gold); font-weight: 700; }

.tv-number-hint { font-size: 1.6em; color: var(--muted); text-align: center; }

.tv-answer-big {
  font-size: 4em;
  font-weight: 800;
  color: var(--gold);
  text-align: center;
  margin: 0;
}

.tv-guesses, .tv-board {
  list-style: none;
  margin: 0 auto;
  padding: 0;
  width: min(100%, 56em);
  display: flex;
  flex-direction: column;
  gap: 0.8vh;
}

.tv-row {
  display: grid;
  grid-template-columns: 2.2em 1fr auto auto;
  gap: 1em;
  align-items: center;
  padding: 1vh 1.2em;
  border-radius: 10px;
  background: var(--bg-2);
  font-size: 1.2em;
}

.tv-row .rank { color: var(--muted); font-weight: 700; text-align: right; }
.tv-row .name { text-align: left; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tv-row .score { font-weight: 800; font-variant-numeric: tabular-nums; }
.tv-row .gain { color: var(--ok); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 4.5em; text-align: right; }
.tv-row .gain.zero { color: var(--muted); font-weight: 400; }
.tv-row.first { background: rgba(245, 197, 66, 0.18); border: 1px solid var(--gold); }

.tv-podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 2vw;
}

.tv-step {
  width: 18vw;
  text-align: center;
}

.tv-step .block {
  border-radius: var(--radius) var(--radius) 0 0;
  background: var(--bg-2);
  border: 2px solid var(--line);
  border-bottom: 0;
  display: grid;
  place-items: center;
  font-size: 2.6em;
  font-weight: 800;
  color: var(--muted);
}

.tv-step.p1 .block { height: 26vh; border-color: var(--gold); color: var(--gold); }
.tv-step.p2 .block { height: 19vh; }
.tv-step.p3 .block { height: 14vh; }
.tv-step .who { font-weight: 700; font-size: 1.3em; margin-bottom: 0.3em; overflow-wrap: anywhere; }
.tv-step .pts { color: var(--muted); margin-bottom: 0.6em; }

.tv-corner-qr {
  position: fixed;
  right: 2vw;
  bottom: 3vh;
  width: 11vh;
  background: #fff;
  padding: 0.6vh;
  border-radius: 10px;
}

.tv-corner-qr img { display: block; width: 100%; }

.tv-pause {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(11, 16, 32, 0.92);
  z-index: 20;
  text-align: center;
}

.tv-fullscreen {
  position: fixed;
  top: 12px;
  right: 12px;
  padding: 8px 14px;
  background: var(--bg-2);
  color: var(--muted);
  border: 1px solid var(--line);
  font-size: 14px;
  z-index: 30;
}

/* ===================================================================== */
/* Telefón kapitána a moderátor                                           */
/* ===================================================================== */

body.phone, body.host {
  min-height: 100vh;
  font-size: 17px;
}

.wrap {
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 16px 40px;
}

.host .wrap { max-width: 900px; }

h1 { font-size: 1.5rem; margin: 0 0 4px; color: var(--gold); }
h2 { font-size: 1.15rem; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }

.card {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-top: 16px;
}

label { display: block; font-weight: 600; margin-bottom: 6px; }

input[type="text"], input[type="password"], input[inputmode] {
  width: 100%;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  font-size: 1.1rem;
}

.btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  padding: 15px;
  background: var(--gold);
  color: var(--on-opt);
  font-weight: 800;
  font-size: 1.05rem;
}

.btn:disabled { opacity: 0.4; cursor: default; }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  font-weight: 600;
}

.btn-danger { background: transparent; color: var(--bad); border: 1px solid var(--bad); font-weight: 700; }

.link {
  background: none;
  color: var(--muted);
  text-decoration: underline;
  padding: 8px 0;
  margin-top: 8px;
}

.team-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.team-head .score { text-align: right; }
.team-head .score strong { font-size: 1.6rem; display: block; color: var(--gold); }

.answers {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.answer-btn {
  aspect-ratio: 1.3;
  background: var(--c);
  color: var(--on-opt);
  font-size: 3rem;
  font-weight: 900;
  position: relative;
  border: 4px solid transparent;
}

.answer-btn.is-mine { border-color: var(--text); box-shadow: 0 0 0 4px var(--c); }
.answer-btn.is-dim { opacity: 0.35; }

.answer-btn .mine {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  font-size: 0.9rem;
  font-weight: 800;
}

.big-msg {
  text-align: center;
  padding: 28px 8px;
}

.big-msg .emoji { font-size: 2.6rem; display: block; margin-bottom: 8px; }
.big-msg strong { display: block; font-size: 1.4rem; margin-bottom: 6px; }

.result-ok strong { color: var(--ok); }
.result-bad strong { color: var(--bad); }

.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--gold);
}

.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 20px;
  max-width: 528px;
  margin: 0 auto;
  background: var(--bad);
  color: var(--on-opt);
  padding: 12px 16px;
  border-radius: 10px;
  font-weight: 700;
  z-index: 40;
}

/* ---- moderátor -------------------------------------------------------- */

.host-status {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  color: var(--muted);
}

.pill {
  padding: 3px 10px;
  border-radius: 8px;
  background: var(--line);
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
}

.host-q { font-size: 1.15rem; font-weight: 600; margin: 6px 0; }

.host-answer {
  display: inline-block;
  margin-top: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  background: var(--ok);
  color: var(--on-opt);
  font-weight: 800;
}

.host-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.host-actions .btn { margin-top: 0; padding: 12px; font-size: 0.95rem; }

.btn-primary-xl { font-size: 1.25rem; padding: 20px; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
th { color: var(--muted); font-weight: 600; font-size: 0.85rem; }
td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
td.tools { white-space: nowrap; text-align: right; }
td.tools button { padding: 6px 9px; margin-left: 4px; background: var(--line); color: var(--text); font-size: 0.85rem; }
td.tools button.del { background: transparent; color: var(--bad); border: 1px solid var(--bad); }
.yes { color: var(--ok); font-weight: 800; }
.no { color: var(--muted); }
