/* Erzeugt von scripts/build-edition.mjs aus editions/grundschule/ – nicht von Hand bearbeiten. */
/* Math Cup Grundschule · helles, kindgerechtes Theme über dem gemeinsamen Motor.
   @{schlüssel} ersetzt build-edition.mjs durch den Pfad aus edition.json → extraImages. */

/* Tipps: die Zahleneule überlegt mit */
body.edition-grundschule .math-hint:not([hidden]) {
  padding-left: 76px;
  position: relative;
}

body.edition-grundschule .math-hint:not([hidden])::before {
  content: "";
  position: absolute;
  left: 8px;
  bottom: 4px;
  width: 64px;
  height: 64px;
  background: url("assets/kids/begleiter/kids_guide_eule_ueberlegt.png") center / contain no-repeat;
  pointer-events: none;
}

/* Aufgabenkarte: so groß wie die Aufgabe statt Balken über das halbe Feld.
   Halbtransparent, damit Stadion und Zuschauer sichtbar bleiben; Level nur als Randfarbe. */
body.edition-grundschule .field .word-display,
body.edition-grundschule .field .word-display.answer-visible,
body.edition-grundschule.level-challenge .field .word-display,
body.edition-grundschule.level-elite .field .word-display,
body.edition-grundschule.possession-rush-active .field .word-display {
  /* Feste Maße: die Schriftanpassung (fitPromptText) braucht einen Kasten mit Spielraum.
     Etwa halbe Feldbreite statt 84 %, damit Tore und Zuschauer sichtbar bleiben. */
  width: min(56%, 700px);
  height: clamp(124px, 26%, 180px);
  padding: 30px clamp(24px, 2.6vw, 40px) 14px;
  border: 3px solid rgba(255, 255, 255, 0.55);
  border-radius: 26px;
  background: rgba(14, 42, 58, 0.5);
  -webkit-backdrop-filter: blur(6px) saturate(1.1);
  backdrop-filter: blur(6px) saturate(1.1);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

body.edition-grundschule.level-challenge .field .word-display { border-color: rgba(255, 196, 70, 0.85); }
body.edition-grundschule.level-elite .field .word-display { border-color: rgba(255, 96, 110, 0.85); }
body.edition-grundschule .field .word-display.answer-visible { background: rgba(40, 52, 20, 0.55); border-color: rgba(255, 226, 120, 0.9); }

body.edition-grundschule .field .word-display::before { opacity: 0.35; border-radius: 23px; }

body.edition-grundschule .field .word-display strong {
  font-size: clamp(52px, 6vw, 110px);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), 0 0 18px rgba(0, 0, 0, 0.25);
}

body.edition-grundschule .mc-visual text {
  text-shadow: none;
  -webkit-text-stroke: 0;
}

body.edition-grundschule .penalty-prompt-card strong.mc-task:not(.mc-task-visual) {
  font-size: clamp(28px, 3.75vw, 48px);
}

/* Steuerleiste: „Nächste Aufgabe“ groß in der Mitte, damit man sie sofort trifft.
   Links: Andere Aufgabe, Lösung, Tipp · rechts: Einstellungen, Rückgängig, Neustart. */
body.edition-grundschule .controls .middle-panel {
  grid-template-columns: 1fr 1.3fr 1fr;
  grid-auto-rows: minmax(0, auto);
  grid-auto-flow: row dense;
  align-items: stretch;
  gap: 5px;
}

body.edition-grundschule .controls .middle-panel > .tool {
  grid-column: 1;
  grid-row: auto;
  min-height: 0;
  padding: 4px 8px;
  font-size: clamp(10px, 0.8vw, 12px);
  line-height: 1.15;
}

body.edition-grundschule .controls .middle-panel > [data-action="edit-prompts"],
body.edition-grundschule .controls .middle-panel > [data-action="undo"],
body.edition-grundschule .controls .middle-panel > [data-action="reset"] {
  grid-column: 3;
}

body.edition-grundschule .controls .middle-panel > [data-action="next-round"] {
  grid-column: 2;
  grid-row: 1 / span 3;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: clamp(15px, 1.35vw, 21px);
  line-height: 1.1;
}

/* Keine Meta-Angaben („Normal 2“) auf der Aufgabenkarte – die Kinder sehen nur die Aufgabe. */
body.edition-grundschule #mathTaskBadge { display: none !important; }

/* Aufgabennummer für die Lehrkraft (passt zur Zeile auf dem Lösungsblatt): im Duel Mode klein auf dem
   Knopf „Lösung zeigen“, in Possession Rush (ohne diesen Knopf) klein und blass unten rechts in der Karte
   (die Karte schneidet Überstehendes ab, ihr Glanzlicht läuft über den Rand). */
body.edition-grundschule .math-task-number:not([hidden]) {
  display: block;
  margin-top: 2px;
  font-size: 0.85em;
  font-weight: 800;
  color: var(--mc-gold, #f7d84a);
  opacity: 0.9;
  white-space: nowrap;
}

body.edition-grundschule.possession-rush-active .field .word-display #mathTaskBadge:not([hidden]) {
  display: block !important;
  top: auto;
  left: auto;
  bottom: 6px;
  right: 10px;
  font-size: 11px;
  padding: 1px 8px;
  opacity: 0.75;
  white-space: nowrap;
}
body.edition-grundschule .field .word-display { padding-top: 16px; }

/* Setup Grundschule: feste Teamfarben und Standards, weniger Stellschrauben. */
body.edition-grundschule #setup .team-name-settings .color-setting,
body.edition-grundschule #setup .season-color-field,
body.edition-grundschule #setup .countdown-length-setting:has(#countdownLengthSelect),
body.edition-grundschule #setup .pressure-advanced,
body.edition-grundschule #setup .quick-possession-rush-advanced,
body.edition-grundschule #setup .setup-section-title:has(+ .timer-helper + .shot-animation-settings),
body.edition-grundschule #setup .timer-helper:has(+ .shot-animation-settings),
body.edition-grundschule #setup .shot-animation-settings {
  display: none !important;
}

@media (min-width: 761px) {
  body.edition-grundschule #setup .team-name-settings {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Steuerleiste Grundschule: normale Schreibweise, breitere Mitte, Knöpfe mindestens 32 px hoch. */
body.edition-grundschule .controls .middle-panel {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr);
}

body.edition-grundschule .controls .middle-panel > .tool {
  min-height: 32px;
  text-transform: none;
  letter-spacing: 0;
  font-size: clamp(11px, 0.95vw, 13px);
}

body.edition-grundschule .controls .middle-panel > [data-action="next-round"] {
  font-size: clamp(16px, 1.45vw, 22px);
  text-transform: none;
  letter-spacing: 0;
}

/* Mit Tipp-Knopf (ab Klasse 2): Das Zwölfer-Raster aus math-hints.css würde „Nächste Aufgabe“ in eine
   schmale Spalte drücken. In der Grundschul-Edition bleiben drei Spalten: links Andere Aufgabe,
   Lösung zeigen, Tipp; Mitte „Nächste Aufgabe“ über alle Zeilen; rechts Einstellungen, Rückgängig, Neustart. */
@media (min-width: 981px) and (min-height: 501px) {
  body.edition-grundschule:not(.possession-rush-active) .controls .middle-panel:has(> .math-hint-tool:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr);
  }

  body.edition-grundschule:not(.possession-rush-active) .controls .middle-panel:has(> .math-hint-tool:not([hidden])) > .tool,
  body.edition-grundschule:not(.possession-rush-active) .controls .middle-panel:has(> .math-hint-tool:not([hidden])) > .math-hint-tool {
    grid-column: 1;
  }

  body.edition-grundschule:not(.possession-rush-active) .controls .middle-panel:has(> .math-hint-tool:not([hidden])) > [data-action="edit-prompts"],
  body.edition-grundschule:not(.possession-rush-active) .controls .middle-panel:has(> .math-hint-tool:not([hidden])) > [data-action="undo"],
  body.edition-grundschule:not(.possession-rush-active) .controls .middle-panel:has(> .math-hint-tool:not([hidden])) > [data-action="reset"] {
    grid-column: 3;
  }

  body.edition-grundschule:not(.possession-rush-active) .controls .middle-panel:has(> .math-hint-tool:not([hidden])) > [data-action="next-round"] {
    grid-column: 2;
    grid-row: 1 / span 3;
  }
}

/* Rechenaufgaben stehen immer in einer Zeile wie im Heft (Rückmeldung 27.09.2026, Klasse 4:
   „□ + 420.000 = 510.000“ brach um). Passt die Zeile nicht, verkleinert fitPromptText die Schrift. */
body.edition-grundschule .word-display strong.mc-task:not(.mc-task-visual),
body.edition-grundschule .penalty-prompt-card strong.mc-task:not(.mc-task-visual) {
  flex-wrap: nowrap;
}

/* Math Cup 1.1.5: Bildkarten brauchen lesbare Auswahlwörter und Uhrziffern.
   #field überstimmt auch die gemeinsame Stadion- und Rush-Geometrie. */
body.edition-grundschule #field.field .word-display:has(strong.mc-task-visual) {
  top: 7%;
  width: min(74%, 860px);
  height: 43.5%;
  max-height: 250px;
  padding: 4px 12px;
  border: 0;
  background: transparent;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  box-shadow: none;
}

body.edition-grundschule #field.field .word-display.answer-visible:has(strong.mc-task-visual) {
  padding-top: 36px;
}

body.edition-grundschule .field .word-display:has(strong.mc-task-visual)::before {
  display: none;
}

body.edition-grundschule .word-display strong.mc-task-visual .mc-visual-wrap svg {
  max-height: 100%;
  filter: drop-shadow(0 10px 22px rgba(0, 0, 0, 0.3));
}

body.edition-grundschule .word-display.answer-visible strong.mc-task-visual .mc-visual-wrap svg {
  max-height: 100%;
}

/* Lebendige Zuschauer (Code-Lösung): Die vordere Reihe wippt, jubelt bei richtigen Antworten
   und springt bei Toren. Statt der langsamen Kamerafahrt, damit Bild und Reihe deckungsgleich bleiben. */
body.edition-grundschule.fx-ready .field-bg-image {
  animation: none;
}

body.edition-grundschule .field-bg .crowd-band {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, transparent 76%, #000 81%);
  mask-image: linear-gradient(to bottom, transparent 0, transparent 76%, #000 81%);
  transform-origin: 50% 100%;
  animation: crowdBob 2.6s ease-in-out infinite;
}

body.edition-grundschule .field-bg.crowd-cheer .crowd-band {
  animation: crowdCheer 0.8s ease-out 1;
}

body.edition-grundschule .field-bg.crowd-jump .crowd-band {
  animation: crowdJump 1.5s ease-out 1;
}

@keyframes crowdBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

@keyframes crowdCheer {
  0% { transform: translateY(0); }
  35% { transform: translateY(-7px); }
  100% { transform: translateY(0); }
}

@keyframes crowdJump {
  0% { transform: translateY(0); }
  14% { transform: translateY(-12px); }
  28% { transform: translateY(0); }
  44% { transform: translateY(-9px); }
  58% { transform: translateY(0); }
  74% { transform: translateY(-5px); }
  100% { transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  body.edition-grundschule .field-bg .crowd-band { animation: none !important; }
}

body.edition-grundschule.performance-mode .field-bg .crowd-band {
  animation: none !important;
}

/* Possession Rush (Nachbesserung 29.09.2026): dieselbe flache Leiste wie im Duel Mode, damit das
   Spielfeld nicht schrumpft. Team links/rechts mit Namen seitlich, in der Mitte links Elfmeter und Tipp,
   groß in der Mitte Pause, rechts Einstellungen, Rückgängig, Neustart. */
@media (min-width: 760px) and (orientation: landscape) {
  body.edition-grundschule.possession-rush-active .controls {
    gap: clamp(8px, 0.8vw, 12px);
    padding: 6px;
    border-color: rgba(255, 255, 255, 0.09);
    background: linear-gradient(180deg, rgba(10, 26, 44, 0.6), rgba(3, 10, 20, 0.46));
    backdrop-filter: blur(10px) saturate(1.12);
  }

  body.edition-grundschule.possession-rush-active .controls .action-panel {
    grid-template-columns: minmax(28px, auto) minmax(0, 1fr) minmax(0, 1fr);
    grid-template-rows: auto;
    align-items: stretch;
    gap: clamp(5px, 0.6vw, 8px);
    padding: clamp(4px, 0.6dvh, 7px);
  }

  body.edition-grundschule.possession-rush-active .controls .action-panel:last-child {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(28px, auto);
  }

  body.edition-grundschule.possession-rush-active .controls .action-panel > .action-title {
    grid-column: 1;
    grid-row: 1;
    align-self: center;
    min-height: 0;
    height: auto;
    max-width: 96px;
    padding-inline: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 11px;
  }

  body.edition-grundschule.possession-rush-active .controls .action-panel > [data-action^="score-"] { grid-column: 2; grid-row: 1; }
  body.edition-grundschule.possession-rush-active .controls .action-panel > [data-action^="penalty-"] { grid-column: 3; grid-row: 1; }
  body.edition-grundschule.possession-rush-active .controls .action-panel:last-child > .action-title { grid-column: 3; }
  body.edition-grundschule.possession-rush-active .controls .action-panel:last-child > [data-action^="score-"] { grid-column: 1; }
  body.edition-grundschule.possession-rush-active .controls .action-panel:last-child > [data-action^="penalty-"] { grid-column: 2; }

  body.edition-grundschule.possession-rush-active .controls .action {
    height: auto;
    min-height: clamp(44px, 6.6dvh, 58px);
  }

  body.edition-grundschule.possession-rush-active .controls .middle-panel,
  body.edition-grundschule.possession-rush-active .controls .middle-panel:has(> .math-hint-tool:not([hidden])) {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) minmax(0, 1fr);
    grid-template-rows: repeat(3, minmax(32px, auto));
    grid-auto-flow: row;
    gap: 5px;
  }

  body.edition-grundschule.possession-rush-active .controls .middle-panel > .tool {
    min-height: 32px;
    padding: 4px 8px;
    white-space: nowrap;
  }

  body.edition-grundschule.possession-rush-active .controls .middle-panel > [data-action="possession-penalty"] {
    grid-column: 1 !important;
    grid-row: 1 / span 2;
    font-size: clamp(13px, 1.1vw, 16px);
  }

  body.edition-grundschule.possession-rush-active .controls .middle-panel:not(:has(> .math-hint-tool:not([hidden]))) > [data-action="possession-penalty"] {
    grid-row: 1 / span 3;
  }

  body.edition-grundschule.possession-rush-active .controls .middle-panel > .math-hint-tool {
    grid-column: 1 !important;
    grid-row: 3;
  }

  body.edition-grundschule.possession-rush-active .controls .middle-panel > [data-action="possession-pause"] {
    grid-column: 2 !important;
    grid-row: 1 / span 3;
    border-radius: 14px;
    font-size: clamp(16px, 1.45vw, 22px);
  }

  body.edition-grundschule.possession-rush-active .controls .middle-panel > [data-action="edit-prompts"] { grid-column: 3 !important; grid-row: 1; }
  body.edition-grundschule.possession-rush-active .controls .middle-panel > [data-action="undo"] { grid-column: 3 !important; grid-row: 2; }
  body.edition-grundschule.possession-rush-active .controls .middle-panel > [data-action="reset"] { grid-column: 3 !important; grid-row: 3; }
}

/* PowerShot-Leiste, Team Assist und Comeback-Zeichen über der vorderen Tierreihe statt auf ihr:
   Die Reihe belegt die unteren 24 % des Spielfelds (Maske der crowd-band). */
body.edition-grundschule.possession-rush-active #field .possession-powershot-meters {
  bottom: 25% !important;
}

/* Rand um das Spielfeld (Nachbesserung 29.09.2026): dasselbe Stadionbild wie auf dem Feld, groß,
   weich und etwas dunkler. So passt der Rand zu jeder Arena und Stufe, ohne eigene Randbilder. */
body.edition-grundschule,
body.edition-grundschule.level-challenge,
body.edition-grundschule.level-elite {
  background:
    radial-gradient(ellipse at 50% 45%, transparent 38%, rgba(2, 8, 16, 0.5) 100%),
    linear-gradient(180deg, rgba(3, 13, 24, 0.08), rgba(2, 8, 16, 0.32));
}

html:has(body.edition-grundschule) {
  background: #06121f;
}

body.edition-grundschule::after {
  content: "";
  position: fixed;
  inset: -48px;
  z-index: -2;
  pointer-events: none;
  background: var(--arena-backdrop-image, var(--gameplay-outer-background)) center / cover no-repeat;
  filter: blur(16px) brightness(0.62) saturate(1.12);
  transition: background-image 520ms ease;
}

body.edition-grundschule.level-challenge::after { filter: blur(16px) brightness(0.58) saturate(1.18) sepia(0.12); }
body.edition-grundschule.level-elite::after { filter: blur(16px) brightness(0.52) saturate(1.2); }

body.edition-grundschule.performance-mode::after {
  filter: brightness(0.5);
}

/* Possession Rush: „Normales Spiel“ in normaler Schreibweise statt klein geschrieben. */
body.edition-grundschule.possession-rush-active .round-timer-status {
  text-transform: none;
  font-size: clamp(0.62rem, 0.66vw, 0.74rem);
}

/* Ergebnis (Game-Design-Test V19/V20): Weiter-Knopf groß genug für Finger und letzte Reihe,
   Karte passt ohne inneren Scrollbalken ins Bild, kein waagrechter Scrollbalken durch Konfetti. */
body.edition-grundschule .result-screen {
  /* Waagrecht nichts (Konfetti), senkrecht notfalls scrollen: Mit Season-Block kann die Karte höher
     als das Bild werden (Season-Test 29.09.2026, 1280 × 720). „safe“ hält den Kartenkopf sichtbar. */
  overflow-x: hidden;
  overflow-y: auto;
  place-items: safe center;
}

body.edition-grundschule .result-card {
  max-height: calc(100dvh - 24px);
}

body.edition-grundschule .result-card #resultContinue {
  min-height: 56px;
  padding: 0 28px;
  font-size: clamp(16px, 1.3vw, 20px);
}

body.edition-grundschule .result-card .full-cup-trophy,
body.edition-grundschule .result-card .mode-result-trophy {
  max-height: 26vh;
  width: auto;
}

/* Game-Design-Test V32/V33: kein waagrechter Scrollbalken im Elfmeter-Dialog; Spielstand des Teams ohne Ball
   bleibt lesbar (nur die Knöpfe werden gedimmt). */
body.edition-grundschule .penalty-card {
  overflow-x: hidden;
}

body.edition-grundschule.possession-rush-active .scoreboard .team-card.possession-inactive {
  opacity: 0.82;
  filter: saturate(0.75);
}

/* Season Hub (Game-Design-Test D2): Wappen über dem Teamnamen statt darauf; Karte „Zur Siegerehrung“ mit Pokal. */
body.edition-grundschule .season-full-team-badge.season-image-badge img {
  width: 100%;
  height: 100%;
}

body.edition-grundschule .season-full-team-identity {
  gap: 14px;
}

body.edition-grundschule .season-ceremony-entry-card {
  position: relative;
  overflow: hidden;
}

body.edition-grundschule .season-ceremony-entry-card::after {
  content: "";
  position: absolute;
  inset: 60% 22% 5%;
  background: url("assets/kids/pokale/kids_trophy_full_cup.png") center / contain no-repeat;
  filter: drop-shadow(0 12px 24px rgba(0, 0, 0, 0.35));
  pointer-events: none;
}

/* Possession Rush (Game-Design-Test V25): Symbole beschriftet (Namen bleiben englisch, Nutzerentscheidung 29.09.2026). */
body.edition-grundschule.possession-rush-active #field .possession-powershot-meter,
body.edition-grundschule.possession-rush-active #field .possession-underdog-emblem,
body.edition-grundschule.possession-rush-active #field .possession-team-assist {
  position: relative;
  overflow: visible;
}

body.edition-grundschule.possession-rush-active #field .possession-powershot-meter::after,
body.edition-grundschule.possession-rush-active #field .possession-underdog-emblem::after,
body.edition-grundschule.possession-rush-active #field .possession-team-assist::after {
  position: absolute;
  left: 50%;
  top: calc(100% + 2px);
  transform: translateX(-50%);
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(4, 14, 26, 0.72);
  color: #fff;
  font-size: clamp(10px, 0.85vw, 13px);
  font-weight: 900;
  white-space: nowrap;
  pointer-events: none;
}

body.edition-grundschule.possession-rush-active #field .possession-powershot-meter::after { content: "PowerShot"; }
body.edition-grundschule.possession-rush-active #field .possession-underdog-emblem::after { content: "Underdog Boost"; }
body.edition-grundschule.possession-rush-active #field .possession-team-assist::after { content: "Team Assist"; }

/* Duel Mode mit Pause (V11): „Nächste Aufgabe“ über zwei Zeilen, darunter „Pause“. */
body.edition-grundschule:not(.possession-rush-active) .controls .middle-panel > [data-action="next-round"] {
  grid-row: 1 / span 2 !important;
}

body.edition-grundschule:not(.possession-rush-active) .controls .middle-panel > [data-action="possession-pause"]:not([hidden]) {
  grid-column: 2 !important;
  grid-row: 3;
}

/* Ergebnis auf niedrigen Bildschirmen (Reel-Prüfung P1: bei 1280 × 720 ragte „Weiter“ aus dem Bild):
   die ganze Karte gleichmäßig verkleinern statt einzelne Teile zu beschneiden. */
@media (max-height: 820px) {
  body.edition-grundschule .result-card {
    zoom: 0.86;
    max-height: none;
  }
}

@media (max-height: 680px) {
  body.edition-grundschule .result-card {
    zoom: 0.74;
  }
}

/* Ergebnis mit Season-Block („Ergebnis in die Season übernehmen“): stärker verkleinern
   (Nachtest 29.09.2026: bei 1366 × 768 lagen die Knöpfe unter dem Bildrand). */
@media (max-height: 900px) {
  body.edition-grundschule .result-card:has(#seasonResultConfirmation) {
    zoom: 0.7;
  }
}

@media (max-height: 800px) {
  body.edition-grundschule .result-card:has(#seasonResultConfirmation) {
    zoom: 0.6;
  }
}

/* Keine Karte mit eigenem Scrollbereich: Sonst fängt sie das Mausrad ab, obwohl sie gar nicht scrollt.
   Gescrollt wird, wenn überhaupt, der ganze Ergebnisbildschirm. */
body.edition-grundschule .result-card,
body.edition-grundschule .result-card.final-result {
  max-height: none;
  overflow: visible;
  overscroll-behavior: auto;
}

.field .ball.ball-style-mathe { --ball-image: url("assets/kids/baelle/kids_ball_mathe.png"); }
.ball-style-preview-mathe { --ball-preview-image: url("assets/kids/baelle/kids_ball_mathe.png"); }
.field .ball.ball-style-stars { --ball-image: url("assets/kids/baelle/kids_ball_stars.png"); }
.ball-style-preview-stars { --ball-preview-image: url("assets/kids/baelle/kids_ball_stars.png"); }
.field .ball.ball-style-dots { --ball-image: url("assets/kids/baelle/kids_ball_dots.png"); }
.ball-style-preview-dots { --ball-preview-image: url("assets/kids/baelle/kids_ball_dots.png"); }
