/* Pastellgrünes Design. --gold ist aus historischen Gründen der Name der Akzentfarbe (dunkles Salbeigrün). */
:root {
  --bg: #eef7f0;
  --bg-2: #dcefe2;
  --panel: #ffffff;
  --panel-2: #f1f8f3;
  --line: #c6e4d0;
  --cell: #a6dbbb;
  --cell-hi: #8fd0a9;
  --cell-used: #e3f0e7;
  --gold: #3f8f63;
  --accent-soft: #d3eedd;
  --text: #1e3a2b;
  --muted: #5f7f6b;
  --good: #3aa76d;
  --bad: #de6b6b;
  --shadow: 0 6px 20px rgba(45, 100, 68, .14);
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
[hidden] { display: none !important; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(ellipse at top, var(--bg-2), var(--bg) 70%) fixed;
  color: var(--text);
  font: 15px/1.45 "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding-inline: 16px;
}
h1, h2, h3 { margin: 0 0 .5em; line-height: 1.2; }
a { color: var(--gold); }
button, input, select, textarea { font: inherit; color: inherit; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  padding: .55em 1em; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); cursor: pointer; white-space: nowrap; color: var(--text);
  transition: background .15s, transform .05s;
}
.btn:hover { background: var(--accent-soft); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--gold); color: #fff; border-color: var(--gold); font-weight: 700; }
.btn.primary:hover { background: #357a54; }
.btn.good { background: #dff3e7; border-color: var(--good); color: #226b44; }
.btn.good:hover { background: #cbeeda; }
.btn.bad { background: #fbe6e6; border-color: var(--bad); color: #a33c3c; }
.btn.bad:hover { background: #f7d6d6; }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.small { padding: .3em .6em; font-size: .88em; }
.btn.active { outline: 2px solid var(--gold); outline-offset: 1px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%; padding: .55em .7em; border-radius: 10px;
  border: 1px solid var(--line); background: var(--panel-2);
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--cell-hi); outline-offset: 0; border-color: var(--gold); }
textarea { resize: vertical; min-height: 4.5em; }
label { display: block; font-size: .9em; color: var(--muted); margin-bottom: .25em; }
.field { margin-bottom: .9em; }

.wrap { max-width: 1400px; margin: 0 auto; padding-block: 16px 48px; }
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding-block: 12px; border-bottom: 1px solid var(--line); margin-bottom: 16px;
}
.topbar .brand { font-weight: 900; letter-spacing: .06em; color: var(--gold); font-size: 1.25em; }
.topbar .spacer { flex: 1; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 16px; align-items: start; }
@media (max-width: 1000px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Board */
.board-scroll { overflow-x: auto; }
.board {
  display: grid; gap: 8px; min-width: calc(var(--cols) * 62px);
  grid-template-columns: repeat(var(--cols), minmax(56px, 1fr));
}
.board .cat, .board .cell {
  border-radius: 12px; display: flex; align-items: center; justify-content: center; text-align: center;
  padding: 8px; min-height: 64px;
}
.board .cat {
  background: var(--gold); color: #fff; font-weight: 800; text-transform: uppercase; font-size: clamp(.72rem, 1.1vw, 1rem);
  letter-spacing: .03em; overflow-wrap: anywhere; hyphens: auto; box-shadow: var(--shadow);
}
.board .cell {
  position: relative; background: var(--cell); color: #fff; font-weight: 900;
  font-size: clamp(1.1rem, 2.6vw, 2.2rem); text-shadow: 0 2px 0 #4c9a6c, 0 3px 8px rgba(40, 100, 64, .35);
  min-height: clamp(60px, 9vh, 110px); border: 0; cursor: default; box-shadow: 0 4px 0 #86c69f;
}
.board .cell.clickable { cursor: pointer; }
.board .cell.clickable:hover { background: var(--cell-hi); transform: translateY(-1px); }
.board .cell.used { background: var(--cell-used); color: transparent; text-shadow: none; box-shadow: none; }
.board .cell.used.admin { color: #9dbfa9; }
.board .cell.empty { background: transparent; border: 2px dashed var(--line); color: var(--muted); text-shadow: none; box-shadow: none; }
.board .cell.current { outline: 3px solid var(--gold); outline-offset: 2px; }
.board .cell .kind { position: absolute; top: 4px; right: 6px; font-size: .9rem; text-shadow: none; opacity: .9; }

/* ---------- Frage */
.question {
  background: var(--panel); border: 2px solid var(--cell); border-radius: 20px; padding: clamp(16px, 3vw, 36px);
  text-align: center; box-shadow: 0 16px 50px rgba(45, 100, 68, .22);
}
.question .meta { color: var(--gold); font-weight: 800; letter-spacing: .05em; text-transform: uppercase; margin-bottom: .6em; }
.question .prompt { font-size: clamp(1.3rem, 3vw, 2.4rem); font-weight: 800; margin: .3em 0 .6em; white-space: pre-wrap; }
.question .media img { max-width: 100%; max-height: 60vh; border-radius: 12px; image-rendering: pixelated; background: #dbe9df; }
.question .answer { margin-top: 1em; padding: .7em 1em; border-radius: 12px; background: var(--accent-soft); font-size: clamp(1.1rem, 2.4vw, 1.8rem); }
.question .answer .lbl { color: var(--gold); font-size: .6em; display: block; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.audio-indicator { font-size: 3rem; margin: .2em 0; }
.audio-indicator.playing { animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.15); } }

.overlay {
  position: fixed; inset: 0; background: rgba(214, 236, 222, .82); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) 16px max(16px, env(safe-area-inset-bottom, 0px)); z-index: 20; overflow-y: auto;
}
.overlay > .question { width: min(1000px, 100%); }

.buzzer {
  margin-top: 1.2em; width: min(320px, 100%); aspect-ratio: 2.4; border-radius: 999px; border: 0;
  background: radial-gradient(circle at 50% 35%, #ffb3a7, #f07b6b); color: #fff; font-size: 1.8rem; font-weight: 900;
  letter-spacing: .08em; box-shadow: 0 8px 0 #c95a4b, 0 14px 30px rgba(200, 90, 75, .35); cursor: pointer;
  text-shadow: 0 2px 0 #c95a4b;
}
.buzzer:active { transform: translateY(4px); box-shadow: 0 4px 0 #c95a4b; }
.buzzer:disabled { background: #c9d6cd; box-shadow: 0 8px 0 #a9bbae; text-shadow: none; cursor: not-allowed; }
.buzz-list { list-style: none; padding: 0; margin: 1em auto 0; max-width: 420px; text-align: left; }
.buzz-list li { display: flex; align-items: center; gap: 8px; padding: .45em .7em; border-radius: 12px; background: var(--panel-2); margin-bottom: 6px; flex-wrap: wrap; }
.buzz-list li:first-child { background: var(--accent-soft); outline: 2px solid var(--gold); }
.buzz-list .pos { color: var(--gold); font-weight: 900; width: 1.6em; }
.buzz-list .nm { flex: 1; display: flex; align-items: center; gap: 8px; }

/* ---------- Scores */
.scores { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.score {
  flex: 1 1 140px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; text-align: center; box-shadow: var(--shadow);
}
.score .nm { font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 8px; }
.score .pts { font-size: 1.8rem; font-weight: 900; color: var(--gold); }
.score .pts.neg { color: var(--bad); }
.score.me { outline: 2px solid var(--gold); }
.score.buzzed { outline: 2px solid var(--bad); }

.score-admin { display: grid; gap: 8px; }
.score-admin .item { display: grid; grid-template-columns: 1fr auto; gap: 6px; align-items: center; background: var(--panel-2); border-radius: 12px; padding: 8px 10px; }
.score-admin .item > span:first-child { display: flex; align-items: center; gap: 6px; }
.score-admin .item .pts { font-weight: 900; color: var(--gold); font-size: 1.2em; }
.score-admin .item .btns { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 1em; }
.controls .group { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; background: var(--panel-2); border: 1px solid var(--line); padding: 6px; border-radius: 12px; }

/* ---------- Editor */
.list { display: grid; gap: 8px; }
.list-item { display: flex; gap: 10px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; flex-wrap: wrap; box-shadow: var(--shadow); }
.list-item .grow { flex: 1; min-width: 160px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.chip-input { width: 7em !important; }
.cat-input { flex: 1 1 160px; }

.modal { position: fixed; inset: 0; background: rgba(214, 236, 222, .85); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; z-index: 30; overflow-y: auto; }
.modal .panel { width: min(640px, 100%); }
.type-switch { display: flex; gap: 6px; margin-bottom: 1em; flex-wrap: wrap; }
.preview img { max-width: 100%; max-height: 260px; border-radius: 12px; display: block; }
.preview audio { width: 100%; }

.toast-box { position: fixed; bottom: max(16px, env(safe-area-inset-bottom, 0px)); left: 50%; transform: translateX(-50%); z-index: 50; display: grid; gap: 8px; width: min(420px, calc(100% - 32px)); }
.toast { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .7em 1em; box-shadow: var(--shadow); }
.toast.err { border-color: var(--bad); background: #fdf0f0; }

.login-card { max-width: 380px; margin: 12vh auto 0; }
.login-card h1 { color: var(--gold); text-align: center; font-size: 2.2rem; letter-spacing: .06em; }
.error { color: var(--bad); min-height: 1.4em; }
.banner { background: var(--accent-soft); border: 1px solid var(--gold); border-radius: 12px; padding: .6em 1em; margin-bottom: 12px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.empty-state { text-align: center; padding: 10vh 0; color: var(--muted); font-size: 1.2em; }

/* ---------- Timer + Entpixeln */
.timer-box {
  position: fixed; top: calc(env(safe-area-inset-top, 0px) + 10px); left: 50%; transform: translateX(-50%); z-index: 40;
  min-width: 130px; padding: 6px 18px 10px; border-radius: 16px; text-align: center;
  background: #ffffffee; border: 2px solid var(--gold); box-shadow: var(--shadow);
}
.timer-num { font-size: 2.4rem; font-weight: 900; color: var(--gold); font-variant-numeric: tabular-nums; line-height: 1.1; }
.timer-bar { height: 6px; border-radius: 3px; background: var(--accent-soft); overflow: hidden; }
.timer-bar span { display: block; height: 100%; background: var(--gold); transition: width .1s linear; }
.timer-box.low { border-color: var(--bad); animation: pulse .5s infinite; }
.timer-box.low .timer-num, .timer-box.done .timer-num { color: var(--bad); }
.timer-box.low .timer-bar span { background: var(--bad); }
.timer-box.paused { opacity: .75; border-style: dashed; }
.reveal-bar { height: 5px; border-radius: 3px; background: var(--accent-soft); overflow: hidden; max-width: 420px; margin: 6px auto 0; }
.reveal-bar span { display: block; height: 100%; background: var(--gold); transition: width .3s; }
.rounds { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.sep { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
.check { display: flex; gap: 8px; align-items: center; color: var(--text); margin-top: 8px; font-size: .95em; }
.check input { accent-color: var(--gold); }
.seconds-input { width: 5.5em !important; }

/* ---------- Warteraum */
.lobby { max-width: 560px; margin: 6vh auto 0; text-align: center; }
.lobby-icon { display: flex; justify-content: center; margin-bottom: 6px; }
.lobby-lists { display: flex; gap: 24px; justify-content: center; flex-wrap: wrap; text-align: left; margin-top: 12px; }
.lobby-lists ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.lobby-lists li { display: flex; align-items: center; gap: 8px; }
.lobby-lists h3 { font-size: 1rem; color: var(--gold); }
.dot { display: inline-block; width: .6em; height: .6em; border-radius: 50%; background: #b5c4ba; margin-right: .2em; vertical-align: middle; flex: none; }
.dot.on { background: var(--good); box-shadow: 0 0 6px var(--good); }
.live-badge { color: var(--bad); font-weight: 900; letter-spacing: .08em; animation: pulse 1.6s infinite; }
@media (max-width: 520px) {
  .board { gap: 5px; }
  .board .cat { font-size: .62rem; padding: 4px; letter-spacing: 0; }
  .board .cell { font-size: 1.05rem; padding: 4px; }
}

/* ---------- Hinweise */
.hints { list-style: none; padding: 0; margin: .4em auto .6em; max-width: 780px; display: grid; gap: 8px; counter-reset: hint; }
.hints li { counter-increment: hint; background: var(--panel-2); border-left: 5px solid var(--gold); border-radius: 12px; padding: .55em .9em; text-align: left;
  font-size: clamp(1.05rem, 2.2vw, 1.5rem); white-space: pre-wrap; }
.hints li::before { content: counter(hint) ". "; color: var(--gold); font-weight: 900; }
.hints li.hidden-hint { opacity: .45; border-left-color: var(--line); font-size: 1rem; }
.hints li.new { animation: hint-in .45s ease-out; }
.hint-tag { font-size: .7em; text-transform: uppercase; letter-spacing: .06em; background: var(--line); border-radius: 4px; padding: 1px 6px; margin-right: 8px; }
.hint-count { margin-bottom: .4em; }
@keyframes hint-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- YouTube + Punktabzug */
.yt-box { position: fixed; right: 0; bottom: 0; width: 320px; height: 180px; opacity: 0; pointer-events: none; z-index: -1; }
.yt-box.visible {
  opacity: 1; pointer-events: auto; z-index: 45; right: auto; bottom: auto; left: 50%; top: 50%;
  transform: translate(-50%, -50%); width: min(860px, calc(100vw - 32px)); height: auto; aspect-ratio: 16 / 9;
  border: 3px solid var(--gold); border-radius: 14px; overflow: hidden; box-shadow: 0 20px 60px rgba(30, 70, 45, .35);
}
.yt-box iframe { width: 100%; height: 100%; display: block; }
.old-value { opacity: .55; }
.penalty-preview { font-size: .85em; margin-top: 4px; }

/* „Ton aktivieren“ muss auch über einer offenen Frage antippbar sein */
#audioBanner { position: fixed; left: 50%; bottom: max(16px, env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 60;
  width: min(420px, calc(100% - 32px)); background: #fff7e6; border-color: #e0b35a; box-shadow: var(--shadow); margin: 0; }
/* Beim Admin erscheint das Video unten rechts, damit die Steuerung frei bleibt */
.is-admin .yt-box.visible { left: auto; top: auto; right: 16px; bottom: 16px; transform: none; width: min(420px, calc(100vw - 32px)); }

/* ---------- Avatare */
.avatar { display: inline-block; flex: none; width: var(--size, 32px); height: var(--size, 32px); border-radius: 50%; overflow: hidden;
  background: var(--av-bg, #e8f5ec); box-shadow: 0 0 0 2px #fff, 0 2px 6px rgba(45, 100, 68, .2); vertical-align: middle; }
.avatar svg { width: 100%; height: 100%; display: block; }
.avatar-pick { display: flex; flex-wrap: wrap; gap: 6px; }
.avatar-pick button { border: 2px solid transparent; background: none; padding: 2px; border-radius: 50%; cursor: pointer; }
.avatar-pick button.sel { border-color: var(--gold); }
.me-chip { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; }
