/* Quiz-Arena — zentrales Stylesheet
   Vollbild-Layouts (kein max-width-Korsett), Dark Theme,
   Public Display separat auf Distanz-Lesbarkeit getrimmt. */

:root {
  --bg: #0d1017;
  --panel: #151b26;
  --panel-2: #1d2533;
  --line: #2a3548;
  --ink: #e9edf5;
  --muted: #8b96ab;
  --gold: #f5b933;
  --gold-dim: #b98a1f;
  --blue: #5b8cff;
  --ok: #34d17b;
  --bad: #ff5470;
  --radius: 10px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
}

h1, h2, h3 { font-family: var(--font-display); letter-spacing: .01em; margin: 0 0 .5em; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: .72rem;
  font-weight: 700;
  color: var(--gold);
}

/* ------------------------------ Grundbausteine ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  gap: .4em;
  padding: .5em .95em;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: border-color .12s, background .12s, transform .06s;
}
.btn:hover { border-color: var(--gold-dim); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #14100a; }
.btn.primary:hover { background: #ffcb52; }
.btn.danger { border-color: var(--bad); color: var(--bad); background: transparent; }
.btn.ok { border-color: var(--ok); color: var(--ok); background: transparent; }
.btn.ghost { background: transparent; }
.btn.small { padding: .28em .6em; font-size: .85rem; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.selected { background: var(--gold); border-color: var(--gold); color: #14100a; }
.btn.selected-wrong { background: var(--bad); border-color: var(--bad); color: #fff; }

input, select, textarea {
  width: 100%;
  padding: .55em .7em;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0f141d;
  color: var(--ink);
  font: inherit;
}
input::placeholder, textarea::placeholder { color: #5c667a; }
label { display: block; font-size: .82rem; color: var(--muted); margin: .7em 0 .25em; }
textarea { resize: vertical; min-height: 90px; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.right { margin-left: auto; }
.mono { font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: .12em .55em;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--muted);
}
.badge.gold { border-color: var(--gold-dim); color: var(--gold); }
.badge.ok { border-color: var(--ok); color: var(--ok); }
.badge.bad { border-color: var(--bad); color: var(--bad); }

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--gold-dim);
  color: var(--ink);
  padding: .6em 1.1em;
  border-radius: var(--radius);
  z-index: 999;
  display: none;
  max-width: min(90vw, 560px);
}
#toast.error { border-color: var(--bad); }

/* --------------------------------- Login ----------------------------------- */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card { width: min(420px, 100%); }
.auth-card h1 { font-size: 1.6rem; }
.logo-mark { color: var(--gold); }

/* ------------------------------- App-Layout --------------------------------- */
/* Volle Breite, kein zentriertes Schmal-Layout. */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar .brand { font-weight: 800; font-size: 1.05rem; }
.topbar .brand .logo-mark { margin-right: .15em; }

.app-main { padding: 16px 18px 40px; width: 100%; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }

.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs .btn[aria-selected="true"] { background: var(--gold); border-color: var(--gold); color: #14100a; }

table.list { width: 100%; border-collapse: collapse; }
table.list th, table.list td { text-align: left; padding: .5em .6em; border-bottom: 1px solid var(--line); }
table.list th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }

.q-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: var(--panel-2); }
.q-item + .q-item { margin-top: 8px; }

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--ink);
  width: min(720px, 94vw);
  padding: 20px;
}
dialog::backdrop { background: rgba(5, 8, 13, .7); }

/* ----------------------------- Host-Live-Ansicht ---------------------------- */
/* Grid, das die volle Viewport-Hoehe nutzt; wichtige Aktionen ohne Scrollen. */

.host-live {
  display: grid;
  grid-template-columns: minmax(300px, 380px) 1fr minmax(260px, 330px);
  grid-template-rows: 100%;
  gap: 12px;
  height: calc(100vh - 53px);
  padding: 12px;
}
.host-col { display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: auto; }

.answer-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 8px;
}
.answer-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-2);
  padding: 8px 10px;
}
.answer-card.has-answer { border-color: var(--gold-dim); }
.answer-card.eliminated { opacity: .45; }
.answer-card .name { font-weight: 700; }
.answer-card .opts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }

.solution-box {
  border: 1px dashed var(--gold-dim);
  border-radius: var(--radius);
  padding: 8px 12px;
  color: var(--gold);
  font-weight: 700;
}

@media (max-width: 1200px) {
  .host-live { grid-template-columns: 1fr 1fr; height: auto; }
  .host-col.scores { grid-column: 1 / -1; }
}
@media (max-width: 760px) {
  .host-live { grid-template-columns: 1fr; }
}

/* ------------------------------ Public Display ------------------------------ */
/* Beamer/Stream: grosse Typo, hoher Kontrast, volle Flaeche. */

.display-body { overflow: hidden; }

.display-stage {
  display: grid;
  grid-template-columns: 1fr minmax(300px, 24vw);
  grid-template-rows: auto 1fr;
  gap: clamp(10px, 1.5vw, 24px);
  width: 100vw;
  height: 100vh;
  padding: clamp(12px, 2vw, 32px);
}

.display-head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 18px;
}
.display-head .title { font-size: clamp(1rem, 1.6vw, 1.5rem); font-weight: 800; }
.display-head .qcount { color: var(--muted); font-size: clamp(.9rem, 1.3vw, 1.2rem); }

.display-question {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.6vh, 22px);
  min-height: 0;
}

.display-qtext {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.6rem, 4.2vw, 4rem);
  line-height: 1.15;
}

.display-media { max-height: 38vh; display: flex; }
.display-media img {
  max-height: 38vh;
  max-width: 100%;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  object-fit: contain;
}
.display-media audio { width: min(560px, 100%); }

.display-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(340px, 100%), 1fr));
  gap: clamp(8px, 1.2vw, 16px);
}
.display-option {
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  padding: clamp(10px, 1.6vh, 20px) clamp(12px, 1.4vw, 22px);
  font-size: clamp(1.1rem, 2.2vw, 2rem);
  font-weight: 700;
  display: flex;
  gap: .6em;
  align-items: center;
}
.display-option .letter {
  color: var(--gold);
  font-weight: 900;
  font-size: 1.1em;
}
.display-option.correct { border-color: var(--ok); background: rgba(52, 209, 123, .12); }
.display-option.dimmed { opacity: .35; }

.display-answerline {
  font-size: clamp(1.2rem, 2.4vw, 2.2rem);
  font-weight: 800;
  color: var(--ok);
}

/* Signature-Element: Countdown-Ring */
.timer-ring { width: clamp(64px, 7vw, 110px); height: clamp(64px, 7vw, 110px); position: relative; flex: none; }
.timer-ring svg { transform: rotate(-90deg); width: 100%; height: 100%; }
.timer-ring circle { fill: none; stroke-width: 8; }
.timer-ring .track { stroke: var(--line); }
.timer-ring .bar { stroke: var(--gold); stroke-linecap: round; transition: stroke-dashoffset .25s linear, stroke .25s; }
.timer-ring.low .bar { stroke: var(--bad); }
.timer-ring .num {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  font-variant-numeric: tabular-nums;
}

/* Rangliste (Broadcast-Stil) */
.display-board { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow: hidden; }
.display-board h2 { font-size: clamp(.9rem, 1.3vw, 1.15rem); }
.board-list { display: flex; flex-direction: column; gap: clamp(4px, .8vh, 10px); overflow: hidden; }
.board-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(6px, 1vh, 12px) 12px;
  font-size: clamp(.95rem, 1.5vw, 1.35rem);
}
.board-row .rank {
  width: 2em;
  height: 2em;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 900;
}
.board-row:nth-child(1) .rank { background: var(--gold); color: #14100a; }
.board-row .bname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .bteam { color: var(--muted); font-size: .75em; }
.board-row .bpts { margin-left: auto; font-weight: 900; font-variant-numeric: tabular-nums; }
.board-row.eliminated { opacity: .4; text-decoration: line-through; }
.board-row.answered { border-color: var(--gold-dim); }
.board-row .dot { width: .55em; height: .55em; border-radius: 50%; background: var(--gold); flex: none; }
.board-row .lives { color: var(--bad); letter-spacing: .1em; font-size: .8em; }
.board-row .res-ok { color: var(--ok); font-weight: 900; }
.board-row .res-bad { color: var(--bad); font-weight: 900; }
.board-row .shown { color: var(--muted); font-size: .78em; }

.display-center {
  grid-column: 1 / -1;
  display: grid;
  place-items: center;
  text-align: center;
  gap: 12px;
}
.display-code {
  font-size: clamp(2.4rem, 8vw, 7rem);
  font-weight: 900;
  letter-spacing: .18em;
  color: var(--gold);
}

.podium { display: flex; gap: 18px; align-items: flex-end; justify-content: center; }
.podium .p {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 26px;
  text-align: center;
}
.podium .p .pn { font-weight: 800; font-size: clamp(1.1rem, 2vw, 1.8rem); }
.podium .p .pp { color: var(--gold); font-weight: 900; font-size: clamp(1.3rem, 2.6vw, 2.4rem); }
.podium .p.first { border-color: var(--gold); transform: translateY(-14px); }

@media (max-width: 900px) {
  .display-stage { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
