:root {
  --grund: #fff8e7;
  --text: #3b3355;
  --sanft: #8a84a3;
  --karte: #ffffff;
  --gut: #51cf66;
  --naja: #ffa94d;
  --schatten: 0 6px 0 rgba(59, 51, 85, .12), 0 10px 24px rgba(59, 51, 85, .10);
  --rund: 28px;
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Varela Round", "Arial Rounded MT Bold", system-ui, sans-serif;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--grund);
  overscroll-behavior: none;
}

body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button {
  font: inherit;
  color: inherit;
  border: 0;
  cursor: pointer;
}

/* ---------- Start ---------- */

.kopf {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 16px 4px;
}

.logo {
  margin: 0;
  font-size: clamp(2rem, 8vw, 3.2rem);
  font-weight: 900;
  letter-spacing: .02em;
  text-shadow: 0 3px 0 rgba(59, 51, 85, .12);
}

.eltern-knopf {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: transparent;
  font-size: 1.4rem;
  opacity: .55;
}

.eltern-knopf .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 4px solid #4dabf7;
  clip-path: inset(0 100% 0 0);
}

.eltern-knopf.haelt .ring { animation: fuellen 2s linear forwards; }

@keyframes fuellen { to { clip-path: inset(0 0 0 0); } }

.kacheln {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  padding: 16px;
  flex: 1;
  align-content: center;
}

.kachel {
  aspect-ratio: 1 / 1;
  border-radius: var(--rund);
  box-shadow: var(--schatten);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  transition: transform .12s;
}

.kachel:active { transform: translateY(4px) scale(.98); }

.kachel-bild {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.kachel-bild svg { width: 80%; max-height: 100%; }
.kachel-titel { font-weight: 800; font-size: 1rem; color: var(--sanft); }
.riesig { font-size: 5.5rem; font-weight: 900; line-height: 1; }
.emoji { font-size: 4.5rem; line-height: 1; }
.formel { font-size: 3.4rem; font-weight: 900; color: #339af0; }

/* ---------- Leiste ---------- */

.leiste {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
}

.leiste h2 { margin: 0; font-size: 1.4rem; }

.rund {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--karte);
  box-shadow: var(--schatten);
  font-size: 1.6rem;
  flex: none;
  position: relative;
}

.rund:active { transform: translateY(3px); }
.rund.gross { width: 72px; height: 72px; font-size: 2rem; }

.perlen { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }

.perle {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #e9e4f5;
  transition: background .3s, transform .3s;
}

.perle.gut { background: var(--gut); transform: scale(1.2); }
.perle.naja { background: var(--naja); }

/* Ohr: Zustand der Spracherkennung */
.ohr { opacity: .35; }
.ohr[data-stand="bereit"] { opacity: 1; }
.ohr[data-stand="hoert"] { opacity: 1; background: #d3f9d8; animation: pochen 1.2s ease-in-out infinite; }
.ohr.hoertwas { background: #8ce99a; }
.ohr[data-stand="verweigert"] { opacity: .25; filter: grayscale(1); }

.ohr .ladering {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  display: none;
  background: conic-gradient(#4dabf7 calc(var(--anteil, 0) * 360deg), transparent 0);
  -webkit-mask: radial-gradient(circle, transparent 30px, #000 31px);
  mask: radial-gradient(circle, transparent 30px, #000 31px);
}

.ohr[data-stand="laedt"] .ladering { display: block; }

@keyframes pochen { 50% { transform: scale(1.12); } }

/* ---------- Übung ---------- */

.uebung { display: flex; flex-direction: column; min-height: 100dvh; }

.buehne {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  min-height: 240px;
}

.buehne.neu { animation: herein .35s ease-out; }
.buehne.jubel { animation: huepfen .6s ease-out; }
.buehne.wackeln { animation: wackeln .5s ease-in-out; }

@keyframes herein { from { opacity: 0; transform: scale(.85); } }
@keyframes huepfen { 30% { transform: scale(1.15) rotate(-3deg); } 60% { transform: scale(.97) rotate(2deg); } }
@keyframes wackeln { 20%, 60% { transform: translateX(-12px); } 40%, 80% { transform: translateX(12px); } }

.zahl {
  font-size: clamp(9rem, 45vw, 18rem);
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 8px 0 rgba(59, 51, 85, .12);
}

.lautsprecher {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: #d3f9d8;
  box-shadow: var(--schatten);
  font-size: 5rem;
}

.menge .bild, .zehner .bild { width: min(88vw, 440px); max-height: 46vh; }
.bild-finger .bild { width: min(92vw, 480px); }

/* Mengenbilder */
.bild .ding { transition: transform .2s, fill .2s; transform-box: fill-box; transform-origin: center; }
.bild .ding.leuchtet, .reihe .ding.leuchtet { transform: scale(1.3); }
.wuerfel { fill: #fff; stroke: #3b3355; stroke-width: 4; }
.bild-wuerfel .ding, .kachel .ding { fill: #3b3355; }
.bild-wuerfel .ding.leuchtet { fill: #ff6b6b; }
.finger, .handflaeche { fill: #ffd8a8; stroke: #e8590c; stroke-width: 3; }
.finger.ding.leuchtet { fill: #ff922b; }
.rahmen { fill: #fff; stroke: #3b3355; stroke-width: 4; }
.zehner .ding, .bild-zehnerfeld .ding, .kachel .bild .ding { fill: #4dabf7; }
.ding.extra { fill: #ffa94d !important; }
.leer { fill: #f1edf9; stroke: #d0c9e4; stroke-width: 2; stroke-dasharray: 5 4; }
.bild-zehnerfeld .ding.leuchtet { fill: #ff6b6b; }
.bild-punkte .ding.leuchtet { stroke: #3b3355; stroke-width: 6; }

/* Rechnen */
.rechnung {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: clamp(6px, 2vw, 18px);
  font-weight: 900;
  font-size: clamp(3.5rem, 15vw, 7rem);
  line-height: 1;
}

.rechnung.klein { font-size: clamp(2.5rem, 10vw, 4rem); margin-top: 16px; }
.glied { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: .8em; }
.glied > span { display: block; }
.op { color: var(--sanft); }
.loesung span { color: #9775fa; }
.reihe { min-height: 1px; }
.reihe .ding { fill: #4dabf7; transition: transform .2s; transform-box: fill-box; transform-origin: center; }
.reihe .ding.weg { fill: #d0c9e4; }
.reihe .strich { stroke: #ff6b6b; stroke-width: 3; stroke-linecap: round; }
.zehner { display: flex; flex-direction: column; align-items: center; }

/* Antworten */
.antworten {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 0 16px;
  min-height: 96px;
  visibility: hidden;
}

.antworten.sichtbar { visibility: visible; animation: herein .3s ease-out; }
.antworten:has(.wahl:nth-child(3):last-child) { grid-template-columns: repeat(3, 1fr); }

.wahl {
  height: 92px;
  border-radius: 24px;
  background: var(--karte);
  box-shadow: var(--schatten);
  font-size: 3rem;
  font-weight: 900;
  color: var(--f);
  transition: transform .12s, background .2s;
}

.wahl:active, .wahl.gedrueckt { transform: translateY(4px); }
.wahl.richtig { background: #b2f2bb; }
.wahl.falsch { background: #ffd8a8; opacity: .7; }

.fuss { display: flex; justify-content: center; padding: 16px 16px 24px; }

/* ---------- Ende ---------- */

.ende {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
  position: relative;
  overflow: hidden;
  min-height: 100dvh;
}

.sticker.gross { font-size: clamp(8rem, 40vw, 14rem); animation: sticker 1s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes sticker { from { transform: scale(0) rotate(-40deg); } }
.doppelt { font-size: 2rem; font-weight: 900; color: var(--sanft); margin-top: -20px; }
.knoepfe { display: flex; gap: 20px; }
.riesig-knopf { width: 84px; height: 84px; font-size: 2.4rem; }

.konfetti i {
  position: absolute;
  top: -20px;
  left: var(--x);
  width: 12px;
  height: 18px;
  border-radius: 3px;
  background: var(--f);
  animation: fallen 2.6s var(--d) ease-in forwards;
}

@keyframes fallen { to { transform: translateY(110vh) rotate(540deg); } }

/* ---------- Album ---------- */

.seiten {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 10px;
  padding: 8px 16px 24px;
}

.platz {
  aspect-ratio: 1;
  border-radius: 18px;
  background: #f1edf9;
  border: 3px dashed #d0c9e4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 900;
  color: #d0c9e4;
  position: relative;
}

.platz.voll { background: var(--karte); border: 0; box-shadow: var(--schatten); font-size: 2.6rem; }
.platz small { position: absolute; right: 6px; bottom: 2px; font-size: .8rem; color: var(--sanft); }

/* ---------- Eltern ---------- */

.eltern { padding-bottom: 40px; user-select: text; -webkit-user-select: text; }
.eltern section { background: var(--karte); border-radius: 20px; margin: 12px 16px; padding: 4px 18px 14px; box-shadow: 0 2px 10px rgba(59, 51, 85, .06); }
.eltern h3 { margin: 14px 0 8px; font-size: 1.05rem; }
.eltern p { margin: 8px 0; line-height: 1.45; }
.eltern .hinweis, .eltern .klein { color: var(--sanft); font-size: .92rem; }
.eltern a { color: #1c7ed6; }
.gruppe { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }

.schalter {
  padding: 10px 16px;
  border-radius: 14px;
  background: #f1edf9;
  font-weight: 700;
}

.schalter.an { background: #4dabf7; color: #fff; }
.schalter:disabled { opacity: .4; cursor: default; }
.schalter.warnung { background: #ffe3e3; color: #c92a2a; }
.haken { display: flex; align-items: center; gap: 8px; font-weight: 600; padding: 6px 0; }
.haken input { width: 22px; height: 22px; accent-color: #4dabf7; }

.feldraster { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; }
.feldraster .feld:first-child { grid-column: 1 / -1; justify-self: start; width: calc(10% - 4px); }

.feld {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 30px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 800;
  background: #f1edf9;
  color: var(--sanft);
  vertical-align: middle;
}

.legende .feld { width: 24px; height: 18px; margin: 0 4px 0 10px; }
.feld.s0 { background: #ffc9c9; color: #c92a2a; }
.feld.s1 { background: #ffe8cc; color: #d9480f; }
.feld.s2, .feld.s3 { background: #d3f9d8; color: #2b8a3e; }
.feld.s4 { background: #51cf66; color: #fff; }
.wackel { display: inline-block; background: #ffe3e3; color: #c92a2a; border-radius: 10px; padding: 2px 10px; margin: 2px; font-weight: 700; }

@media (max-width: 420px) {
  .kacheln { grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 12px; }
  .riesig { font-size: 4.2rem; }
  .emoji { font-size: 3.6rem; }
  .formel { font-size: 2.6rem; }
  .wahl { height: 80px; font-size: 2.4rem; }
  .antworten { gap: 8px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  .kacheln { grid-template-columns: repeat(6, 1fr); }
  .zahl { font-size: 40vh; }
  .buehne { min-height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
