/* =====================================================================
   Lernnest – 10-Finger-Spiele + Bildschirm-Tastatur (tastatur.js)
   Wird von tippen.html geladen. aufgabe.html nutzt die .tt-/.kb-Klassen
   ebenfalls; dort fallen sie auf einfache Standarddarstellung zurück,
   falls diese Datei nicht eingebunden ist.
   ===================================================================== */
:root {
  --f-lp: #f6c9d3;  /* kleiner Finger: Rosa */
  --f-lr: #fbdcae;  /* Ringfinger: Aprikose */
  --f-lm: #cfe6c4;  /* Mittelfinger: Minze */
  --f-li: #c3dcf1;  /* Zeigefinger links: Himmel */
  --f-ri: #d9cdf0;  /* Zeigefinger rechts: Lavendel */
  --f-rm: #cfe6c4;
  --f-rr: #fbdcae;
  --f-rp: #f6c9d3;
  --f-th: #ece4d6;  /* Daumen: Sand */
  --key-ink: #3e3530;
  --tt-font: ui-monospace, 'Atkinson Hyperlegible Mono', 'Menlo', 'Consolas', monospace;
}
html[data-theme="nacht"] {
  --f-lp: #c9909c; --f-lr: #c9a675; --f-lm: #93b487; --f-li: #86a9c7;
  --f-ri: #a597c4; --f-rm: #93b487; --f-rr: #c9a675; --f-rp: #c9909c; --f-th: #a89d8b;
  --key-ink: #1f1a17;
}
html[data-font="dyslexie"] { --tt-font: var(--font); }

/* ---------- Abtipp-Übung ---------- */
.tt { display: flex; flex-direction: column; gap: .9rem; }
.tt-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; font-weight: 700; }
.tt-progress { flex: 1 1 160px; }
.tt-line {
  font-family: var(--tt-font);
  font-size: clamp(1.6rem, 4.2vw, 2.4rem);
  line-height: 1.6; letter-spacing: .04em;
  padding: .8rem 1rem;
  background: var(--surface-soft, #f4ebde);
  border-radius: var(--r, 20px);
  overflow-wrap: break-word;
  min-height: 3.2em;
}
.tt-char { color: var(--text-soft, #6f635a); border-radius: 6px; padding: 0 .02em; transition: color .15s; }
.tt-char--done { color: var(--sage-deep, #4f7d48); }
.tt-char--cur {
  color: var(--text, #3e3530);
  background: color-mix(in srgb, var(--honey, #e9c46a) 35%, transparent);
  box-shadow: inset 0 -.18em 0 var(--peach-deep, #b8632d);
}
.tt-char--space.tt-char--cur { min-width: .7em; display: inline-block; }
.tt-char--wrong { animation: tt-wrong .5s ease; }
@keyframes tt-wrong {
  0%, 60% { color: var(--rose-deep, #a9494e); background: var(--rose-soft, #f9e3e2); box-shadow: inset 0 -.18em 0 var(--rose-deep, #a9494e); }
  20% { transform: translateX(-3px); } 40% { transform: translateX(3px); }
}
.tt-done { color: var(--sage-deep, #4f7d48); font-family: var(--font); font-weight: 800; }
.tt-hint { min-height: 1.5em; font-weight: 700; color: var(--peach-deep, #b8632d); }
.tt-next { font-family: var(--tt-font); font-size: 1rem; }
.tt-input { gap: .5rem; }
.tt-hidden {
  position: absolute; opacity: 0; width: 1px; height: 1px; padding: 0; border: 0;
  font-size: 16px; /* verhindert Zoom auf dem iPad */
  pointer-events: none;
}
.tt-focus { min-height: 48px; }
@media (hover: hover) and (pointer: fine) { .tt-focus { opacity: .7; } }

/* ---------- Bildschirm-Tastatur ---------- */
.kb { display: flex; flex-direction: column; gap: .6rem; user-select: none; -webkit-user-select: none; }
.kb-board {
  display: flex; flex-direction: column; gap: clamp(3px, .5vw, 6px);
  padding: clamp(6px, 1vw, 12px);
  background: var(--surface-soft, #f4ebde);
  border-radius: var(--r, 20px);
  max-width: 860px; width: 100%; margin: 0 auto;
}
.kb-row { display: flex; gap: clamp(3px, .5vw, 6px); }
.kb-row--space { justify-content: center; }
.kb-key {
  --w: 1;
  flex: var(--w) 1 0; min-width: 0;
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  aspect-ratio: calc(var(--w) * 1.05) / 1;
  max-height: 58px;
  border-radius: 9px;
  background: var(--f-th);
  color: var(--key-ink);
  font-weight: 700; font-size: clamp(.7rem, 1.6vw, 1.05rem); line-height: 1.05;
  box-shadow: 0 2px 0 rgba(92, 64, 40, .18);
  transition: transform .12s, box-shadow .12s, outline-color .2s;
  outline: 3px solid transparent; outline-offset: 1px;
}
.kb-key__shift { font-size: .7em; opacity: .65; }
.kb-key--special { font-size: clamp(.65rem, 1.3vw, .9rem); opacity: .85; }
.kb-space { aspect-ratio: auto; height: clamp(26px, 4.4vw, 46px); flex: 0 1 50%; }
.kb-f-lp { background: var(--f-lp); } .kb-f-lr { background: var(--f-lr); }
.kb-f-lm { background: var(--f-lm); } .kb-f-li { background: var(--f-li); }
.kb-f-ri { background: var(--f-ri); } .kb-f-rm { background: var(--f-rm); }
.kb-f-rr { background: var(--f-rr); } .kb-f-rp { background: var(--f-rp); }
.kb-f-th { background: var(--f-th); }
.kb-key--home::after {
  content: ""; position: absolute; bottom: 14%; left: 38%; right: 38%;
  height: 3px; border-radius: 3px; background: var(--key-ink); opacity: .55;
}
.kb-key--next {
  outline-color: var(--peach-deep, #b8632d);
  transform: translateY(-2px) scale(1.08);
  box-shadow: 0 0 0 4px #fff, 0 6px 14px rgba(184, 99, 45, .35);
  z-index: 1;
  animation: kb-glow 1.4s ease-in-out infinite;
}
@keyframes kb-glow { 50% { box-shadow: 0 0 0 6px #fff, 0 6px 18px rgba(184, 99, 45, .5); } }
.kb-key--ok { animation: kb-ok .35s ease; }
.kb-key--bad { animation: kb-bad .45s ease; }
@keyframes kb-ok { 50% { background: var(--sage, #8ab17d); transform: scale(.94); } }
@keyframes kb-bad { 0%, 50% { background: var(--rose, #e5989b); } 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }

/* Hände-Legende */
.kb-legend { display: flex; align-items: flex-end; justify-content: center; gap: 1rem; }
.kb-hand { position: relative; display: flex; align-items: flex-end; gap: 4px; padding-bottom: 18px; }
.kb-palm {
  position: absolute; left: 0; right: 0; bottom: 0; height: 26px;
  border-radius: 10px 10px 18px 18px; background: var(--paper-2, #f4ebde); border: 2px solid var(--line, #ebe0d1);
  z-index: 0;
}
.kb-finger {
  position: relative; z-index: 1;
  width: 18px; border-radius: 9px 9px 4px 4px;
  border: 2px solid rgba(92, 64, 40, .15);
  transition: transform .2s, box-shadow .2s;
}
.kb-hand .kb-f-lp, .kb-hand .kb-f-rp { height: 34px; }
.kb-hand .kb-f-lr, .kb-hand .kb-f-rr { height: 46px; }
.kb-hand .kb-f-lm, .kb-hand .kb-f-rm { height: 52px; }
.kb-hand .kb-f-li, .kb-hand .kb-f-ri { height: 46px; }
.kb-hand .kb-f-th { height: 24px; width: 20px; }
.kb-hand--l .kb-f-th { transform: rotate(35deg) translate(2px, -2px); }
.kb-hand--r .kb-f-th { transform: rotate(-35deg) translate(-2px, -2px); }
.kb-finger--on { box-shadow: 0 0 0 3px var(--peach-deep, #b8632d); transform: translateY(-6px); }
.kb-hand--l .kb-f-th.kb-finger--on { transform: rotate(35deg) translate(2px, -8px); }
.kb-hand--r .kb-f-th.kb-finger--on { transform: rotate(-35deg) translate(-2px, -8px); }
.kb-info { flex: 0 1 22rem; text-align: center; font-size: 1.05rem; min-height: 2.6em; display: flex; align-items: center; justify-content: center; }

/* ---------- Seite ---------- */
.tp-title { margin: .2rem 0 0; }
.tp-kid { display: inline-flex; align-items: center; gap: .4rem; font-weight: 800; }
.tp-kid__avatar { font-size: 1.6rem; }
.tp-course {
  flex-direction: row; justify-content: flex-start; text-align: left; gap: 1rem;
  min-height: 110px;
  background: linear-gradient(120deg, var(--sky-soft, #e0eef7), var(--sage-soft, #e6efdf));
  border: 2px solid color-mix(in srgb, var(--sky, #7fb3d5) 55%, transparent);
}
.tp-course__text { display: flex; flex-direction: column; gap: .2rem; flex: 1; }
.tp-course .tile__label { font-size: 1.35rem; }
.tp-course__arrow { font-size: 2rem; font-weight: 800; color: var(--sky-deep, #3f789f); }
.tp-settings__grid { display: grid; grid-template-columns: minmax(260px, 1fr) auto; gap: 1rem 1.5rem; align-items: end; }
.tp-settings__grid > .field:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
.tp-settings__grid #layout-chips { gap: .5rem; flex-wrap: wrap; }
@media (max-width: 640px) { .tp-settings__grid { grid-template-columns: 1fr; } }
.tp-keys { margin: .6rem 0 0; }
.tp-keylist { letter-spacing: .12em; font-family: var(--tt-font); color: var(--text); }
.tp-games .tile { min-height: 170px; }
.tp-game .muted { font-size: .95rem; }
.tp-statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .8rem; }
.tp-stat { display: flex; flex-direction: column; align-items: center; text-align: center; padding: .7rem; border-radius: var(--r, 20px); background: var(--surface-soft, #f4ebde); }
.tp-stat__num { font-size: 2rem; font-weight: 800; color: var(--sage-deep, #4f7d48); }
.tp-stat__lab { font-size: .9rem; color: var(--text-soft); }

.tp-gamebar { align-items: center; gap: .8rem; flex-wrap: wrap; scroll-margin-top: 90px; }
.tp-gametitle { margin: 0; font-size: 1.6rem; }
.tp-intro { display: flex; flex-direction: column; gap: 1rem; align-items: flex-start; }
.tp-intro--small { flex-direction: row; flex-wrap: wrap; align-items: center; padding-block: .8rem; }
.tp-intro--small .mascot { display: none; }
.tp-intro__btns { gap: .6rem; align-items: center; }
.tp-intro--small .btn--big { min-height: 52px; padding: .5rem 1.3rem; font-size: 1.05rem; }
.tp-playhead { align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: .6rem; }
.tp-clock { font-variant-numeric: tabular-nums; }
.tp-inputrow { margin: .6rem 0; }
.tp-kb { margin-top: .4rem; }

/* Ergebnis */
.tp-result { display: flex; flex-direction: column; align-items: center; gap: .8rem; text-align: center; margin-top: 1rem; }
.tp-stars { font-size: 3rem; letter-spacing: .2em; }
.tp-star { color: var(--line, #ebe0d1); display: inline-block; }
.tp-star--on { color: var(--honey, #e9c46a); text-shadow: 0 2px 0 var(--honey-deep, #8a6a14); animation: tp-star .6s var(--ease, ease) both; }
.tp-star--on:nth-child(2) { animation-delay: .15s; } .tp-star--on:nth-child(3) { animation-delay: .3s; }
@keyframes tp-star { from { transform: scale(0) rotate(-40deg); } to { transform: none; } }
.tp-result__nums { font-size: 1.15rem; font-weight: 700; margin: 0; }
.tp-result__btns { justify-content: center; gap: .6rem; flex-wrap: wrap; }

/* ---------- Blätter fallen ---------- */
.tp-forest {
  position: relative; overflow: hidden;
  height: clamp(300px, 46vh, 420px);
  border-radius: var(--r-lg, 28px);
  background: linear-gradient(180deg, #f9eedb 0%, #fbe3c4 55%, #f3d5ad 100%);
  border: 1px solid var(--line, #ebe0d1);
}
html[data-theme="nacht"] .tp-forest { background: linear-gradient(180deg, #3b3230, #4a3a30); }
.tp-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 46px; background: linear-gradient(180deg, #c9a77c, #b48a5e); border-radius: 50% 50% 0 0 / 18px 18px 0 0; }
.tp-tree { position: absolute; bottom: 30px; font-size: 5.5rem; opacity: .35; }
.tp-tree--1 { left: 2%; } .tp-tree--2 { right: 18%; font-size: 4.5rem; }
.tp-basket { position: absolute; right: 3%; bottom: 14px; font-size: 3.6rem; z-index: 3; }
.tp-basket--bump { animation: tp-bump .4s ease; }
@keyframes tp-bump { 40% { transform: scale(1.2) rotate(-6deg); } }
.tp-target {
  background: var(--surface, #fffdf9); border-radius: var(--r-pill, 999px); padding: .3rem 1rem;
  box-shadow: var(--shadow-sm); font-weight: 700; white-space: nowrap;
}
.tp-target:empty { display: none; }
.tp-target__word { font-family: var(--tt-font); font-size: 1.6rem; }
.tp-leaf {
  position: absolute; top: 0; z-index: 2;
  display: flex; align-items: center; gap: .2rem;
  padding: .25rem .7rem .25rem .3rem;
  background: hsl(calc(28 + var(--hue, 0)) 85% 88%);
  border: 2px solid hsl(calc(22 + var(--hue, 0)) 60% 70%);
  border-radius: 999px 999px 999px 8px;
  box-shadow: 0 3px 8px rgba(120, 70, 30, .15);
  will-change: transform;
}
.tp-leaf__icon { font-size: 1.6rem; }
.tp-leaf__word { font-family: var(--tt-font); font-size: 1.35rem; font-weight: 700; color: #4a3326; }
.tp-leaf__word .tt-char { color: #6b4b37; }
.tp-leaf__word .tt-char--done { color: var(--sage-deep, #4f7d48); }
.tp-leaf__word .tt-char--cur { background: transparent; box-shadow: none; }
.tp-leaf--target { z-index: 3; border-color: var(--peach-deep, #b8632d); box-shadow: 0 0 0 4px rgba(255, 255, 255, .9), 0 6px 16px rgba(184, 99, 45, .35); }
.tp-leaf--target .tt-char--cur { box-shadow: inset 0 -.15em 0 var(--peach-deep, #b8632d); }
.tp-leaf--ground { opacity: .6; transition: transform .6s ease, opacity .6s; filter: saturate(.7); z-index: 1; }
.tp-leaf--fly { transition: transform .7s var(--ease, ease), opacity .7s ease; }
.tp-forest--paused::after {
  content: "⏸ Pause"; position: absolute; inset: 0; z-index: 5;
  display: grid; place-items: center; font-size: 2rem; font-weight: 800;
  background: rgba(255, 250, 240, .7);
}

/* ---------- Schnecken-Rennen ---------- */
.tp-track { display: flex; flex-direction: column; gap: .6rem; padding: 1rem; border-radius: var(--r-lg, 28px); background: linear-gradient(180deg, #e9f2e1, #dcebd0); border: 1px solid var(--line); }
html[data-theme="nacht"] .tp-track { background: #33402f; }
.tp-lane { display: flex; align-items: center; gap: .8rem; }
.tp-lane__name { width: 5.5rem; font-weight: 800; }
.tp-lane__path { position: relative; flex: 1; height: 3.4rem; border-bottom: 3px dashed rgba(79, 125, 72, .45); }
.tp-snail { position: absolute; bottom: 0; left: 0; font-size: 2.6rem; line-height: 1; transform: scaleX(-1); transition: left .35s ease-out; }
.tp-snail--cpu { filter: hue-rotate(160deg) saturate(.8); }
.tp-snail--home { animation: tp-hop .8s ease 2; }
@keyframes tp-hop { 50% { transform: scaleX(-1) translateY(-10px); } }
.tp-goal { position: absolute; right: -.4rem; bottom: 0; font-size: 2.2rem; }
.tp-racetext { font-size: clamp(1.4rem, 3.6vw, 2.1rem); }

/* ---------- Tasten-Detektiv ---------- */
.tp-detective { display: flex; flex-direction: column; align-items: center; gap: .6rem; }
.tp-bigkey {
  display: grid; place-items: center;
  min-width: 9rem; height: 9rem; padding: 0 1.5rem;
  border-radius: 28px;
  background: var(--surface-soft, #f4ebde);
  box-shadow: 0 6px 0 var(--line, #ebe0d1), var(--shadow);
  font-family: var(--tt-font); font-size: 5rem; font-weight: 800;
}
.tp-bigkey--pop { animation: tp-pop .35s var(--ease, ease); }
@keyframes tp-pop { from { transform: scale(.6); opacity: 0; } }
.tp-detective__msg { font-size: 1.2rem; font-weight: 700; min-height: 1.6em; margin: 0; text-align: center; }

/* ---------- Ruhig-Modus ---------- */
html[data-motion="ruhig"] .kb-key--next,
html[data-motion="ruhig"] .kb-key--ok,
html[data-motion="ruhig"] .kb-key--bad,
html[data-motion="ruhig"] .tt-char--wrong,
html[data-motion="ruhig"] .tp-star--on,
html[data-motion="ruhig"] .tp-basket--bump,
html[data-motion="ruhig"] .tp-snail--home,
html[data-motion="ruhig"] .tp-bigkey--pop { animation: none; }
html[data-motion="ruhig"] .tt-char--wrong { color: var(--rose-deep, #a9494e); background: var(--rose-soft, #f9e3e2); }
html[data-motion="ruhig"] .kb-key--bad { background: var(--rose, #e5989b); }
html[data-motion="ruhig"] .kb-key--ok { background: var(--sage, #8ab17d); }
html[data-motion="ruhig"] .tp-leaf--fly { transition: opacity .4s; }
html[data-motion="ruhig"] .tp-snail { transition: none; }
@media (prefers-reduced-motion: reduce) {
  .kb-key--next, .tp-star--on, .tp-bigkey--pop, .tp-snail--home { animation: none; }
}

@media (max-width: 640px) {
  .kb-hand { display: none; }
  .tp-lane__name { width: 4rem; font-size: .9rem; }
}
