/* Startbildschirm und Menüs: Ladeanzeige, Intro-Buttons, Hauptmenü, Untermenüs, gespeicherte Situationen,
   Punkte der Vorspann-Szenen */

/* Kleine Links im Hauptmenü (Anleitung) */
.menu-links { display: flex; gap: 22px; margin-top: 14px; }
.menu-links button { padding: 4px 0; background: none; border: 0; color: var(--muted); font-size: 15px; font-weight: 500; }
.menu-links button:hover:not(:disabled) { background: none; color: var(--fg); }
/* Laufende Version rechtsbündig in der Zeile unter dem Hauptmenü (src/ui/version.js) */
.menu-links .app-version { margin-left: auto; align-self: center; color: var(--muted); font-size: 12px;
  font-variant-numeric: tabular-nums; letter-spacing: .02em; opacity: .75; user-select: text; }

/* Startbildschirm */
#menu { transition: opacity 1.4s ease; }
#menu.intro-wait { opacity: 0; pointer-events: none; }
/* Ladeanzeige vor dem Intro: Dreieck der Roten, Umriss und Füllung (Höhe = Fortschritt); nach dem Laden ein Klick
   auf „Start Game“ startet Intro und Song (Browser spielen Ton erst nach einer Bedienung ab) */
#loader { position: fixed; inset: 0; z-index: 60; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 18px; opacity: 0; pointer-events: none; transition: opacity .4s ease; }
#loader.show { opacity: 1; }
#loader.show.ready, #loader.error { pointer-events: auto; }
#loader .rack { display: block; width: 104px; height: auto; overflow: visible; }
#loader .outline { fill: none; stroke: rgba(244, 241, 236, .38); stroke-width: 1.4; }
/* Füllung mit gleich breitem Rand: deckt den Umriss ganz ab */
#loader .fill { fill: var(--accent); stroke: var(--accent); stroke-width: 1.4; }
#loader.error .fill { fill: #c0524a; stroke: #c0524a; }
#loader .label { margin: 0; min-height: 52px; display: flex; align-items: center; font-family: var(--display); font-style: italic;
  font-weight: 700; font-size: 18px; letter-spacing: .32em; text-transform: uppercase; color: var(--muted); }
#loader.ready .label { display: none; }
#loader.error .label { font-family: inherit; font-style: normal; font-size: 13px; letter-spacing: .06em; text-transform: none; }
#loader .retry { display: none; }
#loader.error .retry { display: inline-block; }
#letsGo { min-width: 240px; height: 52px; padding: 0 32px; font-size: 26px; line-height: 1; border-radius: var(--radius); animation: reveal .35s ease-out; }
/* Der Button bekommt beim Erscheinen den Fokus (Leertaste, Enter): ohne Fokusrahmen, er ist ohnehin hervorgehoben */
#letsGo:focus { outline: none; }
#skipIntro { position: fixed; right: calc(64px + var(--sar)); bottom: calc(18px + var(--sab)); z-index: 50; padding: 9px 16px; border-radius: 999px; font-size: 13px;
  background: rgba(10,14,20,.6); border-color: rgba(127,220,255,.35); color: #bfeeff; letter-spacing: .03em; }
#skipIntro:hover, #songMute:hover { background: rgba(20,40,60,.8); border-color: rgba(127,220,255,.7); }
/* Ton für den Intro-Song: runder Button rechts neben „Intro überspringen“, bleibt bis zum Ende des Songs */
#songMute { position: fixed; right: calc(18px + var(--sar)); bottom: calc(18px + var(--sab)); z-index: 50; width: 38px; height: 38px; padding: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10,14,20,.6); border-color: rgba(127,220,255,.35); color: #bfeeff; }
#songMute svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
#songMute .muted, #songMute.off .waves { display: none; }
#songMute.off .muted { display: inline; }
/* Hauptmenü ohne Kasten: die Elemente stehen frei, dahinter ein großer, sehr schwacher Schatten */
.modal .panel.start { position: relative; max-width: 500px; padding: 30px 30px 24px; background: none; border: 0; box-shadow: none;
  backdrop-filter: none; -webkit-backdrop-filter: none; }
/* Ein gemeinsamer Hintergrund für Haupt- und Untermenüs (Abdunklung und großer, weicher Schatten hinter dem
   Menü), fest am Bildschirm: bleibt beim Wechsel zwischen den Menüs unverändert stehen. Sichtbar, solange eines der
   Menüs offen ist (das Hauptmenü erst nach dem Intro); die Menüs selbst bleiben durchsichtig */
.modal:has(> .panel.start) { background: none; }
#menuBackdrop { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity .4s ease;
  background: radial-gradient(ellipse at 50% 40%, rgba(40,28,16,.3), rgba(10,7,5,.72)); }
/* Der Schatten ist ein fein abgestufter Verlauf, der genau wie der frühere weichgezeichnete aussieht (gemessen am
   Verlauf .55 → .28 bei 55 % → 0 mit blur(36px)): ohne filter: blur, der auf dem iPhone beim Erscheinen des Menüs
   eine riesige Fläche weichzeichnen musste (Ruckler, Knacken in der Musik) */
#menuBackdrop::before { content: ""; position: absolute; left: 50%; top: 50%; width: 1200px; height: 1340px; transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(8, 6, 4, .514), rgba(8, 6, 4, .494) 10%, rgba(8, 6, 4, .447) 20%,
    rgba(8, 6, 4, .4) 30%, rgba(8, 6, 4, .353) 40%, rgba(8, 6, 4, .302) 50%, rgba(8, 6, 4, .247) 60%, rgba(8, 6, 4, .188) 70%,
    rgba(8, 6, 4, .125) 80%, rgba(8, 6, 4, .067) 90%, rgba(8, 6, 4, .035) 95%, transparent); }
body:has(#menu:not(.hidden):not(.intro-wait), #playMenu:not(.hidden), #trainingMenu:not(.hidden), #challengeMenu:not(.hidden)) #menuBackdrop { opacity: 1; }
/* Große Bildschirme: Haupt- und Untermenüs links, damit vom Vorspann mehr zu sehen ist; Abdunklung und Schatten
   liegen dann nur links hinter dem Menü */
@media (min-width: 1100px) and (min-height: 600px) {
  .modal .panel.start { margin: auto auto auto max(56px, 6vw); }
  #menuBackdrop { background: linear-gradient(90deg, rgba(10,7,5,.78) 0, rgba(10,7,5,.6) 32%, rgba(10,7,5,.18) 58%, rgba(10,7,5,0) 78%); }
  #menuBackdrop::before { left: calc(max(56px, 6vw) + 250px); width: 900px; }
}
.brand { display: flex; align-items: center; gap: 18px; margin-bottom: 24px; }
.brand > div { display: flex; flex-direction: column; }
/* Kleine Zeile über dem Titel, Titel groß, Unterzeile darunter */
.brand .tagline { order: -1; margin: 0 0 4px; font-family: var(--display); font-style: italic; font-weight: 700; font-size: 13.6px;
  letter-spacing: .32em; text-transform: uppercase; color: var(--accent); }
.brand h1 { margin: 0; font-size: 60px; line-height: .9; color: #fff; text-shadow: 0 4px 18px rgba(0,0,0,.35); }
.brand .sub { margin: 10px 0 0; font-size: 14px; line-height: 1.5; }
/* Spielmodi als breite Zeilen: Titel links, Beschreibung rechts */
.modes { display: flex; flex-direction: column; gap: 10px; margin-bottom: 20px; }
.mode { display: flex; align-items: baseline; gap: 12px; padding: 14px 18px; border-radius: var(--radius);
  background: var(--btn); border: 1px solid var(--line); text-align: left; }
.mode:hover:not(:disabled) { background: var(--btn-hover); transform: translateX(4px); }
.mode.on { background: rgba(255,181,71,.12); border-color: var(--accent); }
/* Schnellstart oben im Hauptmenü: Amber wie die Hauptaktionen */
.mode.quick { background: var(--accent); border-color: var(--accent); }
.mode.quick:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.mode.quick .mode-title { color: var(--accent-ink); }
.mode.quick .mode-desc { color: rgba(26, 18, 8, .72); }
.mode-title { flex: none; font-size: 28px; line-height: 1; color: #fff; white-space: nowrap; }
/* Nebentext einzeilig, zu lang: mit Auslassungspunkten gekürzt */
.mode-desc { flex: 1 1 auto; min-width: 0; margin-left: auto; font-size: 12.8px; color: var(--muted); text-align: right;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.field-label { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .16em; text-transform: uppercase; }
.names { display: flex; gap: 10px; }
.names .field { flex: 1; min-width: 0; }
@keyframes reveal { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
#start { width: 100%; padding: 18px 22px; font-size: 32px; line-height: 1; border-radius: var(--radius); margin-top: 6px; text-align: left; }
.btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.btns button { flex: 1; padding: 14px 18px; font-size: 22px; line-height: 1; border-radius: var(--radius); }
.sub { color: var(--muted); }
/* Wechsel zwischen Hauptmenü und Untermenüs (switchMenu in hud.js): leicht seitlich gleiten und blenden. Die
   Strecke richtet sich nach der Breite (auf dem Handy wären 48 px ein Achtel des Bildschirms); das alte Menü fährt
   sanft an (eigene Keyframes mit ease-in statt rückwärts abgespielt, das wäre am Anfang am schnellsten) */
:root { --menu-shift: 48px; }
.modal.menu-in-right, .modal.menu-in-left { animation: dialog-fade .32s ease-out; overflow: hidden; }
.modal.menu-in-right > .panel { animation: menu-from-right .32s cubic-bezier(.2, .8, .3, 1); }
.modal.menu-in-left > .panel { animation: menu-from-left .32s cubic-bezier(.2, .8, .3, 1); }
.modal.menu-out-left, .modal.menu-out-right { pointer-events: none; overflow: hidden; animation: menu-fade-out .26s ease-out forwards; }
.modal.menu-out-left > .panel { animation: menu-to-left .26s ease-out forwards; }
.modal.menu-out-right > .panel { animation: menu-to-right .26s ease-out forwards; }
@keyframes menu-from-right { from { transform: translateX(var(--menu-shift)); } to { transform: none; } }
@keyframes menu-from-left { from { transform: translateX(calc(-1 * var(--menu-shift))); } to { transform: none; } }
@keyframes menu-to-left { from { transform: none; } to { transform: translateX(calc(-1 * var(--menu-shift))); } }
@keyframes menu-to-right { from { transform: none; } to { transform: translateX(var(--menu-shift)); } }
/* Eigene Keyframes statt dialog-fade rückwärts: reverse spiegelt auch die Kurve (aus ease-out würde ease-in), das
   Ausblenden liefe dann gegen das Gleiten – lange voll sichtbar, am Ende abrupt weg */
@keyframes menu-fade-out { from { opacity: 1; } to { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .modal[class*="menu-"], .modal[class*="menu-"] > .panel { animation-duration: .01s !important; } }

/* Gespeicherte Situationen im Trainingsmenü: Zeile zum Spielen, daneben Bearbeiten und Löschen */
.saved-head { margin: 4px 0 -2px; }
.saved-row { display: flex; gap: 6px; align-items: stretch; }
.saved-row .mode { flex: 1; min-width: 0; }
/* Kompakt: nur der Name (Beschreibung als Tooltip), etwas kleiner als die Spielmodi, zu lang mit Auslassungspunkten */
.saved-row .mode { padding: 10px 16px; }
.saved-row .mode-title { max-width: 100%; overflow: hidden; text-overflow: ellipsis; font-size: 21px; }
.saved-row .icon-btn { width: 46px; height: auto; border-radius: var(--radius); background: var(--btn); }
.saved-row .icon-btn.del:hover:not(:disabled) { border-color: rgba(217,72,59,.7); }

/* Challenges im Menü: Name und Aufgabe links, Status rechts (gelöst in Amber); eigene mit Kopieren und Löschen */
.mode.challenge { align-items: center; }
.ch-text { display: flex; flex-direction: column; gap: 5px; min-width: 0; flex: 1 1 auto; }
.ch-text .mode-title { overflow: hidden; text-overflow: ellipsis; }
.ch-task { font-size: 12.8px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-status { flex: none; display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--muted); text-align: right; white-space: nowrap; }
.ch-status b { font-weight: 600; }
.ch-status small { font-size: 11.5px; }
.ch-status small:empty { display: none; }
.ch-status.solved b { color: var(--accent); }
.saved-row .mode.challenge { padding: 12px 16px; }
.saved-row .icon-btn.copy svg { width: 18px; height: 18px; }

/* Punkte für die Szenen des Vorspanns unten mittig, wie bei einer Bilderschau: nur auf dem Desktop und solange
   ein Menü offen ist (nicht während des Intros) */
/* über den Menüs (die reichen über die ganze Fläche), ausgeblendet, solange ein Fenster oder Dialog offen ist */
#sceneDots { position: fixed; left: 50%; bottom: calc(18px + var(--sab)); transform: translateX(-50%); z-index: 41; display: none; gap: 2px; }
body:has(#menu:not(.hidden):not(.intro-wait), #playMenu:not(.hidden), #trainingMenu:not(.hidden), #challengeMenu:not(.hidden)) #sceneDots { display: flex; }
body.dialog-open #sceneDots, body:has(#overlay:not(.hidden)) #sceneDots { display: none !important; }
@media (max-width: 760px), (hover: none), (pointer: coarse) { #sceneDots { display: none !important; } }
#sceneDots button { width: 15px; height: 20px; padding: 0; background: none; border: 0; border-radius: 50%; }
#sceneDots button::before { content: ""; display: block; width: 7px; height: 7px; margin: auto; border-radius: 50%;
  background: #fff; opacity: .35; transition: opacity .2s, transform .2s; }
#sceneDots button:hover:not(:disabled) { background: none; }
#sceneDots button:hover::before { opacity: .7; }
#sceneDots button[aria-current="true"]::before { opacity: 1; transform: scale(1.25); }
/* Untermenüs: kleiner Zurück-Button in Amber über dem Titel */
.back-top { display: inline-flex; align-items: center; gap: 2px; margin-bottom: 18px; padding: 6px 12px 6px 6px; border-radius: 999px;
  background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-family: var(--display); font-style: italic;
  font-weight: 800; font-size: 15px; line-height: 1; letter-spacing: .06em; text-transform: uppercase; }
.back-top:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); }
.back-top svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* Kleine Bildschirme: Startbildschirm kompakt, Modi als flache Zeilen */
@media (max-width: 520px), (max-height: 760px) {
  .modal { padding: calc(10px + var(--sat)) calc(10px + var(--sar)) calc(10px + var(--sab)) calc(10px + var(--sal)); }
  .modal .panel.start { padding: 20px 20px 16px; }
  .brand { gap: 14px; margin-bottom: 16px; }
  .brand h1 { font-size: 44px; }
  .brand .tagline { font-size: 11px; letter-spacing: .26em; }
  .brand .sub { font-size: 12.5px; margin-top: 6px; }
  .modes { gap: 8px; margin-bottom: 14px; }
  .mode { padding: 11px 14px; }
  .mode-title { font-size: 22px; }
  .mode-desc { font-size: 12px; }
  .saved-row .mode { padding: 8px 14px; }
  /* Challenges: Status darf umbrechen, damit die Aufgabe lesbar bleibt */
  .ch-status { flex: 0 1 auto; max-width: 36%; white-space: normal; }
  .saved-row .mode-title { font-size: 18px; }
  .field { gap: 6px; margin-bottom: 12px; }
  .seg button { padding: 9px 8px; font-size: 17px; }
  .modal input { padding: 10px 12px; }
  #start { padding: 14px 18px; font-size: 26px; }
}
@media (max-height: 640px) { .brand .sub { display: none; } }
