/* Spukvilla — Designsystem
   Farben: Nachtviolett als Grund, Kürbisorange als einzige Aktionsfarbe,
   Knochenweiß für Text. Keine Webfonts (keine Drittanfragen, DSGVO). */

:root {
  --night-950: #07050d;
  --night-900: #0b0814;
  --night-800: #150f24;
  --night-700: #221838;
  --line: #3a2d55;
  --bone: #f1ead8;
  --bone-dim: #b9b0c9;
  --pumpkin: #ff7a1a;
  --pumpkin-hi: #ffa04d;
  --candle: #ffe066;
  --slime: #8be04e;
  --blood: #ff4d5e;

  --radius: 12px;
  --gap: clamp(0.75rem, 2vw, 1.25rem);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: Georgia, "Times New Roman", serif;

  color-scheme: dark;
}

* { box-sizing: border-box; }

/* hidden muss immer gewinnen, auch gegen display:grid/flex der Komponenten */
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

/* Die Seite ist eine reine Spielfläche: genau eine Bildschirmhöhe, kein Scrollen. */
html, body { height: 100%; overflow: hidden; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse at 50% -10%, #2a1740 0%, transparent 60%),
    var(--night-900);
  color: var(--bone);
  font: 16px/1.55 var(--font);
}

a { color: var(--pumpkin-hi); }
a:hover { color: var(--candle); }

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--candle); outline-offset: 3px; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  border: 2px solid transparent;
  padding: 0.75rem 1.6rem;
  min-height: 44px;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.15s ease, border-color 0.15s ease;
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.98); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary { background: var(--pumpkin); color: #1d0b00; box-shadow: 0 0 24px rgba(255, 122, 26, 0.35); }
.btn-primary:hover:not(:disabled) { background: var(--pumpkin-hi); }

.btn-secondary { background: transparent; color: var(--bone); border-color: var(--line); }
.btn-secondary:hover:not(:disabled) { border-color: var(--pumpkin); }

/* Runde Symbol-Knöpfe (Info, Ton, Pause, Schließen) */
.btn-round {
  flex: none;
  display: grid;
  place-items: center;
  width: var(--btn, 2.4em);
  height: var(--btn, 2.4em);
  padding: 0;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--night-700);
  color: var(--bone);
  font: 700 1.15em/1 var(--font-display);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.15s ease, color 0.15s ease;
}
.btn-round:hover:not(:disabled) { border-color: var(--pumpkin); color: var(--candle); }
.btn-round:active:not(:disabled) { transform: scale(0.94); }
.btn-round:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-info { color: var(--pumpkin-hi); }
.ico { width: 55%; height: 55%; display: block; }

/* Zustand per Symbol: Ton an/aus, Pause/Weiter */
#btn-sound[aria-pressed="false"] { color: var(--bone-dim); }
#btn-sound[aria-pressed="true"] .ico-sound-off,
#btn-sound[aria-pressed="false"] .ico-sound-on,
#btn-pause[data-state="paused"] .ico-pause,
#btn-pause:not([data-state="paused"]) .ico-play { display: none; }

/* ---------- Layout ----------
   .app ist ein Größen-Container. Das Spielfeld (.board = Anzeige + Szene)
   wird mit Container-Einheiten so groß wie möglich berechnet:
   - schmale Bildschirme: Anzeige oben, Szene nutzt die volle Breite
   - breite Bildschirme (ab 16:10): Anzeige links, Szene nutzt die volle Höhe
   So landet die Anzeige immer dort, wo ohnehin Platz übrig ist. */
.app {
  --pad: clamp(6px, 1.2vmin, 14px);
  height: 100vh;
  height: 100svh;
  padding:
    max(var(--pad), env(safe-area-inset-top))
    max(var(--pad), env(safe-area-inset-right))
    max(var(--pad), env(safe-area-inset-bottom))
    max(var(--pad), env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  container-type: size;
}

.board {
  /* Schrift (und damit Anzeige und Knöpfe) wächst mit dem Bildschirm mit */
  font-size: clamp(0.85rem, 1.6vmin + 0.3rem, 1.25rem);
  --bar-h: 3.6em;
  display: grid;
  grid-template-rows: var(--bar-h) auto;
  width: min(100%, calc((100vh - 5rem) * 10 / 7));
  width: min(100cqw, (100cqh - var(--bar-h)) * 10 / 7);
}

.panel {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.6em 1.4em;
  padding: 0 0.6em 0 1em;
  overflow: hidden;
  background: var(--night-800);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: var(--radius) var(--radius) 0 0;
}

.logo {
  margin: 0;
  flex: none;
  font-family: var(--font-display);
  font-size: 1.6em;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1;
  color: var(--pumpkin);
  text-shadow: 0 0 14px rgba(255, 122, 26, 0.45), 0 2px 0 #5a1e00;
  white-space: nowrap;
}

.hud-stats { display: flex; align-items: center; gap: 0.5em 1.3em; }
.hud-stat { display: flex; flex-direction: column; line-height: 1.15; min-width: 3.2em; }
.hud-label { font-size: 0.62em; text-transform: uppercase; letter-spacing: 0.08em; color: var(--bone-dim); }
.hud-value { font-size: 1.3em; font-weight: 800; font-variant-numeric: tabular-nums; }
#score.bump, #time.bump { animation: bump 0.25s ease-out; }
#combo.hot { color: var(--candle); }

.hud-time { position: relative; padding-bottom: 6px; }
.hud-time.urgent .hud-value { color: var(--blood); }
.timebar { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--night-700); border-radius: 2px; overflow: hidden; }
.timebar > span { display: block; height: 100%; background: var(--pumpkin); transform-origin: left; }
.hud-time.urgent .timebar > span { background: var(--blood); }

.hud-actions { display: flex; gap: 0.4em; }

/* Impressum: klein, aber immer sichtbar (§ 5 ECG: ständig erreichbar) */
.imprint-link {
  margin-left: auto;
  padding: 6px 4px;
  font-size: max(0.72em, 11px);
  line-height: 1.1;
  color: var(--bone-dim);
  text-decoration: none;
  white-space: nowrap;
}
.imprint-link:hover { color: var(--candle); text-decoration: underline; }

/* Schmal (Handy hochkant): Anzeige zweizeilig – Logo + Knöpfe, darunter Werte */
@media (max-width: 600px) {
  .board { --bar-h: 6.4em; }
  .panel {
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-areas: "logo link actions" "stats stats stats";
    align-content: center;
    gap: 0.5em;
    padding: 0 0.6em 0 0.8em;
  }
  .logo { grid-area: logo; font-size: 1.45em; }
  .hud-actions { grid-area: actions; margin: 0; }
  .imprint-link { grid-area: link; }
  .hud-stats { grid-area: stats; justify-content: space-between; padding-right: 0.3em; }
}

/* Breit (Desktop 16:9, Handy quer): Anzeige als Spalte links neben der Szene */
@media (min-aspect-ratio: 8/5) {
  .board {
    --panel-w: 9em;
    grid-template-columns: var(--panel-w) 1fr;
    grid-template-rows: auto;
    width: min(100%, calc(var(--panel-w) + (100vh - 2rem) * 10 / 7));
    width: min(100cqw, var(--panel-w) + 100cqh * 10 / 7);
  }
  .panel {
    contain: size; /* Höhe kommt von der Szene, nicht vom Inhalt */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1.4em;
    padding: 1.1em 0.7em;
    border: 1px solid var(--line);
    border-right: 0;
    border-radius: var(--radius) 0 0 var(--radius);
  }
  .logo { font-size: 1.45em; text-align: center; }
  .hud-stats { flex-direction: column; align-items: stretch; gap: 0.9em; padding-inline: 0.3em; }
  .hud-value { font-size: 1.55em; }
  .hud-actions { margin: auto 0 0; justify-content: center; gap: 0.35em; --btn: 2.1em; }
  .imprint-link { order: 1; margin: -0.8em 0 -0.4em; text-align: center; }
  .scene { border-radius: 0 var(--radius) var(--radius) 0; }
}
/* Breit und niedrig (Handy quer): Anzeige enger setzen */
@media (min-aspect-ratio: 8/5) and (max-height: 440px) {
  .panel { gap: 0.8em; padding-block: 0.9em 0.5em; }
  .hud-stats { gap: 0.5em; }
  .hud-value { font-size: 1.35em; }
}

.scene {
  position: relative;
  width: 100%;
  align-self: start;
  aspect-ratio: 1000 / 700;
  overflow: hidden;
  font-size: 1rem;
  border: 1px solid var(--line);
  border-radius: 0 0 var(--radius) var(--radius);
  background: var(--night-950);
  cursor: crosshair;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.scene.shake { animation: shake 0.28s ease-in-out; }

.rotate-hint { display: none; margin: 0; text-align: center; font-size: 0.9rem; color: var(--bone-dim); }
.lang-hint { display: none; margin: 0; text-align: center; font-size: 0.9rem; }
@media (orientation: portrait) and (max-width: 600px) {
  .rotate-hint { display: block; }
}

.layer { position: absolute; inset: 0; width: 100%; height: 100%; }
.layer-back, .layer-behind, .layer-front, .layer-glow, .layer-over, .clouds-drift, .lurkers, .fx { pointer-events: none; }

/* Die Villa blockiert Klicks nur dort, wo sie gemalt ist — sonst gehen
   Klicks auf Monster hinter dem Dach durch das Haus hindurch. */
.layer-house { pointer-events: none; }
.layer-house .solid { pointer-events: visiblePainted; }

/* Kerzenlicht hinter den Fenstern: eigene Ebene, nur Deckkraft animiert */
.glow {
  position: absolute;
  left: var(--x); top: var(--y); width: var(--w); height: var(--h);
  background: radial-gradient(ellipse 50% 50% at 50% 58%, rgba(255, 196, 110, 0.55), rgba(255, 140, 40, 0.22) 55%, transparent 100%);
  animation: candle var(--dur, 4s) var(--delay, 0s) infinite;
  will-change: opacity;
}

/* Kerzen, grüne Laterne, rotes Glimmen: kleine, schnellere Flammen */
.glow--candle { background: radial-gradient(circle, rgba(255, 210, 120, 0.8), rgba(255, 150, 40, 0.25) 45%, transparent 72%); }
.glow--lantern { background: radial-gradient(circle, rgba(140, 255, 170, 0.55), rgba(60, 220, 110, 0.18) 50%, transparent 75%); }
.glow--ember { background: radial-gradient(circle, rgba(255, 60, 30, 0.55), rgba(180, 20, 10, 0.2) 50%, transparent 75%); animation-name: ember; }

/* Wolken ziehen langsam am Mond vorbei (Kachel = halbe Ebenenbreite → nahtlos) */
.clouds-drift {
  width: 200%;
  height: 48%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='300'%3E%3Cfilter id='c' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.0025 .01' numOctaves='5' seed='17' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .13  0 0 0 0 .09  0 0 0 0 .22  0 0 0 2.4 -1.15'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23c)'/%3E%3C/svg%3E") repeat-x 0 0 / 50% 100%;
  opacity: 0.85;
  -webkit-mask-image: linear-gradient(to bottom, #000 55%, transparent);
  mask-image: linear-gradient(to bottom, #000 55%, transparent);
  animation: drift-x 160s linear infinite;
  will-change: transform;
}

/* ---------- Monster ---------- */
.slot {
  position: absolute;
  left: var(--x); top: var(--y); width: var(--w); height: var(--h);
}
.slot--window, .slot--ground { overflow: hidden; }
.slot--window { border-radius: 2px; }

.m {
  position: absolute;
  inset: 0;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
  color: inherit;
  cursor: inherit;
  pointer-events: none;
  transform: translate(0, var(--hide, 100%));
  transition: transform 0.2s cubic-bezier(.2, .9, .3, 1.2);
  will-change: transform;
}
.slot--side[data-dir="left"] .m { transform: translate(100%, 0); }
.slot--side[data-dir="right"] .m { transform: translate(-100%, 0); }
.slot .m.up { transform: translate(0, 0); pointer-events: auto; }
.m.dead { pointer-events: none; }
.m:focus-visible { outline: 3px dashed var(--candle); outline-offset: -3px; }

.m-art { display: block; width: 100%; height: 100%; overflow: visible; transform-origin: 50% 80%; }
.m--ghost .m-art { filter: drop-shadow(0 0 8px rgba(170, 200, 255, 0.55)); opacity: 0.9; animation: hover 1.8s ease-in-out infinite; will-change: transform; }
.m--pumpkin .m-art { filter: drop-shadow(0 0 10px rgba(255, 150, 30, 0.7)); }
.m--werewolf .m-art { filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.7)); }
.m--zombie .m-art, .m--skeleton .m-art { filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.6)); }
.m.hurt .m-art { animation: wobble 0.3s ease-in-out; filter: brightness(1.7) saturate(0.6); }
.m.dead .m-art { animation: poof 0.35s ease-in forwards; }

.bat {
  position: absolute;
  left: 0; top: 0;
  width: 8%;
  aspect-ratio: 2 / 1;
  padding: 0; margin: 0; border: 0; background: none;
  cursor: inherit;
  pointer-events: auto;
}
.bat svg { width: 100%; height: 100%; display: block; animation: flap 0.18s ease-in-out infinite alternate; }
.bat.dead { pointer-events: none; }
.bat.dead svg { animation: poof 0.35s ease-in forwards; }

/* ---------- Was in der Dunkelheit lauert ---------- */
/* Je weiter die Nacht, desto röter: --dread (0 … 1) setzt game.js pro Stufe */
.bloodmoon {
  position: absolute;
  left: 77.2%; top: 8.86%; width: 11.6%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 36%, rgba(255, 110, 70, 0.5), rgba(170, 20, 10, 0.78) 68%, rgba(110, 0, 0, 0.9));
  box-shadow: 0 0 40px 14px rgba(200, 20, 10, 0.35);
  opacity: var(--dread, 0);
  transition: opacity 6s ease;
}
.grade {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 90% 80% at 50% 35%, rgba(70, 0, 10, 0.18), rgba(90, 0, 14, 0.55));
  opacity: calc(var(--dread, 0) * 0.8);
  transition: opacity 6s ease;
}

/* Augenpaare zwischen den Bäumen: tauchen auf, blinzeln, verschwinden */
.eyes {
  position: absolute;
  left: var(--x); top: var(--y);
  width: 1.5%; aspect-ratio: 3;
  --c: 255, 205, 60;
  background:
    radial-gradient(circle at 22% 50%, rgba(var(--c), 1) 0 18%, rgba(var(--c), 0.35) 30%, transparent 48%),
    radial-gradient(circle at 78% 50%, rgba(var(--c), 1) 0 18%, rgba(var(--c), 0.35) 30%, transparent 48%);
  opacity: 0;
  animation: lurk var(--dur, 12s) var(--delay, 0s) infinite;
  will-change: opacity, transform;
}
.eyes--red { --c: 255, 40, 30; }
.eyes--green { --c: 150, 255, 90; }

/* Fledermausschwarm kreist in der Ferne um den Mond */
.swarm { position: absolute; left: 83%; top: 17%; width: 0; height: 0; transform: scaleY(0.42); }
.swarm-bat {
  position: absolute;
  left: -10px; top: -4px; width: 20px; height: 8px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 8'%3E%3Cpath fill='%23050307' d='M10 3C9 1 7 0 4 1l1 1C3 2 2 3 1 5c1-1 3-1 3 0 1-1 2-1 3 0 1-1 2-1 3 0 0-1 1-2 0-2Zm0 0c1-2 3-3 6-2l-1 1c2 0 3 1 4 3-1-1-3-1-3 0-1-1-2-1-3 0-1-1-2-1-3 0 0-1-1-2 0-2Z'/%3E%3C/svg%3E") center / contain no-repeat;
  animation: orbit var(--dur, 18s) var(--delay, 0s) linear infinite;
  will-change: transform;
}

/* Gestalt neben dem Haus: unsichtbar, nur beim Blitz als Silhouette */
.stranger {
  position: absolute;
  left: 89.2%; top: 60.6%; width: 1.8%; aspect-ratio: 20 / 64; /* Füße auf dem Hügel rechts neben dem Haus */
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 64'%3E%3Cpath fill='%23020103' d='M10 0c-2.6 0-4 2-4 4.6 0 2 1 3.4 2 4l-4 2c-1.4.8-2 2-2.2 4L0 34l1.6.4 2-15 .6 18 1.8 26h2.6L9.6 40h.8L12 63.6h2.6l1.8-26 .6-18 2 15 1.6-.4-1.8-19.4c-.2-2-.8-3.2-2.2-4l-4-2c1-.6 2-2 2-4C14 2 12.6 0 10 0Z'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0;
}
.stranger.on { animation: bolt 0.55s ease-out; }

/* Irrlichter: schweben langsam über den Gräbern und pulsieren */
.wisp {
  position: absolute;
  left: var(--x); top: var(--y);
  width: 1.8%; aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(235, 255, 252, 1), rgba(120, 240, 220, 0.6) 40%, transparent 72%);
  box-shadow: 0 0 18px 8px rgba(90, 220, 200, 0.3);
  animation: wisp var(--dur, 10s) var(--delay, 0s) ease-in-out infinite;
  will-change: transform, opacity;
}

/* ---------- Effekte ---------- */
.fog {
  position: absolute;
  left: 0;
  width: 200%;
  pointer-events: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1000' height='260'%3E%3Cfilter id='f' x='0' y='0' width='100%25' height='100%25'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.004 .02' numOctaves='4' seed='5' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .78  0 0 0 0 .76  0 0 0 0 .9  0 0 0 1.6 -.62'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E") repeat-x 0 0 / 50% 100%;
  will-change: transform;
}
.fog {
  -webkit-mask-image: linear-gradient(to top, #000 35%, transparent);
  mask-image: linear-gradient(to top, #000 35%, transparent);
}
.fog-a { bottom: -2%; height: 30%; opacity: 0.3; animation: drift-x 70s linear infinite; }
.fog-b { bottom: -6%; height: 18%; opacity: 0.28; animation: drift-x 45s linear infinite reverse; }

.vignette {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse 75% 70% at 52% 45%, transparent 55%, rgba(0, 0, 0, 0.62) 100%);
}
.grain {
  position: absolute; inset: -20%;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='g'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='1 0 0 0 0  1 0 0 0 0  1 0 0 0 0  0 0 0 0 .5'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23g)'/%3E%3C/svg%3E") 0 0 / 180px 180px;
  opacity: 0.07;
  animation: grain 0.6s steps(4) infinite;
  will-change: transform;
}

.bolt { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; opacity: 0; }
.bolt path {
  fill: none;
  stroke: #eef2ff;
  stroke-width: 2.2;
  stroke-linejoin: round;
  filter: drop-shadow(0 0 4px #c4d0ff) drop-shadow(0 0 14px #7f93ff);
}
.bolt.on { animation: bolt 0.55s ease-out; }

/* Ein einzelner Blitz pro Ereignis (WCAG 2.3.1: max. 3 Blitze pro Sekunde) */
.flash {
  position: absolute; inset: 0; opacity: 0;
  background: radial-gradient(circle at 70% 5%, #fff 0%, #c9d6ff 35%, rgba(120, 140, 255, 0.2) 75%);
}
.flash.on { animation: flash 0.9s ease-out; }

.particle {
  position: absolute;
  left: var(--px); top: var(--py);
  width: 9px; height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--pc);
  box-shadow: 0 0 8px var(--pc);
  animation: burst 0.65s ease-out forwards;
}
.particle.p-smoke { width: 26px; height: 26px; margin: -13px 0 0 -13px; background: radial-gradient(circle, rgba(225, 235, 255, 0.75), transparent 70%); box-shadow: none; animation: puff 0.9s ease-out forwards; }
.particle.p-shard { width: 3px; height: 11px; border-radius: 1px; background: #efe6cf; box-shadow: 0 0 2px #000; }
.particle.p-chunk { width: 7px; height: 6px; border-radius: 2px 4px 1px 3px; background: #ec7420; box-shadow: inset -1.5px -1.5px 0 #7a2c06; }
.particle.p-tuft { width: 2px; height: 10px; border-radius: 1px; background: var(--pc); box-shadow: none; }
.particle.p-dirt { width: 5px; height: 4px; border-radius: 40%; background: #3a2a1c; box-shadow: none; }

.popup {
  position: absolute;
  left: var(--px); top: var(--py);
  transform: translate(-50%, -50%);
  font: 800 clamp(0.9rem, 2.4vw, 1.5rem)/1 var(--font);
  color: var(--candle);
  text-shadow: 0 2px 0 #000, 0 0 10px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
  animation: rise 0.85s ease-out forwards;
}
.popup.bad { color: var(--blood); }
.popup.time { font-size: clamp(0.75rem, 1.8vw, 1.1rem); color: var(--slime); }
.popup.time.bad { color: var(--blood); }
/* Stufenansage: groß, langsam aufsteigend */
.popup.stage {
  font: 700 clamp(1.4rem, 5.5vw, 3.4rem)/1 var(--font-display);
  color: var(--pumpkin);
  text-shadow: 0 0 18px rgba(255, 122, 26, 0.6), 0 3px 0 #5a1e00;
  animation: stage 1.9s ease-out forwards;
}
.popup.big { font-size: clamp(1.1rem, 3.4vw, 2.1rem); }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 0.75rem;
  overflow-y: auto;
  background: rgba(6, 3, 12, 0.74);
  backdrop-filter: blur(2px);
  cursor: default;
  z-index: 10;
}

.card { max-width: 30rem; text-align: center; }
.card h2 {
  margin: 0 0 0.4rem;
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 4.5vw, 2.4rem);
  color: var(--pumpkin);
  text-shadow: 0 0 14px rgba(255, 122, 26, 0.4);
}
.card p { margin: 0 0 0.9rem; font-size: clamp(0.85rem, 2.2vw, 1.05rem); }
.card .fineprint { margin: 0.7rem 0 0; font-size: 0.8rem; color: var(--bone-dim); }

.end-score { font-size: clamp(1rem, 3vw, 1.4rem) !important; margin-bottom: 0.1rem !important; }
#end-score { font-size: clamp(2rem, 8vw, 3.6rem); font-weight: 800; color: var(--candle); font-variant-numeric: tabular-nums; }
.end-time { margin-top: 0.2rem !important; color: var(--bone-dim); }
.end-rank { font-family: var(--font-display); font-style: italic; color: var(--bone); }
.end-record { color: var(--slime); font-weight: 800; animation: bump 0.6s ease-out 2; }

.end-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.25rem 1.2rem; margin: 0 0 1rem; }
.end-stats div { display: flex; flex-direction: column; }
.end-stats dt { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--bone-dim); }
.end-stats dd { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }

.card-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.6rem; }

.noscript { padding: 1rem; background: var(--night-800); border-radius: var(--radius); }

/* Kleine Szenen (Handy hochkant): Overlays kompakter */
@media (max-width: 520px) {
  .overlay .fineprint, .end-stats { display: none; }
  .lang-hint { display: block; } /* ersetzt den Umschalter aus der Kleingedruckt-Zeile */
  .card p { margin-bottom: 0.5rem; }
  .btn { padding: 0.55rem 1.2rem; }
}

/* ---------- Einwilligung (Google Analytics) ---------- */
.consent {
  position: fixed;
  left: 50%;
  bottom: max(12px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 50;
  width: min(42rem, calc(100% - 24px));
  max-height: calc(100% - 24px);
  overflow-y: auto;
  padding: 0.9rem 1.1rem 1rem;
  background: var(--night-800);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.6);
  font-size: 0.92rem;
}
.consent h2 { margin: 0 0 0.3rem; font: 700 1.1rem/1.2 var(--font-display); color: var(--pumpkin); }
.consent p { margin: 0 0 0.7rem; color: var(--bone-dim); }
/* Ablehnen und Zustimmen gleich gestaltet: gleich leicht zu treffen (DSB-Empfehlung) */
.consent-actions { display: flex; gap: 0.6rem; justify-content: flex-end; flex-wrap: wrap; }
.consent-actions .btn { min-width: 9rem; padding-block: 0.55rem; }
@media (max-height: 440px) { .consent { font-size: 0.82rem; padding: 0.6rem 0.9rem 0.7rem; } .consent p { margin-bottom: 0.4rem; } }

/* ---------- Spielregeln (Dialog) ---------- */
.info {
  width: min(40rem, 100% - 1.5rem);
  max-width: none;
  max-height: calc(100% - 1.5rem);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--night-800);
  color: var(--bone);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.65), 0 0 40px rgba(255, 122, 26, 0.12);
}
.info[open] { animation: pop 0.18s ease-out; }
.info::backdrop { background: rgba(6, 3, 12, 0.72); backdrop-filter: blur(3px); }
/* Inhalt füllt den Dialog ganz aus: Klicks direkt auf <dialog> kommen nur vom Hintergrund */
.info-body { padding: 1.1rem clamp(1rem, 4vw, 1.6rem) 1.4rem; }

.info-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.9rem; }
.info-head h2 { margin: 0; font-family: var(--font-display); font-size: clamp(1.4rem, 4vw, 1.9rem); color: var(--pumpkin); }
.info-head .btn-round { --btn: 2.6rem; font-size: 1rem; }

.intro { margin: 0 0 1rem; }
.steps { margin: 0 0 1.2rem; padding-left: 1.4rem; }
.steps li { margin-bottom: 0.45rem; }
.steps li::marker { color: var(--pumpkin); font-weight: 800; }

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 13.5rem), 1fr));
  gap: 0.5rem;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.7rem;
  background: var(--night-700);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.legend svg { width: 38px; height: 38px; flex: none; }
.legend span { flex: 1; display: flex; flex-direction: column; line-height: 1.2; }
.legend small { color: var(--bone-dim); font-size: 0.78rem; }
.legend b { color: var(--candle); font-variant-numeric: tabular-nums; }
.legend .legend-bad { border-color: #6b2030; }
.legend .legend-bad b { color: var(--blood); }

.keys { color: var(--bone-dim); font-size: 0.9rem; margin: 1.1rem 0 0; }
kbd {
  font: 600 0.8rem var(--font);
  padding: 0.1rem 0.45rem;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--night-900);
}
.privacy { margin: 0.5rem 0 0; font-size: 0.85rem; color: var(--bone-dim); }
/* Reine Touch-Geräte haben keine Tastatur */
@media (hover: none) and (pointer: coarse) {
  .keys { display: none; }
}

/* ---------- Animationen ---------- */
/* unregelmäßig wie eine Kerzenflamme */
@keyframes candle {
  0%, 100% { opacity: 0.85; } 8% { opacity: 1; } 12% { opacity: 0.7; } 19% { opacity: 0.95; }
  31% { opacity: 0.8; } 37% { opacity: 1; } 52% { opacity: 0.62; } 55% { opacity: 0.9; }
  68% { opacity: 0.78; } 74% { opacity: 1; } 88% { opacity: 0.72; }
}
@keyframes drift-x { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes grain {
  0% { transform: translate(0, 0); } 25% { transform: translate(-5%, 3%); }
  50% { transform: translate(4%, -4%); } 75% { transform: translate(-3%, -6%); } 100% { transform: translate(0, 0); }
}
/* zwei kurze Aufblitzer — bleibt unter 3 Blitzen pro Sekunde (WCAG 2.3.1) */
@keyframes bolt { 0% { opacity: 1; } 12% { opacity: 0.25; } 22% { opacity: 1; } 70% { opacity: 0.6; } 100% { opacity: 0; } }
@keyframes flash { 0% { opacity: 0; } 5% { opacity: 0.55; } 100% { opacity: 0; } }
@keyframes hover { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5%); } }
@keyframes flap { from { transform: scaleY(1); } to { transform: scaleY(0.55); } }
@keyframes poof { to { transform: scale(1.45) rotate(-10deg); opacity: 0; filter: blur(3px); } }
@keyframes wobble {
  0%, 100% { transform: scale(1); } 30% { transform: scale(0.85, 1.12); } 65% { transform: scale(1.1, 0.9); }
}
@keyframes burst { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot, 0deg)) scale(0.3); opacity: 0; } }
@keyframes puff { to { transform: translate(var(--dx), var(--dy)) scale(2.4); opacity: 0; } }
@keyframes ember { 0%, 100% { opacity: 0.55; } 40% { opacity: 1; } 60% { opacity: 0.7; } 80% { opacity: 0.95; } }
@keyframes lurk {
  0%, 62% { opacity: 0; transform: scaleY(1); }
  70% { opacity: 0.9; } 78% { opacity: 0.9; transform: scaleY(1); }
  80% { transform: scaleY(0.1); } 82% { transform: scaleY(1); }
  90% { opacity: 0.85; } 96%, 100% { opacity: 0; }
}
@keyframes orbit {
  from { transform: rotate(0deg) translateX(var(--r)) scale(var(--s, 1)) rotate(0deg); }
  to { transform: rotate(360deg) translateX(var(--r)) scale(var(--s, 1)) rotate(-360deg); }
}
@keyframes wisp {
  0%, 100% { transform: translate(0, 0) scale(1); opacity: 0.25; }
  25% { transform: translate(140%, -90%) scale(0.8); opacity: 0.85; }
  50% { transform: translate(260%, 20%) scale(1.1); opacity: 0.4; }
  75% { transform: translate(90%, 70%) scale(0.9); opacity: 0.9; }
}
@keyframes rise { to { transform: translate(-50%, -170%); opacity: 0; } }
@keyframes stage {
  0% { transform: translate(-50%, -50%) scale(0.7); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.05); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(-50%, -110%) scale(1); opacity: 0; }
}
@keyframes bump { 50% { transform: scale(1.25); } }
@keyframes pop { from { opacity: 0; transform: scale(0.96); } }
@keyframes shake {
  20% { transform: translate(-4px, 2px); } 40% { transform: translate(4px, -2px); }
  60% { transform: translate(-3px, -1px); } 80% { transform: translate(2px, 1px); }
}

@media (prefers-reduced-motion: reduce) {
  .glow, .clouds-drift, .fog, .grain, .bat svg, .m--ghost .m-art, .swarm-bat, .wisp { animation: none; }
  .eyes { animation: none; opacity: 0.6; }
  .flash, .bolt, .stranger { display: none; }
  .scene.shake { animation: none; }
  .m { transition-duration: 0.05s; }
  .particle { display: none; }
  .info[open] { animation: none; }
}
