@font-face {
  font-family: "Grundschrift";
  src: url("assets/fonts/grundschrift-beta.ttf") format("truetype");
  font-style: normal;
  font-weight: 400;
  font-display: block;
}

:root {
  --ink: #233245;
  --muted: #6d7784;
  --cream: #fff8ec;
  --paper: #ffffff;
  --green: #35a66f;
  --green-dark: #137a4c;
  --orange: #f2a23a;
  --purple: #7356c8;
  --blue: #4b8bd8;
  --shadow: 0 20px 60px rgba(58, 48, 33, .16);
  --reading-font: "Grundschrift", sans-serif;
  font-family: ui-rounded, "SF Pro Rounded", "Avenir Next", system-ui, sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: radial-gradient(circle at 20% 10%, #fff 0, var(--cream) 45%, #f8e8cd 100%); min-height: 100vh; }
button, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.app-shell { min-height: 100vh; min-height: 100dvh; width: min(100%, 920px); margin: 0 auto; position: relative; overflow: hidden; }
.screen { display: none; min-height: 100vh; min-height: 100dvh; padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); }
.screen.active { display: flex; }

#home { flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 16px; }
.parent-link { position: absolute; top: max(16px, env(safe-area-inset-top)); right: 18px; border: 0; background: rgba(255,255,255,.7); color: var(--muted); padding: 9px 13px; border-radius: 999px; }
.hero-dragon { display: flex; align-items: center; justify-content: center; font-size: clamp(76px, 18vw, 124px); height: 150px; }
.dragon-body { animation: hover 2.2s ease-in-out infinite; filter: drop-shadow(0 12px 12px rgba(52, 74, 62, .18)); }
.dragon-wing { width: 42px; height: 56px; background: #8bd1a6; border-radius: 100% 10% 100% 10%; opacity: .7; }
.wing-left { transform: rotate(-25deg); animation: flap-left .7s ease-in-out infinite alternate; }
.wing-right { transform: scaleX(-1) rotate(-25deg); animation: flap-right .7s ease-in-out infinite alternate; }
@keyframes hover { 50% { transform: translateY(-10px) rotate(2deg); } }
@keyframes flap-left { to { transform: rotate(-50deg) scaleY(.75); } }
@keyframes flap-right { to { transform: scaleX(-1) rotate(-50deg) scaleY(.75); } }

.eyebrow { margin: 0; color: var(--purple); font-weight: 850; letter-spacing: .12em; text-transform: uppercase; font-size: 13px; }
h1 { margin: 0; max-width: 650px; font-size: clamp(36px, 8vw, 64px); line-height: 1.02; letter-spacing: -.04em; }
.lesson-pill { margin: 2px 0 0; background: #ece5ff; color: #563ca9; padding: 9px 16px; border-radius: 999px; font-weight: 800; }
.home-lesson-picker, .home-focus-picker { width: min(100%, 720px); }
.home-lesson-picker h2, .home-focus-picker h2 { margin: 0 0 10px; color: var(--muted); font-size: 15px; letter-spacing: .02em; }
.home-lesson-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.lesson-choice { position: relative; min-height: 86px; border: 2px solid rgba(86,60,169,.13); border-radius: 18px; background: rgba(255,255,255,.78); color: var(--ink); padding: 13px 10px 10px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; box-shadow: 0 5px 16px rgba(58,48,33,.06); }
.lesson-choice strong { font-size: 15px; }
.lesson-choice span { color: var(--muted); font-size: 12px; }
.lesson-choice small { color: var(--purple); font-weight: 850; font-size: 11px; }
.lesson-choice.selected { border-color: var(--green); background: #eaf8f0; box-shadow: 0 0 0 4px rgba(53,166,111,.12); }
.lesson-choice.selected small { color: var(--green-dark); }
.home-focus-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.focus-choice { min-height: 54px; border: 2px solid rgba(86,60,169,.13); border-radius: 16px; background: rgba(255,255,255,.78); color: var(--ink); padding: 8px 7px; font-weight: 800; cursor: pointer; }
.focus-choice span { display: block; color: var(--muted); font-size: 10px; font-weight: 700; margin-top: 2px; }
.focus-choice.selected { border-color: var(--purple); background: #eee9ff; color: #563ca9; box-shadow: 0 0 0 3px rgba(115,86,200,.1); }
.home-copy { margin: 0; color: var(--muted); font-size: clamp(17px, 3vw, 21px); max-width: 520px; }
.primary-button, .secondary-button { border: 0; border-radius: 18px; min-height: 62px; padding: 0 28px; font-weight: 900; font-size: 20px; cursor: pointer; }
.primary-button { background: linear-gradient(135deg, var(--green), var(--green-dark)); color: white; box-shadow: 0 10px 28px rgba(19, 122, 76, .25); }
.secondary-button { background: #ece5ff; color: #563ca9; }
.home-stats { display: flex; gap: 24px; color: var(--muted); margin-top: 8px; }
.home-stats strong { color: var(--ink); }

@media (max-width: 620px) {
  #home { justify-content: flex-start; padding-top: max(70px, env(safe-area-inset-top)); gap: 13px; }
  .hero-dragon { height: 100px; font-size: 76px; }
  .home-lesson-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .home-focus-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .lesson-choice { min-height: 72px; }
}

#trainer { flex-direction: column; gap: 16px; background: linear-gradient(#eef8ff 0 23%, var(--cream) 23%); }
.trainer-header { display: grid; grid-template-columns: 52px 1fr 62px; align-items: center; gap: 12px; }
.icon-button { width: 48px; height: 48px; border-radius: 50%; border: 0; background: rgba(255,255,255,.85); color: var(--muted); font-size: 32px; }
.phase-copy { text-align: center; display: flex; flex-direction: column; }
.phase-copy span { color: var(--muted); font-weight: 750; font-size: 14px; }
.phase-copy strong { font-variant-numeric: tabular-nums; font-size: 22px; }
.star-counter { background: #fff0a7; color: #805b00; padding: 10px 13px; border-radius: 999px; display: flex; justify-content: center; gap: 6px; font-size: 18px; }
.flight-track { position: relative; height: 18px; border-radius: 99px; background: rgba(75,139,216,.13); margin: 0 10px; }
#flight-progress { height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, #69b4e5, #7acb9a); transition: width .45s ease; }
#flying-dragon { position: absolute; top: 50%; left: 0; transform: translate(-45%, -55%); font-size: 25px; transition: left .45s ease; }

.card-zone { flex: 1; display: grid; place-items: center; position: relative; min-height: 360px; }
.reading-card { width: min(100%, 720px); min-height: min(54vh, 540px); background: var(--paper); border-radius: 34px; box-shadow: var(--shadow); padding: clamp(24px, 5vw, 48px); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 24px; position: relative; overflow: hidden; transform-origin: center; }
.reading-card.enter { animation: card-enter .34s cubic-bezier(.2,.8,.2,1); }
.reading-card.leave { animation: card-leave .24s ease forwards; }
.reading-card.success { animation: card-success .45s ease; }
@keyframes card-enter { from { opacity: 0; transform: translateX(45px) scale(.96); } }
@keyframes card-leave { to { opacity: 0; transform: translateX(-55px) rotate(-2deg); } }
@keyframes card-success { 50% { transform: scale(1.025); box-shadow: 0 0 0 10px rgba(53,166,111,.13), var(--shadow); } }
.kind-label { position: absolute; top: 22px; left: 24px; color: var(--muted); font-weight: 800; font-size: 14px; }
.card-seconds { position: absolute; top: 18px; right: 20px; min-width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: #f4f6f8; color: var(--muted); font-weight: 900; font-variant-numeric: tabular-nums; }
.card-content { width: 100%; display: flex; align-items: center; justify-content: center; gap: clamp(14px, 5vw, 52px); text-align: center; font-family: var(--reading-font); font-size: clamp(62px, 13vw, 128px); font-weight: 400; letter-spacing: .015em; line-height: 1.12; }
.card-content.long { font-size: clamp(34px, 7.4vw, 72px); }
.card-content.sentence { font-size: clamp(29px, 6.4vw, 60px); line-height: 1.22; }
.card-content.visual-card { flex-wrap: wrap; gap: clamp(12px, 2.5vw, 28px); }
.visual-text { white-space: nowrap; }
.inline-pictogram { display: block; width: auto; height: 1.42em; max-width: 2.15em; object-fit: contain; mix-blend-mode: multiply; }
.inline-pictogram.icon-herz { height: 1.05em; max-width: 1.25em; }
.card-content.monster-card { flex-direction: column; gap: clamp(10px, 2vw, 20px); }
.monster-pictogram { width: auto; height: clamp(82px, 16vw, 128px); object-fit: contain; mix-blend-mode: multiply; }
.monster-syllables { white-space: nowrap; }
.card-content.syllable-sentence { display: flex; flex-wrap: wrap; align-content: center; gap: .12em .34em; }
.card-content.syllable-sentence.with-illustration { display: grid; grid-template-columns: clamp(110px, 20vw, 170px) minmax(0, 1fr); align-items: center; gap: clamp(14px, 3vw, 28px); }
.sentence-words { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: .12em .34em; }
.niko-illustration { display: block; width: 100%; aspect-ratio: 1.46; border: 2px solid #d8d8d2; border-radius: 16px; background-repeat: no-repeat; background-position: center; background-size: cover; box-shadow: 0 7px 18px rgba(35,50,69,.09); }
.niko-girls { background-image: url("assets/niko/nala-emma-malen.jpg"); }
.niko-painting { background-image: url("assets/niko/mama-ali-malen.jpg"); }
.syllable-word { display: inline-flex; white-space: nowrap; }
.syllable-blue { color: #2f72b7; }
.syllable-red { color: #c83f4c; }
.chunk:nth-child(odd) { color: #347ec7; }
.chunk:nth-child(even) { color: #d34f54; }
.blend-part { min-width: .7em; }
.blend-part:first-child { animation: blend-left 3.4s ease-in-out infinite; }
.blend-part:last-child { animation: blend-right 3.4s ease-in-out infinite; }
@keyframes blend-left { 0%,18% { transform: translateX(-35px); } 55%,100% { transform: translateX(8px); } }
@keyframes blend-right { 0%,18% { transform: translateX(35px); } 55%,100% { transform: translateX(-8px); } }
.audio-button { border: 0; background: #eef4ff; color: #3265a2; border-radius: 999px; padding: 11px 18px; font-weight: 800; align-self: center; margin: -4px auto 0; }
.card-hint { min-height: 24px; margin: 0; color: var(--muted); text-align: center; font-size: 16px; }
.timer { position: absolute; left: 0; right: 0; bottom: 0; height: 10px; background: #eef0f2; }
#timer-fill { height: 100%; width: 100%; transform-origin: left; background: linear-gradient(90deg, var(--green), var(--orange)); }
.timeout-note { position: absolute; z-index: 5; opacity: 0; transform: translateY(12px); background: #fff3cf; color: #7f5a0b; padding: 12px 18px; border-radius: 999px; font-weight: 800; pointer-events: none; }
.timeout-note.show { animation: note 1.25s ease; }
@keyframes note { 15%,75% { opacity: 1; transform: translateY(0); } }

.answer-bar { display: grid; grid-template-columns: 1fr 1.15fr; gap: 14px; width: min(100%, 720px); margin: 0 auto; }
.answer-button { min-height: 76px; border: 0; border-radius: 23px; display: flex; align-items: center; justify-content: center; gap: 10px; font-size: clamp(17px, 4vw, 22px); cursor: pointer; box-shadow: 0 8px 20px rgba(35,50,69,.1); }
.answer-button span { font-size: 30px; }
.try-again { background: #fff1dc; color: #91580e; }
.correct { background: var(--green); color: white; }

#summary { flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 18px; }
.summary-dragon { font-size: 96px; animation: hover 2s ease-in-out infinite; }
#summary h2 { font-size: clamp(40px, 9vw, 70px); margin: 0; }
.summary-message { max-width: 580px; margin: 0; color: var(--muted); font-size: 20px; }
.summary-grid { display: grid; grid-template-columns: repeat(3, 1fr); width: min(100%, 620px); gap: 12px; }
.summary-grid div { background: white; border-radius: 22px; padding: 20px 10px; box-shadow: 0 8px 28px rgba(58,48,33,.08); }
.summary-grid strong { display: block; font-size: 34px; }
.summary-grid span { color: var(--muted); font-size: 14px; }
.practice-list { min-height: 28px; color: var(--purple); font-weight: 800; }

dialog { width: min(92vw, 560px); border: 0; border-radius: 28px; padding: 0; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(25,31,39,.45); backdrop-filter: blur(4px); }
.parent-panel { padding: 32px; display: flex; flex-direction: column; gap: 14px; }
.parent-panel h2 { margin: 0 0 8px; font-size: 30px; }
.dialog-close { position: absolute; right: 16px; top: 14px; border: 0; background: transparent; font-size: 30px; color: var(--muted); }
.parent-panel label { font-weight: 850; }
.parent-panel select { min-height: 52px; border: 2px solid #dfe4e8; border-radius: 14px; padding: 0 14px; background: white; }
.parent-note { color: var(--muted); line-height: 1.45; }
.font-credit { color: var(--muted); font-size: 11px; line-height: 1.35; }
.parent-progress { background: #f5f6f8; border-radius: 15px; padding: 14px; font-size: 14px; color: var(--muted); }
.danger-link { border: 0; background: transparent; color: #a44444; text-decoration: underline; align-self: flex-start; padding: 8px 0; }

@media (max-width: 540px) {
  .screen { padding-left: 14px; padding-right: 14px; }
  #trainer { gap: 11px; }
  .reading-card { border-radius: 25px; min-height: 50vh; }
  .answer-button { min-height: 68px; }
  .card-content.syllable-sentence.with-illustration { grid-template-columns: 105px minmax(0, 1fr); gap: 12px; }
  .summary-grid { gap: 7px; }
  .summary-grid div { padding: 15px 6px; }
}

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