/* RechenHelden – Kinder-Oberfläche, große Tippflächen, hoher Kontrast */

:root {
  --bg: #eef4ff;
  --card: #ffffff;
  --ink: #17233a;
  --ink-soft: #5b6b86;
  --line: #d7e2f5;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --ok: #16a34a;
  --ok-bg: #dcfce7;
  --bad: #dc2626;
  --bad-bg: #fee2e2;
  --gold: #f59e0b;
  --shadow: 0 4px 0 rgba(23, 35, 58, .13);
  --radius: 18px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, "Noto Sans", Roboto, sans-serif;
  font-size: 17px;
  line-height: 1.45;
  overscroll-behavior: none;
}

body { padding-top: var(--safe-top); padding-bottom: var(--safe-bottom); }

button { font-family: inherit; font-size: inherit; cursor: pointer; border: none; background: none; color: inherit; }

/* ---------- Views ---------- */
.view { display: none; min-height: 100vh; padding-bottom: 28px; }
.view.active { display: block; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Startseite ---------- */
.home-header { position: relative; text-align: center; padding: 16px 16px 8px; }
.home-header h1 { margin: 4px 0 0; font-size: 30px; letter-spacing: -.5px; }
.tagline { margin: 2px 0 10px; color: var(--ink-soft); font-size: 15px; }
.mascot { font-size: 54px; line-height: 1; margin-top: 34px; }

.profile-chip, .parent-btn {
  position: absolute; top: 12px;
  background: var(--card); border: 2px solid var(--line);
  border-radius: 999px; padding: 7px 13px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow);
}
.profile-chip { left: 12px; }
.parent-btn { right: 12px; }

.streak-row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; padding: 0 16px 10px; }
.streak-pill {
  background: var(--card); border: 2px solid var(--line); border-radius: 999px;
  padding: 6px 14px; font-size: 14px; font-weight: 600;
}
.streak-pill.hot { border-color: var(--gold); background: #fffbeb; }

.classes-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 0 16px; }

.class-card {
  position: relative; text-align: left;
  background: var(--card); border: 3px solid var(--line);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 2px; min-height: 128px;
}
.class-card:active { transform: translateY(2px); box-shadow: none; }
.class-icon { font-size: 32px; line-height: 1; }
.class-name { font-size: 18px; font-weight: 700; }
.class-range { font-size: 13px; color: var(--ink-soft); }
.class-progress { margin-top: auto; display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; }
.mini-bar { flex: 1; height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; }
.mini-fill { height: 100%; background: var(--ok); border-radius: 4px; transition: width .3s; }
.class-badge {
  position: absolute; top: -9px; right: 10px;
  background: var(--gold); color: #fff; font-size: 11px; font-weight: 700;
  padding: 3px 9px; border-radius: 999px;
}

.extra-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 12px 16px 0; }
.extra-card {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 14px; box-shadow: var(--shadow); text-align: left;
  display: flex; flex-direction: column; gap: 1px;
}
.extra-card:active { transform: translateY(2px); box-shadow: none; }
.extra-card.trainer { border-color: #fcd34d; background: #fffbeb; }
.extra-icon { font-size: 26px; }
.extra-title { font-weight: 700; }
.extra-sub { font-size: 13px; color: var(--ink-soft); }

.home-footer {
  display: flex; justify-content: center; gap: 18px;
  padding: 16px; font-weight: 700; color: var(--ink-soft); font-size: 15px;
}
.version-tag { text-align: center; font-size: 11px; color: #9db0cc; padding-bottom: 6px; }

/* ---------- Unter-Header ---------- */
.sub-header, .play-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; background: var(--card); border-bottom: 2px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.sub-header h2 { flex: 1; margin: 0; font-size: 19px; text-align: center; }
.header-spacer { width: 42px; }
.back-btn {
  width: 42px; height: 42px; flex: none; border-radius: 12px;
  background: var(--bg); font-size: 26px; font-weight: 700; line-height: 1;
}
.class-sub { text-align: center; color: var(--ink-soft); margin: 10px 16px 0; font-size: 14px; }

/* ---------- Welten & Level ---------- */
.worlds-grid { display: grid; gap: 10px; padding: 12px 16px; }
.world-card {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 13px; box-shadow: var(--shadow);
}
.world-card:active { transform: translateY(2px); box-shadow: none; }
.world-card.locked { opacity: .62; }
.world-icon { font-size: 30px; flex: none; }
.world-info { flex: 1; min-width: 0; }
.world-name { font-weight: 700; font-size: 17px; }
.world-meta { font-size: 13px; color: var(--ink-soft); display: flex; align-items: center; gap: 6px; }
.world-stars { font-size: 14px; font-weight: 700; color: var(--gold); flex: none; }
.free-tag {
  background: var(--ok-bg); color: var(--ok); font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px;
}

.levels-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 14px 16px; }
.level-card {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 13px; box-shadow: var(--shadow); text-align: left;
  display: flex; flex-direction: column; gap: 4px; min-height: 104px;
}
.level-card:active { transform: translateY(2px); box-shadow: none; }
.level-card.locked { opacity: .55; }
.level-card.done { border-color: var(--ok); }
.level-num { font-size: 12px; font-weight: 700; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .5px; }
.level-title { font-weight: 700; line-height: 1.25; }
.level-stars { margin-top: auto; font-size: 17px; letter-spacing: 1px; }

/* ---------- Spielfeld ---------- */
.progress-bar { flex: 1; height: 12px; background: var(--bg); border-radius: 6px; overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: var(--primary); border-radius: 6px; transition: width .3s; }
.progress-label { font-size: 13px; font-weight: 700; color: var(--ink-soft); min-width: 34px; text-align: center; }
.hint-btn { width: 42px; height: 42px; flex: none; border-radius: 12px; background: var(--bg); font-size: 21px; }

.play-area { padding: 16px; max-width: 560px; margin: 0 auto; }
.question { font-size: 19px; font-weight: 600; text-align: center; margin: 4px 0 14px; }

.display {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 20px 14px; text-align: center; font-size: 34px; font-weight: 800;
  letter-spacing: 1px; margin-bottom: 16px; box-shadow: var(--shadow); word-break: break-word;
}
.display.small { font-size: 25px; }
.bild-row {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 16px 12px; text-align: center; font-size: 30px; line-height: 1.5;
  margin-bottom: 16px; box-shadow: var(--shadow); word-break: break-word; white-space: pre-line;
}
.form-box {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 16px; box-shadow: var(--shadow); text-align: center;
}
.form-box svg { width: 150px; height: 150px; }

.options { display: grid; gap: 11px; }
.options.two-col { grid-template-columns: repeat(2, 1fr); }
.option {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 17px 14px; font-size: 22px; font-weight: 700; box-shadow: var(--shadow);
  text-align: center; transition: background .15s, border-color .15s;
}
.option:active { transform: translateY(2px); box-shadow: none; }
.option.correct { border-color: var(--ok); background: var(--ok-bg); }
.option.wrong { border-color: var(--bad); background: var(--bad-bg); }
.option:disabled { cursor: default; }

/* Vergleichsaufgaben */
.vgl-row { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 18px; }
.vgl-side {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 16px 12px; font-size: 27px; font-weight: 800; min-width: 92px; text-align: center;
  box-shadow: var(--shadow);
}
.vgl-gap { font-size: 30px; font-weight: 800; color: var(--ink-soft); min-width: 44px; text-align: center; }

/* Sortieraufgaben */
.sort-target {
  display: flex; gap: 8px; justify-content: center; flex-wrap: wrap;
  min-height: 62px; padding: 10px; margin-bottom: 14px;
  border: 3px dashed var(--line); border-radius: var(--radius); background: #f8fbff;
}
.sort-slot {
  background: var(--primary); color: #fff; border-radius: 12px;
  padding: 9px 15px; font-size: 21px; font-weight: 800;
}
.sort-pool { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.sort-chip {
  background: var(--card); border: 3px solid var(--line); border-radius: 14px;
  padding: 13px 19px; font-size: 23px; font-weight: 800; box-shadow: var(--shadow);
}
.sort-chip:active { transform: translateY(2px); box-shadow: none; }
.sort-chip.used { opacity: .3; }

/* Zahlen-Tastenfeld */
.answer-field {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--card); border: 3px solid var(--primary); border-radius: var(--radius);
  padding: 15px; margin-bottom: 12px; font-size: 32px; font-weight: 800; min-height: 68px;
  box-shadow: var(--shadow);
}
.answer-field.correct { border-color: var(--ok); background: var(--ok-bg); }
.answer-field.wrong { border-color: var(--bad); background: var(--bad-bg); }
.answer-value { min-width: 26px; }
.answer-caret { width: 3px; height: 30px; background: var(--primary); animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }
.answer-unit { font-size: 20px; color: var(--ink-soft); font-weight: 700; }

.keypad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
/* Die Möglichkeiten, die nach einem Fehler an die Stelle des Ziffernblocks
   treten. Etwas Luft nach oben, damit sie nicht am Antwortfeld kleben und als
   neues Angebot erkennbar sind. */
.hilfs-auswahl { margin-top: 14px; }
.key {
  background: var(--card); border: 3px solid var(--line); border-radius: 14px;
  padding: 15px 0; font-size: 25px; font-weight: 800; box-shadow: var(--shadow);
}
.key:active { transform: translateY(2px); box-shadow: none; }
.key.wide { grid-column: span 1; }
.key.action { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.key.del { background: #f1f5fb; }

/* Feedback & Tipp */
.hint-box {
  margin: 0 16px 12px; padding: 12px 14px; border-radius: 14px;
  background: #fffbeb; border: 2px solid #fcd34d; font-size: 15px;
  max-width: 560px; margin-left: auto; margin-right: auto;
}
.feedback {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  padding: 16px 16px calc(16px + var(--safe-bottom));
  font-size: 19px; font-weight: 700; text-align: center;
  animation: slideUp .2s ease;
}
@keyframes slideUp { from { transform: translateY(100%); } to { transform: none; } }
.feedback.ok { background: var(--ok-bg); color: #14532d; border-top: 3px solid var(--ok); }
.feedback.bad { background: var(--bad-bg); color: #7f1d1d; border-top: 3px solid var(--bad); }

/* ---------- Ergebnis ---------- */
.result-card { max-width: 460px; margin: 0 auto; padding: 46px 22px; text-align: center; }
.result-mascot { font-size: 68px; }
.result-card h2 { font-size: 27px; margin: 8px 0; }
.result-stars { font-size: 42px; letter-spacing: 5px; margin: 8px 0; }
.result-buttons { display: grid; gap: 10px; margin-top: 22px; }

/* ---------- Buttons ---------- */
.big-btn {
  border-radius: 15px; padding: 15px 20px; font-size: 17px; font-weight: 700;
  border: 3px solid transparent; box-shadow: var(--shadow);
}
.big-btn:active { transform: translateY(2px); box-shadow: none; }
.big-btn.primary { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.big-btn.secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.big-btn.danger { background: var(--bad); color: #fff; border-color: #b91c1c; }
.big-btn.wide { width: 100%; margin-bottom: 8px; }
.center-actions { padding: 0 16px; text-align: center; }
.center-actions .big-btn { width: 100%; max-width: 320px; }

/* ---------- Profile ---------- */
.profile-list { display: grid; gap: 10px; padding: 14px 16px; }
.profile-row {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 13px; box-shadow: var(--shadow); width: 100%;
}
.profile-row.active { border-color: var(--primary); }
.profile-avatar { font-size: 30px; }
.profile-name { flex: 1; font-weight: 700; }
.profile-stats { font-size: 13px; color: var(--ink-soft); }
.profile-del { padding: 8px 10px; font-size: 18px; border-radius: 10px; background: var(--bg); }

/* ---------- Trainer ---------- */
.trainer-setup { padding: 16px; max-width: 520px; margin: 0 auto; }
.trainer-intro { text-align: center; font-size: 17px; margin-bottom: 16px; }
.trainer-group { margin-bottom: 16px; }
.trainer-group h3 { font-size: 15px; margin: 0 0 8px; color: var(--ink-soft); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  background: var(--card); border: 3px solid var(--line); border-radius: 999px;
  padding: 9px 16px; font-weight: 700; font-size: 16px;
}
.chip.on { background: var(--primary); color: #fff; border-color: var(--primary-dark); }
.trainer-best { text-align: center; margin-top: 14px; color: var(--ink-soft); font-weight: 600; }
.trainer-status {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px; font-size: 21px; font-weight: 800; max-width: 560px; margin: 0 auto;
}
#trainerTime { color: var(--primary); }
#trainerTime.low { color: var(--bad); }

/* ---------- Abzeichen ---------- */
.awards-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding: 14px 16px; }
.award {
  background: var(--card); border: 3px solid var(--line); border-radius: var(--radius);
  padding: 14px; text-align: center; box-shadow: var(--shadow);
}
.award.locked { opacity: .45; }
.award.got { border-color: var(--gold); background: #fffbeb; }
.award-icon { font-size: 34px; }
.award-name { font-weight: 700; margin-top: 4px; }
.award-desc { font-size: 12px; color: var(--ink-soft); }

/* ---------- Eltern ---------- */
.parent-lock { padding: 34px 20px; text-align: center; max-width: 400px; margin: 0 auto; }
.parent-math { font-size: 32px; font-weight: 800; margin: 12px 0; }
.parent-lock input {
  width: 100%; padding: 14px; font-size: 22px; text-align: center;
  border: 3px solid var(--line); border-radius: 14px; margin-bottom: 12px;
  font-family: inherit; background: var(--card); color: var(--ink);
}
.parent-lock .big-btn { width: 100%; }
.parent-error { color: var(--bad); font-weight: 700; }

.parent-content { padding: 14px 16px; max-width: 620px; margin: 0 auto; }
.parent-section {
  background: var(--card); border: 2px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.parent-section h3 { margin: 0 0 10px; font-size: 17px; }
.parent-section.danger { border-color: #fecaca; }
.section-note { font-size: 14px; color: var(--ink-soft); margin: 0 0 10px; }
.settings-row { display: flex; justify-content: space-between; align-items: center; padding: 9px 0; font-weight: 600; }
.settings-row input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--primary); }
.purchase-status { font-size: 14px; color: var(--ink-soft); margin: 8px 0 0; text-align: center; }
.spar-hinweis {
  font-size: 14px; font-weight: 600; color: var(--ok);
  background: var(--ok-bg); border-radius: 10px;
  padding: 8px 12px; margin: 10px 0 8px; text-align: center;
}
.build-info { text-align: center; font-size: 12px; color: #9db0cc; }

.progress-line { display: flex; align-items: center; gap: 10px; padding: 7px 0; font-size: 15px; }
.progress-line .name { font-weight: 700; }   /* Breite regelt engine.css */
.progress-line .mini-bar { flex: 1; }
.progress-line .val { flex: none; font-size: 13px; color: var(--ink-soft); min-width: 66px; text-align: right; }

.stats-chart { display: flex; align-items: flex-end; gap: 4px; height: 96px; padding: 20px 0 22px; }
.stats-bar { flex: 1; background: var(--line); border-radius: 4px 4px 0 0; min-height: 3px; position: relative; }
.stats-bar.has { background: var(--primary); }
/* Wert über dem Balken, Wochentag darunter – beide absolut, sonst schiebt der
   Text den Balken auseinander und klebt mitten in der Säule. */
.stats-bar .stat-value { position: absolute; bottom: 100%; left: -2px; right: -2px; text-align: center;
  font-size: 11px; font-weight: 700; color: var(--ink-soft); margin-bottom: 3px; }
.stats-bar .stat-label { position: absolute; top: 100%; left: -2px; right: -2px; text-align: center;
  font-size: 10px; color: var(--ink-soft); margin-top: 4px; }
.stats-bar.today { outline: 2px solid var(--gold); outline-offset: 1px; }
.stats-note { font-size: 13px; color: var(--ink-soft); margin: 14px 0 0; }

.unlock-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.unlock-row:last-of-type { border-bottom: none; }
.unlock-name { flex: 1; font-weight: 600; }
.unlock-btn { background: var(--primary); color: #fff; border-radius: 11px; padding: 8px 14px; font-weight: 700; font-size: 14px; }
.unlock-done { color: var(--ok); font-weight: 700; }

.topic-row { display: flex; align-items: center; gap: 10px; padding: 6px 0; font-size: 15px; }
.topic-row .name { flex: 1; }
.topic-row .quote { font-weight: 700; }
.topic-row .quote.low { color: var(--bad); }
.topic-row .quote.mid { color: var(--gold); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  font-weight: 600; z-index: 90; max-width: 88vw; text-align: center;
  animation: fade .2s ease;
}

/* ---------- Konfetti ---------- */
.confetti {
  position: fixed; top: -12px; z-index: 80; pointer-events: none; border-radius: 2px;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(680deg); opacity: .1; }
}

/* ---------- Größere Displays ---------- */
@media (min-width: 620px) {
  .classes-grid, .extra-grid { max-width: 620px; margin: 0 auto; }
  .worlds-grid, .levels-grid, .profile-list, .awards-grid { max-width: 620px; margin: 0 auto; }
}
@media (max-width: 340px) {
  .classes-grid, .levels-grid { grid-template-columns: 1fr; }
  .display { font-size: 28px; }
}

/* Kennzahlen sitzen oben bei den Kacheln statt als Fußzeile unter allem. */
.home-stats { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px;
  margin: 2px 0 14px; padding: 10px 12px; background: #fff; border-radius: 14px;
  font-size: 15px; font-weight: 600; color: var(--ink-soft); }
