/* Geburtstagsquiz - Ruth & Alisi
   Warm, hochkontrastig, auf Handys im halbdunklen Saal lesbar. */

:root {
  --bg:            #fdfaf5;
  --surface:       #ffffff;
  --surface-2:     #f5efe6;
  --border:        #e3d9c9;
  --text:          #241f19;
  --text-muted:    #6d6355;
  --accent:        #9b2c3f;   /* Weinrot */
  --accent-soft:   #f6e7ea;
  --gold:          #b8863b;
  --ok:            #2f6b4f;
  --ok-soft:       #e4f0ea;
  --warn:          #a6641a;
  --warn-soft:     #fbeedd;
  --bad:           #99332b;
  --bad-soft:      #f8e6e4;
  --radius:        14px;
  --shadow:        0 1px 2px rgba(36,31,25,.06), 0 8px 24px rgba(36,31,25,.06);
  --font:          ui-sans-serif, system-ui, -apple-system, "Segoe UI", Inter, Helvetica, Arial, sans-serif;
  --mono:          ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #17140f;
    --surface:     #211c16;
    --surface-2:   #2b241c;
    --border:      #3d342a;
    --text:        #f3ece1;
    --text-muted:  #a99b88;
    --accent:      #e8788c;
    --accent-soft: #3a2126;
    --gold:        #d8a860;
    --ok:          #7fc9a3;
    --ok-soft:     #1d3029;
    --warn:        #e0a462;
    --warn-soft:   #352617;
    --bad:         #ef8c82;
    --bad-soft:    #36201d;
    --shadow:      0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.3);
  }
}
:root[data-theme="dark"] {
  --bg:#17140f; --surface:#211c16; --surface-2:#2b241c; --border:#3d342a;
  --text:#f3ece1; --text-muted:#a99b88; --accent:#e8788c; --accent-soft:#3a2126;
  --gold:#d8a860; --ok:#7fc9a3; --ok-soft:#1d3029; --warn:#e0a462; --warn-soft:#352617;
  --bad:#ef8c82; --bad-soft:#36201d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px 96px; }
.wrap-wide { max-width: 1280px; margin: 0 auto; padding: 0 16px 96px; }

/* ---------- Kopf ---------- */
.masthead { padding: 28px 0 20px; text-align: center; }
.masthead h1 {
  margin: 0; font-size: clamp(26px, 7vw, 40px); letter-spacing: -.02em; font-weight: 700;
}
.masthead .sub { color: var(--accent); font-size: clamp(17px, 4.5vw, 22px); font-weight: 600; margin-top: 2px; }
.masthead .rule {
  width: 56px; height: 3px; background: var(--gold); border-radius: 2px; margin: 14px auto 0;
}

/* ---------- Karten ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 4px; font-size: 20px; }
.card p.lead { margin: 0 0 14px; color: var(--text-muted); }

/* ---------- Frageblock ---------- */
.block-head {
  display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
  margin: 32px 0 6px;
}
.block-head h2 { margin: 0; font-size: 22px; }
.block-head .pts { color: var(--text-muted); font-size: 14px; white-space: nowrap; }
.block-note {
  background: var(--surface-2); border-left: 3px solid var(--gold);
  padding: 10px 14px; border-radius: 0 8px 8px 0; color: var(--text-muted);
  font-size: 15px; margin-bottom: 8px;
}

.q { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
     padding: 16px; margin: 12px 0; box-shadow: var(--shadow); }
.q-head { display: flex; gap: 10px; align-items: baseline; }
.q-code {
  font-family: var(--mono); font-size: 13px; font-weight: 700; color: var(--accent);
  background: var(--accent-soft); padding: 2px 7px; border-radius: 6px; white-space: nowrap;
}
.q-prompt { font-weight: 600; flex: 1; }
.q-pts { color: var(--text-muted); font-size: 13px; white-space: nowrap; }
.q-hint { color: var(--text-muted); font-size: 14px; margin: 6px 0 0; font-style: italic; }

.q-media { margin: 12px 0 4px; }
.q-media img {
  width: 100%; max-height: 46vh; object-fit: contain;
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 8px;
}
.q-media audio { width: 100%; margin-top: 4px; }

/* ---------- Eingaben ---------- */
.fields { display: grid; gap: 10px; margin-top: 12px; }
.fields.two { grid-template-columns: 1fr 1fr; }
@media (max-width: 560px) { .fields.two { grid-template-columns: 1fr; } }

label.field { display: block; }
label.field .lbl {
  display: block; font-size: 13px; font-weight: 600; color: var(--text-muted);
  margin-bottom: 4px; text-transform: uppercase; letter-spacing: .04em;
}
input[type="text"], input[type="password"], input[type="number"], select, textarea {
  width: 100%; font: inherit; font-size: 17px; color: var(--text);
  background: var(--bg); border: 1.5px solid var(--border); border-radius: 10px;
  padding: 11px 12px; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
input.saved { border-color: var(--ok); }

.choice-row { display: flex; gap: 8px; flex-wrap: wrap; }
.choice {
  flex: 1 1 60px; text-align: center; padding: 12px 0; font-weight: 700; font-size: 18px;
  background: var(--bg); border: 1.5px solid var(--border); border-radius: 10px; cursor: pointer;
  user-select: none;
}
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice:has(input:checked) {
  background: var(--accent); color: #fff; border-color: var(--accent);
}

.saved-by { font-size: 12.5px; color: var(--text-muted); margin-top: 6px; min-height: 1.2em; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; font-size: 16px;
  padding: 12px 18px; border-radius: 10px; border: 1.5px solid var(--border);
  background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 14px; border-radius: 8px; }
.btn-ok { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.btn-bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Teamwahl ---------- */
.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.team-pick {
  display: block; text-align: left; padding: 14px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--surface); cursor: pointer;
}
.team-pick:hover { border-color: var(--accent); }
.team-pick .nm { display: block; font-weight: 700; font-size: 17px; line-height: 1.25; }
.team-pick .cnt { display: block; color: var(--text-muted); font-size: 13px; margin-top: 3px; }
.team-pick:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.team-pick input { position: absolute; opacity: 0; }

/* ---------- Status ---------- */
.pill {
  display: inline-block; font-size: 12px; font-weight: 700; padding: 3px 9px;
  border-radius: 999px; text-transform: uppercase; letter-spacing: .04em;
}
.pill-open    { background: var(--ok-soft);   color: var(--ok); }
.pill-closed  { background: var(--surface-2); color: var(--text-muted); }
.pill-reveal  { background: var(--warn-soft); color: var(--warn); }

.empty {
  text-align: center; padding: 48px 20px; color: var(--text-muted);
}
.empty .big { font-size: 40px; margin-bottom: 8px; }

/* ---------- Sticky Kopfzeile Team ---------- */
.teambar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.teambar .who { font-weight: 700; }
.teambar .who small { display: block; font-weight: 400; font-size: 12.5px; color: var(--text-muted); }

/* ======================= Admin ======================= */

.adminbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 93%, transparent);
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
  padding: 10px 16px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.adminbar .brand { font-weight: 800; letter-spacing: -.01em; }
.adminbar nav { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.adminbar nav a { font-size: 14.5px; padding: 6px 12px; border-radius: 8px; color: var(--text); text-decoration: none; }
.adminbar nav a:hover { background: var(--surface-2); }
.adminbar nav a.on { background: var(--accent); color: #fff; }

[data-live-dot] { color: var(--text-muted); }
[data-live-dot][data-online="yes"] { color: var(--ok); }
[data-live-dot][data-online="no"] { color: var(--bad); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
@media (max-width: 860px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* Kennzahlen */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.stat {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow);
}
.stat .k { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.stat .v { font-size: 30px; font-weight: 700; line-height: 1.1; margin-top: 4px; font-variant-numeric: tabular-nums; }
.stat .v small { font-size: 15px; font-weight: 500; color: var(--text-muted); }

/* Blocksteuerung */
/* Raster statt Flex: die Knopfreihe steht bei jedem Block an derselben Stelle,
   auch wenn ein Blocktitel laenger ist als die anderen. */
.block-ctl {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border);
}
.block-ctl:last-child { border-bottom: 0; }
.block-ctl .nm { font-weight: 700; min-width: 0; }
.block-ctl .nm small { display: block; font-weight: 400; color: var(--text-muted); font-size: 13px; }
.block-ctl .acts { display: flex; gap: 6px; }
@media (max-width: 720px) {
  .block-ctl { grid-template-columns: 1fr auto; }
  .block-ctl .acts { grid-column: 1 / -1; }
}
.block-ctl form { display: inline; }

/* Fortschrittsraster */
.progress-wrap { overflow-x: auto; }
table.progress { border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.progress th, table.progress td { padding: 0; }
table.progress thead th {
  font-size: 10.5px; font-weight: 700; color: var(--text-muted);
  writing-mode: vertical-rl; text-orientation: mixed;
  height: 62px; width: 20px; padding-bottom: 4px; vertical-align: bottom;
}
table.progress thead th.blocksep { border-left: 2px solid var(--border); }
table.progress td.blocksep { border-left: 2px solid var(--border); }
table.progress th.team, table.progress td.team {
  position: sticky; left: 0; background: var(--bg); z-index: 2;
  text-align: left; padding-right: 10px; white-space: nowrap;
  writing-mode: horizontal-tb; width: auto; font-size: 14px;
}
table.progress td.team { font-weight: 600; }
table.progress td.team .paper { color: var(--text-muted); font-weight: 400; font-size: 12px; }
.cell { display: block; width: 18px; height: 18px; margin: 1px; border-radius: 4px; background: var(--surface-2); }
.cell.partial { background: var(--warn); opacity: .55; }
.cell.full { background: var(--ok); }
tr.paper-row td.team, tr.paper-row .cell { opacity: .42; }
table.progress td.num { text-align: right; padding-left: 12px; font-variant-numeric: tabular-nums; font-weight: 700; writing-mode: horizontal-tb; }
table.progress td.pct { text-align: right; padding-left: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums; writing-mode: horizontal-tb; }

.legend { display: flex; gap: 16px; font-size: 13px; color: var(--text-muted); margin-top: 10px; flex-wrap: wrap; }
.legend span { display: flex; align-items: center; gap: 6px; }

/* Korrekturliste */
.gitem { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
         padding: 14px; margin: 10px 0; box-shadow: var(--shadow); }
.gitem.needs { border-left: 4px solid var(--warn); }
.gitem.done { opacity: .6; }
.gitem-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.gitem-head .team { font-weight: 700; }
.gitem-head .spacer { margin-left: auto; }
.gfield { display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px dashed var(--border); flex-wrap: wrap; }
.gfield .lbl { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); min-width: 92px; }
.gfield .given { font-weight: 600; flex: 1 1 180px; }
.gfield .given.empty { color: var(--text-muted); font-weight: 400; font-style: italic; }
.gfield .exp { font-size: 13px; color: var(--text-muted); flex: 1 1 150px; }
.gfield .acts { display: flex; gap: 5px; align-items: center; margin-left: auto; }
.verdict { font-size: 11px; font-weight: 700; padding: 2px 7px; border-radius: 999px; text-transform: uppercase; }
.verdict.MATCH { background: var(--ok-soft); color: var(--ok); }
.verdict.UNSURE { background: var(--warn-soft); color: var(--warn); }
.verdict.NO_MATCH { background: var(--bad-soft); color: var(--bad); }
.star { background: none; border: 0; font-size: 19px; cursor: pointer; line-height: 1; padding: 2px 4px; filter: grayscale(1); opacity: .45; }
.star[data-on="1"] { filter: none; opacity: 1; }

.danger { border-color: var(--bad); }
.danger h2 { color: var(--bad); }

.qr-box { text-align: center; }
.qr-box img { width: 100%; max-width: 260px; border-radius: 10px; border: 1px solid var(--border); background: #fff; padding: 8px; }
.qr-box code { display: block; margin-top: 8px; font-size: 13px; color: var(--text-muted); word-break: break-all; }

.ranktable { width: 100%; border-collapse: collapse; }
.ranktable td, .ranktable th { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; }
.ranktable th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.ranktable td.n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.ranktable .pos { color: var(--text-muted); width: 30px; font-variant-numeric: tabular-nums; }
.ranktable input.paper { width: 62px; padding: 5px 7px; font-size: 14px; }

/* ======================= Beamer ======================= */
body.presenter { background: var(--bg); }
.beamer { max-width: 1500px; margin: 0 auto; padding: 32px 40px 60px; }
.beamer h1 { font-size: clamp(34px, 5vw, 62px); margin: 0 0 4px; letter-spacing: -.02em; }
.beamer .sub { font-size: clamp(20px, 2.6vw, 30px); color: var(--accent); font-weight: 600; }
.beamer .huge { font-size: clamp(54px, 9vw, 128px); font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; }
.beamer .muted { color: var(--text-muted); }

.rank-list { list-style: none; margin: 18px 0 0; padding: 0; }
.rank-list li {
  display: flex; align-items: baseline; gap: 18px;
  padding: 14px 20px; margin-bottom: 8px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border);
  font-size: clamp(20px, 2.4vw, 30px);
}
.rank-list li .pos { font-weight: 800; color: var(--text-muted); min-width: 56px; font-variant-numeric: tabular-nums; }
.rank-list li .nm { font-weight: 700; flex: 1; }
.rank-list li .pt { font-weight: 800; font-variant-numeric: tabular-nums; }
.rank-list li:nth-child(1) { border-color: var(--gold); background: color-mix(in srgb, var(--gold) 12%, var(--surface)); }
/* CSS content dekodiert keine HTML-Entitaeten - hier steht das Zeichen selbst. */
.rank-list li:nth-child(1) .pos::before { content: "\1F947"; margin-right: 6px; }

.star-card {
  background: var(--surface); border: 1px solid var(--border); border-left: 5px solid var(--gold);
  border-radius: 12px; padding: 16px 20px; margin-bottom: 10px;
}
.star-card .qq { font-size: 15px; color: var(--text-muted); }
.star-card .aa { font-size: clamp(20px, 2.2vw, 28px); font-weight: 700; margin-top: 4px; }
.star-card .tt { font-size: 15px; color: var(--accent); margin-top: 4px; font-weight: 600; }

/* ======================= Freude am Ausfuellen ======================= */

/* --- Fortschrittsleiste unter der Kopfzeile --- */
.progressbar {
  position: sticky; top: 52px; z-index: 19;
  background: color-mix(in srgb, var(--bg) 94%, transparent);
  backdrop-filter: blur(8px);
  padding: 8px 16px 10px;
  border-bottom: 1px solid var(--border);
}
.progressbar .track {
  height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden;
}
.progressbar .fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--gold));
  transition: width .45s cubic-bezier(.22,.9,.3,1);
}
.progressbar.complete .fill { background: linear-gradient(90deg, var(--ok), var(--gold)); }
.progress-label {
  display: flex; justify-content: space-between; gap: 10px;
  font-size: 13px; color: var(--text-muted); margin-top: 5px;
}
.progressbar.complete .progress-label { color: var(--ok); font-weight: 600; }

/* --- Taufe des Tisches --- */
.namecard { border: 1.5px solid var(--gold); }
.namecard h2 { font-size: 21px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 10px; }
.chip {
  font: inherit; font-size: 14px; padding: 6px 12px; border-radius: 999px;
  border: 1.5px solid var(--border); background: var(--surface); color: var(--text-muted);
  cursor: pointer;
}
.chip:hover { border-color: var(--accent); color: var(--text); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }

/* --- Beantwortete Fragen --- */
.q { border-left: 3px solid transparent; transition: border-color .25s, background .25s; }
.q.answered { border-left-color: var(--ok); }
.q.answered .q-code { background: var(--ok-soft); color: var(--ok); }

/* --- Preisfelder --- */
.money { display: flex; align-items: stretch; }
.money .cur {
  display: flex; align-items: center; padding: 0 10px;
  background: var(--surface-2); border: 1.5px solid var(--border); border-right: 0;
  border-radius: 10px 0 0 10px; font-weight: 700; color: var(--text-muted); font-size: 15px;
}
.money input { border-radius: 0 10px 10px 0; }
.money:focus-within .cur { border-color: var(--accent); color: var(--accent); }

/* --- Ton --- */
.audio-box { background: var(--surface-2); border-radius: 12px; padding: 10px 12px; }
.audio-meta { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.playcount { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* --- Wartezustand mit Kerzen --- */
.waiting .cake { position: relative; width: 96px; height: 74px; margin: 0 auto 18px; }
.waiting .cakebody {
  position: absolute; bottom: 0; left: 0; right: 0; height: 40px;
  background: var(--accent); border-radius: 8px 8px 6px 6px;
}
.waiting .cakebody::after {
  content: ""; position: absolute; top: 8px; left: 0; right: 0; height: 6px;
  background: var(--gold); opacity: .85;
}
.waiting .flame {
  position: absolute; bottom: 40px; width: 8px; height: 18px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: linear-gradient(180deg, var(--gold), var(--accent));
  transform-origin: 50% 100%;
  animation: flicker 1.6s ease-in-out infinite;
}
.waiting .flame:nth-child(1) { left: 18px; animation-delay: 0s; }
.waiting .flame:nth-child(2) { left: 44px; animation-delay: .35s; }
.waiting .flame:nth-child(3) { left: 70px; animation-delay: .7s; }
@keyframes flicker {
  0%, 100% { transform: scaleY(1) rotate(-2deg); opacity: .95; }
  50%      { transform: scaleY(1.18) rotate(2deg); opacity: 1; }
}
.waiting .mates { font-size: 14px; color: var(--text-muted); margin-top: 14px; }

/* --- Kurzer Hinweis am unteren Rand --- */
.footnote { text-align: center; color: var(--text-muted); font-size: 14px; margin-top: 22px; }

/* --- Zuruf --- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 16px);
  background: var(--text); color: var(--bg);
  padding: 11px 20px; border-radius: 999px; font-weight: 600; font-size: 15px;
  box-shadow: 0 8px 28px rgba(0,0,0,.22); z-index: 60;
  opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none;
  max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* --- Konfetti --- */
canvas.confetti {
  position: fixed; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 55;
}

/* Wer weniger Bewegung moechte, bekommt sie nicht. */
@media (prefers-reduced-motion: reduce) {
  .progressbar .fill { transition: none; }
  .waiting .flame { animation: none; }
  .toast { transition: none; }
  .q { transition: none; }
}
