/* =========================================================================
   QuizMaster - schlichtes, modernes Layout
   ========================================================================= */

:root {
  --bg: #f6f7fb;
  --bg-elevated: #ffffff;
  --border: #e4e6ef;
  --text: #16181d;
  --text-soft: #616676;
  --text-faint: #676f86;   /* 4,65:1 - trägt oft echte Information */
  --accent: #4f46e5;       /* Füllfarbe der Knöpfe */
  --accent-ink: #4f46e5;   /* dieselbe Farbe als Schrift, 7,0:1 auf --bg */
  --accent-soft: #eef0ff;
  --accent-text: #ffffff;
  --track: rgba(22, 24, 29, .10);   /* Schienen und Regler-Rillen */
  --shine-a: #4f46e5;               /* Verlauf im großen Beitrittscode */
  --shine-b: #a855f7;
  --success: #0c7f59;      /* 4,69:1 */
  --success-soft: #e4f6ef;
  --danger: #d7243b;       /* 4,65:1 */
  --danger-soft: #fdeaec;
  --warn: #c77c12;

  /* Antwortfarben. Jede erfüllt mit weißer Schrift mindestens 4,6:1 (WCAG AA)
     und hebt sich zugleich vom hellen wie vom dunklen Hintergrund ab.
     Die Werte sind hergeleitet, nicht geraten - siehe README, Abschnitt Farben. */
  --a1: #da2f46;   /* Rot        weiß 4,67:1 */
  --a2: #2f71da;   /* Blau       weiß 4,67:1 */
  --a3: #a5651d;   /* Bernstein  weiß 4,68:1 */
  --a4: #17845c;   /* Grün       weiß 4,66:1 */
  --a5: #a048df;   /* Violett    weiß 4,68:1 */
  --a6: #1a7e93;   /* Türkis     weiß 4,70:1 */
  --a7: #c74c23;   /* Ziegel     weiß 4,70:1 */
  --a8: #6b748e;   /* Grau       weiß 4,67:1 */

  --radius: 14px;
  --radius-lg: 20px;
  --shadow: 0 1px 2px rgba(16, 20, 40, .05), 0 8px 24px rgba(16, 20, 40, .06);
  --shadow-lg: 0 2px 4px rgba(16, 20, 40, .06), 0 18px 48px rgba(16, 20, 40, .12);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 16px;
  line-height: 1.5;
}

/* Das dunkle Erscheinungsbild. Es hängt am <html>-Element, nicht mehr an der
   Beamer-Ansicht: So gilt dieselbe Palette für Bühne, Adminbereich und
   Eingangsseite, und ein einziger Schalter stellt alles zugleich um.
   Gesetzt wird das Attribut von einem kurzen Skript im <head> jeder Seite. */
:root[data-theme="dark"] {
  --bg: #0e1017;
  --bg-elevated: #171a24;
  --border: #262b39;
  --text: #f3f4f8;
  --text-soft: #a4abbd;
  --text-faint: #7d8497;   /* 4,62:1 auf dunklen Karten */
  /* Die Füllfarbe der Knöpfe bleibt dieselbe - mit weißer Schrift trägt sie
     auch im Dunkeln. Für Schrift auf dunklem Grund braucht es dagegen einen
     helleren Ton, sonst wäre ein Link kaum zu lesen (2,9:1). */
  --accent-ink: #a5a4ff;   /* 8,9:1 auf #0e1017 */
  --accent-soft: #1d2036;
  --success-soft: #102c22;
  --danger-soft: #351720;
  --success: #3ddc9a;
  --danger: #ff6b7f;
  --warn: #e0a341;
  --track: rgba(255, 255, 255, .10);
  --shine-a: #ffffff;
  --shine-b: #b9baff;
  --shadow: none;
  --shadow-lg: 0 24px 64px rgba(0, 0, 0, .5);
}

[hidden] { display: none !important; }

h1, h2, h3 { margin: 0 0 .4em; font-weight: 650; letter-spacing: -.02em; line-height: 1.2; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
p  { margin: 0 0 1em; }
a  { color: var(--accent-ink); }

.muted   { color: var(--text-soft); }
.faint   { color: var(--text-faint); }
.small   { font-size: .875rem; }
.tiny    { font-size: .78rem; }
.center  { text-align: center; }
.mono    { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.hidden  { display: none !important; }
.grow    { flex: 1; }
.nowrap  { white-space: nowrap; }

/* ---------- Layout ---------- */

.wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 24px 20px 64px;
}
.wrap.narrow { max-width: 460px; }
.wrap.wide   { max-width: 1400px; }

.stack   { display: flex; flex-direction: column; gap: 14px; }
.row     { display: flex; align-items: center; gap: 12px; }
.row.wrap-row { flex-wrap: wrap; }
.spread  { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 22px;
}
.card.tight { padding: 16px; }

/* ---------- Formulare ---------- */

label { display: block; font-size: .85rem; font-weight: 600; color: var(--text-soft); margin-bottom: 6px; }

input[type=text], input[type=password], input[type=number], input[type=url],
input[type=search], input[type=email], input[type=tel], select, textarea {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 11px 13px;
  transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 80px; line-height: 1.45; }
/* Safari gibt Suchfeldern eine eigene, schmale Darstellung mitsamt Innenabstand. */
input[type=search] { -webkit-appearance: none; appearance: none; }

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  /* Erste Zeile als Rückfalloption für ältere Safari-Fassungen ohne color-mix */
  box-shadow: 0 0 0 3px rgba(79, 70, 229, .2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

input.code {
  font-size: 2rem;
  letter-spacing: .35em;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 14px 10px;
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }

.checkline { display: flex; align-items: center; gap: 9px; font-size: .9rem; color: var(--text); font-weight: 500; }
.checkline input { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; flex: none; }
.checkline label { margin: 0; font-weight: 500; color: inherit; }

/* ---------- Buttons ---------- */

button, .btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 11px 18px;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-text);
  transition: filter .15s, transform .06s, background .15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  line-height: 1.2;
}
button:hover, .btn:hover { filter: brightness(1.07); }
button:active, .btn:active { transform: translateY(1px); }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.btn-ghost {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border);
}
.btn-ghost:hover { background: var(--accent-soft); }
.btn-danger { background: #d33049; color: #fff; border-color: transparent; }
.btn-quiet { background: transparent; color: var(--text-soft); border-color: transparent; padding: 8px 10px; }
.btn-quiet:hover { background: var(--accent-soft); color: var(--text); }
.btn-block { width: 100%; }
.btn-lg { padding: 15px 24px; font-size: 1.05rem; border-radius: 16px; }
.btn-sm { padding: 7px 12px; font-size: .84rem; border-radius: 10px; }

/* ---------- Badges & Meldungen ---------- */

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent-soft); color: var(--accent-ink);
  border-radius: 999px; padding: 4px 11px;
  font-size: .78rem; font-weight: 650;
}
.badge.ok   { background: var(--success-soft); color: var(--success); }
.badge.bad  { background: var(--danger-soft);  color: var(--danger); }

.notice {
  border-radius: var(--radius);
  padding: 11px 14px;
  font-size: .9rem;
  border: 1px solid transparent;
}
.notice.error { background: var(--danger-soft); color: var(--danger); border-color: rgba(220, 47, 69, .28); }
.notice.ok    { background: var(--success-soft); color: var(--success); border-color: rgba(15, 157, 110, .28); }
@supports (border-color: color-mix(in srgb, red 25%, transparent)) {
  .notice.error { border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
  .notice.ok    { border-color: color-mix(in srgb, var(--success) 25%, transparent); }
}
.notice.info  { background: var(--accent-soft); color: var(--text-soft); border-color: var(--border); }

/* ---------- Antwortkacheln ---------- */

.answers {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.answers > * { min-width: 0; }
.answers.cols-1, .answers.cols-3 { grid-template-columns: 1fr; }
@media (min-width: 620px) {
  .answers.cols-3 { grid-template-columns: repeat(3, 1fr); }
}

.tile {
  --tint: var(--a1);
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  background: var(--tint);
  color: #fff;
  border: 2px solid transparent;
  border-radius: 16px;
  padding: 18px 16px;
  min-height: 84px;
  font-size: 1.02rem;
  font-weight: 600;
  width: 100%;
  box-shadow: 0 2px 0 rgba(0, 0, 0, .12);
  transition: transform .08s, opacity .15s, box-shadow .15s;
}
.tile:hover:not(:disabled) { filter: brightness(1.06); }
.tile .key {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: rgba(255, 255, 255, .22);
  display: grid; place-items: center;
  font-weight: 800; font-size: 1rem;
}
.tile .txt { flex: 1; min-width: 0; overflow-wrap: break-word; overflow-x: auto; }
.tile .txt::-webkit-scrollbar { height: 4px; }
/* Formeln dürfen umbrechen - abgeschnittene Antworten wären schlimmer
   als ein zweizeiliger Term. */
.tile .txt .katex { font-size: 1em; }
.tile .mark {
  position: absolute; top: 8px; right: 10px;
  font-size: 1.2rem; opacity: 0; pointer-events: none;
}

.tile.picked { border-color: #fff; box-shadow: 0 0 0 4px rgba(255, 255, 255, .35), 0 2px 0 rgba(0,0,0,.12); }
.tile.dimmed { opacity: .32; }
.tile.right  { outline: 3px solid var(--success); outline-offset: 2px; }
.tile.right .mark { opacity: 1; }
.tile:disabled { cursor: default; }

.tile-1 { --tint: var(--a1); } .tile-2 { --tint: var(--a2); }
.tile-3 { --tint: var(--a3); } .tile-4 { --tint: var(--a4); }
.tile-5 { --tint: var(--a5); } .tile-6 { --tint: var(--a6); }
.tile-7 { --tint: var(--a7); } .tile-8 { --tint: var(--a8); }

/* ---------- Timer ---------- */

.timerbar {
  height: 8px;
  border-radius: 999px;
  background: var(--border);
  overflow: hidden;
}
.timerbar > i {
  display: block; height: 100%; width: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width .25s linear, background .3s;
}
.timerbar.warn > i { background: var(--warn); }
.timerbar.crit > i { background: var(--danger); }

.timerdial {
  width: 96px; height: 96px;
  flex: none;
  display: grid; place-items: center;
  border-radius: 50%;
  font-size: 2.1rem; font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  background:
    radial-gradient(closest-side, var(--bg-elevated) 79%, transparent 80% 100%),
    conic-gradient(var(--accent) var(--pct, 100%), var(--border) 0);
}
.timerdial.warn { background: radial-gradient(closest-side, var(--bg-elevated) 79%, transparent 80% 100%), conic-gradient(var(--warn) var(--pct, 100%), var(--border) 0); }
.timerdial.crit { background: radial-gradient(closest-side, var(--bg-elevated) 79%, transparent 80% 100%), conic-gradient(var(--danger) var(--pct, 100%), var(--border) 0); }

/* ---------- Tabellen / Rangliste ---------- */

.lb { display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
}
.lb-row.me { border-color: var(--accent); background: var(--accent-soft); }
.lb-rank { width: 34px; font-weight: 750; color: var(--text-soft); font-variant-numeric: tabular-nums; }
.lb-name { flex: 1; font-weight: 600; overflow-wrap: anywhere; }
.lb-score { font-weight: 700; font-variant-numeric: tabular-nums; }
.lb-delta { font-size: .78rem; color: var(--success); font-weight: 650; min-width: 52px; text-align: right; }

.podium { display: flex; align-items: flex-end; justify-content: center; gap: 14px; margin: 24px 0; }
.podium .step {
  flex: 1; max-width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 18px 18px 0 0;
  padding: 18px 12px;
  text-align: center;
}
.podium .step.p1 { padding-bottom: 54px; border-color: var(--accent); }
.podium .step.p2 { padding-bottom: 34px; }
.podium .step.p3 { padding-bottom: 20px; }
.podium .medal { font-size: 1.7rem; }
.podium .who { font-weight: 700; margin-top: 4px; overflow-wrap: anywhere; }
.podium .pts { color: var(--text-soft); font-variant-numeric: tabular-nums; }

table.grid { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.grid th, table.grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); }
table.grid th { color: var(--text-soft); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
table.grid tr:last-child td { border-bottom: none; }

/* ---------- Auflösung auf dem Beamer ---------- */

.reveal-head { text-align: center; max-width: 1100px; margin: 0 auto 18px; }
.reveal-head .qtext { font-size: clamp(1.1rem, 1.9vw, 1.6rem); font-weight: 600; }
.reveal-head .qimage { display: flex; justify-content: center; }
.reveal-head .qimage img { max-height: 16vh; }

.solution-wrap { max-width: 1060px; margin: 0 auto 26px; text-align: center; }
.solution-label {
  font-size: .8rem; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--success); margin-bottom: 12px;
}
.solution {
  --tint: var(--a1);
  display: flex; align-items: center; justify-content: center; gap: 20px;
  background: var(--tint); color: #fff;
  border-radius: 22px; padding: 24px 30px; margin: 0 auto 12px;
  /* Die Kachel legt sich um ihren Inhalt (`fit-content`), wächst aber nie über
     die Fläche hinaus. Ohne diese Grenze schöbe ein langer Term die Kachel aus
     dem Bild - und der Text hätte nie "zu wenig Platz", auf den
     fitSolutions() reagieren könnte. */
  width: fit-content;
  max-width: 100%;
  box-shadow: 0 0 0 4px var(--success), 0 16px 44px rgba(0, 0, 0, .35);
  font-size: clamp(1.5rem, 3.1vw, 2.7rem); font-weight: 700; line-height: 1.25;
  animation: pop .35s cubic-bezier(.2, 1.3, .4, 1) both;
}
.solution .key {
  flex: none; width: 56px; height: 56px; border-radius: 16px;
  background: rgba(255, 255, 255, .24);
  display: grid; place-items: center; font-size: 1.5rem; font-weight: 800;
}
/* Die Lösung steht immer auf einer Zeile. Ein Umbruch mitten in einer Formel
   ("1/8 =" oben, "0,125" darunter) ist nicht nur hässlich, er ist falsch zu
   lesen - und die Kachel hat dafür auch gar keine Höhe. Passt der Term nicht,
   verkleinert ihn `fitSolutions()` in host.js über `--fit`, statt ihn
   umzubrechen. */
.solution .txt {
  --fit: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  font-size: calc(1em * var(--fit));
}
.solution .txt .katex { font-size: 1em; white-space: nowrap; }
.solution.multi { font-size: clamp(1.2rem, 2.2vw, 1.9rem); padding: 18px 24px; }
.solution.multi .key { width: 44px; height: 44px; font-size: 1.15rem; border-radius: 13px; }

.solution-expl {
  margin-top: 18px; font-size: clamp(1rem, 1.5vw, 1.3rem);
  line-height: 1.45; max-width: 900px; margin-inline: auto;
}
.solution-expl .muted { display: block; margin-bottom: 4px; }

.reveal-foot { max-width: 1060px; margin: 0 auto; }

/* ---------- Verteilungsbalken ---------- */

.dist { display: flex; align-items: flex-end; gap: 10px; height: 120px; margin-top: 12px; }
.dist .bar { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; height: 100%; }
.dist .bar > .fill {
  width: 100%;
  border-radius: 8px 8px 4px 4px;
  background: var(--tint, var(--a1));
  min-height: 4px;
  transition: height .5s cubic-bezier(.2,.8,.3,1);
}
.dist .bar.correct > .fill { box-shadow: 0 0 0 3px var(--success); }
.dist .bar > .cap { font-size: .8rem; font-weight: 700; color: var(--text-soft); }

/* ---------- Sonstiges ---------- */

.pill-list { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 13px; font-size: .88rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: 8px;
  animation: pop .3s cubic-bezier(.2,1.4,.4,1);
}
.pill button { padding: 0 2px; background: none; border: none; color: var(--text-faint); font-size: 1rem; }
.pill.off { opacity: .45; }

@keyframes pop { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes fadeUp { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.fade-up { animation: fadeUp .3s ease both; }

.pin-display {
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  font-weight: 750;
  letter-spacing: .12em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.qr { background: #fff; padding: 14px; border-radius: 18px; display: inline-block; line-height: 0; }
.qr img { width: 100%; max-width: 280px; height: auto; display: block; }

.qtext { font-size: clamp(1.25rem, 2.6vw, 2.1rem); font-weight: 650; line-height: 1.3; }

.qimage { margin-top: 12px; }
.qimage img {
  max-width: 100%; max-height: 34vh; width: auto;
  border-radius: 14px; border: 1px solid var(--border); display: block;
  background: var(--bg);
}
.qimage.small-img img { max-height: 20vh; }
.qtext .katex { font-size: 1.05em; }

.katex-display { margin: .5em 0 !important; }
.katex { overflow-wrap: normal; }

.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-elevated);
  position: sticky; top: 0; z-index: 20;
}
.topbar .brand { font-weight: 750; letter-spacing: -.02em; display: flex; align-items: center; gap: 9px; }
.logo {
  width: 26px; height: 26px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #8b5cf6);
  display: grid; place-items: center; color: #fff; font-size: .8rem; font-weight: 800;
}

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- Dialoge ---------- */

.modal-back {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(10, 12, 20, .55);
  display: grid; place-items: center; padding: 20px;
  animation: fadeIn .15s ease both;
}
.modal {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  width: 100%; max-width: 520px; max-height: 88vh; overflow: auto;
  animation: pop .2s cubic-bezier(.2, 1.2, .4, 1) both;
}
.modal h2 { margin: 0 0 6px; font-size: 1.25rem; }
.modal .modal-text { margin: 0 0 16px; color: var(--text-soft); font-size: .95rem; }
.modal .modal-text:last-of-type { margin-bottom: 0; }
.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 20px; flex-wrap: wrap;
}
.modal-actions button { min-width: 110px; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Warnung bei fehlender Live-Verbindung */
.conn-warning {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 100;
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: #7f1d2c; color: #fff;
  border-radius: var(--radius); padding: 14px 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
  font-size: .9rem; line-height: 1.4;
  animation: fadeUp .25s ease both;
}
.conn-warning .txt { flex: 1; min-width: 200px; display: flex; flex-direction: column; gap: 3px; }
.conn-warning .txt span { opacity: .92; }
.conn-warning button { background: rgba(255, 255, 255, .16); color: #fff; border-color: transparent; flex: none; }
@media (min-width: 900px) {
  .conn-warning { left: auto; right: 20px; bottom: 20px; max-width: 560px; }
}

.split { display: grid; grid-template-columns: 1fr; gap: 18px; }
@media (min-width: 900px) {
  .split.aside { grid-template-columns: minmax(0, 1fr) 320px; }
  .split.half  { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (min-width: 900px) {
  .answers.big .tile { min-height: 110px; font-size: 1.2rem; }
}

/* Schülergerät: große, gut treffbare Kacheln, die den Bildschirm füllen */
/* Nur auf dem Schülergerät - auf der Beamer-Ansicht regelt die Bühne die Höhe.
   Ohne diese Einschränkung erzwingt die Regel dort eine Mindesthöhe und die
   unteren Antwortkacheln rutschen aus dem Bild. */
body:not(.stage) #v-question {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 130px);   /* Rückfalloption für ältere Safari-Fassungen */
  min-height: calc(100dvh - 130px);
}
body:not(.stage) .play-answers { flex: 1; grid-auto-rows: minmax(84px, 1fr); align-content: stretch; }
.play-answers .tile { min-height: 84px; height: 100%; }

@media (max-width: 480px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .topbar .brand { font-size: .95rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .badge { padding: 4px 9px; font-size: .72rem; }
  .wrap { padding: 16px 14px 40px; }
  .tile { font-size: .95rem; padding: 14px 12px; gap: 10px; }
  .tile .key { width: 30px; height: 30px; font-size: .9rem; }
}

/* =========================================================================
   Erscheinungsbild: Atmosphäre, Tiefe und Bewegung
   -------------------------------------------------------------------------
   Alles rein mit CSS erzeugt - keine externen Bilddateien. Das hält die
   Anwendung auch in einem abgeschotteten Schulnetz vollständig funktionsfähig
   und kostet keine Ladezeit. Wer Bewegung nicht mag, bekommt sie nicht:
   ganz unten steht die Regel für "prefers-reduced-motion".
   ========================================================================= */

:root {
  --glass: rgba(255, 255, 255, .72);
  --glass-line: rgba(255, 255, 255, .65);
  --glow: 99, 102, 241;
  --aurora-1: rgba(99, 102, 241, .22);
  --aurora-2: rgba(217, 70, 239, .14);
  --aurora-3: rgba(20, 184, 166, .16);
  --grid-line: rgba(22, 24, 29, .05);
}

:root[data-theme="dark"] {
  --glass: rgba(23, 26, 36, .68);
  --glass-line: rgba(255, 255, 255, .07);
  --aurora-1: rgba(99, 102, 241, .30);
  --aurora-2: rgba(217, 70, 239, .18);
  --aurora-3: rgba(20, 184, 166, .20);
  --grid-line: rgba(255, 255, 255, .045);
}

body {
  position: relative;
  isolation: isolate;
  overflow-x: hidden;
  min-height: 100vh;   /* deckt den Bildschirm auch bei wenig Inhalt */
}

/* Weiche, langsam wandernde Farbschleier */
body::before {
  content: '';
  position: fixed; inset: -25%;
  z-index: -2; pointer-events: none;
  background:
    radial-gradient(38rem 30rem at 14% 16%, var(--aurora-1), transparent 64%),
    radial-gradient(32rem 26rem at 86% 10%, var(--aurora-2), transparent 62%),
    radial-gradient(40rem 32rem at 74% 90%, var(--aurora-3), transparent 66%);
  animation: aurora 34s ease-in-out infinite alternate;
  will-change: transform;
}

/* Feines Raster darüber - gibt Tiefe, ohne sich vorzudrängen */
body::after {
  content: '';
  position: fixed; inset: 0;
  z-index: -1; pointer-events: none;
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 46px 46px;
  -webkit-mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 78%);
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 35%, transparent 78%);
}

@keyframes aurora {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  50%  { transform: translate3d(2%, -1.5%, 0) scale(1.06); }
  100% { transform: translate3d(-2%, 2%, 0) scale(1.03); }
}

/* ---------- Glasflächen ---------- */

.topbar {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--glass-line);
}

.card, .modal, .qcard, .lb-row, .dropzone, .preview {
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.card, .qcard {
  background: var(--glass);
  border-color: var(--glass-line);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .5) inset,
    0 10px 30px rgba(16, 20, 40, .07);
  transition: transform .18s ease, box-shadow .18s ease;
}
[data-theme="dark"] .card, [data-theme="dark"] .qcard {
  box-shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 18px 44px rgba(0, 0, 0, .45);
}
#quiz-list .card:hover {
  transform: translateY(-2px);
  box-shadow: 0 1px 0 rgba(255, 255, 255, .5) inset, 0 16px 38px rgba(16, 20, 40, .12);
}

.logo {
  box-shadow: 0 4px 14px rgba(var(--glow), .45);
  position: relative; overflow: hidden;
}
.logo::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(120deg, transparent 30%, rgba(255, 255, 255, .55) 50%, transparent 70%);
  transform: translateX(-120%);
  animation: sheen 7s ease-in-out infinite;
}
@keyframes sheen {
  0%, 72% { transform: translateX(-120%); }
  86%, 100% { transform: translateX(120%); }
}

/* ---------- Knöpfe mit etwas mehr Charakter ---------- */

button, .btn {
  position: relative; overflow: hidden;
  background-image: linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0));
}
button:not(.btn-ghost):not(.btn-quiet):not(.tile):hover,
.btn:not(.btn-ghost):not(.btn-quiet):hover {
  box-shadow: 0 8px 22px rgba(var(--glow), .38);
  transform: translateY(-1px);
}
button:active, .btn:active { transform: translateY(1px) scale(.99); }
.btn-ghost:not(.btn-danger) { background-color: var(--glass); }

/* ---------- Antwortkacheln ---------- */

/* Kein aufhellender Verlauf mehr - er hat den Kontrast des weißen Textes
   gesenkt. Stattdessen nur eine leichte Abdunklung nach unten. */
.tile {
  background-image: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, .14));
  box-shadow: 0 10px 26px rgba(0, 0, 0, .18), 0 2px 0 rgba(0, 0, 0, .12);
  animation: tileIn .34s cubic-bezier(.2, .9, .3, 1) both;
}
.answers > *:nth-child(1) { animation-delay: .02s; }
.answers > *:nth-child(2) { animation-delay: .08s; }
.answers > *:nth-child(3) { animation-delay: .14s; }
.answers > *:nth-child(4) { animation-delay: .20s; }
.answers > *:nth-child(5) { animation-delay: .26s; }
.answers > *:nth-child(6) { animation-delay: .32s; }

@keyframes tileIn {
  from { opacity: 0; transform: translateY(14px) scale(.97); }
  to   { opacity: 1; transform: none; }
}

button.tile:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 16px 34px rgba(0, 0, 0, .26), 0 2px 0 rgba(0, 0, 0, .12);
}
button.tile:active:not(:disabled) { transform: translateY(0) scale(.985); }
.tile.picked { animation: none; }
.tile.right {
  animation: rightPulse 1.6s ease-in-out 2;
}
@keyframes rightPulse {
  0%, 100% { outline-color: var(--success); }
  50%      { outline-color: rgba(61, 220, 154, .35); }
}

/* ---------- Beamer: Lobby und Timer ---------- */

.pin-display {
  background: linear-gradient(120deg, var(--shine-a) 20%, var(--shine-b) 45%, var(--shine-a) 70%);
  -webkit-background-clip: text; background-clip: text;
  color: transparent;
  background-size: 220% 100%;
  animation: shimmer 6s linear infinite;
}
@keyframes shimmer {
  from { background-position: 0% 0; }
  to   { background-position: 220% 0; }
}

.qr { animation: float 7s ease-in-out infinite; box-shadow: 0 18px 44px rgba(0, 0, 0, .35); }
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.timerdial { box-shadow: 0 0 0 1px var(--border), 0 10px 30px rgba(0, 0, 0, .25); }
.timerdial.crit { animation: heartbeat 1s ease-in-out infinite; }
@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

/* ---------- Auflösung ---------- */

.solution {
  background-image: linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(0, 0, 0, .16));
  animation: solutionIn .5s cubic-bezier(.2, 1.1, .3, 1) both;
}
.solution:nth-child(2) { animation-delay: .1s; }
.solution:nth-child(3) { animation-delay: .2s; }
.solution:nth-child(4) { animation-delay: .3s; }
@keyframes solutionIn {
  from { opacity: 0; transform: translateY(22px) scale(.94); }
  to   { opacity: 1; transform: none; }
}
.solution-label { animation: fadeIn .4s ease both; }

/* ---------- Ranglisten ---------- */

.lb-row {
  background: var(--glass);
  border-color: var(--glass-line);
  animation: rowIn .38s cubic-bezier(.2, .9, .3, 1) both;
}
.lb-row:nth-child(1) { animation-delay: .03s; }
.lb-row:nth-child(2) { animation-delay: .09s; }
.lb-row:nth-child(3) { animation-delay: .15s; }
.lb-row:nth-child(4) { animation-delay: .21s; }
.lb-row:nth-child(5) { animation-delay: .27s; }
.lb-row:nth-child(6) { animation-delay: .33s; }
.lb-row:nth-child(7) { animation-delay: .39s; }
.lb-row:nth-child(8) { animation-delay: .45s; }
@keyframes rowIn {
  from { opacity: 0; transform: translateX(-18px); }
  to   { opacity: 1; transform: none; }
}

.lb-row:nth-child(1) .lb-rank { color: #e3b341; }
.lb-row:nth-child(2) .lb-rank { color: #b7bdc8; }
.lb-row:nth-child(3) .lb-rank { color: #c98b52; }

.podium .step { animation: riseUp .55s cubic-bezier(.2, 1.05, .3, 1) both; }
.podium .step.p2 { animation-delay: .05s; }
.podium .step.p1 { animation-delay: .2s; }
.podium .step.p3 { animation-delay: .35s; }
@keyframes riseUp {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: none; }
}
.podium .step.p1 {
  box-shadow: 0 0 0 1px var(--accent), 0 18px 44px rgba(var(--glow), .34);
}
.podium .medal { animation: medalPop .6s cubic-bezier(.2, 1.6, .4, 1) both; animation-delay: .45s; }
@keyframes medalPop {
  from { opacity: 0; transform: scale(.3) rotate(-25deg); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Sanfter Auftritt für Abschnitte ---------- */

#v-question, #v-reveal, #v-board, #v-end, #v-lobby, #v-sent {
  animation: sectionIn .32s ease both;
}
@keyframes sectionIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- Rücksicht auf Bewegungsempfindlichkeit ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
  body::before { animation: none !important; }
}

/* =========================================================================
   Beamer als Bühne
   -------------------------------------------------------------------------
   Drei Regeln liegen diesem Abschnitt zugrunde:
   1. Pro Phase gibt es genau einen Blickfang.
   2. Der Inhalt füllt die Fläche - eine Projektion hat kein "unten rechts".
   3. Werkzeug der Lehrkraft verschwindet, wenn es nicht gebraucht wird.
   ========================================================================= */

/* Die Bühne ist eine Flex-Spalte: Kopfzeile, Schiene und Inhalt teilen sich
   die Höhe ohne Rechnerei mit festen Pixelwerten. */
body.stage {
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}
body.stage > .topbar,
body.stage > .rail { flex: none; }

.stage-top {
  padding: 10px 26px;
  min-height: 54px;
}
.stage-top .brand { font-size: .95rem; color: var(--text-soft); }
.stage-top .brand .logo { width: 22px; height: 22px; font-size: .7rem; }

/* ---------- Fortschritts- und Zeitschiene ---------- */

.rail {
  position: sticky; top: 0; z-index: 15;
  padding: 0 26px 8px;
  background: linear-gradient(180deg, var(--bg) 60%, transparent);
}
.rail-track {
  height: 10px; border-radius: 999px;
  background: var(--track);
  overflow: hidden;
}
.rail-track > i {
  display: block; height: 100%; width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #8b5cf6);
  transition: width .25s linear, background .4s;
}
.rail.warn .rail-track > i { background: linear-gradient(90deg, #d9891a, #e8a33c); }
.rail.crit .rail-track > i { background: linear-gradient(90deg, #d7243b, #ff6b7f); }

.rail-info {
  display: flex; align-items: center; gap: 14px;
  margin-top: 8px;
  font-size: .95rem; color: var(--text-soft);
}
.rail-step { letter-spacing: .02em; }
.rail-chip {
  background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: 999px; padding: 4px 14px; font-weight: 600; font-size: .9rem;
}
.rail-time {
  font-size: 2.1rem; font-weight: 750; line-height: 1;
  min-width: 2.4ch; text-align: right; color: var(--text);
}
.rail.crit .rail-time { color: var(--danger); animation: heartbeat 1s ease-in-out infinite; }

/* ---------- Bühnenflächen ---------- */

.stage-main {
  flex: 1; min-height: 0;
  overflow: hidden;
  padding: 0 26px 100px;  /* Platz für die Steuerleiste, mit etwas Luft */
  display: flex; flex-direction: column;
}

.stage-view {
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; gap: 18px;
  animation: sectionIn .32s ease both;
}
.stage-view.centered { justify-content: center; align-items: center; }
.stage-view.centered .lb,
.stage-view.centered .podium { width: min(880px, 100%); }
.stage-view.centered h1 { font-size: clamp(1.8rem, 3.4vw, 3rem); margin-bottom: 22px; }

.stage-label {
  margin: 0 0 6px; font-size: .8rem; font-weight: 700;
  letter-spacing: .16em; text-transform: uppercase; color: var(--text-soft);
}

/* ---------- Lobby: drei Spalten, volle Höhe ---------- */

.stage-view.lobby {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  grid-template-areas: 'code people' 'qr people';
  align-items: center;
  gap: 22px 30px;
  padding-top: 10px;
}
.lobby-code   { grid-area: code; align-self: end; min-width: 0; }
.lobby-qr     { grid-area: qr; align-self: start; }
.lobby-people { grid-area: people; align-self: stretch; }
.lobby-code .pin-display { font-size: clamp(3rem, 8.5vw, 7rem); }
.lobby-url {
  font-size: clamp(1.1rem, 1.9vw, 1.7rem); font-weight: 650;
  overflow-wrap: anywhere;
}
.lobby-qr { display: flex; flex-direction: column; align-items: flex-start; }
.lobby-qr .qr { padding: 18px; }
.lobby-qr .qr img { width: clamp(200px, 22vw, 330px); max-width: none; }
.lobby-people {
  min-width: 0;
  background: var(--glass); border: 1px solid var(--glass-line);
  border-radius: var(--radius-lg); padding: 22px;
  display: flex; flex-direction: column;
  overflow: auto;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.lobby-people .pill-list { align-content: flex-start; }
.lobby-people .pill { font-size: 1rem; padding: 8px 15px; }

/* ---------- Frage: Kopf klein, Kacheln füllen den Rest ---------- */

.stage-head { flex: none; text-align: center; padding-top: 6px; }
.stage-head .qtext { font-size: clamp(1.4rem, 3vw, 2.6rem); }
.stage-head .qimage { display: flex; justify-content: center; }
.stage-head .qimage img { max-height: 24vh; }
.stage-meta {
  display: flex; justify-content: center; gap: 22px;
  margin-top: 10px; font-size: .9rem; color: var(--text-soft);
}

#v-question .answers.big {
  flex: 1; min-height: 0;
  grid-auto-rows: minmax(0, 1fr);
  align-content: stretch;
}
#v-question .answers.big .tile { height: 100%; min-height: 0; font-size: clamp(1.05rem, 1.7vw, 1.5rem); }

/* ---------- Auflösung füllt ebenfalls ---------- */

#v-reveal { justify-content: space-between; overflow: auto; }
#v-reveal .reveal-head { margin-bottom: 0; }
#v-reveal .reveal-foot { flex: none; }

/* ---------- Steuerleiste, die sich zurückzieht ---------- */

.teacherbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 12px 26px;
  background: var(--glass); border-top: 1px solid var(--glass-line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
  transition: transform .35s cubic-bezier(.2, .8, .3, 1), opacity .35s;
}
body.stage.idle .teacherbar {
  transform: translateY(120%);
  opacity: 0;
  pointer-events: none;
}
body.stage.idle { cursor: none; }

@media (max-width: 1100px) {
  .stage-view.lobby {
    grid-template-columns: 1fr;
    grid-template-areas: 'code' 'qr' 'people';
    overflow: auto;
  }
  .lobby-qr { align-items: center; }
}

/* ---------- Auflösung auf der Bühne: Kopf, Lösung, Verteilung ---------- */

body.stage #v-reveal {
  justify-content: flex-start;
  gap: 0;
  overflow: hidden;
}
body.stage #v-reveal .reveal-head { flex: none; margin-bottom: 14px; }
body.stage #v-reveal .solution-wrap {
  /* Auf der Projektion ist Platz: Je breiter die Kachel, desto seltener muss
     ein langer Term überhaupt verkleinert werden. `width: 100%` ist dabei
     entscheidend - als Flex-Element mit automatischen Außenmaßen würde der
     Bereich sonst so breit wie sein Inhalt und niemals begrenzen. */
  width: 100%;
  max-width: 100%;
  flex: 1; min-height: 0;
  display: flex; flex-direction: column; justify-content: center;
  margin-bottom: 10px;
}
body.stage #v-reveal .reveal-foot {
  flex: none;
  width: 100%; max-width: none;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
body.stage #v-reveal .dist { height: 120px; }
body.stage #v-reveal .reveal-head .qimage img { max-height: 18vh; }

/* Die kleine Beschriftung unter den Balken bleibt einzeilig und gekürzt */

/* ---------- Schriftgröße auf der Bühne ----------
   Wie weit hinten die letzte Reihe sitzt, weiß nur die Lehrkraft im Raum.
   Deshalb ist die Größe während der Runde verstellbar - die Einstellung
   bleibt für die nächste Runde erhalten.

   Der Regler vergrößert nicht nur die Antworten, sondern die ganze Bühne:
   Frage, Antwortkacheln, Lösung und Erklärung hängen am selben Faktor. Sonst
   verschöbe sich beim Vergrößern das Verhältnis - eine riesige Antwort unter
   einer winzigen Frage -, und genau das Layout, das man auf der Probe gesehen
   hat, wäre im Unterricht ein anderes. Nur die Bilder bleiben, wo sie sind:
   Sie sind schon auf einen Anteil der Bildhöhe begrenzt, also so groß, wie die
   Fläche es hergibt. */

body.stage { --answer-scale: 1; }

.fontsize {
  display: flex; align-items: center; gap: 6px;
  padding-left: 10px; margin-left: 4px;
  border-left: 1px solid var(--border);
}
.fontsize button { min-width: 44px; font-weight: 700; }
.fontsize button .minus,
.fontsize button .plus { font-size: .78em; margin-left: 1px; }
.fontsize-value {
  min-width: 4.5ch; text-align: center; display: inline-block;
  font-size: .82rem; color: var(--text-soft);
  transition: transform .18s ease, color .18s ease;
}
.fontsize-value.changed { color: var(--text); transform: scale(1.12); }

body.stage #v-question .answers.big .tile {
  font-size: calc(clamp(1.05rem, 1.7vw, 1.5rem) * var(--answer-scale));
}
body.stage #v-question .answers.big .tile .key {
  width: calc(34px * var(--answer-scale));
  height: calc(34px * var(--answer-scale));
  font-size: calc(1rem * var(--answer-scale));
}
body.stage .solution {
  font-size: calc(clamp(1.5rem, 3.1vw, 2.7rem) * var(--answer-scale));
}
body.stage .solution.multi {
  font-size: calc(clamp(1.2rem, 2.2vw, 1.9rem) * var(--answer-scale));
}
body.stage .solution .key {
  width: calc(56px * var(--answer-scale));
  height: calc(56px * var(--answer-scale));
  font-size: calc(1.5rem * var(--answer-scale));
}
body.stage .solution.multi .key {
  width: calc(44px * var(--answer-scale));
  height: calc(44px * var(--answer-scale));
  font-size: calc(1.15rem * var(--answer-scale));
}

/* Die Frage - während der Frage und noch einmal bei der Auflösung. */
body.stage .stage-head .qtext {
  font-size: calc(clamp(1.4rem, 3vw, 2.6rem) * var(--answer-scale));
}
body.stage .stage-meta {
  font-size: calc(.9rem * var(--answer-scale));
}
body.stage #v-reveal .reveal-head .qtext {
  font-size: calc(clamp(1.1rem, 1.9vw, 1.6rem) * var(--answer-scale));
}
body.stage .solution-label {
  font-size: calc(.8rem * var(--answer-scale));
}
body.stage .solution-expl {
  font-size: calc(clamp(1rem, 1.5vw, 1.3rem) * var(--answer-scale));
}

/* Bei einer Frage mit Bild ist der Kopf schon voll. Damit sich die Schrift
   trotzdem vergrößern lässt, gibt das Bild nach - bis zu einem Zehntel der
   Bildhöhe. Wer den Regler zieht, will den Text lesen, nicht das Foto. */
body.stage .stage-head .qimage img {
  max-height: max(10vh, calc(24vh / var(--answer-scale)));
}
body.stage #v-reveal .reveal-head .qimage img {
  max-height: max(8vh, calc(18vh / var(--answer-scale)));
}

/* Wächst die Frage, bekommen die Kacheln weniger Platz - aber nie zu wenig:
   Der Kopf gibt nach, bevor die Antworten unlesbar klein werden. */
body.stage .stage-head { flex: 0 1 auto; min-height: 0; overflow: hidden; }
body.stage #v-question .answers.big { min-height: 46%; }

/* Unter den Balken steht nur noch der Buchstabe - deshalb etwas kräftiger. */
.dist .bar > .cap.label {
  font-size: .95rem; font-weight: 750; color: var(--text);
}
.dist .bar.correct > .cap.label { color: var(--success); }

/* =========================================================================
   Ein Haus, drei Räume
   -------------------------------------------------------------------------
   Beamer, Adminbereich und Eingangsseite teilen sich ab hier dieselbe
   Bildsprache: Farbschleier im Hintergrund, Glasflächen darüber, ein
   Verlaufston für alles, was Aufmerksamkeit verdient. Was sich unterscheidet,
   ist nur der Maßstab - der Beamer arbeitet auf zehn Meter, das Handy auf
   dreißig Zentimeter.
   ========================================================================= */

/* ---------- Umschalter hell / dunkel ---------- */

.theme-toggle {
  width: 38px; height: 38px; padding: 0;
  flex: none;
  border-radius: 12px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-soft);
  background-image: none;
}
.theme-toggle:hover { background: var(--accent-soft); color: var(--accent-ink); transform: none; box-shadow: none; }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.theme-toggle[data-pref="dark"] svg path { fill: currentColor; stroke: none; }
.theme-toggle[data-pref="auto"] svg .half { fill: currentColor; stroke: none; }
.theme-toggle .rays { transform-origin: 12px 12px; animation: spin 22s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.theme-toggle.floating {
  position: fixed; top: 14px; right: 14px; z-index: 40;
  background: var(--glass); border-color: var(--glass-line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

/* ---------- Auftakt einer Seite ---------- */

.hero { text-align: center; margin-bottom: 26px; }
.hero .mark {
  width: 62px; height: 62px; border-radius: 20px; font-size: 1.7rem;
  margin: 0 auto 16px;
}
.hero p { margin: 6px 0 0; }

.display-title {
  font-size: clamp(1.9rem, 5vw, 2.9rem);
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.1;
  margin: 0;
  color: var(--text);
}
@supports ((-webkit-background-clip: text) or (background-clip: text)) {
  .display-title {
    background: linear-gradient(100deg, var(--shine-a) 12%, var(--shine-b) 48%, var(--shine-a) 84%);
    background-size: 240% 100%;
    -webkit-background-clip: text; background-clip: text;
    color: transparent; -webkit-text-fill-color: transparent;
    animation: shimmer 11s linear infinite;
  }
}

/* Ein schmaler Farbverlauf als oberer Abschluss - dieselbe Geste wie die
   Fortschrittsschiene auf dem Beamer. */
.topbar { position: relative; }
.topbar::after {
  content: '';
  position: absolute; left: 0; right: 0; bottom: -1px; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent) 25%, #a855f7 60%, transparent);
  opacity: .55;
}

/* ---------- Karten mit Kante ---------- */

.card.accent-edge { position: relative; overflow: hidden; }
.card.accent-edge::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--accent), #a855f7);
}

/* Die Anmeldekarte bekommt denselben leichten Auftritt wie eine Bühnenphase. */
#login .card, #register .card, .hero { animation: fadeUp .45s cubic-bezier(.2, .9, .3, 1) both; }
#register .card { animation-delay: .04s; }

/* ---------- Schieberegler ---------- */

input[type=range] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 22px;
  background: transparent;
  cursor: pointer;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 6px; border-radius: 999px; background: var(--track);
}
input[type=range]::-moz-range-track {
  height: 6px; border-radius: 999px; background: var(--track);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 20px; height: 20px; margin-top: -7px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 2px 8px rgba(var(--glow), .45);
  transition: transform .12s;
}
input[type=range]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg-elevated);
  box-shadow: 0 2px 8px rgba(var(--glow), .45);
}
input[type=range]:hover::-webkit-slider-thumb { transform: scale(1.12); }
input[type=range]:focus-visible::-webkit-slider-thumb,
input[type=range]:focus-visible::-moz-range-thumb { outline: 3px solid var(--accent); outline-offset: 3px; }
input[type=range]:disabled { opacity: .5; cursor: not-allowed; }

/* ---------- Sichtbarer Tastaturfokus ----------
   Ohne diese Regel sieht man beim Durchtabben auf den dunklen Flächen nichts. */

:focus-visible {
  outline: 3px solid var(--accent-ink);
  outline-offset: 2px;
}
.tile:focus-visible { outline-color: #fff; }

/* Überschriften der Adminbereiche: dieselbe Geste wie auf der Eingangsseite,
   nur eine Nummer kleiner. */
.display-title.sm { font-size: clamp(1.5rem, 3vw, 1.9rem); letter-spacing: -.02em; }

/* Die Karten der Quizliste bekommen beim Überfahren eine farbige Kante -
   dieselbe Sprache wie die Antwortkacheln, nur zurückhaltender. */
#quiz-list .card { position: relative; overflow: hidden; }
#quiz-list .card::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
  background: linear-gradient(180deg, var(--accent), #a855f7);
  transform: translateX(-4px);
  transition: transform .18s ease;
}
#quiz-list .card:hover::before { transform: none; }

/* Auf der Bühne bleibt der Umschalter klein: Die Kopfzeile ist knapp
   bemessen, und jeder Pixel dort fehlt unten bei den Antwortkacheln. */
.stage-top .theme-toggle { width: 32px; height: 32px; border-radius: 10px; }
.stage-top .theme-toggle svg { width: 17px; height: 17px; }

/* Beim Regler folgt der Fokusring der runden Form statt ein Rechteck um die
   ganze Zeile zu ziehen. */
input[type=range]:focus-visible { border-radius: 999px; outline-offset: 5px; }

/* ---------- Fußleiste mit der Fassung ----------
   Welche Fassung gerade läuft, ist nach einem Deploy die erste Frage. Bisher
   stand die Nummer ganz unten auf der Seite und war weggescrollt; jetzt liegt
   sie in einer eigenen, dauerhaft sichtbaren Leiste. Sie ist bewusst leise:
   kleine, zurückgenommene Schrift auf Glas. */

body.has-appbar {
  --appbar-h: 34px;
  padding-bottom: calc(var(--appbar-h) + env(safe-area-inset-bottom, 0px));
}

.appbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  height: 34px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  box-sizing: content-box;
  font-size: .76rem;
  letter-spacing: .02em;
  color: var(--text-faint);
  background: var(--glass);
  border-top: 1px solid var(--glass-line);
  -webkit-backdrop-filter: saturate(150%) blur(12px);
  backdrop-filter: saturate(150%) blur(12px);
}

/* Alles, was sonst am unteren Rand klebt, rückt um die Leiste nach oben. */
body.has-appbar .sticky-actions { bottom: calc(var(--appbar-h) + env(safe-area-inset-bottom, 0px)); }
body.has-appbar .conn-warning { bottom: calc(16px + var(--appbar-h) + env(safe-area-inset-bottom, 0px)); }

/* =========================================================================
   Bilder als Antwortmöglichkeit
   -------------------------------------------------------------------------
   Eine Antwort kann ein Bild sein - ein Graph, eine Skizze, ein Term als
   Foto. Dann kippt die Kachel von "Buchstabe links, Text rechts" auf
   "Buchstabe in der Ecke, Bild groß, Text darunter": Das Bild ist der Inhalt
   und braucht die Fläche, der Buchstabe nur seine Ecke.
   ========================================================================= */

.tile.has-img { flex-direction: column; align-items: center; gap: 8px; padding: 14px 12px; }
/* Über einem hellen Bild wäre der weiße Buchstabe unsichtbar - er bekommt
   deshalb einen eigenen dunklen Grund und einen hellen Rand. */
.tile.has-img .key {
  position: absolute; top: 8px; left: 10px; z-index: 2;
  background: rgba(0, 0, 0, .5);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .38);
}
.tile-img {
  flex: 1 1 auto;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 10px;
  background: rgba(255, 255, 255, .9);
}
.tile.has-img .txt { flex: 0 0 auto; text-align: center; width: 100%; }
.tile.has-img .txt:empty { display: none; }
.play-answers .tile.has-img { min-height: 150px; }
.play-answers .tile.has-img .tile-img { max-height: 130px; }
#v-question .answers.big .tile.has-img .tile-img { max-height: 100%; }
.solution .tile-img { max-height: 22vh; border-radius: 12px; }

/* =========================================================================
   Lobby groß: nur noch Code und QR-Code
   ========================================================================= */

body.lobby-focus .stage-view.lobby {
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'code qr';
  align-items: center;
  gap: 40px;
}
body.lobby-focus .lobby-people { display: none; }
body.lobby-focus .lobby-code { align-self: center; }
body.lobby-focus .lobby-qr { align-self: center; }
/* Sechs Ziffern mit 0,12em Sperrung brauchen rund 4,4 × die Schriftgröße an
   Breite. Bei 12vw und der halben Bühne für den Code geht das auf - mehr wäre
   schön, würde die letzte Ziffer aber abschneiden, und ein abgeschnittener
   Code ist schlimmer als ein kleinerer. */
body.lobby-focus .lobby-code .pin-display { font-size: clamp(3.5rem, 12vw, 13rem); }
body.lobby-focus .lobby-url { font-size: clamp(1.2rem, 2.6vw, 2.2rem); }
body.lobby-focus .lobby-qr .qr img { width: clamp(220px, 26vw, 440px); }
body.lobby-focus .stage-label { font-size: clamp(1rem, 1.6vw, 1.5rem); }
@media (max-width: 900px) {
  body.lobby-focus .stage-view.lobby {
    grid-template-columns: 1fr; grid-template-areas: 'code' 'qr';
  }
}

/* =========================================================================
   Sprachumschalter
   ========================================================================= */

.lang-toggle {
  width: 38px; height: 38px; padding: 0;
  flex: none;
  border-radius: 12px;
  background: transparent; background-image: none;
  border: 1px solid transparent;
  color: var(--text-soft);
  font-size: .78rem; font-weight: 700; letter-spacing: .04em;
}
.lang-toggle:hover { background: var(--accent-soft); color: var(--accent-ink); transform: none; box-shadow: none; }
.lang-toggle:active { transform: scale(.94); }
.stage-top .lang-toggle { width: 32px; height: 32px; border-radius: 10px; font-size: .72rem; }
.lang-toggle.floating {
  position: fixed; top: 14px; right: 60px; z-index: 40;
  background: var(--glass); border-color: var(--glass-line);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}

/* Mehrzeilige Meldungen in Dialogen (z. B. die Liste fehlerhafter Formeln)
   sollen ihre Zeilenumbrüche behalten. */
.modal .modal-text { white-space: pre-line; }

/* =========================================================================
   Übungsmodus
   -------------------------------------------------------------------------
   Nach dem Prüfen sind die Kacheln gesperrt - lesbar müssen sie trotzdem
   bleiben, denn genau jetzt wird die Lösung angeschaut. Der übliche
   „disabled“-Schleier (opacity .45) gilt hier deshalb nicht; unterschieden
   wird über die grüne Markierung und das gezielte Abblenden des Fehlgriffs.
   ========================================================================= */

#run-answers .tile:disabled { opacity: 1; cursor: default; }
#run-answers .tile.dimmed { opacity: .45; }
#run-answers .tile:disabled:hover { filter: none; transform: none; }

#v-run .timerbar i { transition: width .35s cubic-bezier(.2, .8, .3, 1); }
#run-feedback .katex { font-size: 1em; }
#done-review .card .katex { font-size: 1em; }
.loesung { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.loesung-key {
  flex: none; min-width: 22px; height: 22px; padding: 0 6px;
  border-radius: 7px; background: var(--accent-soft); color: var(--accent-ink);
  display: inline-grid; place-items: center; font-weight: 700; font-size: .78rem;
}
.loesung-img { max-height: 56px; max-width: 110px; border-radius: 6px; border: 1px solid var(--border); }

/* =========================================================================
   Adminbereich
   -------------------------------------------------------------------------
   Diese Regeln standen bis zuletzt im <style>-Block von admin.html. Dort waren
   sie zwar nah an ihrer Seite, aber am falschen Ort: Wer eine Regel sucht,
   sucht sie im Stylesheet. Ausgeliefert werden beide Dateien ohnehin unter
   derselben Kennung, es geht also nichts an Frische verloren.
   ========================================================================= */

  /* Reiter als zusammenhängende Leiste - eine Fläche statt fünf Knöpfe. */
  .tabs { display:flex; gap:2px; flex-wrap:wrap; padding:4px; border-radius:14px;
          background:var(--glass); border:1px solid var(--glass-line);
          -webkit-backdrop-filter:blur(10px); backdrop-filter:blur(10px); }
  .tabs button { background:transparent; background-image:none; color:var(--text-soft); border:none;
                 padding:8px 14px; border-radius:10px; box-shadow:none; }
  .tabs button:hover { color:var(--text); transform:none; box-shadow:none; }
  .tabs button.active { background:var(--bg-elevated); color:var(--accent-ink);
                        box-shadow:0 2px 10px rgba(16,20,40,.14); }
  .qcard { border:1px solid var(--border); border-radius:var(--radius); background:var(--bg-elevated); }
  .qhead { display:flex; align-items:center; gap:10px; padding:12px 14px; cursor:pointer; }
  /* Griff zum Ziehen: unauffällig, bis man in die Nähe kommt. */
  .qhead .grip { flex:none; width:26px; height:26px; padding:0; border:none; background:transparent;
                 background-image:none; box-shadow:none; color:var(--text-faint); cursor:grab;
                 font-size:1rem; line-height:1; border-radius:8px; touch-action:none; }
  .qhead .grip:hover { background:var(--accent-soft); color:var(--accent-ink); transform:none; box-shadow:none; }
  .qhead .grip:active { cursor:grabbing; }
  .qcard { transition:box-shadow .15s, opacity .15s; }
  .qcard.dragging { opacity:.5; outline:2px dashed var(--accent); outline-offset:2px; }
  .qcard.dragging .qhead { cursor:grabbing; }
  .qhead .num { width:26px;height:26px;border-radius:8px;background:var(--accent-soft);color:var(--accent-ink);
                display:grid;place-items:center;font-size:.78rem;font-weight:750;flex:none; }
  .qhead .title { flex:1; font-weight:600; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .qbody { padding:0 14px 16px; border-top:1px solid var(--border); }
  .opt-row { display:flex; align-items:flex-start; gap:10px; margin-bottom:8px; }
  .opt-row .swatch { width:8px; align-self:stretch; border-radius:4px; flex:none; min-height:42px; }
  .preview { background:var(--accent-soft); border-radius:var(--radius); padding:10px 12px; min-height:42px;
             font-size:.95rem; overflow-x:auto; }
  .toolbar { display:flex; flex-wrap:wrap; gap:5px; margin-bottom:6px; }
  .toolbar button { padding:4px 9px; font-size:.78rem; border-radius:8px; background:var(--bg); color:var(--text-soft);
                    border:1px solid var(--border); font-weight:600; }
  .toolbar button:hover { background:var(--accent-soft); color:var(--accent-ink); }
  .qlist { display:flex; flex-direction:column; gap:10px; }
  .sticky-actions { position:sticky; bottom:0; background:var(--glass); padding:12px 14px; margin:0 -14px;
                    border-top:1px solid var(--glass-line); border-radius:0 0 var(--radius-lg) var(--radius-lg);
                    -webkit-backdrop-filter:blur(12px); backdrop-filter:blur(12px);
                    display:flex; gap:10px; justify-content:flex-end; z-index:10; flex-wrap:wrap; }
  .kv { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
  @media (max-width:620px) { .kv { grid-template-columns:1fr; } }
  .imgbox { display:flex; gap:12px; align-items:flex-start; flex-wrap:wrap; }
  .imgbox img { max-width:200px; max-height:130px; border-radius:10px; border:1px solid var(--border); display:block; }
  .dropzone { border:1.5px dashed var(--border); border-radius:var(--radius); padding:16px; text-align:center;
              color:var(--text-soft); font-size:.88rem; cursor:pointer; flex:1; min-width:220px; }
  .dropzone:hover, .dropzone.over { border-color:var(--accent); background:var(--accent-soft); color:var(--accent-ink); }
  .code-pill { font-family:ui-monospace, SFMono-Regular, Menlo, monospace; font-weight:700; letter-spacing:.08em; }

  /* Mehr Breite, damit Titel und alle vier Knöpfe nebeneinander passen */
  #app { max-width: 1280px; }
  .quiz-row { display:flex; align-items:center; justify-content:space-between; gap:20px; }
  .quiz-info { min-width:0; flex:1; }
  .quiz-info .name { display:flex; align-items:center; gap:8px; min-width:0; }
  .quiz-info .name > .label { font-weight:650; font-size:1.05rem;
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .quiz-info .sub { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .quiz-actions { display:flex; align-items:center; gap:8px; flex:none; flex-wrap:nowrap; }
  .quiz-actions > * { flex:none; white-space:nowrap; }
  @media (max-width: 860px) {
    .quiz-row { flex-direction:column; align-items:stretch; gap:12px; }
    .quiz-actions { flex-wrap:wrap; }
    .quiz-info .name > .label, .quiz-info .sub { white-space:normal; }
  }

  /* Aufklappbarer Abschnitt (Punktesystem) */
  .panel { padding:0; overflow:hidden; }
  .panel > summary { display:flex; align-items:center; gap:12px; padding:16px 22px; cursor:pointer;
                     font-weight:650; list-style:none; }
  .panel > summary::-webkit-details-marker { display:none; }
  .panel > summary::after { content:'⌄'; margin-left:auto; color:var(--text-soft); font-size:1.1rem;
                            transition:transform .2s ease; }
  .panel[open] > summary::after { transform:rotate(180deg); }
  .panel > summary:hover { background:var(--accent-soft); }
  .panel .sum-title { font-size:1.05rem; }
  .panel .panel-body { padding:4px 22px 20px; border-top:1px solid var(--glass-line); }
  .panel.is-custom > summary { box-shadow:inset 3px 0 0 var(--accent); }

  /* Auswahlkästchen zum Übertragen von Fragen */
  .qhead .qpick { flex:none; width:18px; height:18px; margin:0; cursor:pointer; }
  #select-bar { position:sticky; top:8px; z-index:5; }

  /* Fragen-Bibliothek: ein Treffer sieht aus wie eine Fragenkarte im Editor,
     ist aber aufklappbar und trägt seine Herkunft mit sich. */
  .libcard { border:1px solid var(--border); border-radius:14px; background:var(--card); overflow:hidden; }
  .libcard + .libcard { margin-top:8px; }
  .libcard .libhead { display:flex; align-items:center; gap:10px; padding:11px 14px; cursor:pointer; }
  .libcard .libhead:hover { background:var(--accent-soft); }
  /* Die Markierung sitzt auf der Kopfzeile, nicht auf der Karte: Die Kopfzeile
     füllt die Karte aus, und ihr Hover-Hintergrund würde einen Schatten der
     Karte sonst verdecken - ausgerechnet dann, wenn die Maus darauf steht. */
  .libcard.on > .libhead { box-shadow:inset 3px 0 0 var(--accent); }
  .libcard .libpick { flex:none; width:18px; height:18px; margin:0; cursor:pointer; }
  .libcard .libtext { flex:1; min-width:0; font-weight:600; overflow:hidden;
                      text-overflow:ellipsis; white-space:nowrap; }
  .libcard .libsrc { flex:none; max-width:34%; overflow:hidden; text-overflow:ellipsis;
                     white-space:nowrap; font-size:.78rem; color:var(--text-faint); }
  .libcard .libbody { padding:0 14px 14px; border-top:1px solid var(--border); }
  .liboption { display:flex; align-items:flex-start; gap:9px; padding:7px 0; }
  .liboption .mark { flex:none; width:20px; text-align:center; color:var(--text-faint); }
  .liboption.right .mark { color:var(--success); font-weight:800; }
  .liboption.right { font-weight:600; }
  .liboption img { max-height:60px; max-width:120px; border-radius:6px; border:1px solid var(--border); }
  mark.treffer { background:var(--accent-soft); color:var(--accent-ink); border-radius:4px; padding:0 2px; }

  /* Auswertung: eine Zeile je Frage, der Balken zeigt die Verteilung */
  .awq { border:1px solid var(--border); border-radius:14px; background:var(--card);
         padding:14px 16px; margin-bottom:10px; }
  .awq-kopf { display:flex; align-items:baseline; gap:12px; }
  .awq-quote { flex:none; min-width:58px; font-size:1.35rem; font-weight:750;
               font-variant-numeric:tabular-nums; }
  .awq.gut .awq-quote { color:var(--success); }
  .awq.mittel .awq-quote { color:var(--warn, #b8860b); }
  .awq.schlecht .awq-quote { color:var(--danger); }
  .awq-text { flex:1; min-width:0; font-weight:600; }
  .awq-zahlen { flex:none; font-size:.8rem; color:var(--text-faint); white-space:nowrap; }
  .awq-balken { display:flex; height:10px; border-radius:999px; overflow:hidden;
                background:var(--track, var(--border)); margin:10px 0 4px; }
  .awq-balken i { display:block; }
  .awq-balken .r { background:var(--success); }
  .awq-balken .t { background:var(--warn, #d8a01a); }
  .awq-balken .f { background:var(--danger); }
  .awq-opt { display:flex; align-items:center; gap:10px; padding:4px 0; font-size:.9rem; }
  .awq-opt .k { flex:none; width:22px; height:22px; border-radius:7px; display:grid;
                place-items:center; font-weight:700; font-size:.75rem;
                background:var(--accent-soft); color:var(--accent-ink); }
  .awq-opt.richtig .k { background:var(--success); color:#fff; }
  .awq-opt .t { flex:1; min-width:0; }
  .awq-opt .n { flex:none; font-variant-numeric:tabular-nums; color:var(--text-faint); }

  /* Bild als Antwortmöglichkeit */
  .opt-img { display:flex; align-items:center; gap:10px; flex-wrap:wrap; }
  .opt-thumb { max-height:70px; max-width:130px; border-radius:8px; border:1px solid var(--border);
               background:var(--card); object-fit:contain; }

  .formula { text-align:center; padding:10px; border-radius:var(--radius);
             background:var(--accent-soft); color:var(--text); font-weight:650; margin:14px 0 18px; }
  .knob { margin-bottom:20px; }
  .knob-head { display:flex; align-items:baseline; justify-content:space-between; gap:12px; }
  .knob-head label { margin:0; }
  .knob-value { font-weight:750; font-variant-numeric:tabular-nums; color:var(--accent-ink);
                background:var(--accent-soft); border-radius:999px; padding:2px 10px; font-size:.85rem; }
  .knob p { margin:2px 0 0; }
  .example { border-left:3px solid var(--accent); padding:2px 0 2px 12px; color:var(--text-soft); }

  /* Vorschau -------------------------------------------------------------
     Eine eigene Ebene über dem Adminbereich, bewusst im Beamer-Look: So sieht
     man beim Durchklicken das, was später an der Wand steht. */
  .pv { position:fixed; inset:0; z-index:60; display:flex; flex-direction:column;
        background:var(--bg); }
  .pv::before { content:''; position:absolute; inset:0; pointer-events:none;
    background:radial-gradient(38rem 30rem at 14% 16%, var(--aurora-1), transparent 64%),
               radial-gradient(32rem 26rem at 86% 10%, var(--aurora-2), transparent 62%); }
  .pv-top { position:relative; display:flex; align-items:center; gap:12px; padding:12px 20px;
            border-bottom:1px solid var(--glass-line); background:var(--glass);
            -webkit-backdrop-filter:blur(12px); backdrop-filter:blur(12px); }
  .pv-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .pv-main { position:relative; flex:1; min-height:0; overflow:auto;
             padding:22px 24px 96px; display:flex; flex-direction:column; gap:16px;
             max-width:1100px; width:100%; margin:0 auto; }
  .pv-head { text-align:center; }
  .pv-head .qimage { display:flex; justify-content:center; }
  .pv-answers-note { text-align:center; }
  .pv .answers { align-content:start; }
  .pv .tile { cursor:pointer; min-height:92px; }
  .pv .tile.wrongpick { opacity:.45; }
  .pv-end { position:relative; flex:1; display:none; flex-direction:column; align-items:center;
            justify-content:center; text-align:center; gap:6px; padding:24px; }
  .pv.done .pv-main, .pv.done .pv-bar > button, .pv.done .pv-keys { display:none; }
  .pv.done .pv-end { display:flex; }
  .pv-bar { position:relative; display:flex; align-items:center; gap:10px; padding:12px 20px;
            border-top:1px solid var(--glass-line); background:var(--glass);
            -webkit-backdrop-filter:blur(12px); backdrop-filter:blur(12px); }
  .pv-keys { margin-left:auto; }
  @media (max-width:640px) { .pv-keys { display:none; } .pv-main { padding:16px 14px 92px; } }

  /* Speichern: kurze Bestätigung, dann schließt sich der Editor ---------- */
  .btn-saved { background:var(--success) !important; background-image:none !important;
               color:#fff !important; border-color:transparent !important;
               animation:savedPop .45s cubic-bezier(.2,1.4,.4,1); }
  @keyframes savedPop {
    0%   { transform:scale(1);    box-shadow:0 0 0 0 rgba(16,185,129,.55); }
    45%  { transform:scale(1.07); box-shadow:0 0 0 12px rgba(16,185,129,0); }
    100% { transform:scale(1);    box-shadow:0 0 0 0 rgba(16,185,129,0); }
  }
  #tab-editor.leaving { animation:editorOut .26s ease forwards; pointer-events:none; }
  @keyframes editorOut { to { opacity:0; transform:translateY(10px) scale(.995); } }

/* =========================================================================
   Scratch-Werkstatt
   -------------------------------------------------------------------------
   Die Oberfläche lehnt sich an die Scratch-Umgebung an, die die Lerngruppen
   aus der Informatik kennen: eine farbige Menüleiste, Bereiche mit eigener
   Kategoriefarbe und Flächen, die wie Blöcke aussehen - mit einer unteren
   Kante, die beim Klick einrastet.

   Zwei Dinge sind dabei bewusst getrennt:

   - Die Scratch-Farben (--k-*) sind Erkennungsfarben. Sie stehen hinter
     Punkten, Kanten und Streifen, nie hinter weißem Text: Scratch-Blau
     trägt Weiß nur mit 2,9:1 und wäre am Beamer nicht zu lesen.
   - Für Schrift gibt es zu jeder Kategorie einen abgedunkelten (hell) bzw.
     aufgehellten (dunkel) Ton --k-*-ink, jeder über 4,5:1 auf seinem Grund.

   Die geprüften Antwortfarben --a1 bis --a8 bleiben unverändert. Nur ihre
   Form wird zum Block.
   ========================================================================= */

:root {
  /* Scratch-Motion-Blau, so weit vertieft, dass weiße Schrift darauf
     5,2:1 erreicht. Das Original #4C97FF lebt in --k-motion weiter. */
  --accent: #2563eb;
  --accent-ink: #1d4fd7;          /* 6,1:1 auf dem hellen Grund */
  --accent-soft: #e8eeff;
  --akzent-2: #6d3ff0;            /* vertieftes Looks-Violett, Weiß 5,8:1 */
  --accent-text: #ffffff;
  --glow: 37, 99, 235;
  --shine-a: #2563eb;
  --shine-b: #9966ff;

  --bg: #f3f5fb;
  --aurora-1: rgba(76, 151, 255, .24);
  --aurora-2: rgba(153, 102, 255, .16);
  --aurora-3: rgba(89, 192, 89, .14);

  /* Die untere Kante eines Blocks: einmal neutral für helle Flächen,
     einmal als abgedunkelte Akzentfarbe für gefüllte Knöpfe. */
  --kante: rgba(12, 22, 60, .22);
  --kante-voll: #173d92;

  /* Kategoriefarben aus der Scratch-Palette */
  --k-motion:  #4C97FF;  --k-motion-ink:  #2f5e9e;
  --k-looks:   #9966FF;  --k-looks-ink:   #5f3f9e;
  --k-control: #FFAB19;  --k-control-ink: #9e6a10;
  --k-sensing: #5CB1D6;  --k-sensing-ink: #396e85;
  --k-sound:   #CF63CF;  --k-sound-ink:   #803d80;
  --k-ops:     #59C059;  --k-ops-ink:     #377737;
  --k-vars:    #FF8C1A;  --k-vars-ink:    #9e5710;

  /* Voreinstellung, falls ein Bereich keine eigene Farbe gesetzt hat */
  --kat: var(--k-motion);
  --kat-ink: var(--k-motion-ink);
}

:root[data-theme="dark"] {
  --bg: #0b0e1a;
  --bg-elevated: #161a28;
  --border: #262c40;
  --accent-ink: #9db4ff;          /* 9,5:1 auf dem dunklen Grund */
  --accent-soft: #1a2039;
  --glass: rgba(22, 26, 40, .68);
  --kante: rgba(0, 0, 0, .5);
  --aurora-1: rgba(76, 151, 255, .30);
  --aurora-2: rgba(153, 102, 255, .22);
  --aurora-3: rgba(89, 192, 89, .16);

  --k-motion-ink:  #70acff;
  --k-looks-ink:   #ad85ff;
  --k-control-ink: #ffbc47;
  --k-sensing-ink: #7dc1de;
  --k-sound-ink:   #d982d9;
  --k-ops-ink:     #7acd7a;
  --k-vars-ink:    #ffa348;
}

/* ---------- Jeder Bereich trägt seine Farbe ----------
   Der Reiterknopf und der zugehörige Abschnitt teilen sich dieselbe Farbe.
   Dadurch wandert der Farbton beim Umschalten durch die ganze Seite. */

[data-tab="quizzes"],    #tab-quizzes, #tab-editor { --kat: var(--k-motion);  --kat-ink: var(--k-motion-ink); }
[data-tab="library"],    #tab-library              { --kat: var(--k-looks);   --kat-ink: var(--k-looks-ink); }
[data-tab="assignments"],#tab-assignments          { --kat: var(--k-control); --kat-ink: var(--k-control-ink); }
[data-tab="history"],    #tab-history              { --kat: var(--k-sensing); --kat-ink: var(--k-sensing-ink); }
[data-tab="users"],      #tab-users                { --kat: var(--k-sound);   --kat-ink: var(--k-sound-ink); }
[data-tab="storage"],    #tab-storage              { --kat: var(--k-ops);     --kat-ink: var(--k-ops-ink); }
[data-tab="account"],    #tab-account              { --kat: var(--k-vars);    --kat-ink: var(--k-vars-ink); }

/* ---------- Menüleiste ----------
   Ein durchgehendes Farbband wie in Scratch, nicht mehr Milchglas. Alles
   darin schreibt weiß; der Verlauf trägt Weiß an beiden Enden mit über
   5:1. */

.topbar {
  background: linear-gradient(100deg, var(--accent), var(--akzent-2));
  border-bottom: none;
  color: #fff;
  box-shadow: 0 6px 24px rgba(var(--glow), .26);
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.topbar::after { display: none; }
.topbar .brand { font-weight: 800; color: #fff; }
.topbar .logo {
  background: #fff;
  color: var(--accent);
  border-radius: 9px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, .18);
}
.topbar .logo::after { display: none; }
.topbar .badge {
  background: rgba(255, 255, 255, .18);
  border: 1px solid rgba(255, 255, 255, .34);
  color: #fff;
  flex: none;
  max-width: 24ch;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block;
}
.topbar { gap: 10px; padding: 10px 18px; }
.topbar .grow { min-width: 0; }
.topbar .theme-toggle,
.topbar .lang-toggle,
.topbar .btn-quiet { color: #fff; }
.topbar .theme-toggle:hover,
.topbar .lang-toggle:hover,
.topbar .btn-quiet:hover { background: rgba(255, 255, 255, .2); color: #fff; }

/* Die Bühne bekommt das Farbband nicht: An der Wand soll die Frage das
   Hellste im Bild sein, nicht die Kopfzeile. Dort bleibt es bei Milchglas. */
.topbar.stage-top {
  background: var(--glass);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid var(--glass-line);
  color: var(--text);
  box-shadow: none;
}
.stage-top .brand { color: var(--text-soft); font-weight: 750; }
.stage-top .logo {
  background: linear-gradient(135deg, var(--accent), var(--akzent-2));
  color: #fff;
  box-shadow: 0 4px 14px rgba(var(--glow), .45);
}
.stage-top .badge {
  background: var(--accent-soft); color: var(--accent-ink);
  border: none; max-width: none;
}
.stage-top .theme-toggle, .stage-top .lang-toggle, .stage-top .btn-quiet { color: var(--text-soft); }
.stage-top .theme-toggle:hover, .stage-top .lang-toggle:hover, .stage-top .btn-quiet:hover {
  background: var(--accent-soft); color: var(--accent-ink);
}

/* ---------- Reiter als Blockpalette ----------
   Links in Scratch liegen die Kategorien als farbige Punkte untereinander.
   Hier liegen sie nebeneinander in der Leiste: Punkt plus Name, und der
   gewählte Reiter wird zur weißen Fläche mit farbiger Schrift und Kante. */

.tabs {
  background: transparent;
  border: none;
  padding: 2px 0;
  gap: 5px;
  /* Die Leiste bleibt einzeilig. Passt die Palette nicht mehr in die Breite,
     schiebt man sie zur Seite - eine zweite Zeile würde die Kopfleiste
     doppelt so hoch machen und auf dem Beamer Platz kosten. */
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
  -webkit-backdrop-filter: none; backdrop-filter: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  position: relative;
  flex: none;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: .9rem;
  font-weight: 700;
  white-space: nowrap;
  color: #fff;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .22);
  box-shadow: none;
  transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
}
.tabs button::before {
  content: '';
  width: 10px; height: 10px; flex: none;
  border-radius: 4px;
  background: var(--kat);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .55);
}
.tabs button:hover {
  color: #fff;
  background: rgba(255, 255, 255, .28);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
}
.tabs button.active {
  background: #fff;
  border-color: transparent;
  color: var(--k-motion-ink);
  color: var(--kat-ink);
  box-shadow: 0 3px 0 var(--kat);
}
.tabs button.active::before { box-shadow: 0 0 0 2px rgba(0, 0, 0, .08); }
.tabs button.active:hover { background: #fff; transform: translateY(-2px); box-shadow: 0 5px 0 var(--kat); }

/* ---------- Knöpfe als Blöcke ----------
   Eine feste untere Kante statt eines weichen Schattens. Beim Drücken
   rutscht der Knopf um zwei Pixel hinein und die Kante verschwindet -
   dieselbe Bewegung wie bei einem Scratch-Block, der einrastet. */

button, .btn {
  border-radius: 13px;
  font-weight: 700;
  /* Die Kante ist ein dunklerer Ton der Fläche selbst, nicht ein grauer
     Schatten - so sitzt sie am Block statt darunter zu liegen. */
  box-shadow: 0 3px 0 var(--kante-voll);
}
.btn-ghost, .btn-ghost:hover { --kante-voll: var(--kante); }
.btn-danger { --kante-voll: #8e1f2e; }
.btn-lg { border-radius: 16px; }
.btn-sm { border-radius: 11px; }

button:not(.btn-ghost):not(.btn-quiet):not(.tile):hover,
.btn:not(.btn-ghost):not(.btn-quiet):hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 0 var(--kante-voll), 0 10px 24px rgba(var(--glow), .3);
}
.btn-ghost:hover { transform: translateY(-2px); box-shadow: 0 5px 0 var(--kante); }
button:active, .btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--kante-voll); }

/* Was keine Fläche ist, bekommt auch keine Kante. */
.tabs button, .toolbar button, .theme-toggle, .lang-toggle,
.btn-quiet, .qhead .grip, .pill button, .modal-back button.btn-quiet {
  box-shadow: none;
}
.toolbar button:hover, .btn-quiet:hover, .qhead .grip:hover { box-shadow: none; transform: none; }
button:disabled { box-shadow: 0 3px 0 var(--kante-voll); transform: none; }

/* ---------- Antwortkacheln als Blöcke ---------- */

.tile {
  border-radius: 18px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .28), 0 12px 26px rgba(0, 0, 0, .16);
}
button.tile:hover:not(:disabled) {
  transform: translateY(-3px);
  box-shadow: 0 7px 0 rgba(0, 0, 0, .28), 0 18px 34px rgba(0, 0, 0, .22);
}
button.tile:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .28);
}
.tile .key {
  width: 36px; height: 36px;
  border-radius: 11px;
  border: 2px solid rgba(255, 255, 255, .5);
  background: rgba(255, 255, 255, .2);
}
.tile.picked {
  border-color: #fff;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, .4), 0 4px 0 rgba(0, 0, 0, .28);
}

/* ---------- Listenkarten als Blockstapel ----------
   Quiz, Fragen, Bibliothekstreffer und Auswertungszeilen bekommen links
   die Farbe ihres Bereichs. Man sieht am Streifen, wo man gerade ist. */

#quiz-list .card, .qcard, .libcard, .awq {
  border-left: 4px solid var(--kat);
}
#quiz-list .card::before { display: none; }
.qhead .num { background: color-mix(in srgb, var(--kat) 22%, transparent); color: var(--kat-ink); }
@supports not (color: color-mix(in srgb, red 20%, transparent)) {
  .qhead .num { background: var(--accent-soft); color: var(--accent-ink); }
}

/* ---------- Überschriften ---------- */

h1, h2, h3 { font-weight: 800; }
.card { border-radius: 22px; }

/* ---------- Bewegung aus, wenn gewünscht ---------- */

@media (prefers-reduced-motion: reduce) {
  .tabs button:hover, button:hover, .btn:hover, button.tile:hover:not(:disabled) { transform: none; }
}
