:root {
  --bg: #F6F1E4; --card: #FFFFFF; --ink: #4A4036; --green: #7BB369; --green-d: #4C9150; --gold: #E8BE4A;
  --blue: #6FA8DC; --red: #E3705C; --soft: #EDE6D3;
  --m: #5B8FD0; --f: #D8566F; --n: #4C9150;
  font-family: "Andika", "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }
#app { height: 100%; display: flex; flex-direction: column; }
.hidden { display: none !important; }

/* Kopfleiste */
.topbar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: #FFFDF6; border-bottom: 3px solid var(--soft); min-height: 76px; }
.bar-title { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.bar-title small { display: block; font-size: .8rem; font-weight: 400; opacity: .7; }
.spacer { flex: 1; }
.icon-btn { width: 60px; height: 60px; border-radius: 50%; background: var(--gold); font-size: 1.8rem; box-shadow: 0 4px 0 #B98616; display: grid; place-items: center; flex: none; }
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #B98616; }
.icon-btn.small { width: 44px; height: 44px; font-size: 1.5rem; }
.pet-chip { display: flex; align-items: center; gap: 8px; background: #FFF3D6; border-radius: 40px; padding: 4px 16px 4px 6px; border: 3px solid var(--gold); }
.pet-img svg { width: 56px; height: 56px; display: block; }
.star-count { font-weight: 700; font-size: 1.3rem; }
.star-count small { font-weight: 400; opacity: .6; }
.bounce { animation: bounce .6s; }
@keyframes bounce { 30% { transform: scale(1.15) rotate(-4deg); } 60% { transform: scale(.95) rotate(3deg); } }
.music { position: relative; }
.music-panel { position: absolute; right: 0; top: 70px; z-index: 10; display: flex; align-items: center; gap: 8px; background: #fff; padding: 8px 12px; border-radius: 40px; box-shadow: 0 6px 18px #0003; border: 3px solid var(--soft); }
.meter { display: flex; gap: 4px; }
.meter i { width: 14px; height: 26px; border-radius: 4px; background: var(--soft); }
.meter i.on { background: var(--green); }
.gear { width: 44px; height: 44px; border-radius: 50%; font-size: 1.4rem; opacity: .35; }
.gear.holding { opacity: 1; background: var(--soft); }

/* Startseite */
.home { flex: 1; overflow-y: auto; padding: 18px 20px 40px; max-width: 1100px; width: 100%; margin: 0 auto; }
.train-btn { display: flex; align-items: center; gap: 14px; width: 100%; padding: 14px 20px; margin-bottom: 18px; background: linear-gradient(90deg, #FFE9A8, #FFF3D6); border: 3px solid var(--gold); border-radius: 26px; font-size: 1.3rem; text-align: left; box-shadow: 0 5px 0 #D8B34A; }
.train-btn span { font-size: 2rem; } .train-btn em { margin-inline-start: auto; font-style: normal; opacity: .75; font-size: 1rem; }
.unit { margin-bottom: 26px; }
.unit h2 { display: flex; align-items: center; gap: 14px; font-size: 1.4rem; margin: 6px 0 12px; }
.unit h2 small { display: block; font-size: 1rem; font-weight: 400; opacity: .75; }
.unit-no { width: 54px; height: 54px; border-radius: 50%; background: var(--uc); color: #fff; display: grid; place-items: center; font-size: 1.7rem; font-weight: 700; flex: none; }
.path { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.lesson { display: grid; grid-template-columns: 56px 1fr; grid-template-areas: "n p" "n t" "n a" "s s"; align-items: center; column-gap: 12px; text-align: left; padding: 14px 16px; background: var(--card); border-radius: 24px; border: 4px solid var(--uc); box-shadow: 0 6px 0 color-mix(in srgb, var(--uc), #000 20%); min-height: 132px; }
.lesson:active { transform: translateY(3px); }
.l-no { grid-area: n; width: 52px; height: 52px; border-radius: 50%; background: var(--uc); color: #fff; font-size: 1.6rem; font-weight: 700; display: grid; place-items: center; }
.l-page { grid-area: p; font-size: .85rem; opacity: .65; }
.l-title { grid-area: t; font-weight: 700; font-size: 1.05rem; line-height: 1.15; }
.l-ar { grid-area: a; font-size: .95rem; opacity: .8; text-align: right; }
.l-stars { grid-area: s; display: flex; gap: 4px; justify-content: center; font-size: 1.6rem; margin-top: 6px; }
.l-stars i { font-style: normal; color: #D9D3C2; } .l-stars i.on { color: var(--gold); text-shadow: 0 2px 0 #B98616; }
.lesson.locked { opacity: .55; filter: grayscale(.6); border-color: #BBB; box-shadow: 0 6px 0 #AAA; }
.lesson.locked .l-no { background: #BBB; }
.lesson.done { background: #F4FBEF; }
.shake { animation: shake .45s; }
@keyframes shake { 20%,60% { transform: translateX(-10px); } 40%,80% { transform: translateX(10px); } }

/* Lektion */
.steps { display: flex; gap: 6px; margin-inline-start: 12px; }
.step { width: 44px; height: 44px; border-radius: 50%; background: var(--soft); display: grid; place-items: center; font-size: 1.3rem; opacity: .55; }
.step.on { background: var(--green); opacity: 1; transform: scale(1.12); box-shadow: 0 3px 0 var(--green-d); }
.step.done { background: #CFE8C8; opacity: 1; }
.stage { flex: 1; display: flex; flex-direction: column; align-items: center; padding: 14px 18px 20px; min-height: 0; position: relative; }
.ghead { display: flex; align-items: center; gap: 14px; align-self: stretch; justify-content: space-between; }
.gprog { background: var(--soft); border-radius: 30px; padding: 6px 16px; font-size: 1.1rem; font-weight: 700; }
.pill { background: #fff; border: 3px solid var(--soft); border-radius: 40px; padding: 10px 20px; font-size: 1.1rem; box-shadow: 0 4px 0 var(--soft); }
.pill:active { transform: translateY(3px); box-shadow: none; }
.pill.big { display: block; width: 100%; margin-top: 12px; padding: 14px; font-size: 1.15rem; }
.pill.danger { border-color: #E9A59A; }

/* Karten */
.card-big { margin: auto; background: #fff; border-radius: 36px; padding: 18px 40px 22px; text-align: center; box-shadow: 0 8px 0 var(--soft); border: 4px solid #F1E9D0; min-width: min(560px, 92vw); }
.card-pic { width: min(300px, 42vh); height: min(300px, 42vh); display: block; margin: 0 auto; border-radius: 28px; background: #FFFDF6; border: 3px dashed #E6DDBF; padding: 10px; }
.pic, .pic svg { display: block; width: 100%; height: 100%; }
.card-word { font-size: clamp(2.2rem, 7vw, 3.4rem); font-weight: 700; margin-top: 10px; }
.art { font-size: .62em; padding: 0 .35em; border-radius: 10px; color: #fff; vertical-align: .12em; }
.art.m { background: var(--m); } .art.f { background: var(--f); } .art.n { background: var(--n); }
.card-syl { font-size: 1.5rem; letter-spacing: 3px; opacity: .65; margin-top: 2px; }
.card-ar { font-size: 1.6rem; margin-top: 6px; color: #7A5A3A; }
.card-btns { display: flex; gap: 12px; justify-content: center; margin-top: 12px; }
.next-btn { position: absolute; right: 22px; bottom: 22px; width: 84px; height: 84px; border-radius: 50%; background: var(--green); color: #fff; font-size: 2.8rem; box-shadow: 0 6px 0 var(--green-d); display: grid; place-items: center; }
.next-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--green-d); }
.dots { display: flex; gap: 8px; margin-top: 8px; } .dots i { width: 14px; height: 14px; border-radius: 50%; background: var(--soft); } .dots i.on { background: var(--green); }

/* Hören */
.big-speak { width: 120px; height: 120px; border-radius: 50%; font-size: 3.4rem; background: var(--blue); box-shadow: 0 7px 0 #3E7CB1; margin: 14px 0 10px; display: grid; place-items: center; }
.choices { display: flex; gap: 22px; flex-wrap: wrap; justify-content: center; margin: auto 0; }
.choice { width: min(250px, 28vw, 40vh); height: min(250px, 28vw, 40vh); min-width: 150px; min-height: 150px; border-radius: 30px; background: #fff; border: 5px solid #EDE6D3; padding: 12px; box-shadow: 0 7px 0 var(--soft); transition: transform .15s; }
.choice:active { transform: scale(.96); }
.choice.right { border-color: var(--green); background: #EAF7E5; animation: pop .5s; }
.choice.wrong { border-color: var(--red); background: #FBE9E5; animation: shake .45s; opacity: .55; }
.choice.hint { border-color: var(--gold); animation: pulse 1s infinite; }
@keyframes pop { 40% { transform: scale(1.1); } }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* Schreiben */
.write-top, .build-top { display: flex; align-items: center; gap: 16px; margin: 8px 0; }
.wpic { position: relative; width: 120px; height: 120px; border-radius: 24px; background: #fff; border: 4px solid var(--soft); padding: 8px; }
.wpic .spk { position: absolute; right: -8px; bottom: -8px; background: var(--blue); border-radius: 50%; width: 38px; height: 38px; display: grid; place-items: center; font-size: 1.1rem; }
.write-wrap { flex: 1; width: 100%; min-height: 0; display: flex; align-items: center; justify-content: center; background: #fff; border-radius: 28px; border: 4px solid var(--soft); padding: 6px; }
.write-svg { width: 100%; height: 100%; max-height: 100%; touch-action: none; }
.write-wrap.celebrate { animation: pop .6s; border-color: var(--green); }
.pulse circle { animation: pulseDot .5s 2; transform-box: fill-box; transform-origin: center; }
@keyframes pulseDot { 50% { transform: scale(1.8); } }

/* Bauen */
.build-top { align-self: center; }
.slots { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 14px 0 20px; }
.slot { width: 64px; height: 76px; border-radius: 14px; border: 4px dashed #CBBF9C; background: #fff; display: grid; place-items: center; font-size: 2.6rem; font-weight: 700; }
.slot.small { width: 50px; height: 62px; font-size: 2rem; }
.slot.filled { border: 4px solid var(--green); background: #EAF7E5; }
.slots.celebrate .slot { animation: pop .5s; }
.tiles { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: auto; padding-bottom: 12px; }
.tile { width: 84px; height: 90px; border-radius: 20px; background: var(--gold); font-size: 2.8rem; font-weight: 700; box-shadow: 0 6px 0 #B98616; }
.tile.small { width: 66px; height: 76px; font-size: 2.2rem; }
.tile:active { transform: translateY(4px); box-shadow: 0 2px 0 #B98616; }
.tile.used { visibility: hidden; }
.tile.hint { background: #FFE27A; animation: pulse 1s infinite; }

/* Memory */
.mem-grid { display: grid; gap: 16px; margin: auto; width: min(900px, 100%); }
.mem-grid.cols3 { grid-template-columns: repeat(3, 1fr); } .mem-grid.cols4 { grid-template-columns: repeat(4, 1fr); }
.mem-card { position: relative; aspect-ratio: 1.05; border-radius: 26px; perspective: 600px; }
.face { position: absolute; inset: 0; border-radius: 26px; display: grid; place-items: center; backface-visibility: hidden; transition: transform .35s; padding: 8px; }
.face.back { background: var(--green); font-size: 3rem; box-shadow: 0 6px 0 var(--green-d); }
.face.front { background: #fff; border: 4px solid var(--gold); transform: rotateY(180deg); }
.mem-card.open .back, .mem-card.done .back { transform: rotateY(180deg); }
.mem-card.open .front, .mem-card.done .front { transform: rotateY(0); }
.mem-card.done .front { background: #EAF7E5; border-color: var(--green); }
.mem-word { font-size: clamp(1.1rem, 3.2vw, 2rem); font-weight: 700; text-align: center; line-height: 1.2; overflow-wrap: anywhere; }
.mem-word small { display: block; font-size: .6em; width: fit-content; margin: 0 auto 2px; }

/* Abschluss */
.celebrate-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; position: relative; }
.celebrate-screen h1 { margin: 0; font-size: 2rem; }
.big-stars { font-size: 5.5rem; display: flex; gap: 14px; } .big-stars i { font-style: normal; color: #D9D3C2; transform: scale(.3); opacity: 0; animation: starIn .6s var(--d) forwards; }
.big-stars i.on { color: var(--gold); text-shadow: 0 5px 0 #B98616; }
.big-stars i:not(.on) { animation-name: starInDim; }
@keyframes starIn { to { transform: scale(1); opacity: 1; } } @keyframes starInDim { to { transform: scale(1); opacity: .6; } }
.pet-big svg { width: 180px; height: 180px; } .pet-big.grow svg { animation: grow 1.4s 1s; }
@keyframes grow { 30% { transform: scale(1.5) rotate(-6deg); } 60% { transform: scale(.9) rotate(5deg); } }
.pet-note { font-size: 1.7rem; margin: 0; }

/* Dialog */
.overlay { position: fixed; inset: 0; background: #0006; display: grid; place-items: center; z-index: 50; }
.dialog { background: #fff; border-radius: 26px; padding: 22px 26px; width: min(460px, 92vw); }
.dialog h2 { margin-top: 0; } .dialog p { opacity: .75; }

@media (max-width: 700px) {
  .topbar { padding: 8px 10px; gap: 8px; }
  .bar-title { font-size: 1rem; }
  .step { width: 36px; height: 36px; font-size: 1rem; }
  .choice { min-width: 110px; min-height: 110px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ===== Sachunterricht-Spiele ===== */
.card-text { font-size: clamp(1.3rem, 3.4vw, 1.9rem); line-height: 1.35; margin-top: 8px; max-width: 640px; }
.card-word { font-size: clamp(1.8rem, 5vw, 2.6rem); }
.card-ar { font-size: 1.4rem; margin-top: 8px; color: #7A5A3A; }
.board-area { flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; min-height: 0; padding: 4px 0; }
.diagram { width: 100%; height: 100%; max-height: 100%; max-width: 900px; }
.svg-slot { cursor: pointer; }
.sbox { fill: #fff; stroke: #E0762B; stroke-width: 2; stroke-dasharray: 5 3; }
.svg-given .sbox { fill: #EFEAD9; stroke: #B9B09A; stroke-dasharray: none; }
.svg-slot.sel .sbox { fill: #FFF2C2; stroke-width: 3.5; }
.svg-slot.filled .sbox { fill: #EAF7E5; stroke: #4C9150; stroke-dasharray: none; }
.stext { font: 700 13px "Trebuchet MS", Verdana, sans-serif; fill: #4A4036; }
.svg-slot.shake { animation: shake .45s; }
.tray { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; padding: 10px 4px 14px; }
.chip { background: var(--gold); border-radius: 22px; padding: 12px 20px; font-size: 1.35rem; font-weight: 700; box-shadow: 0 5px 0 #B98616; max-width: 46%; line-height: 1.2; }
.chip:active { transform: translateY(3px); box-shadow: 0 2px 0 #B98616; }
.chip.sel { background: #FFE27A; outline: 4px solid var(--green); }
.chip.used { visibility: hidden; }
.chip .art, .clabel .art { font-size: .7em; }
.cells { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.cell { display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(190px, 28vw); }
.cell-pic { width: 100%; aspect-ratio: 1; background: #fff; border: 4px solid var(--soft); border-radius: 22px; padding: 6px; }
.slot-btn { min-width: 100%; min-height: 58px; padding: 6px 10px; border-radius: 16px; border: 4px dashed #CBBF9C; background: #fff; font-size: 1.15rem; font-weight: 700; line-height: 1.15; }
.slot-btn.sel { background: #FFF2C2; border-color: var(--gold); }
.slot-btn.filled { border: 4px solid var(--green); background: #EAF7E5; }
.steck { display: flex; gap: 20px; align-items: center; width: min(900px, 100%); }
.steck-pic { width: min(220px, 26vw); aspect-ratio: 1; background: #fff; border: 4px solid var(--soft); border-radius: 22px; padding: 8px; flex: none; }
.steck-tab { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.srow { display: grid; grid-template-columns: 120px 1fr; align-items: center; gap: 10px; font-size: 1.2rem; }
.srow .slot-btn.wide { text-align: left; }

.question { display: flex; align-items: center; gap: 16px; background: #fff; border: 4px solid var(--soft); border-radius: 26px; padding: 14px 20px; margin: 10px 0; max-width: 860px; width: 100%; }
.q-text { font-size: clamp(1.25rem, 3.2vw, 1.8rem); line-height: 1.35; font-weight: 600; }
.question.big .q-text { font-size: clamp(1.6rem, 4.4vw, 2.4rem); }
.q-speak { flex: none; background: var(--blue); box-shadow: 0 4px 0 #3E7CB1; }
.choice.with-label { width: min(240px, 28vw); height: auto; min-height: 0; aspect-ratio: auto; padding: 10px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.choice.with-label .pic { width: min(170px, 22vw); height: min(170px, 22vw); }
.clabel { font-size: 1.25rem; font-weight: 700; }
.tf-btns { display: flex; gap: 30px; margin: auto 0; }
.tf { width: min(200px, 34vw); height: min(180px, 26vh); border-radius: 36px; font-size: 5rem; color: #fff; box-shadow: 0 8px 0 rgba(0,0,0,.2); }
.tf.yes { background: var(--green); } .tf.no { background: var(--red); }
.tf.right { outline: 8px solid #fff; animation: pop .5s; } .tf.wrong { opacity: .5; animation: shake .45s; } .tf.hint { outline: 8px solid var(--gold); animation: pulse 1s infinite; }
.tf-btns.locked .tf { pointer-events: none; }
.fix { font-size: 1.5rem; background: #FFF3D6; border: 3px solid var(--gold); border-radius: 20px; padding: 10px 18px; margin-bottom: 14px; max-width: 800px; text-align: center; }
.fix small { display: block; opacity: .65; font-size: .75em; }
.sort-card { display: flex; align-items: center; gap: 16px; background: #fff; border: 5px solid var(--gold); border-radius: 28px; padding: 12px 24px; margin: 10px 0 0; min-height: 140px; box-shadow: 0 7px 0 var(--soft); }
.sort-card .pic { width: 110px; height: 110px; flex: none; }
.sc-text { font-size: clamp(1.5rem, 4vw, 2.2rem); font-weight: 700; }
.arrow-down { font-size: 2rem; opacity: .5; margin: 2px 0; }
.baskets { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: auto; width: 100%; }
.basket { flex: 1; min-width: 180px; max-width: 320px; display: flex; flex-direction: column; align-items: center; gap: 4px; background: #E8DDC0; border: 4px solid #C9B98C; border-radius: 10px 10px 36px 36px; padding: 12px 10px 16px; box-shadow: 0 6px 0 #B8A878; }
.basket:active { transform: translateY(3px); }
.b-pic .pic { width: 84px; height: 84px; } .b-label { font-size: 1.3rem; font-weight: 700; text-align: center; line-height: 1.15; }
.basket.right { background: #CFE8C8; border-color: var(--green); animation: pop .5s; } .basket.wrong { background: #F6D4CC; border-color: var(--red); animation: shake .45s; }
.baskets.locked { pointer-events: none; }
