/* Schlichtes Grunddesign: hell/dunkel nach Systemeinstellung, viel Weissraum. */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #16181d;
  --muted: #5f6673;
  --border: #e2e5ea;
  --accent: #3b5bdb;
  --accent-text: #ffffff;
  --good: #2b8a3e;
  --danger: #c92a2a;
  --info-bg: #e7f0ff;
  --error-bg: #ffe9e9;
  --success-bg: #e6f6ea;
  --radius: 12px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111317;
    --surface: #1a1d23;
    --text: #eceef2;
    --muted: #9aa1ad;
    --border: #2a2e36;
    --accent: #7b93ff;
    --accent-text: #0d0f14;
    --good: #69db7c;
    --danger: #ff8787;
    --info-bg: #1c2a44;
    --error-bg: #3a1d1f;
    --success-bg: #1b3324;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

a { color: var(--accent); }

/* Kopfzeile */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.brand { font-weight: 700; color: var(--text); text-decoration: none; }
.nav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.nav a { color: var(--text); text-decoration: none; }
.nav a:hover { color: var(--accent); }

/* Layout */
.page { max-width: 820px; margin: 2rem auto; padding: 0 1rem; }
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
}
.card.narrow { max-width: 440px; margin-left: auto; margin-right: auto; }
.card.highlight { border-color: var(--accent); }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }
.tile { display: flex; flex-direction: column; gap: 0.25rem; color: var(--text); text-decoration: none; }
.tile:hover { border-color: var(--accent); }

h1 { font-size: 1.5rem; margin: 0 0 0.75rem; }
h2 { font-size: 1.15rem; margin: 0 0 0.75rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.nowrap { white-space: nowrap; }
p { margin: 0 0 0.75rem; }

/* Formulare */
.stack { display: flex; flex-direction: column; gap: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 0.3rem; }
.field label { font-weight: 600; font-size: 0.9rem; }
.help { color: var(--muted); font-size: 0.8rem; }
.help ul { margin: 0.2rem 0 0; padding-left: 1.1rem; }
.errorlist { list-style: none; margin: 0; padding: 0; color: var(--danger); font-size: 0.85rem; }
.has-error input, .has-error select { border-color: var(--danger); }

input[type="text"], input[type="password"], input[type="email"], select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

button, .button {
  display: inline-block;
  padding: 0.55rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-decoration: none;
}
button:hover, .button:hover { border-color: var(--accent); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
button.danger { border-color: var(--danger); color: var(--danger); }
button.link { border: none; background: none; padding: 0; color: var(--accent); }
.danger-text { color: var(--danger) !important; }
.actions { display: flex; gap: 0.75rem; flex-wrap: wrap; }
form.inline { display: inline; margin: 0; }
.row-form { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.row-form select { width: auto; }
.list .row-form { margin: 0; }
.check { display: inline-flex; align-items: center; gap: 0.3rem; font-size: 0.9rem; }
.copy-row { display: flex; gap: 0.5rem; }

/* Meldungen */
.messages { margin-bottom: 1rem; }
.alert { padding: 0.7rem 0.9rem; border-radius: 8px; background: var(--info-bg); margin: 0 0 0.75rem; }
.alert.error { background: var(--error-bg); }
.alert.success { background: var(--success-bg); }
.alert .errorlist { color: inherit; }

/* Tabellen & Kennzeichen */
.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
table.list th, table.list td { text-align: left; padding: 0.55rem 0.5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.list th { color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }
.badge { display: inline-block; padding: 0.1rem 0.5rem; border-radius: 999px; border: 1px solid var(--border); font-size: 0.8rem; color: var(--muted); }
.badge.good { color: var(--good); border-color: var(--good); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.25rem; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.pager { display: flex; justify-content: space-between; align-items: center; margin-top: 1rem; }

/* 2FA */
.steps { padding-left: 1.2rem; margin: 0 0 1rem; }
.qr { display: block; margin: 0.5rem auto 1rem; background: #fff; padding: 8px; border-radius: 8px; }
.secret { font-size: 1rem; letter-spacing: 0.05em; word-break: break-all; }

/* Etappe 3: Fragen, Medien, Profilbilder */
[hidden] { display: none !important; }
.head-row { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head-row h1 { margin: 0; }
.count { font-size: 1rem; font-weight: 400; }
.button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); font-weight: 600; }
.filters input[type="text"] { flex: 1 1 200px; width: auto; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .two-cols { grid-template-columns: 1fr; } }
textarea {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
input[type="number"] {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}
input[type="file"] { font: inherit; color: var(--muted); }
.group { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; margin: 0; display: flex; flex-direction: column; gap: 0.75rem; }
.group legend { font-weight: 600; padding: 0 0.4rem; }
.option-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.option-row input[type="text"] { flex: 1 1 240px; width: auto; }
/* Medien immer im Original-Seitenverhältnis anzeigen (nie verzerren). */
.media-preview { display: block; width: auto; height: auto; max-width: 100%; max-height: 360px; object-fit: contain; border-radius: 8px; }
.media-current, .media-new:not(:empty) { display: flex; flex-direction: column; align-items: flex-start; gap: 0.4rem; }
.media-current audio, .media-new audio { align-self: stretch; }
audio { width: 100%; }
.push-right { margin-left: auto; }
.inline-actions { margin-top: 0.75rem; }

.avatar { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; object-fit: cover; flex-shrink: 0; background: var(--border); color: var(--text); font-weight: 600; }
.avatar.sm { width: 28px; height: 28px; font-size: 0.8rem; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.6rem; }
.avatar.initials { background: var(--accent); color: var(--accent-text); }
.nav .me { display: inline-flex; align-items: center; gap: 0.5rem; }
.profile-head { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.profile-head h1 { margin: 0; }
.user-cell { display: flex; gap: 0.6rem; align-items: center; }

/* Etappe 4: Modi und Spiele */
ul.plain { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.round-list, .item-list { list-style: decimal; padding-left: 1.4rem; margin: 0 0 1rem; }
.round-item { padding: 0.6rem 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.round-item::marker { color: var(--muted); }
.round-main { display: flex; flex-direction: column; min-width: 0; flex: 1 1 260px; }
.round-actions { display: flex; gap: 0.4rem; align-items: center; flex-wrap: wrap; margin: 0; }
.round-actions button, .round-actions .button { padding: 0.35rem 0.7rem; }
.round-actions select { width: auto; padding: 0.35rem 0.5rem; }
.round-actions button:disabled, button:disabled { opacity: 0.4; cursor: default; }
.add-round input[type="text"] { flex: 1 1 200px; width: auto; }
.add-round select { flex: 1 1 200px; }
input.short { width: 5rem; }
table.board { border-collapse: separate; border-spacing: 6px; width: 100%; }
table.board th { font-size: 0.85rem; font-weight: 600; padding: 0.4rem; text-align: center; }
table.board td { text-align: center; padding: 0.8rem 0.4rem; border-radius: 8px; font-weight: 700; }
table.board td.filled { background: var(--accent); color: var(--accent-text); }
table.board td.empty { background: var(--border); color: var(--muted); font-weight: 400; }

/* Etappe 5: Live-Spiel */
.session-list { list-style: none; margin: 0; padding: 0; }
.session-list li { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; padding: 0.6rem 0; border-bottom: 1px solid var(--border); }
.session-list li > div:first-child { display: flex; flex-direction: column; }

.live .page { max-width: 760px; }
.live-screen .page { max-width: none; margin: 0; padding: 1.5rem 2rem; }
.live-screen .topbar { display: none; }
.conn { color: var(--muted); text-align: center; }
.center { text-align: center; }
.big { font-size: 1.25rem; }
.live-root .card h1 { font-size: 1.6rem; }
.live-header { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 0.75rem; }
.timer { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.2rem; }
.timer.low { color: var(--danger); }
.question-text { font-size: 1.3rem; font-weight: 600; margin: 0.5rem 0 1rem; white-space: pre-line; }
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin: 0.75rem 0; }
@media (max-width: 600px) { .options { grid-template-columns: 1fr; } }
.option { display: flex; gap: 0.6rem; align-items: center; padding: 0.9rem 1rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; text-align: left; }
button.option { cursor: pointer; }
.option .letter { font-weight: 700; color: var(--muted); }
.option.selected { border-color: var(--accent); outline: 2px solid var(--accent); }
.option.correct { border-color: var(--good); background: var(--success-bg); }
.buzzer { display: block; width: min(70vw, 260px); height: min(70vw, 260px); margin: 1.5rem auto; border-radius: 50%; border: none; background: var(--danger); color: #fff; font-size: 2rem; font-weight: 800; letter-spacing: 0.05em; box-shadow: 0 8px 0 rgba(0, 0, 0, 0.25); touch-action: manipulation; }
.buzzer:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25); }
.buzzer:disabled { opacity: 0.55; }
.buzzer.active { background: var(--good); opacity: 1; font-size: 1.4rem; }
.answer-row { display: flex; gap: 0.5rem; }
.answer-row input { flex: 1; font-size: 1.1rem; }
.solution { display: flex; flex-direction: column; gap: 0.2rem; padding: 0.9rem 1rem; border-radius: 10px; background: var(--success-bg); margin: 0.75rem 0; }
.solution strong { font-size: 1.3rem; }
.solution.host { background: var(--info-bg); }
.verdict { text-align: center; font-size: 1.4rem; font-weight: 700; }
.verdict.good, .results .good > span:first-child, .answer-list .good { color: var(--good); }
.verdict.bad, .results .bad > span:first-child, .answer-list .bad { color: var(--danger); }
.results, .answer-list, .buzz-queue { list-style: none; padding: 0; margin: 0.5rem 0; }
.results li, .answer-list li { display: flex; gap: 0.75rem; align-items: center; padding: 0.4rem 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.results .name, .answer-list .name { font-weight: 600; color: var(--text); }
.results strong { margin-left: auto; }
.answer-list .judge { margin-left: auto; display: flex; gap: 0.3rem; }
.buzz-queue { list-style: decimal; padding-left: 1.4rem; }
.buzz-queue li { padding: 0.3rem 0; display: flex; gap: 0.5rem; }
.buzz-queue li.active { font-weight: 700; color: var(--accent); }
.buzz-queue li.wrong { text-decoration: line-through; color: var(--muted); }
.scoreboard { list-style: none; padding: 0; margin: 0.5rem 0; counter-reset: rank; }
.scoreboard li { display: flex; align-items: center; gap: 0.6rem; padding: 0.45rem 0; border-bottom: 1px solid var(--border); counter-increment: rank; }
.scoreboard li::before { content: counter(rank) "."; width: 1.6rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.scoreboard li.me { font-weight: 700; color: var(--accent); }
.scoreboard .name { flex: 1; }
.host-scores button { padding: 0.25rem 0.55rem; }
button.small { padding: 0.25rem 0.6rem; font-size: 0.85rem; }
.media-controls { align-items: center; }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 0.7rem 1.1rem; border-radius: 10px; z-index: 50; max-width: 90vw; }
.unlock { position: fixed; top: 0.75rem; right: 0.75rem; z-index: 40; }

/* Hauptbildschirm: gross und gut lesbar aus Distanz */
.screen-layout { display: grid; grid-template-columns: 1fr 300px; gap: 2rem; align-items: start; }
@media (max-width: 900px) { .screen-layout { grid-template-columns: 1fr; } }
.screen-main .live-header .badge { font-size: 1rem; }
.screen-q { font-size: clamp(1.6rem, 3.2vw, 3rem); line-height: 1.25; }
.screen-main .option { font-size: clamp(1.1rem, 2vw, 1.8rem); padding: 1.2rem; }
.screen-main .timer { font-size: 2.5rem; }
.screen-media { display: flex; justify-content: center; margin: 1rem 0; }
.media-full { display: block; max-width: 100%; max-height: 55vh; width: auto; height: auto; object-fit: contain; border-radius: 12px; }
.audio-indicator { font-size: 2rem; color: var(--muted); }
.buzz-banner { text-align: center; font-size: clamp(1.5rem, 3vw, 2.6rem); font-weight: 800; padding: 1rem; border-radius: 14px; color: var(--muted); }
.buzz-banner.on { background: var(--accent); color: var(--accent-text); }
.screen-main .solution strong { font-size: clamp(1.5rem, 3vw, 2.6rem); }
.screen-side { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; }
.screen-lobby, .screen-intro { text-align: center; padding-top: 8vh; }
.screen-lobby h1, .screen-intro h1 { font-size: clamp(2.5rem, 6vw, 5rem); margin-bottom: 1rem; }
.join-url { font-size: clamp(1.4rem, 3vw, 2.4rem); font-weight: 700; color: var(--accent); }
.lobby-players { display: flex; flex-wrap: wrap; gap: 1.5rem; justify-content: center; margin-top: 2rem; }
.lobby-player { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; font-size: 1.2rem; }

/* Etappe 6 */
details > summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸"; color: var(--muted); }
details[open] > summary::before { content: "▾"; }
.inline-h { display: inline; margin: 0; }
.jboard { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 8px; margin: 0.75rem 0; }
.jcol { display: flex; flex-direction: column; gap: 8px; }
.jhead { text-align: center; font-weight: 700; font-size: 0.9rem; padding: 0.5rem 0.25rem; min-height: 2.6rem; display: flex; align-items: center; justify-content: center; }
.jcell { display: flex; align-items: center; justify-content: center; min-height: 3.2rem; border-radius: 10px; background: var(--accent); color: var(--accent-text); font-weight: 800; font-size: 1.2rem; border: none; font-family: inherit; }
button.jcell { cursor: pointer; }
button.jcell:hover { filter: brightness(1.1); }
.jcell.used { background: var(--border); color: transparent; }
.jcell.current { outline: 3px solid var(--good); }
.live-screen .jcell { min-height: 5rem; font-size: clamp(1.4rem, 2.5vw, 2.4rem); }
.live-screen .jhead { font-size: clamp(1rem, 1.6vw, 1.5rem); }
.jvalue { font-weight: 700; color: var(--accent); font-size: 1.3rem; margin: 0; }
.player-media { display: flex; justify-content: center; margin: 0.5rem 0 1rem; }
.player-media .media-full { max-height: 40vh; }

/* Etappe 7: Ranglisten */
.tabs { display: flex; gap: 0.4rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a { padding: 0.35rem 0.8rem; border-radius: 999px; border: 1px solid var(--border); text-decoration: none; color: var(--text); font-size: 0.9rem; }
.tabs a.active { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.ranking .place { font-size: 1.1rem; width: 2.5rem; }
.ranking tr.me td { font-weight: 700; }
.scoreboard.final li::before { content: none; }
.scoreboard .place { width: 2rem; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.75rem; margin-bottom: 1rem; }
.stat-grid div { display: flex; flex-direction: column; padding: 0.8rem; border: 1px solid var(--border); border-radius: 10px; }
.stat-grid strong { font-size: 1.5rem; }
.result-question { padding: 0.5rem 0; border-bottom: 1px solid var(--border); }
.row-tools { display: flex; gap: 0.8rem; margin-top: 0.3rem; }
