/* GVZH Lernspiele: gemeinsames Design-System
   Leitfarbe ist das GVZH-Blau der Webseite, Deutsch trägt das GVZH-Orange.
   Ruhige helle Flächen und Pillen-Buttons wie auf gymivorbereitung-zuerich.ch,
   dazu eine verspielte Titelschrift und eine sehr gut lesbare Grundschrift für den Beamer. */
:root {
  --gv-blue: #1F5BFF;
  --gv-blue-ink: #1641C8;
  --gv-blue-soft: #E5ECFF;
  --gv-orange: #F0870E;
  --gv-orange-ink: #A65300;
  --gv-orange-soft: #FFEEDB;
  --bg: #F2F4F9;
  --surface: #FFFFFF;
  --surface-2: #EDF0F7;
  --ink: #0E1630;
  --muted: #586179;
  --line: #D3D9E6;
  --hl: #FFD43B;
  --ok: #0F9D4E;
  --ok-soft: #D9F4E4;
  --bad: #E0362B;
  --bad-soft: #FDE1DD;
  --on-blue: #FFFFFF;
  --math: var(--gv-blue);
  --math-soft: var(--gv-blue-soft);
  --math-ink: var(--gv-blue-ink);
  --deutsch: var(--gv-orange);
  --deutsch-soft: var(--gv-orange-soft);
  --deutsch-ink: var(--gv-orange-ink);
  --t1: #1F5BFF; --t2: #E8590C; --t3: #0F9D74; --t4: #9C36B5; --t5: #C2255C; --t6: #5C7CFA;
  --on-team: #FFFFFF;
  --a1: #1F5BFF; --a2: #E8590C; --a3: #0F9D74; --a4: #9C36B5;
  --font-display: "Bricolage Grotesque", "Roboto", "Segoe UI", system-ui, sans-serif;
  --font-body: "Atkinson Hyperlegible", "Roboto", Verdana, "Segoe UI", system-ui, sans-serif;
  --r-pill: 999px;
  --r-card: 18px;
  --r-sm: 10px;
  --shadow: 0 14px 34px -22px rgba(14, 22, 48, .5);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --gv-blue: #5C88FF; --gv-blue-ink: #A8C0FF; --gv-blue-soft: #18244A;
    --gv-orange: #FF9F3A; --gv-orange-ink: #FFC27D; --gv-orange-soft: #3A2610;
    --bg: #0D1220; --surface: #161D2E; --surface-2: #1D2539; --ink: #EAF0FA; --muted: #9CA8BD; --line: #2B3550;
    --hl: #FFD43B; --ok: #3DD17F; --ok-soft: #133524; --bad: #FF6B5E; --bad-soft: #3D1A18; --on-blue: #0B1220;
    --t1: #7EA2FF; --t2: #FF9354; --t3: #3DD6B0; --t4: #D08BFF; --t5: #FF7BA8; --t6: #9DB1FF; --on-team: #0B1220;
    --a1: #7EA2FF; --a2: #FF9354; --a3: #3DD6B0; --a4: #D08BFF;
    --shadow: 0 14px 34px -22px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --gv-blue: #5C88FF; --gv-blue-ink: #A8C0FF; --gv-blue-soft: #18244A;
  --gv-orange: #FF9F3A; --gv-orange-ink: #FFC27D; --gv-orange-soft: #3A2610;
  --bg: #0D1220; --surface: #161D2E; --surface-2: #1D2539; --ink: #EAF0FA; --muted: #9CA8BD; --line: #2B3550;
  --hl: #FFD43B; --ok: #3DD17F; --ok-soft: #133524; --bad: #FF6B5E; --bad-soft: #3D1A18; --on-blue: #0B1220;
  --t1: #7EA2FF; --t2: #FF9354; --t3: #3DD6B0; --t4: #D08BFF; --t5: #FF7BA8; --t6: #9DB1FF; --on-team: #0B1220;
  --a1: #7EA2FF; --a2: #FF9354; --a3: #3DD6B0; --a4: #D08BFF;
  --shadow: 0 14px 34px -22px rgba(0, 0, 0, .8);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 16px; line-height: 1.45;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--gv-blue); outline-offset: 2px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3, .display { font-family: var(--font-display); letter-spacing: -0.02em; text-wrap: balance; }
kbd {
  font-family: inherit; font-size: .82em; padding: 0 6px; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 5px; background: var(--surface-2); white-space: nowrap;
}

/* App-Rahmen: volle Höhe für den Beamer */
.gv-app { min-height: 100%; display: flex; flex-direction: column; max-width: 2400px; margin: 0 auto; }
.gv-app.fill { height: 100%; }
.gv-main { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* Kopfzeile */
.gv-top { display: flex; align-items: center; gap: 10px; padding-block: 10px; flex-wrap: wrap; flex: none; }
.gv-brand { display: flex; align-items: center; gap: 10px; margin-right: auto; color: inherit; text-decoration: none; min-width: 0; }
.gv-brand img { width: 40px; height: 40px; border-radius: 6px; flex: none; }
.gv-brand-txt { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.gv-brand-txt small { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.gv-brand-txt b { font-family: var(--font-display); font-size: 1.3rem; font-weight: 800; letter-spacing: -0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gv-top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.gv-icon-btn {
  display: inline-flex; align-items: center; gap: 6px; height: 38px; padding: 0 14px;
  border-radius: var(--r-pill); border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; font-weight: 700; font-size: .92rem; text-decoration: none; color: inherit;
}
.gv-icon-btn:hover { border-color: var(--gv-blue); }
.gv-icon-btn svg { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gv-icon-btn[aria-pressed="false"] .on, .gv-icon-btn[aria-pressed="true"] .off { display: none; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--r-pill); border: 2px solid transparent; padding: 11px 22px;
  font-weight: 700; font-size: 1.02rem; cursor: pointer; text-decoration: none; line-height: 1.15;
  transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--gv-blue); color: var(--on-blue); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.08); }
.btn-orange { background: var(--gv-orange); color: #1A1206; }
.btn-ghost { background: var(--surface); color: var(--ink); border-color: var(--line); }
.btn-ghost:hover:not(:disabled) { border-color: var(--gv-blue); }
.btn-big { padding: 15px 28px; font-size: 1.18rem; }
.btn-sm { padding: 7px 14px; font-size: .9rem; }
.btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }

/* Karten, Chips */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; border-radius: var(--r-pill); padding: 3px 11px;
  font-weight: 700; font-size: .82rem; background: var(--surface-2); color: var(--ink); border: 1px solid var(--line);
}
.chip-math { background: var(--math-soft); color: var(--math-ink); border-color: transparent; }
.chip-deutsch { background: var(--deutsch-soft); color: var(--deutsch-ink); border-color: transparent; }
.chip-ex { background: var(--gv-blue); color: var(--on-blue); border-color: transparent; }
.eyebrow { font-size: .76rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; margin: 0; }

/* Formulare (Einrichten-Bildschirm) */
.gv-setup { display: flex; flex-direction: column; gap: 18px; }
.gv-setup fieldset { border: 0; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.gv-setup legend { font-weight: 700; padding: 0; margin-bottom: 8px; }
.gv-field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; min-width: 0; }
.gv-field small { font-weight: 400; color: var(--muted); }
input[type="text"], input[type="number"], select, textarea {
  padding: 9px 12px; border-radius: var(--r-sm); border: 1px solid var(--line);
  background: var(--surface-2); color: var(--ink); min-width: 0; width: 100%;
}
textarea { resize: vertical; min-height: 120px; line-height: 1.4; }
.gv-check { display: flex; align-items: center; gap: 8px; font-weight: 700; cursor: pointer; }
.gv-check input { width: 20px; height: 20px; accent-color: var(--gv-blue); flex: none; }
.gv-options { display: flex; flex-wrap: wrap; gap: 8px; }
.gv-option {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: var(--r-pill);
  border: 2px solid var(--line); background: var(--surface); cursor: pointer; font-weight: 700;
}
.gv-option:has(input:checked) { border-color: var(--gv-blue); background: var(--gv-blue-soft); color: var(--gv-blue-ink); }
.gv-option input { accent-color: var(--gv-blue); margin: 0; }
.gv-stepper { display: flex; align-items: center; gap: 10px; }
.gv-stepper button {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 1.3rem; font-weight: 700; cursor: pointer; line-height: 1;
}
.gv-stepper output { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; min-width: 1.4ch; text-align: center; font-variant-numeric: tabular-nums; }
.gv-teamnames { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.gv-teamnames label { display: flex; align-items: center; gap: 8px; min-width: 0; }

/* Feste Auswahl aus dem Dashboard («Heute») */
.gv-kontext { display: flex; flex-direction: column; gap: 8px; padding: 14px 16px; border-radius: var(--r-card); background: var(--gv-blue-soft); }
.gv-kontext[data-fach="d"] { background: var(--gv-orange-soft); }
.gv-kontext-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.gv-kontext-link { font-weight: 700; font-size: .9rem; color: var(--gv-blue-ink); }
.gv-kontext[data-fach="d"] .gv-kontext-link { color: var(--gv-orange-ink); }
.gv-kontext-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.gv-kontext-chips .chip { background: var(--surface); }
.gv-kontext-title { margin: 0; font-family: var(--font-display); font-weight: 800; font-size: 1.45rem; letter-spacing: -0.01em; line-height: 1.15; }
.gv-kontext-title span { display: block; font-family: var(--font-body); font-weight: 700; font-size: 1.05rem; color: var(--muted); letter-spacing: 0; }

/* Startbildschirm eines Spiels */
.gv-start { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, 1fr); gap: clamp(16px, 3vw, 44px); padding-block: 8px 28px; align-content: start; }
.gv-hero { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.gv-hero h1 { font-weight: 800; font-size: clamp(2.4rem, 5.6vw, 4.8rem); line-height: .95; margin: 0; letter-spacing: -0.035em; }
.gv-hero h1 em { font-style: normal; color: var(--gv-blue); }
.gv-lede { font-size: 1.1rem; max-width: 62ch; margin: 0; text-wrap: pretty; }
.gv-steps { list-style: none; counter-reset: s; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; }
.gv-steps li { counter-increment: s; display: flex; gap: 10px; align-items: flex-start; font-size: .95rem; min-width: 0; }
.gv-steps li::before {
  content: counter(s); flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--gv-blue);
  color: var(--on-blue); display: grid; place-items: center; font-weight: 700; font-size: .88rem;
}

/* Spielbühne: links Inhalt, rechts Panel, unten Teams */
.gv-game { flex: 1; min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 12px; padding-bottom: 12px; }
.gv-stage { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) clamp(320px, 30vw, 460px); grid-template-rows: minmax(0, 1fr); gap: 16px; }
.gv-board { min-width: 0; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: clamp(14px, 2vw, 28px); overflow: auto; }
.gv-panel { min-height: 0; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.gv-panel-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; font-size: .86rem; color: var(--muted); }
.gv-panel-head .pts { margin-left: auto; font-weight: 700; color: var(--gv-blue-ink); }
.gv-question { font-family: var(--font-display); font-weight: 700; font-size: clamp(1.4rem, .9rem + 1.6vw, 2.6rem); line-height: 1.18; margin: 0; letter-spacing: -0.015em; text-wrap: pretty; }
.gv-question mark, .gv-mark { color: inherit; padding: 0 3px; border-radius: 3px; background: linear-gradient(transparent 52%, color-mix(in srgb, var(--hl) 85%, transparent) 52%); }
.gv-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: auto; }
.gv-actions .btn-primary { margin-left: auto; }

/* Antwortkacheln A–D */
.gv-answers { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.gv-answer {
  position: relative; display: flex; align-items: center; gap: 14px; text-align: left;
  padding: 14px 16px; border-radius: var(--r-card); border: 3px solid var(--line); background: var(--surface);
  font-size: clamp(1.05rem, .8rem + .8vw, 1.6rem); font-weight: 700; line-height: 1.2; min-width: 0;
}
button.gv-answer { cursor: pointer; }
button.gv-answer:hover:not(:disabled) { border-color: var(--gv-blue); }
.gv-answer .key {
  flex: none; width: 1.9em; height: 1.9em; border-radius: 12px; display: grid; place-items: center;
  font-family: var(--font-display); font-weight: 800; color: #FFFFFF; background: var(--a1);
}
.gv-answer:nth-child(2) .key { background: var(--a2); }
.gv-answer:nth-child(3) .key { background: var(--a3); }
.gv-answer:nth-child(4) .key { background: var(--a4); }
.gv-answer.is-ok { border-color: var(--ok); background: var(--ok-soft); }
.gv-answer.is-bad { border-color: var(--bad); background: var(--bad-soft); }
.gv-answer.is-dim { opacity: .4; }

/* Teams */
.gv-scores { display: flex; flex-wrap: wrap; gap: 10px; flex: none; }
.gv-team { flex: 1 1 230px; display: flex; align-items: center; gap: 10px; min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 8px 10px; }
.gv-tdot { width: 34px; height: 34px; border-radius: 50%; background: var(--tc); color: var(--on-team); display: grid; place-items: center; font-weight: 800; flex: none; }
.gv-tname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
.gv-tscore { font-family: var(--font-display); font-weight: 800; font-size: 1.85rem; line-height: 1; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.gv-award { height: 36px; min-width: 52px; padding: 0 10px; border-radius: var(--r-pill); border: 2px solid var(--line); background: var(--surface-2); font-weight: 800; cursor: pointer; font-variant-numeric: tabular-nums; }
.gv-award:disabled { opacity: .35; cursor: default; }
.gv-award.ready { border-color: var(--ok); color: var(--ok); }
.gv-award.on { background: var(--ok); border-color: var(--ok); color: var(--surface); }
.gv-minis { display: flex; flex-direction: column; gap: 2px; }
.gv-mini { width: 30px; height: 17px; border-radius: 5px; border: 1px solid var(--line); background: transparent; font-size: .7rem; font-weight: 700; line-height: 1; cursor: pointer; padding: 0; }

/* Ergebnis / Erklärung */
.gv-result { border-top: 1px solid var(--line); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.gv-sol { margin: 0; font-weight: 700; font-size: 1.1rem; }
.gv-sol span { display: block; font-size: .76rem; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); }
.gv-note { margin: 0; padding: 10px 12px; border-radius: var(--r-sm); background: var(--gv-blue-soft); font-size: .97rem; }
.gv-howto { background: var(--gv-blue-soft); border-radius: var(--r-sm); padding: 12px 14px; }
.gv-howto p { margin: 0 0 6px; font-weight: 800; color: var(--gv-blue-ink); }
.gv-howto ol { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 5px; }

/* Timer-Leiste */
.gv-timer { display: flex; align-items: center; gap: 8px; }
.gv-tbar { flex: 1 1 60px; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--line); }
.gv-tbar span { display: block; height: 100%; width: 100%; background: var(--gv-blue); transition: width .2s linear; }

/* Overlay */
.gv-overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center;
  background: color-mix(in srgb, #0B1220 58%, transparent);
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
}
.gv-sheet { background: var(--surface); color: var(--ink); border-radius: var(--r-card); width: min(980px, 100%); max-height: 100%; overflow: auto; padding: 22px; display: flex; flex-direction: column; gap: 14px; }

/* Rangliste */
.gv-end { flex: 1; overflow: auto; display: flex; flex-direction: column; align-items: center; gap: 18px; padding-block: 28px; text-align: center; }
.gv-end h2 { font-weight: 800; font-size: clamp(2rem, 4.5vw, 3.6rem); letter-spacing: -0.03em; margin: 0; line-height: 1; }
.gv-ranking { list-style: none; padding: 0; margin: 0; width: min(680px, 100%); display: flex; flex-direction: column; gap: 10px; }
.gv-rank { display: grid; grid-template-columns: 40px minmax(0, 1fr) minmax(60px, 2fr) 56px; gap: 12px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); padding: 10px 14px; text-align: left; }
.gv-rank .rk { font-family: var(--font-display); font-weight: 800; font-size: 1.4rem; }
.gv-rank .rn { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gv-rank .rbar { height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.gv-rank .rbar span { display: block; height: 100%; background: var(--tc); border-radius: 6px; }
.gv-rank .rs { font-family: var(--font-display); font-weight: 800; font-size: 1.6rem; text-align: right; font-variant-numeric: tabular-nums; }

/* Bewegung */
@keyframes gv-pop { 0% { transform: scale(.85); opacity: 0; } 60% { transform: scale(1.04); opacity: 1; } 100% { transform: scale(1); } }
@keyframes gv-shake { 0%, 100% { transform: translate(0, 0); } 20% { transform: translate(-8px, 3px); } 40% { transform: translate(7px, -4px); } 60% { transform: translate(-5px, 2px); } 80% { transform: translate(4px, -2px); } }
.gv-pop { animation: gv-pop .35s ease both; }
.gv-shake { animation: gv-shake .45s ease; }

@media (max-width: 900px) {
  html, body { height: auto; }
  .gv-app.fill { height: auto; }
  .gv-start { grid-template-columns: minmax(0, 1fr); }
  .gv-stage { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; }
  .gv-panel { overflow: visible; }
  .gv-teamnames { grid-template-columns: minmax(0, 1fr); }
  .gv-icon-btn span { display: none; }
  .gv-answers { grid-template-columns: minmax(0, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
