/* Wortfuchs – kindgerechtes, ruhiges Design für das iPad */

@font-face {
  font-family: "Andika";
  src: url("../fonts/andika-400.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Andika";
  src: url("../fonts/andika-700.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #fbf6ee;
  --bg-2: #f5ecdd;
  --card: #ffffff;
  --ink: #3b2a1f;
  --muted: #86705f;
  --line: #ecdfcc;
  --fox: #e8742a;
  --fox-dark: #c75a14;
  --fox-light: #fde3cf;
  --cream: #fff8ee;
  --green: #3f9a5c;
  --green-light: #e3f3e7;
  --red: #d2544c;
  --red-light: #fdeceb;
  --blue: #5b8fd6;
  --star: #f6b73c;
  --radius: 22px;
  --shadow: 0 2px 0 rgba(59, 42, 31, .06), 0 8px 24px rgba(59, 42, 31, .08);
  --font: "Andika", "Avenir Next", "Helvetica Neue", system-ui, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 110% -10%, #fde3cf 0, transparent 60%),
    radial-gradient(900px 500px at -20% 110%, #e6f1e3 0, transparent 60%),
    var(--bg);
  background-attachment: fixed;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}
button { font-family: inherit; color: inherit; touch-action: manipulation; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; line-height: 1.2; }

.screen {
  min-height: 100vh;
  min-height: 100dvh;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b));
}

/* ----------------------------------------------------------- Bausteine */

.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  border: 0;
  text-align: left;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5em;
  border: 0;
  border-radius: 999px;
  padding: .7em 1.4em;
  font-size: 1.15rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s ease, box-shadow .1s ease, background .15s;
}
.btn:active { transform: translateY(2px) scale(.98); }
.btn-primary { background: var(--fox); color: #fff; box-shadow: 0 4px 0 var(--fox-dark); }
.btn-primary:active { box-shadow: 0 2px 0 var(--fox-dark); }
.btn-secondary { background: var(--card); color: var(--ink); box-shadow: 0 4px 0 var(--line); }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-xl { font-size: 1.5rem; padding: .75em 2em; }

.icon-btn {
  width: 48px; height: 48px;
  flex: none;
  border-radius: 50%;
  border: 0;
  background: var(--card);
  box-shadow: var(--shadow);
  font-size: 1.3rem;
  cursor: pointer;
}
.link-btn { background: none; border: 0; color: var(--muted); font-size: 1rem; text-decoration: underline; cursor: pointer; padding: 12px; }

.progress { height: 12px; border-radius: 99px; background: var(--bg-2); overflow: hidden; }
.progress-bar { height: 100%; width: 0; border-radius: 99px; background: linear-gradient(90deg, var(--star), var(--fox)); transition: width .5s cubic-bezier(.3, 1.4, .6, 1); }
.progress-big { height: 16px; flex: 1 1 160px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip { background: var(--cream); border: 2px solid var(--fox-light); border-radius: 999px; padding: 6px 14px; font-size: 1.15rem; }

.bubble {
  position: relative;
  background: var(--card);
  border-radius: 20px;
  padding: 14px 20px;
  box-shadow: var(--shadow);
  font-size: 1.25rem;
  line-height: 1.35;
}
.bubble-left::before {
  content: "";
  position: absolute;
  left: -10px; top: 50%;
  width: 20px; height: 20px;
  background: inherit;
  transform: translateY(-50%) rotate(45deg);
  border-radius: 4px;
}
.bubble h1 { font-size: 1.6rem; margin-bottom: 4px; }
.bubble p { margin: 0; color: var(--muted); }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-b));
  transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 12px 20px; border-radius: 999px;
  font-size: 1.05rem; z-index: 50;
  box-shadow: var(--shadow);
}

/* ----------------------------------------------------------- Fuchs */

.fox-wrap { width: 150px; flex: none; }
.fox-small { width: 104px; }
.fox-big { width: 180px; }
.fox { display: block; width: 100%; height: auto; overflow: visible; }
.fox-head { transform-origin: 100px 170px; animation: bob 3.2s ease-in-out infinite; }
.fox-ear, .fox-face { fill: var(--fox); }
.fox-ear-in { fill: #7a3b17; opacity: .85; }
.fox-muzzle, .fox-stripe { fill: #fff8ee; }
.fox-stripe { opacity: .55; }
.fox-blush { fill: #f59a8a; opacity: .45; }
.eye ellipse, .fox-nose { fill: #2e1d14; }
.glint { fill: #fff; }
.eyes-happy path, .brows path, .mouth-smile, .mouth-sad { fill: none; stroke: #2e1d14; stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.mouth-in, .mouth-talk { fill: #2e1d14; }
.tongue { fill: #f2777a; }
.eyes-open .eye { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }

.fox .eyes-happy, .fox .brows, .fox .mouth { display: none; }
.fox[data-mood="neutral"] .mouth-smile,
.fox[data-mood="talk"] .mouth-talk,
.fox[data-mood="sad"] .mouth-sad,
.fox[data-mood="sad"] .brows,
.fox[data-mood="happy"] .eyes-happy,
.fox[data-mood="happy"] .mouth-open,
.fox[data-mood="proud"] .eyes-happy,
.fox[data-mood="proud"] .mouth-open { display: inline; }
.fox[data-mood="happy"] .eyes-open,
.fox[data-mood="proud"] .eyes-open { display: none; }
.fox[data-mood="talk"] .mouth-talk { transform-box: fill-box; transform-origin: center; animation: talk .28s ease-in-out infinite alternate; }
.fox[data-mood="happy"] .fox-head { animation: hop .5s ease-out 2; }
.fox[data-mood="sad"] .fox-head { animation: none; transform: rotate(-6deg); transition: transform .3s; }

@keyframes bob { 50% { transform: translateY(-4px) rotate(1deg); } }
@keyframes blink { 0%, 94%, 100% { transform: scaleY(1); } 97% { transform: scaleY(.1); } }
@keyframes talk { from { transform: scaleY(.35); } to { transform: scaleY(1.1); } }
@keyframes hop { 40% { transform: translateY(-14px) rotate(-3deg); } 70% { transform: translateY(0) rotate(2deg); } }

/* ----------------------------------------------------------- Startseite */

#home { max-width: 760px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; padding-top: calc(32px + var(--safe-t)); }
.home-head { display: flex; align-items: center; gap: 24px; }
.home-head .bubble { flex: 1; }

.install-hint { display: flex; align-items: flex-start; gap: 12px; background: #eef4fc; color: #2d4a73; border-radius: 18px; padding: 14px 16px; font-size: 1rem; line-height: 1.4; }
.install-text { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 10px; }
.install-hint p { margin: 0; }
.install-icon { font-size: 1.6rem; }
.install-hint .icon-btn { width: 36px; height: 36px; font-size: 1rem; box-shadow: none; }
.share-ico { display: inline-block; border: 1.5px solid currentColor; border-radius: 5px; padding: 0 4px; font-size: .85em; }

.card-current { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; padding: 28px; position: relative; overflow: hidden; }
.card-current::after { content: "✏️"; position: absolute; right: 10px; top: -34px; font-size: 120px; opacity: .08; transform: rotate(20deg); pointer-events: none; }
.card-current-label { color: var(--fox-dark); font-weight: 700; text-transform: uppercase; letter-spacing: .08em; font-size: .9rem; }
.card-current-title { font-size: 2.6rem; }
.card-current-progress { display: flex; align-items: center; gap: 14px; width: 100%; flex-wrap: wrap; color: var(--muted); font-size: 1.15rem; }
.badge-rounds { background: #fff3d6; color: #8a5a00; border-radius: 999px; padding: 2px 10px; font-size: 1rem; }
.card-current .btn { margin-top: 6px; }
.card-loading, .card-error { text-align: center; color: var(--muted); font-size: 1.2rem; }
.card-error p { margin: 0 0 16px; }

.archive-wrap h2 { font-size: 1.3rem; margin: 4px 4px 12px; color: var(--muted); }
.archive { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.card-archive { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; cursor: pointer; font-size: 1rem; transition: transform .1s; border-left: 6px solid var(--blue); }
.card-archive:active { transform: scale(.97); }
.card-archive.is-done { border-left-color: var(--star); }
.card-archive-title { font-size: 1.35rem; font-weight: 700; }
.card-archive-meta { color: var(--muted); }

.home-foot { text-align: center; margin-top: auto; }

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

#train {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  gap: 12px;
  max-width: 1080px;
  margin: 0 auto;
  padding-bottom: calc(12px + var(--safe-b));
}

.train-top { display: flex; align-items: center; gap: 16px; }
.train-meta { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.train-title { font-size: 1.3rem; font-weight: 700; }
.train-count { font-size: 1.2rem; font-weight: 700; color: var(--fox-dark); min-width: 3.5em; text-align: right; }

.stars { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px; font-size: 1.6rem; line-height: 1; }
.star { color: #e7dccb; transition: transform .3s; }
.star-half { background: linear-gradient(90deg, var(--star) 50%, #e7dccb 50%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.star-full { color: var(--star); animation: pop .5s ease-out; }
.star.is-current { transform: translateY(-3px); text-shadow: 0 0 0 transparent; }
@keyframes pop { 50% { transform: scale(1.5); } }

.stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; min-height: 0; }
.fox-col { display: flex; align-items: center; gap: 22px; max-width: 640px; width: 100%; }
.fox-col .bubble { flex: 1; min-height: 64px; display: flex; align-items: center; }
.listen { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.btn-listen { background: var(--blue); color: #fff; box-shadow: 0 4px 0 #3f6fb0; font-size: 1.3rem; }
.btn-slow { background: var(--card); box-shadow: 0 4px 0 var(--line); }

.compare { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; animation: fadeup .3s ease-out; }
.compare-row { background: var(--card); border-radius: 18px; padding: 10px 20px; box-shadow: var(--shadow); text-align: center; }
.compare-label { display: block; font-size: .95rem; color: var(--muted); }
.compare-word { font-size: 2.2rem; letter-spacing: .04em; white-space: nowrap; }
.compare-word span { display: inline-block; min-width: .3em; border-radius: 6px; }
.attempt .mark-wrong { background: var(--red-light); color: var(--red); text-decoration: underline wavy var(--red); text-underline-offset: 6px; }
.attempt .mark-extra { background: var(--red-light); color: var(--red); text-decoration: line-through 3px; }
.attempt .mark-missing { color: var(--red); background: var(--red-light); }
.attempt.is-other { color: var(--red); }
.target { color: var(--green); }
.target .mark-fix { background: var(--green-light); font-weight: 700; text-decoration: underline 3px; text-underline-offset: 6px; }
.mode-copy .listen { display: none; }
@keyframes fadeup { from { opacity: 0; transform: translateY(8px); } }

/* Schreiblinie */
.slate { display: flex; justify-content: center; }
.line {
  position: relative;
  width: min(100%, 760px);
  height: 108px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 24px 22px;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  font-size: 3.4rem;
  line-height: 1;
  white-space: pre;
  overflow: hidden;
  transition: background .2s, box-shadow .2s;
}
/* Grundschul-Lineatur: Grundlinie + gestrichelte Mittellinie */
.line::before, .line::after { content: ""; position: absolute; left: 24px; right: 24px; pointer-events: none; }
.line::before { bottom: calc(22px + .07em); border-bottom: 2px solid #e6d8c3; }
.line::after { bottom: calc(22px + .72em); border-bottom: 2px dashed #f0e6d8; }
.line > span { position: relative; z-index: 1; }
.placeholder { color: #cdbca6; font-size: 1.8rem; align-self: center; margin-bottom: -22px; position: absolute !important; }
.caret { width: 3px; height: 1em; background: var(--fox); margin-left: 3px; border-radius: 2px; animation: caret 1s steps(1) infinite; align-self: flex-end; margin-bottom: 4px; }
#typed:empty + .caret { display: none; }
.line.is-ok { background: var(--green-light); box-shadow: 0 0 0 4px var(--green), var(--shadow); color: #24603a; }
.line.is-ok .caret, .line.is-wrong .caret { display: none; }
.line.is-wrong { background: var(--red-light); box-shadow: 0 0 0 4px var(--red), var(--shadow); }
.mode-copy .line { box-shadow: 0 0 0 4px var(--blue), var(--shadow); }
.shake { animation: shake .4s; }
@keyframes caret { 50% { opacity: 0; } }
@keyframes shake { 20%, 60% { transform: translateX(-10px); } 40%, 80% { transform: translateX(10px); } }

/* Tastatur */
.kb { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 1000px; margin: 0 auto; transition: opacity .2s; }
.kb.is-disabled { opacity: .45; pointer-events: none; }
.kb-row { display: flex; gap: 7px; justify-content: center; }
.kb-key {
  flex: 1 1 0;
  min-width: 0;
  height: clamp(54px, 7.4vh, 70px);
  border: 0;
  border-radius: 14px;
  background: var(--card);
  box-shadow: 0 4px 0 #e2d4bf;
  font-size: clamp(1.4rem, 3.4vw, 2rem);
  cursor: pointer;
  transition: transform .06s, box-shadow .06s, background .1s;
}
.kb-key.is-pressed, .kb-key:active { transform: translateY(3px); box-shadow: 0 1px 0 #e2d4bf; background: var(--fox-light); }
.kb-shift, .kb-back { background: var(--bg-2); flex-grow: 1.4; }
.kb-shift.is-active { background: var(--fox); color: #fff; box-shadow: 0 4px 0 var(--fox-dark); }
.kb-row-3 .kb-space { flex-grow: 5; font-size: 1.2rem; color: var(--muted); }
.kb-row-3 .kb-enter { flex-grow: 2; background: var(--green); color: #fff; box-shadow: 0 4px 0 #2d7444; font-size: 1.4rem; font-weight: 700; }
.kb-row-3 { padding: 0 6%; }

/* Querformat iPad: Fuchs und Vergleich nebeneinander */
@media (min-aspect-ratio: 5/4) {
  .stage { flex-direction: row; flex-wrap: wrap; }
  .fox-col { max-width: 520px; }
}

/* Hochformat: mehr Platz für den Fuchs */
@media (max-aspect-ratio: 4/5) and (min-height: 900px) {
  .fox-small { width: 140px; }
  .fox-col .bubble { font-size: 1.4rem; }
  .compare-word { font-size: 2.6rem; }
}

/* kleine Höhe (iPad quer mit wenig Platz, iPhone quer) */
@media (max-height: 760px) {
  .fox-small { width: 84px; }
  .stars { font-size: 1.3rem; }
  .line { height: 92px; font-size: 3rem; }
  .compare-word { font-size: 1.8rem; }
  .bubble { font-size: 1.1rem; }
}

/* ----------------------------------------------------------- Geschafft */

#done { display: flex; align-items: center; justify-content: center; text-align: center; }
.done-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; max-width: 640px; }
.trophy-wrap { position: relative; }
.trophy { position: absolute; right: -36px; bottom: 0; font-size: 72px; animation: hop 1s ease-out 2; }
#done h1 { font-size: 3rem; color: var(--fox-dark); }
.done-text { font-size: 1.4rem; margin: 0; }
.done-tricky h2 { font-size: 1.1rem; color: var(--muted); margin-bottom: 10px; }
.done-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }

.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 40; }

/* ----------------------------------------------------------- Elternbereich */

.dialog { border: 0; border-radius: var(--radius); padding: 0; max-width: min(560px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); color: var(--ink); user-select: text; -webkit-user-select: text; }
.dialog::backdrop { background: rgba(59, 42, 31, .4); }
.dialog-inner { padding: 28px; display: flex; flex-direction: column; gap: 12px; font-size: 1.05rem; line-height: 1.5; }
.dialog-inner p { margin: 0; }
.dialog-inner h2 { font-size: 1.6rem; }
.muted { color: var(--muted); }
.switch { display: flex; gap: 10px; align-items: center; font-weight: 700; }
.switch input { width: 22px; height: 22px; accent-color: var(--fox); }
.voice-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.voice-row select { flex: 1 1 200px; font: inherit; font-size: 1rem; padding: 8px 10px; border-radius: 12px; border: 2px solid var(--line); background: var(--cream); color: var(--ink); }
.btn-small { font-size: 1rem; padding: .45em 1em; }
.dialog-actions { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-top: 8px; }
.dialog-actions .btn { font-size: 1rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
