/* Layout: Menü als Stapel bunter Spielschachteln; jedes laufende Spiel füllt den Bildschirm in der Farbe seiner Schachtel.
   Die Farben der Spiele stehen in data/config.json und werden beim Start als CSS-Variablen erzeugt (.theme-<id>). */
:root {
  --paper: #EDEFF4;
  --card: #FFFFFF;
  --ink: #14151F;
  --muted: #565B6E;
  --line: #D3D7E2;
  --ok: #19B866;
  --p1: #2F5BFF;
  --p1-on: #FFFFFF;
  --p2: #E8338A;
  --p2-on: #FFFFFF;
  --display: 'Bricolage Grotesque', 'Arial Narrow', system-ui, sans-serif;
  --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0E1016;
    --card: #1A1D28;
    --ink: #F2F3F8;
    --muted: #A3A8BB;
    --line: #2C3040;
    --p1: #7C9BFF; --p1-on: #0E1016;
    --p2: #FF6AB0; --p2-on: #0E1016;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0E1016;
  --card: #1A1D28;
  --ink: #F2F3F8;
  --muted: #A3A8BB;
  --line: #2C3040;
  --p1: #7C9BFF; --p1-on: #0E1016;
  --p2: #FF6AB0; --p2-on: #0E1016;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 17px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid currentColor; outline-offset: 3px; }

.display {
  font-family: var(--display);
  font-stretch: 80%;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 0.92;
  text-wrap: balance;
}
.wrap { width: 100%; max-width: 520px; margin-inline: auto; padding-inline: 16px; }

#toast {
  position: fixed; left: 16px; right: 16px; bottom: max(20px, env(safe-area-inset-bottom)); z-index: 20;
  max-width: 480px; margin-inline: auto; padding: 14px 16px; border-radius: 14px;
  background: var(--ink); color: var(--paper); font-weight: 600; text-align: center;
}

/* ---------- Seiten (Menü, Einstellungen) ---------- */
.page { min-height: 100dvh; display: flex; flex-direction: column; background: var(--paper); }
.page > .wrap { flex: 0 0 auto; }
.page > .controls { flex: 1 1 auto; display: flex; flex-direction: column; }

.home-head { padding: max(28px, env(safe-area-inset-top)) 0 20px; display: grid; gap: 14px; }
.wordmark { font-size: clamp(64px, 22vw, 108px); }
.lede { color: var(--muted); max-width: 34ch; }
.stack { display: grid; gap: 14px; padding-bottom: 12px; }

.game-card {
  position: relative; display: grid; gap: 10px; align-content: end;
  width: 100%; min-height: 200px; text-align: left; overflow: hidden;
  padding: 22px; border-radius: 28px;
  background: var(--accent); color: var(--on);
  transition: transform .12s ease;
}
.game-card:active { transform: scale(0.985); }
.game-card .name { font-size: 44px; }
.game-card .blurb { display: block; max-width: 24ch; font-size: 16px; line-height: 1.35; }
.game-card .meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.game-card .meta span { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px currentColor; }
.game-card .icon { position: absolute; top: 20px; right: 20px; width: 64px; height: 64px; color: var(--on); }

.soon { margin: 8px 0 40px; padding: 18px 20px; border: 2px dashed var(--line); border-radius: 22px; display: grid; gap: 6px; }
.soon h2 { font-size: 15px; color: var(--muted); font-weight: 700; }
.soon p { font-size: 16px; }

.band { background: var(--accent); color: var(--on); padding: max(14px, env(safe-area-inset-top)) 0 28px; }
.band .wrap { display: grid; gap: 12px; }
.band-title { font-size: clamp(60px, 20vw, 92px); }
.band-text { max-width: 36ch; }
.band.slim { padding-bottom: 14px; }
.band.slim .band-title { font-size: clamp(34px, 10vw, 48px); }
.back { justify-self: start; font-weight: 600; padding: 10px 0; }

.field { display: grid; gap: 12px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.field-label { font-weight: 700; font-size: 15px; color: var(--muted); display: flex; justify-content: space-between; gap: 12px; }
.field-note { font-weight: 500; }
.hint { color: var(--muted); font-size: 15px; }
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg button {
  min-height: 48px; padding: 0 18px; border-radius: 14px; font-weight: 600;
  background: var(--card); box-shadow: inset 0 0 0 2px var(--line);
}
.seg button[aria-checked="true"] { background: var(--accent); color: var(--on); box-shadow: none; }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

.stepper { display: flex; align-items: center; gap: 18px; }
.stepper button {
  width: 56px; height: 56px; border-radius: 50%; font-size: 28px; font-weight: 600; line-height: 1;
  background: var(--card); box-shadow: inset 0 0 0 2px var(--line);
}
.stepper button:disabled { opacity: .4; cursor: not-allowed; }
.stepper output { min-width: 2ch; text-align: center; font-family: var(--display); font-weight: 800; font-size: 48px; font-variant-numeric: tabular-nums; }

.toggle { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 0; font-weight: 600; cursor: pointer; }
.toggle input {
  appearance: none; -webkit-appearance: none; flex: none; position: relative;
  width: 56px; height: 34px; border-radius: 999px; background: var(--line); transition: background-color .15s;
}
.toggle input::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .15s;
}
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(22px); }

.bar { margin-top: auto; position: sticky; bottom: 0; background: var(--paper); padding: 14px 0 calc(14px + env(safe-area-inset-bottom)); display: grid; gap: 10px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; width: 100%;
  min-height: 58px; padding: 0 24px; border-radius: 18px;
  background: var(--accent); color: var(--on); font-weight: 700; font-size: 18px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.plain { background: var(--card); color: var(--ink); box-shadow: inset 0 0 0 2px var(--line); }

/* ---------- Vollbild im Spiel ---------- */
.full {
  position: fixed; inset: 0; z-index: 5; display: flex; flex-direction: column; gap: 16px; overflow: auto;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
  background: var(--accent); color: var(--on);
  transition: background-color .12s;
}
.full > * { width: 100%; max-width: 520px; margin-inline: auto; flex-shrink: 0; }
.full .btn { background: var(--on); color: var(--accent); }
.full .btn.ghost { background: transparent; color: var(--on); box-shadow: inset 0 0 0 2px currentColor; }
.full-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; font-weight: 600; }
.full-top button { padding: 10px 0 10px 16px; font-weight: 600; }
.full-mid { flex: 1 0 auto; display: flex; flex-direction: column; justify-content: center; gap: 18px; }
.full-bottom { display: grid; gap: 10px; }
.full-bottom.row { grid-template-columns: 1fr 1fr; }
.label { font-weight: 700; font-size: 15px; opacity: .85; }
.huge { font-size: clamp(64px, 24vw, 132px); }
.full-text { font-size: 18px; max-width: 30ch; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pills span { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px; box-shadow: inset 0 0 0 1.5px currentColor; }

/* Imposter */
.secret-card { background: #fff; color: #14151F; border-radius: 28px; padding: 28px 22px 30px; text-align: center; display: grid; gap: 12px; }
.secret-card .label { color: #565B6E; opacity: 1; }
.secret { display: block; width: 100%; font-size: 84px; hyphens: manual; -webkit-hyphens: manual; line-height: 1; }
.secret-sub { color: #565B6E; font-size: 16px; min-height: 1.4em; }
.timer { font-size: clamp(88px, 32vw, 168px); font-variant-numeric: tabular-nums; }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.reveal-block { display: grid; gap: 6px; }
.reveal-block .big { font-size: clamp(48px, 16vw, 84px); hyphens: manual; -webkit-hyphens: manual; }

/* Stirnraten */
.count-num { font-size: min(62vw, 320px); text-align: center; line-height: 1; }
.count-num.pop { animation: pop .9s ease-out both; }
@keyframes pop { 0% { transform: scale(.55); opacity: 0; } 30% { transform: scale(1.06); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.meter { height: 10px; border-radius: 999px; background: color-mix(in srgb, var(--on) 22%, transparent); overflow: hidden; }
.meter i { display: block; height: 100%; width: 100%; background: var(--on); border-radius: 999px; }
.play-word-box { flex: 1 1 0; min-height: 0; display: flex; align-items: center; justify-content: center; }
.play-word { width: 100%; text-align: center; font-size: 96px; line-height: 0.98; hyphens: manual; -webkit-hyphens: manual; }
.full.flash-ok { --accent: #19B866; --on: #06210F; }
.full.flash-pass { --accent: #1B1B2F; --on: #FFFFFF; }
.score-pill { font-family: var(--display); font-weight: 800; font-size: 28px; font-variant-numeric: tabular-nums; }
.score-pill::after { content: " richtig"; font-family: var(--body); font-weight: 600; font-size: 15px; }
.end-btn { font-size: 14px; font-weight: 700; padding: 8px 14px !important; border-radius: 999px; box-shadow: inset 0 0 0 2px currentColor; }
.status { font-size: 15px; font-weight: 600; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--on) 12%, transparent); }
.score-big { font-size: clamp(72px, 26vw, 140px); }
.word-section { display: grid; gap: 10px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.word-section h3 { font-size: 15px; color: var(--muted); font-weight: 700; }
.words { display: flex; flex-wrap: wrap; gap: 8px; }
.words span { padding: 6px 12px; border-radius: 999px; background: var(--card); box-shadow: inset 0 0 0 1.5px var(--line); font-weight: 500; }
.words.ok span { background: var(--ok); color: #06210F; box-shadow: none; font-weight: 600; }
.none { color: var(--muted); }

/* Ja/Nein-Rätsel */
.story { font-size: clamp(21px, 5.6vw, 27px); line-height: 1.38; font-weight: 500; white-space: pre-line; }
.story-title { font-size: clamp(40px, 12vw, 64px); }
.notes { display: grid; gap: 10px; }
.note { padding: 12px 14px; border-radius: 14px; background: color-mix(in srgb, var(--on) 14%, transparent); font-size: 17px; }
.note b { display: block; font-size: 13px; opacity: .85; margin-bottom: 2px; }
.rule { font-size: 15px; opacity: .9; }
.story-line { display: block; white-space: pre-line; }

/* Käsekästchen */
.kk-play { gap: 0; }
.kk-main { display: grid; gap: 14px; padding-top: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.kk-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.score-chip {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 10px 14px; border-radius: 16px; font-weight: 700;
  background: var(--card); box-shadow: inset 0 0 0 2px var(--line);
}
.score-chip b { font-family: var(--display); font-size: 30px; font-weight: 800; font-variant-numeric: tabular-nums; }
.score-chip i { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 8px; }
.score-chip[data-p="1"] i { background: var(--p1); }
.score-chip[data-p="2"] i { background: var(--p2); }
.score-chip.active[data-p="1"] { background: var(--p1); color: var(--p1-on); box-shadow: none; }
.score-chip.active[data-p="2"] { background: var(--p2); color: var(--p2-on); box-shadow: none; }
.score-chip.active[data-p="1"] i { background: var(--p1-on); }
.score-chip.active[data-p="2"] i { background: var(--p2-on); }
.kk-status { min-height: 1.5em; font-weight: 600; text-align: center; }
.board-wrap { background: var(--card); border-radius: 24px; padding: 6px; box-shadow: inset 0 0 0 2px var(--line); }
.board { display: block; width: 100%; height: auto; touch-action: manipulation; -webkit-user-select: none; user-select: none; }
.board .dot { fill: var(--ink); }
.board .seg { stroke: var(--line); stroke-width: 5; stroke-linecap: round; }
.board .hit { stroke: transparent; stroke-width: 40; stroke-linecap: butt; }
.board .edge { cursor: pointer; }
.board .edge.p1, .board .edge.p2 { cursor: default; }
.board .edge.p1 .seg { stroke: var(--p1); stroke-width: 8; }
.board .edge.p2 .seg { stroke: var(--p2); stroke-width: 8; }
.board .edge.last .seg { stroke-width: 11; }
.board .box { fill-opacity: .24; }
.board .box.p1 { fill: var(--p1); }
.board .box.p2 { fill: var(--p2); }
.board .boxnum { font-family: var(--display); font-weight: 800; font-size: 24px; text-anchor: middle; dominant-baseline: central; fill: var(--ink); opacity: .75; }
.kk-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.kk-result { text-align: center; display: grid; gap: 2px; }
.kk-result b { font-family: var(--display); font-stretch: 80%; font-weight: 800; font-size: 30px; line-height: 1.05; }

@media (prefers-reduced-motion: reduce) {
  .game-card, .toggle input::after, .full { transition: none; }
  .count-num.pop { animation: none; }
}

/* Fehlermeldung und Hinweis ohne JavaScript (kein Inline-Style, wegen CSP) */
.fatal { padding: 32px 24px; font-family: var(--body, system-ui, sans-serif); }
