/* Mathe-Koppel: Himmel, Wiese, Holzschilder. Bewusst ein helles Tag-Design (kein Dark Mode). */
:root {
  --himmel: #8fd3ff;
  --himmel-hell: #dff3ff;
  --wiese: #7cc35a;
  --wiese-dunkel: #4f9a3a;
  --holz: #b07a43;
  --holz-dunkel: #74491f;
  --papier: #fffaf0;
  --text: #2d3a26;
  --leise: #6b7563;
  --orange: #ee8a2a;
  --orange-dunkel: #b65f12;
  --rot: #d9483b;
  --gruen: #33994a;
  --gold: #eaa531;
  --silber: #a9b8c2;
  --marker: rgba(255, 214, 10, 0.75);
  --schrift: "Fredoka", "Nunito", "Segoe UI", system-ui, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { background: var(--himmel); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--schrift);
  font-size: 18px;
  line-height: 1.4;
  color: var(--text);
  background: linear-gradient(var(--himmel) 0, var(--himmel-hell) 70vh, var(--himmel-hell));
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: max(14px, env(safe-area-inset-top, 0px)) 170px;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--orange-dunkel); outline-offset: 3px; }

/* ---------- Landschaft im Hintergrund ---------- */
.landschaft { position: fixed; inset: auto 0 0 0; height: 170px; z-index: 0; pointer-events: none; }
.landschaft svg { width: 100%; height: 100%; display: block; }
.wolke { position: fixed; z-index: 0; pointer-events: none; opacity: .9; }
.wolke.w1 { top: 6vh; left: -10%; width: 160px; animation: ziehen 70s linear infinite; }
.wolke.w2 { top: 18vh; left: -20%; width: 110px; animation: ziehen 95s linear infinite -40s; }
@keyframes ziehen { to { transform: translateX(130vw); } }

#app { position: relative; z-index: 1; max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

/* ---------- Holzschild ---------- */
.schild {
  background: var(--papier);
  border: 4px solid var(--holz);
  border-radius: 22px;
  box-shadow: 0 6px 0 var(--holz-dunkel), 0 14px 30px rgba(40, 70, 30, .18);
  padding: 20px;
}
.schild h2 { margin: 0 0 4px; font-size: 26px; }
.schild .info { margin: 0 0 16px; color: var(--leise); }

/* ---------- Startseite ---------- */
.titel { display: flex; align-items: center; gap: 14px; padding: 6px 4px 2px; }
.titel > div:not(.wer) { flex: 1; min-width: 0; }
.titel h1 { margin: 0; font-size: clamp(34px, 7vw, 52px); line-height: 1; color: #fff; text-shadow: 0 3px 0 var(--holz-dunkel), 0 6px 14px rgba(0,0,0,.18); }
.titel p { margin: 4px 0 0; font-weight: 600; color: var(--holz-dunkel); }
.titel .hufeisen.gross { width: 64px; height: 64px; flex: none; transform: rotate(-12deg); }
.titel .wer { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-weight: 600; color: var(--holz-dunkel); }
.titel .wer button, .titel .wer a { background: none; border: 0; padding: 0; color: var(--holz-dunkel); text-decoration: underline; font-size: 15px; }
@media (max-width: 520px) {
  .titel { flex-wrap: wrap; }
  .titel .wer { margin-left: 0; width: 100%; flex-direction: row; align-items: center; gap: 12px; }
}

.uebungen { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (min-width: 900px) { .uebungen { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 440px) { .uebungen { grid-template-columns: 1fr; } }
.uebung {
  text-align: left; background: #fff; border: 3px solid #ecdcc3; border-radius: 16px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 4px; color: var(--text);
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.uebung strong { font-size: 21px; }
.uebung span { color: var(--leise); font-size: 15px; }
.uebung .stand { margin-top: 6px; display: flex; align-items: center; gap: 6px; font-size: 14px; color: var(--holz-dunkel); font-weight: 600; }
.uebung .stand .hufeisen { width: 18px; height: 18px; }
.uebung:hover { transform: translateY(-3px); border-color: var(--orange); box-shadow: 0 6px 0 #f3d9b8; }

.bald h2 { margin: 6px 4px 8px; font-size: 18px; color: var(--holz-dunkel); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips span { background: rgba(255,255,255,.7); border: 2px dashed var(--holz); border-radius: 99px; padding: 4px 12px; font-size: 15px; color: var(--holz-dunkel); }

/* ---------- Tieralbum und Meine Ergebnisse ---------- */
.eltern-link { margin-top: 4px; }
.statistik-link { align-self: center; background: none; border: 0; color: var(--holz-dunkel); text-decoration: underline; font-size: 15px; padding: 4px; }
.statistik h2 { margin: 0 0 12px; }
.statistik h3 { margin: 20px 0 8px; font-size: 20px; }
.statistik .legende { justify-content: flex-start; margin-top: 14px; }
.code-form { max-width: 360px; margin: 0; }
.kacheln { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 600px) { .kacheln { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.kachel { background: #fff; border: 2px solid #ecdcc3; border-radius: 14px; padding: 10px 12px; display: flex; flex-direction: column; }
.kachel strong { font-size: 28px; color: var(--wiese-dunkel); font-variant-numeric: tabular-nums; }
.kachel span { color: var(--leise); font-size: 15px; }
.tabelle-wrap { overflow-x: auto; margin-top: 14px; }
.tabelle { width: 100%; border-collapse: collapse; font-size: 16px; font-variant-numeric: tabular-nums; }
.tabelle th { text-align: left; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--leise); padding: 6px 8px; border-bottom: 2px solid #ecdcc3; }
.tabelle td { padding: 8px; border-bottom: 1px solid #f1e6d4; white-space: nowrap; }
.album-knopf { display: flex; align-items: center; gap: 16px; text-align: left; color: var(--text); width: 100%; transition: transform .15s; }
.album-knopf:hover { transform: translateY(-3px); }
.vorschau { display: flex; flex: none; }
.vorschau img { width: 58px; height: 58px; object-fit: cover; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.vorschau img + img { margin-left: -18px; }
.vorschau .hufeisen.gross { width: 52px; height: 52px; }
.album-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.album-text strong { font-size: 24px; }
.album-text span { color: var(--leise); }
@media (max-width: 440px) { .vorschau img:nth-child(n+3) { display: none; } }
.album-raster { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 14px; }
@media (max-width: 440px) { .album-raster { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; } }
.album-tier { border: 0; background: none; padding: 0; display: flex; flex-direction: column; gap: 6px; color: var(--text); font-weight: 600; transition: transform .15s; }
.album-tier:hover { transform: translateY(-3px) rotate(-1deg); }
.album-tier img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 16px; border: 4px solid #fff; box-shadow: 0 4px 10px rgba(60, 40, 20, .2); background: #efe3cf; }
.album-rest { margin: 18px 0 0; text-align: center; color: var(--holz-dunkel); font-weight: 600; }

/* ---------- Hufeisen ---------- */
.hufeisen { width: 26px; height: 26px; color: #e6d8c2; }
.hufeisen.gold { color: var(--gold); }
.hufeisen.silber { color: var(--silber); }
.hufeisen.leer { color: #e6d8c2; opacity: .55; }
.hufeisen.aktuell { color: #f6c987; animation: puls 1.4s ease-in-out infinite; }
@keyframes puls { 50% { transform: scale(1.18); } }
.reihe { display: flex; gap: 4px; }

/* ---------- Kopfleiste in der Runde ---------- */
.leiste {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: rgba(255,255,255,.78); border-radius: 99px; padding: 6px 14px 6px 6px;
}
.zurueck { background: var(--holz); color: #fff; border: 0; border-radius: 99px; padding: 6px 14px; font-weight: 600; }
.zaehler { font-weight: 600; color: var(--holz-dunkel); }
.leiste .reihe { margin-left: auto; }

/* ---------- Aufgabe ---------- */
.aufgabe {
  display: grid; gap: 14px;
  grid-template-areas: "kopf" "figur" "antwort" "hinweis" "los";
}
@media (min-width: 900px) {
  .aufgabe {
    grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas: "figur kopf" "figur antwort" "figur hinweis" "figur los";
    column-gap: 28px; padding: 28px;
  }
  .aufgabe .los { align-self: end; }
  .aufgabe .antwort { justify-content: flex-start; }
}
.aufgabe .kopf { grid-area: kopf; }
.uebung-name { margin: 0; font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--wiese-dunkel); font-weight: 700; }
.frage { margin: 2px 0 0; font-size: 22px; font-weight: 600; text-wrap: balance; }

.figur { grid-area: figur; position: relative; width: min(100%, calc(56vh * var(--ar, 1))); max-width: 580px; margin: 0 auto; container-type: inline-size; align-self: center; }
.figur svg { width: 100%; height: auto; display: block; overflow: visible; }
.flaeche { stroke: none; }
.flaeche-wiese { fill: #b5e39a; }
.flaeche-wald { fill: #7fc46a; }
.flaeche-sand { fill: #f4dd97; }
.flaeche-sport { fill: #9bd97a; }
.flaeche-holz { fill: #ecc995; }
.flaeche-stoff { fill: #f9d6e4; }
.flaeche-asphalt { fill: #cfd3d7; }
.flaeche-glas { fill: #cdeaf8; }
.kante { stroke: #3a2a19; stroke-width: 4; stroke-linecap: round; }
.marker { stroke: transparent; stroke-width: 18; stroke-linecap: round; transition: stroke .3s; }
.marker.an { stroke: var(--marker); animation: markieren .5s ease-out; }
@keyframes markieren { from { stroke-dasharray: 0 400; } to { stroke-dasharray: 400 0; } }
.mass { font: 600 24px var(--schrift); fill: var(--text); }
.innen { font: 600 22px var(--schrift); fill: rgba(45, 58, 38, .5); }

.feld {
  position: absolute; display: flex; align-items: center;
  background: #fff; border: 3px solid var(--orange); border-radius: 10px;
  font-size: max(16px, calc(100cqw * 24 / var(--vb)));
  transition: border-color .2s, background .2s;
}
.feld input {
  width: 100%; min-width: 0; height: 100%; border: 0; background: transparent; outline: none;
  font: inherit; font-weight: 600; color: var(--text); text-align: right; padding: 0 .15em 0 .3em;
}
.feld .einheit { padding-right: .35em; color: var(--leise); font-weight: 600; }
.feld:focus-within { box-shadow: 0 0 0 4px rgba(238, 138, 42, .3); }
.feld.falsch { border-color: var(--rot); background: #ffeceb; animation: wackeln .35s; }
.feld.richtig { border-color: var(--gruen); background: #e8f7ea; }
.feld.loesung { border-color: var(--gruen); background: #fff6cc; }
@keyframes wackeln { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

/* Aufgaben ohne Figur: große Rechnung oder Begriffskarte */
.anzeige { grid-area: figur; display: flex; align-items: center; justify-content: center; min-height: 120px; }
.rechnung {
  background: #fff; border: 3px dashed var(--holz); border-radius: 18px; padding: 16px 24px;
  font-size: clamp(30px, 7vw, 48px); font-weight: 700; font-variant-numeric: tabular-nums; text-align: center;
}
.rechnung mark { background: var(--marker); color: inherit; border-radius: 8px; padding: 0 .15em; }
.begriff-karte {
  background: #fff; border: 3px solid var(--holz); border-radius: 18px; padding: 18px 30px; box-shadow: 0 5px 0 #e2cfb2;
  font-size: clamp(30px, 7vw, 46px); font-weight: 700; color: var(--wiese-dunkel); transform: rotate(-2deg);
}
.beispiel .rechnung, .beispiel .begriff-karte { font-size: 30px; }

/* Antwort zum Antippen */
.feld.wahl { position: static; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; width: 100%; background: none; border: 0; font-size: 22px; }
.feld.wahl:focus-within { box-shadow: none; }
.feld.wahl.falsch, .feld.wahl.richtig, .feld.wahl.loesung { background: none; }
.wahl-knopf {
  min-height: 58px; padding: 8px 10px; border-radius: 14px; border: 3px solid #ecdcc3; background: #fff; color: var(--text);
  font: inherit; font-weight: 600; display: flex; align-items: center; justify-content: center; text-align: center;
  box-shadow: 0 4px 0 #ecdcc3; transition: transform .08s, border-color .15s, background .15s;
}
.wahl-knopf:hover { border-color: var(--orange); }
.wahl-knopf:active { transform: translateY(3px); box-shadow: 0 1px 0 #ecdcc3; }
.wahl-knopf.gewaehlt { border-color: var(--orange); }
.wahl-knopf.richtig { border-color: var(--gruen); background: #e8f7ea; }
.wahl-knopf.falsch { border-color: var(--rot); background: #ffeceb; animation: wackeln .35s; }
.wahl-knopf.loesung { border-color: var(--gruen); background: #fff6cc; }
.wahl-knopf.zeichen { font-size: 40px; font-weight: 700; line-height: 1; }
.gesperrt .wahl-knopf { cursor: default; }
.antwort.nur-wahl { justify-content: stretch; }
.beispiel .feld.wahl { font-size: 18px; }
.beispiel .wahl-knopf { min-height: 44px; }

/* Umwandlungsraster */
.raster { border-collapse: collapse; margin: 0 auto; }
.raster th { background: #f1e4cf; color: var(--holz-dunkel); font-size: 20px; padding: 6px 0; width: 76px; border: 2px solid var(--holz); }
.raster td { border: 2px solid var(--holz); padding: 6px; background: #fff; height: 70px; }
.raster td.frei { background: repeating-linear-gradient(45deg, #f6efe3, #f6efe3 6px, #efe5d4 6px, #efe5d4 12px); }
.raster .feld-zeile { width: 100%; height: 54px; font-size: 26px; }
.raster .feld-zeile input { text-align: center; padding: 0; }
.raster .feld-zeile .einheit { display: none; }
@media (max-width: 440px) { .raster th { width: 64px; } }
.beispiel .raster .feld-zeile { height: 44px; font-size: 20px; }

.antwort { grid-area: antwort; display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; font-size: 26px; font-weight: 600; }
.feld-zeile { position: static; width: 6.2em; height: 58px; font-size: 26px; }

.hinweis { grid-area: hinweis; align-self: start; border-radius: 14px; padding: 12px 16px; font-size: 18px; }
.hinweis p { margin: 4px 0 0; }
.hinweis.tipp { background: #fff4c4; border: 2px solid #f1d46b; }
.hinweis.rechenweg { background: #e7f4ff; border: 2px solid #9fcdf2; }
.hinweis.rechenweg p { font-variant-numeric: tabular-nums; font-weight: 600; }
.hinweis.leer { background: #fff; border: 2px dashed var(--holz); }

.aufgabe .los { grid-area: los; }
.los {
  height: 60px; border: 0; border-radius: 16px; width: 100%;
  background: var(--orange); color: #fff; font-size: 24px; font-weight: 700;
  box-shadow: 0 5px 0 var(--orange-dunkel); transition: transform .08s, box-shadow .08s;
}
.los:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--orange-dunkel); }
.zweit { height: 60px; border: 3px solid var(--holz); border-radius: 16px; background: #fff; color: var(--holz-dunkel); font-size: 20px; font-weight: 600; width: 100%; }

/* ---------- Belohnung ---------- */
.belohnung {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: center;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px));
  background: rgba(32, 58, 22, .55); backdrop-filter: blur(4px);
  animation: einblenden .25s ease-out;
}
.belohnung.weg { animation: ausblenden .25s ease-in forwards; }
@keyframes einblenden { from { opacity: 0; } }
@keyframes ausblenden { to { opacity: 0; } }
.karte {
  width: min(560px, 100%); max-height: 100%; overflow: auto;
  background: var(--papier); border: 5px solid var(--holz); border-radius: 26px;
  box-shadow: 0 8px 0 var(--holz-dunkel), 0 24px 60px rgba(0,0,0,.35);
  display: flex; flex-direction: column;
  animation: aufploppen .45s cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes aufploppen { from { transform: scale(.6) rotate(-6deg); opacity: 0; } }
.foto { position: relative; aspect-ratio: 4 / 3; max-height: 55vh; background-size: cover; background-position: center; overflow: hidden; }
.foto::before { content: ""; position: absolute; inset: 0; backdrop-filter: blur(18px) brightness(.9); }
.foto img { position: relative; width: 100%; height: 100%; object-fit: contain; display: block; }
.zettel { padding: 14px 20px 6px; display: flex; flex-direction: column; gap: 2px; }
.zettel strong { font-size: 32px; color: var(--orange-dunkel); line-height: 1.1; }
.tiername { font-size: 22px; font-weight: 700; color: var(--wiese-dunkel); }
.zettel p { margin: 2px 0 0; font-size: 18px; }
.zettel .lebt { display: inline-flex; align-items: center; gap: 6px; align-self: flex-start; margin: 2px 0 4px; padding: 2px 10px; border-radius: 99px; background: #e6f3dc; color: var(--wiese-dunkel); font-size: 15px; font-weight: 600; }
.zettel .lebt::before { content: ""; width: 10px; height: 10px; border-radius: 50% 50% 50% 0; transform: rotate(-45deg); background: var(--wiese-dunkel); }
.zettel .wusstest { margin-top: 8px; padding: 8px 12px; border-radius: 12px; background: #fff4c4; font-size: 17px; }
.zettel .wusstest strong { color: var(--orange-dunkel); font-size: inherit; line-height: inherit; }
.weiter { margin: 14px 20px 18px; height: 50px; border: 0; border-radius: 14px; background: var(--wiese-dunkel); color: #fff; font-size: 20px; font-weight: 700; }

/* ---------- Ergebnis ---------- */
.ergebnis { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; padding: 28px 20px; max-width: 620px; width: 100%; margin: 0 auto; }
.ergebnis .los { max-width: 360px; margin-top: 8px; }
.ergebnis h1 { margin: 0; font-size: clamp(32px, 7vw, 44px); }
.reihe.gross { gap: 10px; }
.reihe.gross .hufeisen { width: 58px; height: 58px; animation: aufploppen .5s cubic-bezier(.2, 1.6, .4, 1) backwards; }
.reihe.gross .hufeisen:nth-child(2) { animation-delay: .12s; }
.reihe.gross .hufeisen:nth-child(3) { animation-delay: .24s; }
.reihe.gross .hufeisen:nth-child(4) { animation-delay: .36s; }
.reihe.gross .hufeisen:nth-child(5) { animation-delay: .48s; }
.lob { margin: 0; font-size: 22px; font-weight: 600; }
.legende { margin: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: center; font-size: 15px; color: var(--leise); }
.legende .hufeisen { width: 20px; height: 20px; margin-left: 8px; }
.knoepfe { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%; margin-top: 8px; }
@media (max-width: 440px) { .knoepfe { grid-template-columns: 1fr; } }

/* ---------- Anmeldung ---------- */
.anmeldung { max-width: 460px; width: 100%; margin: 0 auto; display: flex; flex-direction: column; gap: 14px; }
.reiter { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; background: #f1e4cf; padding: 5px; border-radius: 14px; }
.reiter button { border: 0; border-radius: 10px; padding: 10px; background: transparent; color: var(--holz-dunkel); font-weight: 600; }
.reiter button[aria-selected="true"] { background: #fff; box-shadow: 0 2px 0 #e2cfb2; }
.anmeldung form { display: flex; flex-direction: column; gap: 12px; }
.anmeldung label { display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.anmeldung input { font: inherit; font-size: 20px; padding: 10px 12px; border: 3px solid #e3cfae; border-radius: 12px; background: #fff; color: var(--text); }
.anmeldung input:focus { border-color: var(--orange); outline: none; }
.fehler { margin: 0; color: var(--rot); font-weight: 600; min-height: 1.4em; }

/* ---------- Eltern-Seite ---------- */
.reiter.breit { max-width: 420px; }
.werkzeug { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.werkzeug .zweit { width: auto; height: 48px; padding: 0 18px; }
.chips.wahl button { border: 2px solid var(--holz); background: rgba(255,255,255,.8); color: var(--holz-dunkel); border-radius: 99px; padding: 6px 14px; font-weight: 600; }
.chips.wahl button[aria-pressed="true"] { background: var(--holz); color: #fff; }
.erklaerung { margin: 0; color: var(--holz-dunkel); font-weight: 500; }
.beispiele { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
@media (max-width: 820px) { .beispiele { grid-template-columns: 1fr; } }
.beispiel { display: flex; flex-direction: column; gap: 10px; padding: 16px; }
.beispiel .frage { font-size: 18px; }
.beispiel .hinweis { font-size: 16px; align-self: stretch; }
.antwort.klein { font-size: 20px; }
.feld-zeile.klein { height: 46px; font-size: 20px; }
.kind h2 { margin: 0; }
.runden { display: flex; flex-direction: column; gap: 6px; }
.runden details { background: #fff; border: 2px solid #ecdcc3; border-radius: 12px; padding: 8px 12px; }
.runden summary { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; cursor: pointer; }
.runden .wann { color: var(--leise); font-variant-numeric: tabular-nums; font-size: 15px; }
.runden .was { font-weight: 600; }
.runden summary .reihe { margin-left: auto; }
.runden summary .hufeisen { width: 20px; height: 20px; }
.runden ol { margin: 8px 0 2px; padding-left: 22px; font-size: 15px; }
.runden li { margin: 4px 0; }
.runden li em { color: var(--leise); font-style: normal; }
.runden li.leer span { color: var(--rot); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
