/* Beat 9 — Querformat, fünf Welten (themes.js): Farben der Welt kommen als
   --w-* aus hud.js applyTheme(). Rajdhani aus assets/css/fonts.css. */
:root {
  --bg: #050b1f;
  --panel: rgba(8, 14, 38, 0.82);
  --line: rgba(125, 211, 252, 0.28);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #22d3ee;         /* Cyan — Intro/Outro, Fortschritt */
  --hot: #f472b6;            /* Magenta — Drop, Play */
  --gold: #facc15;           /* Ringe, Pads */
  --win: #34d399;
  --lose: #fb7185;
  --red: #ff4d6d;            /* Fehler-Rückmeldung aus gameover-ui.js */
  --ng-menu-fg: #f8fafc;
  --ng-menu-accent: #22d3ee;
  --ng-menu-accent-fg: #021018;
  --ng-menu-line: rgba(125, 211, 252, 0.35);
  --ng-menu-btn-bg: rgba(5, 11, 31, 0.6);
  --ng-menu-scrim: rgba(3, 7, 20, 0.88);
  /* Welt des Tages, überschrieben von hud.js applyTheme() */
  --w-edge: #22d3ee; --w-card0: #22d3ee; --w-card1: #0ea5b7; --w-card-ink: #021018; --w-play: #f472b6; --w-sky0: #050b1f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  width: 100%; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: 'Rajdhani', 'Segoe UI', sans-serif;
  overflow: hidden;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
#game { position: absolute; inset: 0; display: block; touch-action: none; }

/* ── Kopfzeile im Lauf ─────────────────────────────────────
   Zwischen den geteilten Knöpfen (Vollbild links, Menü rechts), die Safe-Area
   seitlich eingerechnet: quer liegen Notch und Home-Indikator an den Seiten. */
.hud {
  position: absolute; z-index: 5;
  top: calc(env(safe-area-inset-top, 0px) + var(--ng-menu-top, 10px));
  left: calc(env(safe-area-inset-left, 0px) + var(--ng-sys-clear, 66px));
  right: calc(env(safe-area-inset-right, 0px) + var(--ng-sys-clear, 66px));
  height: 44px;
  display: flex; align-items: center; gap: 14px;
}
.hud.hidden { display: none; }
.hud-attempt, .hud-pct {
  flex: none; font-size: 1.25rem; font-weight: 700; letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums; text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}
.hud-pct { width: 3.2em; text-align: right; }
.hud-progress { flex: 1; min-width: 60px; }
.hud-track { position: relative; height: 6px; border-radius: 3px; background: rgba(248,250,252,0.16); overflow: visible; }
.hud-fill {
  position: absolute; inset: 0; border-radius: 3px; background: var(--w-edge);
  transform-origin: left center; transform: scaleX(0);
}
.hud-best { position: absolute; top: -4px; width: 2px; height: 14px; margin-left: -1px; background: rgba(248,250,252,0.55); }
.hud-best.hidden { display: none; }
.hud-end {
  flex: none; height: 34px; padding: 0 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--ng-menu-btn-bg); color: var(--muted);
  font: 700 0.95rem 'Rajdhani', sans-serif; letter-spacing: 0.06em; text-transform: uppercase;
  cursor: pointer;
}
.hud-end:active { color: var(--text); }

.hud-hint {
  position: absolute; z-index: 5; left: 50%; transform: translateX(-50%);
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  max-width: min(520px, 80vw); padding: 8px 14px; border-radius: 10px;
  font-size: 1rem; font-weight: 600; text-align: center;
  background: rgba(3,7,20,0.6); border: 1px solid var(--line);
  pointer-events: none; transition: opacity 0.5s;
}
.hud-hint.hidden { display: none; }
.hud-hint.fade { opacity: 0; }

.flash {
  position: absolute; z-index: 6; left: 0; right: 0; top: 36%;
  padding: 10px 0; text-align: center;
  font-size: clamp(1.6rem, 6vh, 2.6rem); font-weight: 700; letter-spacing: 0.05em;
  background: rgba(3,7,20,0.6); pointer-events: none;
}
.flash.hidden { display: none; }

/* ── Screens ───────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0; z-index: 10;
  background: radial-gradient(90% 120% at 30% 30%, rgba(34,211,238,0.10), rgba(3,7,20,0) 60%), rgba(3,7,20,0.72);
}
.screen.hidden { display: none; }
.screen-title { background: radial-gradient(70% 110% at 20% 20%, rgba(3,7,20,0.55), rgba(3,7,20,0.15) 70%), rgba(3,7,20,0.25); }
body.theme-light .screen-title { background: radial-gradient(70% 110% at 20% 20%, rgba(255,255,255,0.7), rgba(255,255,255,0.15) 70%); color: #0b1a2e; }
body.theme-light .tagline, body.theme-light .rank-row .d { color: #1e3a5f; }
body.theme-light .rank-row .k, body.theme-light .hint { color: #355377; }
body.theme-light .logo-w { color: #0b1a2e; text-shadow: none; }

/* Titel: Logo und Rang links oben, Knöpfe in den unteren Ecken — quer greifen
   zwei Daumen von außen (game-workflows § Querformat). */
.title-top {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + max(9%, 60px));  /* unter Vollbild- und Menüknopf */
  left: calc(env(safe-area-inset-left, 0px) + 7%);
  right: calc(env(safe-area-inset-right, 0px) + 7%);
  display: flex; flex-direction: column; align-items: flex-start; gap: 10px;
}
.logo { display: flex; align-items: center; gap: 12px; line-height: 0.9; }
.logo-w {
  font-size: clamp(2.8rem, 13vh, 4.6rem); font-weight: 700; letter-spacing: 0.08em;
  color: var(--text); text-shadow: 0 0 18px rgba(34,211,238,0.55), 0 0 2px #fff;
}
/* Die Scheiben-9 aus dem Logo-System (gen-logo-beat9.mjs), 1,13 × die Schriftgröße von
   „BEAT" wie im Mockup; ihre Farben kommen aus der Welt des Tages (--w-eq, --w-eq-drop). */
.logo-n { display: block; height: clamp(3.16rem, 14.7vh, 5.2rem); width: auto; }
.tagline { font-size: clamp(1rem, 3.6vh, 1.25rem); font-weight: 600; color: #cbd5e1; }
.challenge-banner {
  padding: 6px 12px; border-radius: 10px; border: 1.5px dashed var(--line);
  background: var(--panel); color: var(--gold); font-weight: 700;
}
.challenge-banner.hidden { display: none; }
.ranks { display: flex; gap: 22px; margin-top: 4px; }
.ranks.hidden, .rank-row.hidden { display: none; }
.rank-row { display: flex; align-items: baseline; gap: 8px; font-size: 1rem; }
.rank-row .k { color: var(--muted); }
.rank-row .v { font-size: 1.4rem; font-weight: 700; color: var(--w-edge); }
.rank-row .d { color: #cbd5e1; font-weight: 600; }

.corner {
  position: absolute; bottom: calc(env(safe-area-inset-bottom, 0px) + 7%);
  display: flex; flex-direction: column; gap: 8px; width: min(300px, 38vw);
}
.corner-left { left: calc(env(safe-area-inset-left, 0px) + 5%); align-items: flex-start; width: min(360px, 44vw); }
.corner-right { right: calc(env(safe-area-inset-right, 0px) + 5%); align-items: flex-end; text-align: right; width: min(260px, 32vw); }
.hint { font-size: 0.95rem; font-weight: 500; color: var(--muted); line-height: 1.3; }

/* Play / Again: Magenta, dieselbe Stelle unten rechts auf Titel und Ergebnis. */
.mode-btn {
  width: 100%; height: clamp(54px, 17vh, 72px);
  border: none; border-radius: 14px;
  background: var(--hot); color: #1a0312;
  font: 700 clamp(1.6rem, 7vh, 2.1rem) 'Rajdhani', sans-serif; letter-spacing: 0.14em; text-transform: uppercase;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15) inset, 0 5px 0 #9d174d, 0 10px 26px rgba(244,114,182,0.35);
  cursor: pointer; transition: transform 0.08s, box-shadow 0.08s;
}
.mode-btn:active { transform: translateY(3px); box-shadow: 0 0 0 2px rgba(255,255,255,0.15) inset, 0 2px 0 #9d174d; }
/* Song des Tages: gefüllte Karte in der Farbe der heutigen Welt (Mockup v1 A). */
.daily-btn {
  width: 100%; min-height: clamp(58px, 19vh, 78px); padding: 6px 14px;
  border: none; border-radius: 16px;
  background: linear-gradient(135deg, var(--w-card0), var(--w-card1)); color: var(--w-card-ink);
  box-shadow: 0 5px 0 rgba(0,0,0,0.3), 0 12px 28px rgba(0,0,0,0.3);
  display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 2px;
  font: 700 clamp(1.2rem, 5.2vh, 1.55rem) 'Rajdhani', sans-serif; letter-spacing: 0.04em; text-align: left;
  cursor: pointer;
}
.daily-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; line-height: 1; }
.daily-meta { font-size: 0.95rem; font-weight: 700; letter-spacing: 0.02em; opacity: 0.85; }
.daily-btn small { font-size: 0.82rem; font-weight: 600; letter-spacing: 0; opacity: 0.75; }
.daily-btn:active { transform: translateY(2px); }
.daily-btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.eq-ico { display: inline-flex; gap: 3px; align-items: flex-end; height: 18px; flex: none; }
.eq-ico i { width: 4px; height: 100%; background: currentColor; border-radius: 1px; animation: eqico var(--beat, 0.43s) ease-out infinite; }
.eq-ico i:nth-child(2) { animation-delay: calc(var(--beat, 0.43s) * -0.25); }
.eq-ico i:nth-child(3) { animation-delay: calc(var(--beat, 0.43s) * -0.5); }
.eq-ico i:nth-child(4) { animation-delay: calc(var(--beat, 0.43s) * -0.75); }
@keyframes eqico { 0% { height: 100%; } 60% { height: 30%; } 100% { height: 100%; } }
.daily-btn:disabled .eq-ico i { animation: none; height: 30%; }
@media (prefers-reduced-motion: reduce) { .eq-ico i { animation: none; } }

/* Play tritt auf dem Titel zurück, Again auf dem Ergebnis bleibt gefüllt. */
.screen-title .mode-btn {
  background: rgba(0,0,0,0.25); color: var(--w-play); border: 2px solid var(--w-play);
  box-shadow: none; font-size: clamp(1.4rem, 6vh, 1.8rem);
}
body.theme-light .screen-title .mode-btn { background: rgba(255,255,255,0.55); }
.screen-title .mode-btn:active { transform: translateY(2px); box-shadow: none; }

/* Helle Welt (Eis): Kopfzeile dunkel statt weiß */
body.theme-light .hud-attempt, body.theme-light .hud-pct { color: #0b1a2e; text-shadow: none; }
body.theme-light .hud-track { background: rgba(11,26,46,0.15); }
body.theme-light .hud-best { background: rgba(11,26,46,0.55); }

/* ── Ergebnis ──────────────────────────────────────────── */
.go-top {
  position: absolute;
  /* unter der Reihe der geteilten Knöpfe (Vollbild, Menü: 10 + 44 px), sonst liegt die
     Kopfzeile auf schmalen Handys (667 × 375) unter dem Vollbild-Knopf */
  top: calc(env(safe-area-inset-top, 0px) + max(10%, 62px));
  left: calc(env(safe-area-inset-left, 0px) + 7%);
  right: calc(env(safe-area-inset-right, 0px) + 44%);
  display: flex; flex-direction: column; align-items: flex-start; gap: clamp(2px, 1vh, 6px);
}
/* Farben der Welt: Rekord und CTA in der Drop-Farbe, „Geschafft" im Ziel-Grün der Spielregel. */
.screen-over { --go-accent: var(--w-eq-drop, var(--gold)); --go-ink: var(--text); --go-mute: #a7b0c8; --go-goal: #10b981;
  background: radial-gradient(90% 120% at 25% 30%, rgba(255,255,255,0.04), rgba(0,0,0,0) 60%), color-mix(in srgb, var(--w-sky0) 74%, transparent); }
body.theme-light .screen-over { --go-accent: color-mix(in srgb, var(--w-eq-drop) 65%, #000); --go-ink: #0b1a2e; --go-mute: #355377;
  background: rgba(234,248,255,0.78); color: #0b1a2e; }
.go-eyebrow { display: flex; align-items: center; gap: 8px; max-width: 100%;
  font-size: 0.75rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--go-mute); }
.go-eyebrow #go-song { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.go-nine { flex: none; display: flex; }
.go-nine .logo-n { height: 16px; }
.go-mode { display: flex; align-items: center; gap: 8px; margin-top: 2px;
  font-size: clamp(1.1rem, 5.6vh, 1.4rem); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--go-mute); }
.go-mode.win { color: var(--go-goal); }
.go-mode.win::before { content: '✓'; display: grid; place-items: center; width: 1.1em; height: 1.1em; border-radius: 6px;
  background: var(--go-goal); color: #03140c; font-size: 0.75em; letter-spacing: 0; }
.go-score { font-size: clamp(2.8rem, 17.5vh, 4.25rem); font-weight: 700; line-height: 0.9; font-variant-numeric: tabular-nums; color: var(--go-ink); }
.go-score small { font-size: 0.5em; margin-left: 0.15em; color: var(--go-mute); }
.go-score.better { color: var(--go-accent); text-shadow: 0 0 24px color-mix(in srgb, var(--w-eq-drop) 45%, transparent); }
.go-score.better small { color: var(--go-accent); opacity: 0.8; }
.go-best, .go-rank, .go-vs, .go-day { font-size: 1.05rem; font-weight: 600; color: var(--go-mute); }
.go-best:empty { display: none; }
.go-best.better { color: var(--go-accent); }
.go-vs { color: var(--go-ink); }
.go-vs.better { color: var(--go-goal); }
.go-vs.hidden, .go-day.hidden { display: none; }
.go-rank { min-height: 1.3em; color: var(--go-ink); }
.go-rank .up { color: var(--go-goal); }
/* Song-Leiste (fillTrack in hud.js): Teile nach Takten, Drops kräftiger, Tode als Striche. */
.go-track { width: 100%; display: grid; gap: 3px; margin-top: clamp(2px, 1.2vh, 8px); }
.gt-bar { position: relative; height: 14px; display: flex; gap: 2px; }
.gt-sec { height: 100%; border-radius: 3px; background: rgba(255,255,255,0.12); }
.gt-sec.drop { background: rgba(255,255,255,0.22); }
body.theme-light .gt-sec { background: rgba(30,58,95,0.16); }
body.theme-light .gt-sec.drop { background: rgba(30,58,95,0.28); }
.gt-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 3px; background: var(--go-accent); opacity: 0.35; }
.gt-fill.win { background: var(--go-goal); }
.gt-tick { position: absolute; top: -4px; width: 2px; height: 22px; margin-left: -1px; border-radius: 1px; background: var(--go-ink); opacity: 0.55; }
.gt-flag { position: absolute; right: -2px; top: -6px; width: 4px; height: 26px; border-radius: 2px; background: var(--go-goal); }
.gt-labels { display: flex; gap: 2px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--go-mute); }
.gt-labels span { overflow: hidden; white-space: nowrap; }
.gt-insight { font-size: 0.95rem; font-weight: 600; color: var(--go-mute); min-height: 1.2em; }
.gt-insight b { color: var(--go-ink); }

/* Knopfblock unten rechts: „Again" steht dort, wo „Play" stand. */
.action-block {
  position: absolute;
  right: calc(env(safe-area-inset-right, 0px) + 5%);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 7%);
  width: min(260px, 32vw);  /* wie .corner-right: „Nochmal" deckt sich mit „Spielen" (Block E) */
  display: flex; flex-direction: column; align-items: stretch; gap: 8px;
}
.go-cta-zone { display: flex; flex-direction: column; align-items: stretch; gap: 4px; }
.screen-over .mode-btn {
  background: var(--w-card0); color: var(--w-card-ink);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.15) inset, 0 5px 0 color-mix(in srgb, var(--w-card0) 55%, #000), 0 10px 26px color-mix(in srgb, var(--w-card0) 35%, transparent);
}
.screen-over .mode-btn:active { box-shadow: 0 0 0 2px rgba(255,255,255,0.15) inset, 0 2px 0 color-mix(in srgb, var(--w-card0) 55%, #000); }
.cta-btn {
  min-height: 62px; padding: 6px 12px; border-radius: 14px;
  border: 2px solid var(--go-accent, var(--accent)); background: color-mix(in srgb, var(--w-sky0) 60%, transparent); color: var(--go-accent, var(--accent));
  letter-spacing: 0.1em; text-transform: uppercase;
  font: 700 1.1rem 'Rajdhani', sans-serif;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  cursor: pointer;
}
.cta-btn small { font-size: 0.82rem; font-weight: 600; color: var(--go-mute, var(--muted)); text-transform: none; letter-spacing: 0; line-height: 1.2; }
body.theme-light .cta-btn { background: rgba(255,255,255,0.7); }
body.theme-light .quiet-btn { color: #355377; text-decoration-color: rgba(30,58,95,0.35); }
.cta-btn:active { transform: scale(0.97); }
.cta-btn.hidden { visibility: hidden; }
.go-note { font-size: 0.9rem; font-weight: 700; min-height: 1em; text-align: center; }
.go-note.hidden { display: none; }
.go-quiet { display: flex; gap: 12px; justify-content: flex-end; min-height: 34px; }
.quiet-btn { white-space: nowrap; }
.quiet-btn {
  background: none; border: none; color: var(--muted); padding: 6px;
  font: 600 1rem 'Rajdhani', sans-serif;
  text-decoration: underline; text-decoration-color: rgba(148,163,184,0.4); text-underline-offset: 3px;
  cursor: pointer;
}
.quiet-btn:active { color: var(--text); }
.quiet-btn.hidden { display: none; }

/* ── Bottom-Sheets (gameover-ui.js schaltet nur `open`) ── */
.sheet-backdrop {
  position: absolute; inset: 0; z-index: 20; background: rgba(3,7,20,0.72);
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.sheet-backdrop.open { opacity: 1; pointer-events: all; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 21;
  max-width: 460px; margin: 0 auto;
  background: #0b1430; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0;
  padding: 12px 18px calc(env(safe-area-inset-bottom, 0px) + 16px);
  display: flex; flex-direction: column; gap: 8px;
  transform: translateY(100%); transition: transform 0.3s cubic-bezier(.32,1,.32,1);
}
.sheet.open { transform: translateY(0); }
.sheet-handle { width: 36px; height: 4px; border-radius: 2px; background: rgba(248,250,252,0.2); align-self: center; }
.sheet-title { font-size: 0.9rem; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; text-align: center; color: var(--muted); }
.sheet-sub { font-size: 0.95rem; color: var(--muted); text-align: center; }
.sheet form { display: flex; flex-direction: column; gap: 0.5rem; }
.reg-input {
  padding: 10px 12px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.16);
  background: rgba(0,0,0,0.3); color: var(--text); font: 600 1rem 'Rajdhani', sans-serif;
}
.reg-input::placeholder { opacity: 0.45; }
.reg-input:focus { outline: none; border-color: var(--accent); }
.reg-error { font-size: 0.85rem; font-weight: 700; color: var(--red); }
.reg-error.hidden { display: none; }
.reg-saved { font-size: 1rem; font-weight: 700; color: var(--win); text-align: center; padding: 8px 0; }
.reg-row { display: flex; gap: 0.5rem; }
.reg-submit {
  flex: 1; padding: 10px; border: none; border-radius: 10px;
  background: var(--accent); color: #021018; font: 700 1rem 'Rajdhani', sans-serif; cursor: pointer;
}
.reg-skip {
  padding: 10px 16px; border: none; border-radius: 10px;
  background: rgba(255,255,255,0.08); color: var(--text); font: 700 1rem 'Rajdhani', sans-serif; cursor: pointer;
}

/* ── Hochkant: bitte drehen ────────────────────────────── */
.rotate {
  position: fixed; inset: 0; z-index: 950; display: none;
  flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: var(--bg); text-align: center; padding: 24px;
}
body.portrait .rotate { display: flex; }
.rotate-icon { font-size: 4rem; color: var(--accent); animation: rot 2s ease-in-out infinite; }
.rotate-text { font-size: 1.5rem; font-weight: 700; }
@keyframes rot { 0%, 100% { transform: rotate(0); } 50% { transform: rotate(90deg); } }
@media (prefers-reduced-motion: reduce) { .rotate-icon { animation: none; } }
