/* Mathe-Buddy – Gestaltung.
   Zielgerät ist das iPad (Hoch- und Querformat), ab iPadOS 15.
   Deshalb bewusst ohne CSS-Nesting, :has() und color-mix(). */

:root {
  color-scheme: light;
  --bg: #f3f1ff;
  --card: #ffffff;
  --ink: #2b2550;
  --muted: #6f6a92;
  --line: #e1dcf6;
  --primary: #5b4bdb;
  --primary-dark: #4336b0;
  --primary-soft: #e9e5ff;
  --sun: #ffc83d;
  --sun-dark: #dd9f00;
  --sun-soft: #fff4d1;
  --good: #1fb573;
  --good-dark: #15895a;
  --bad: #ff6b6b;
  --bad-dark: #cf4545;
  --bad-soft: #ffe6e6;
  --lv-new: #e9e6f4;
  --lv-0: #ff9a9a;
  --lv-1: #ffc27a;
  --lv-2: #ffe680;
  --lv-3: #a2e6ae;
  --lv-4: #1fb573;
  --radius: 26px;
  --shadow: 0 2px 10px rgba(67, 54, 176, 0.08);
  --font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  overflow: hidden;
  font-family: var(--font);
  font-weight: 600;
  font-size: 18px;
  line-height: 1.35;
  color: var(--ink);
  background:
    radial-gradient(900px 520px at 105% -8%, #e2dcff 0, rgba(226, 220, 255, 0) 62%),
    radial-gradient(760px 460px at -8% 108%, #fff0c7 0, rgba(255, 240, 199, 0) 58%),
    var(--bg);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
}

h1,
h2,
h3,
h4,
p,
ul {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

button {
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-appearance: none;
  appearance: none;
}

input,
textarea {
  font: inherit;
  color: inherit;
  -webkit-user-select: text;
  user-select: text;
  -webkit-appearance: none;
  appearance: none;
}

:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
}

.fallback {
  padding: 40px 24px;
  text-align: center;
}

/* ---------- Grundgerüst ---------- */

.screen {
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-height: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding:
    calc(22px + env(safe-area-inset-top))
    calc(24px + env(safe-area-inset-right))
    calc(26px + env(safe-area-inset-bottom))
    calc(24px + env(safe-area-inset-left));
  animation: screen-in 0.22s ease-out;
}

/* Verkleinern statt verschieben: so entsteht beim Einblenden kein Scrollbereich. */
@keyframes screen-in {
  from {
    opacity: 0;
    transform: scale(0.985);
  }
}

/* „Drückbare“ Flächen: dicke Unterkante, die beim Tippen einsinkt. */
.press {
  --edge: var(--line);
  box-shadow: 0 5px 0 var(--edge);
  transition: transform 0.06s ease, box-shadow 0.06s ease;
}

.press:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 var(--edge);
}

.btn {
  --edge: var(--primary-dark);
  min-height: 60px;
  padding: 14px 28px;
  border-radius: 20px;
  background: var(--primary);
  color: #fff;
  font-size: 21px;
  font-weight: 800;
}

.btn-ghost {
  --edge: var(--line);
  background: var(--card);
  color: var(--primary);
  border: 2px solid var(--line);
}

.btn-sun {
  --edge: var(--sun-dark);
  background: var(--sun);
  color: var(--ink);
}

.btn-danger {
  --edge: var(--bad-dark);
  background: var(--bad);
  color: #fff;
}

.icon-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 54px;
  height: 54px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  color: var(--muted);
  font-size: 22px;
  font-weight: 800;
}

.icon-btn svg {
  width: 26px;
  height: 26px;
}

.chip-btn {
  min-height: 48px;
  padding: 10px 18px;
  border: 2px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
}

.topbar h1 {
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 800;
}

.buddy {
  display: block;
  width: 100%;
  height: auto;
}

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

.home-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px;
  padding-top: 8px;
}

.home-buddy {
  flex: none;
  width: 104px;
  animation: bob 3.2s ease-in-out infinite;
}

@keyframes bob {
  50% {
    transform: translateY(-6px);
  }
}

.home-hello {
  flex: 1;
  min-width: 240px;
}

.home-hello h1 {
  font-size: clamp(32px, 5vw, 46px);
  font-weight: 800;
  line-height: 1.1;
}

.home-hello p {
  margin-top: 6px;
  color: var(--muted);
  font-size: 20px;
}

.badges {
  display: flex;
  gap: 12px;
}

.badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.badge-icon {
  font-size: 26px;
}

.badge b {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.badge small {
  max-width: 5em;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.15;
}

/* Die Übungskarten stehen mittig zwischen Begrüßung und Fußzeile. */
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr));
  gap: 20px;
  margin: auto 0;
}

.exercise-card {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 148px;
  padding: 24px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  text-align: left;
}

.exercise-badge {
  display: grid;
  place-items: center;
  flex: none;
  width: 92px;
  height: 92px;
  border-radius: 28px;
  background: linear-gradient(140deg, #8676f5, var(--primary));
  color: #fff;
  font-size: 36px;
  font-weight: 800;
}

.exercise-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.exercise-text strong {
  font-size: 26px;
  font-weight: 800;
}

.exercise-text span {
  color: var(--muted);
}

.exercise-text .exercise-state {
  margin-top: 8px;
  color: var(--good-dark);
  font-weight: 700;
}

.ring {
  position: relative;
  display: grid;
  place-items: center;
  flex: none;
  width: 84px;
  height: 84px;
}

.ring svg {
  position: absolute;
  inset: 0;
  transform: rotate(-90deg);
}

.ring circle {
  fill: none;
  stroke-width: 11;
}

.ring-track {
  stroke: var(--primary-soft);
}

.ring-value {
  stroke: var(--good);
  stroke-linecap: round;
}

.ring-text {
  position: relative;
  font-size: 18px;
  font-weight: 800;
}

.soon-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 148px;
  padding: 24px;
  border: 3px dashed #cfc8f2;
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.soon-card strong {
  font-size: 22px;
  font-weight: 800;
}

.home-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
}

/* ---------- Übersicht einer Übung ---------- */

.hub h2 {
  margin-top: 6px;
  font-size: 22px;
  font-weight: 800;
}

.hero {
  --edge: var(--primary-dark);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 20px 26px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, #7a6af0, var(--primary));
  color: #fff;
  text-align: left;
}

.hero-buddy {
  flex: none;
  width: 84px;
  padding: 6px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.92);
}

.hero-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
}

.hero-text strong {
  font-size: clamp(26px, 4vw, 34px);
  font-weight: 800;
}

.hero-text span {
  font-size: 19px;
  opacity: 0.92;
}

.hero-go {
  flex: none;
  padding: 14px 28px;
  border-radius: 20px;
  background: var(--sun);
  box-shadow: 0 4px 0 var(--sun-dark);
  color: var(--ink);
  font-size: 24px;
  font-weight: 800;
}

.rows {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}

.row-tile {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 18px 14px 16px;
  border: 2px solid var(--line);
  border-radius: 22px;
  background: var(--card);
}

.row-tile strong {
  font-size: clamp(24px, 4vw, 32px);
  font-weight: 800;
}

.row-mark {
  position: absolute;
  top: 6px;
  right: 9px;
  font-size: 18px;
}

.meter {
  display: block;
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 5px;
  background: var(--primary-soft);
}

.meter-fill {
  display: block;
  height: 100%;
  border-radius: 5px;
  background: var(--good);
}

.duo {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 16px;
}

.mode-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 22px;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--card);
  text-align: left;
}

.mode-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--sun-soft);
  font-size: 32px;
}

.mode-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.mode-text strong {
  font-size: 23px;
  font-weight: 800;
}

.mode-text span {
  color: var(--muted);
}

/* ---------- Üben ---------- */

.screen.practice {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  height: 100%;
  min-height: 0;
  max-width: 1120px;
}

.practice-top {
  display: flex;
  align-items: center;
  gap: 18px;
}

.progress {
  flex: 1;
  height: 20px;
  overflow: hidden;
  border: 2px solid var(--line);
  border-radius: 10px;
  background: var(--card);
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: 8px;
  background: linear-gradient(90deg, #9384f7, var(--primary));
  transition: width 0.3s ease;
}

.blitz-info {
  display: flex;
  flex: 1;
  justify-content: center;
  gap: 12px;
  padding-right: 54px;
}

.pill {
  min-width: 112px;
  padding: 8px 18px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--card);
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.pill-good {
  color: var(--good-dark);
}

.is-ending .pill-clock {
  border-color: var(--bad);
  color: var(--bad-dark);
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  min-height: 0;
  text-align: center;
}

.equation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.28em;
  font-size: clamp(40px, 12vw, 124px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.answer-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.3em;
  height: 1.45em;
  padding: 0 0.18em;
  border: 0.06em solid var(--primary);
  border-radius: 0.26em;
  background: var(--card);
  transition: background-color 0.12s, border-color 0.12s, color 0.12s;
}

.answer-box.is-empty::after {
  content: "";
  width: 0.07em;
  height: 0.8em;
  border-radius: 0.04em;
  background: var(--primary);
  animation: blink 1.1s steps(2, start) infinite;
}

@keyframes blink {
  to {
    visibility: hidden;
  }
}

.stage[data-state="right"] .answer-box {
  border-color: var(--good-dark);
  background: var(--good);
  color: #fff;
}

.stage[data-state="wrong"] .answer-box {
  border-color: var(--bad);
  background: var(--bad-soft);
  color: var(--bad-dark);
  animation: shake 0.35s;
}

.stage[data-state="right"] .answer-box::after,
.stage[data-state="wrong"] .answer-box::after {
  display: none;
}

@keyframes shake {
  20%,
  60% {
    transform: translateX(-9px);
  }
  40%,
  80% {
    transform: translateX(9px);
  }
}

.solution {
  min-height: 1.75em;
  padding: 0.18em 0.7em;
  border-radius: 0.6em;
  font-size: clamp(26px, 5vw, 48px);
  font-weight: 800;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
  visibility: hidden;
}

.stage[data-state="wrong"] .solution,
.stage[data-state="fix"] .solution {
  background: var(--sun-soft);
  box-shadow: inset 0 0 0 3px var(--sun);
  visibility: visible;
}

.trail {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
}

.trail-item {
  min-width: 2.2em;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.hint {
  min-height: 1.5em;
  color: var(--muted);
  font-size: clamp(19px, 3vw, 28px);
  font-weight: 700;
}

.stage[data-state="right"] .hint {
  color: var(--good-dark);
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  justify-self: center;
  width: min(100%, 520px);
}

.key {
  height: clamp(54px, 9.5vh, 92px);
  border: 2px solid var(--line);
  border-radius: 20px;
  background: var(--card);
  box-shadow: 0 5px 0 var(--line);
  font-size: clamp(26px, 4.4vh, 40px);
  font-weight: 800;
  transition: transform 0.05s ease, box-shadow 0.05s ease, background-color 0.05s;
}

.key.is-down,
.key:active {
  transform: translateY(4px);
  background: var(--primary-soft);
  box-shadow: 0 1px 0 var(--line);
}

.key-back {
  color: var(--muted);
}

.key-ok {
  border-color: var(--good-dark);
  background: var(--good);
  box-shadow: 0 5px 0 var(--good-dark);
  color: #fff;
}

.key-ok.is-down,
.key-ok:active {
  background: var(--good-dark);
  box-shadow: 0 1px 0 var(--good-dark);
}

.is-waiting .keypad {
  opacity: 0.35;
  pointer-events: none;
}

.blitz-intro {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  max-width: 460px;
}

.blitz-bolt {
  font-size: 72px;
  line-height: 1;
}

.blitz-intro h2 {
  font-size: 40px;
  font-weight: 800;
}

.blitz-intro p {
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 22px;
}

@media (orientation: landscape) and (min-width: 600px) {
  .screen.practice {
    grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    column-gap: 28px;
  }

  .practice-top {
    grid-column: 1 / -1;
  }

  .equation {
    font-size: clamp(36px, 6.6vw, 112px);
  }

  .solution {
    font-size: clamp(24px, 3.2vw, 46px);
  }

  .keypad {
    align-self: center;
    width: min(100%, 440px);
  }

  .key {
    height: clamp(44px, 15vh, 104px);
    font-size: clamp(24px, 6vh, 40px);
  }
}

/* ---------- Ergebnis ---------- */

.screen.result {
  align-items: center;
  justify-content: center;
}

.result-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(100%, 640px);
  padding: 30px 28px 28px;
  border-radius: 34px;
  background: var(--card);
  box-shadow: var(--shadow);
  text-align: center;
}

.result-buddy {
  width: 120px;
  animation: bob 1.6s ease-in-out infinite;
}

.result-card h1 {
  font-size: clamp(32px, 6vw, 44px);
  font-weight: 800;
}

.stars {
  display: flex;
  gap: 10px;
  font-size: 68px;
  line-height: 1;
}

.star {
  color: var(--lv-new);
}

.star.is-on {
  color: var(--sun);
  text-shadow: 0 4px 0 var(--sun-dark);
  animation: star-pop 0.45s cubic-bezier(0.2, 1.6, 0.4, 1) backwards;
}

@keyframes star-pop {
  from {
    opacity: 0;
    transform: scale(0.2) rotate(-30deg);
  }
}

.result-big {
  font-size: 24px;
}

.result-big b {
  color: var(--primary);
  font-size: 40px;
  font-weight: 800;
}

.result-line {
  font-size: 20px;
  font-weight: 700;
}

.missed {
  width: 100%;
  margin-top: 8px;
  padding: 16px;
  border-radius: 22px;
  background: var(--sun-soft);
}

.missed p {
  margin-bottom: 10px;
  font-weight: 700;
}

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

.chip {
  padding: 7px 14px;
  border-radius: 14px;
  background: var(--card);
  box-shadow: inset 0 0 0 2px var(--line);
  font-size: 19px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.chip-more {
  background: none;
  box-shadow: none;
  color: var(--muted);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin-top: 14px;
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -24px;
  width: 11px;
  height: 18px;
  border-radius: 3px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to {
    transform: translate(var(--drift), 110vh) rotate(var(--spin));
  }
}

/* ---------- Karte ---------- */

.lv-new {
  background: var(--lv-new);
  color: var(--muted);
}

.lv-0 {
  background: var(--lv-0);
}

.lv-1 {
  background: var(--lv-1);
}

.lv-2 {
  background: var(--lv-2);
}

.lv-3 {
  background: var(--lv-3);
}

.lv-4 {
  background: var(--lv-4);
  color: #fff;
}

.map-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: center;
  gap: 24px;
}

/* Feldgröße so, dass die Karte in Breite und Höhe ganz auf den Bildschirm passt. */
.map-grid {
  --cell: min(64px, calc((100vw - 48px) / var(--n) - 6px), calc((100vh - 156px) / var(--n) - 6px));
  display: grid;
  grid-template-columns: repeat(var(--n), var(--cell));
  gap: 6px;
}

/* Eigene Regel statt zweiter Deklaration: Bei Variablen greift kein Fallback,
   wenn ein Browser die Einheit dvh nicht kennt. */
@supports (height: 100dvh) {
  .map-grid {
    --cell: min(64px, calc((100vw - 48px) / var(--n) - 6px), calc((100dvh - 156px) / var(--n) - 6px));
  }
}

.cell {
  display: grid;
  place-items: center;
  height: var(--cell);
  border-radius: 12px;
  font-size: calc(var(--cell) * 0.36);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.cell-head {
  color: var(--primary);
}

.cell.is-selected {
  outline: 4px solid var(--ink);
  outline-offset: 1px;
}

.map-side {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 16px;
  min-width: 250px;
  max-width: 420px;
}

.map-goal {
  color: var(--muted);
}

.map-detail {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-height: 132px;
  padding: 18px 20px;
  border-radius: 22px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.map-detail strong {
  font-size: 32px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.map-detail p {
  color: var(--muted);
}

.level-tag {
  padding: 4px 12px;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 800;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.legend li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.legend b {
  margin-left: auto;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.dot {
  flex: none;
  width: 22px;
  height: 22px;
  border-radius: 7px;
}

.legend-inline {
  flex-direction: row;
  flex-wrap: wrap;
  gap: 6px 16px;
  font-size: 15px;
}

.legend-inline .dot {
  width: 16px;
  height: 16px;
  border-radius: 5px;
}

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

.screen.parents {
  max-width: 820px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--card);
  box-shadow: var(--shadow);
}

.panel h2 {
  font-size: 24px;
  font-weight: 800;
}

.panel h3 {
  font-size: 20px;
  font-weight: 800;
}

.panel h4 {
  margin-top: 4px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.note {
  color: var(--muted);
  font-size: 16px;
}

.note:empty {
  display: none;
}

.notice {
  padding: 14px 18px;
  border-radius: 18px;
  background: #ddf7ea;
  color: var(--good-dark);
  font-weight: 700;
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat-tile {
  display: flex;
  flex-direction: column;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--bg);
}

.stat-tile b {
  font-size: 30px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.stat-tile span {
  color: var(--muted);
  font-size: 15px;
}

.chart {
  display: grid;
  grid-template-columns: repeat(14, 1fr);
  gap: 6px;
  height: 150px;
}

.chart-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  min-width: 0;
  height: 100%;
}

.chart-value {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.chart-bar {
  width: 100%;
  max-width: 34px;
  border-radius: 8px 8px 3px 3px;
  background: var(--primary);
}

.chart-bar.is-empty {
  background: var(--primary-soft);
}

.chart-label {
  color: var(--muted);
  font-size: 12px;
}

.overview {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
  border-top: 2px solid var(--line);
}

.stack {
  display: flex;
  height: 34px;
  overflow: hidden;
  border-radius: 12px;
}

.stack span {
  display: grid;
  place-items: center;
  flex-basis: 0;
  min-width: 26px;
  font-size: 14px;
  font-weight: 800;
}

.overview .chips {
  justify-content: flex-start;
}

.chip-detail {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  font-size: 17px;
}

.chip-detail small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.setting {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  padding-top: 16px;
  border-top: 2px solid var(--line);
}

.setting-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 220px;
}

.setting-text small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

.segmented {
  display: flex;
  padding: 4px;
  border-radius: 16px;
  background: var(--primary-soft);
}

.segment {
  min-width: 58px;
  min-height: 44px;
  padding: 8px 14px;
  border-radius: 12px;
  color: var(--muted);
  font-weight: 800;
}

.segment.is-on {
  background: var(--card);
  box-shadow: var(--shadow);
  color: var(--primary);
}

.text-input {
  min-height: 48px;
  padding: 10px 14px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  font-weight: 600;
}

.text-input:focus {
  border-color: var(--primary);
  outline: none;
}

/* Mindestens 16px, sonst zoomt iOS beim Antippen in das Feld hinein. */
.backup-area {
  width: 100%;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 16px;
  resize: vertical;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.parents .btn {
  min-height: 52px;
  padding: 10px 22px;
  font-size: 18px;
}

.version {
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

/* ---------- Dialog ---------- */

.dialog-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(43, 37, 80, 0.5);
  animation: fade-in 0.15s ease-out;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.dialog {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(100%, 440px);
  padding: 28px;
  border-radius: 30px;
  background: var(--card);
  text-align: center;
}

.dialog h2 {
  font-size: 26px;
  font-weight: 800;
}

.dialog p {
  color: var(--muted);
}

.dialog-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

.dialog-wide {
  width: min(100%, 540px);
}

.dialog-options {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 6px;
}

.dialog-options .mode-card {
  width: 100%;
}

.mode-card.is-primary {
  --edge: var(--primary);
  border-color: var(--primary);
}

.dialog-cancel {
  align-self: center;
  min-height: 44px;
  padding: 8px 20px;
  color: var(--muted);
  font-weight: 700;
}

/* ---------- Schmale Bildschirme (Handy) ---------- */

@media (max-width: 560px) {
  .screen {
    gap: 16px;
    padding-right: calc(16px + env(safe-area-inset-right));
    padding-left: calc(16px + env(safe-area-inset-left));
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .exercise-card {
    gap: 14px;
    padding: 18px;
  }

  .exercise-badge {
    width: 68px;
    height: 68px;
    border-radius: 22px;
    font-size: 27px;
  }

  .exercise-text strong {
    font-size: 21px;
  }

  .ring {
    width: 64px;
    height: 64px;
  }

  .ring-text {
    font-size: 14px;
  }

  .hero {
    gap: 12px;
    padding: 16px;
  }

  .hero-buddy {
    width: 60px;
  }

  .hero-go {
    padding: 10px 16px;
    font-size: 19px;
  }

  .rows {
    gap: 8px;
  }

  .row-tile {
    padding: 12px 8px 10px;
    border-radius: 16px;
  }

  .map-grid {
    --cell: calc((100vw - 32px) / var(--n) - 3px);
    gap: 3px;
  }

  .cell {
    border-radius: 7px;
  }

  .stars {
    font-size: 54px;
  }
}

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