/* ---------- Farbthemen ---------- */
:root {
  --bg: #eaf4ff; --bg2: #ffffff; --card: #ffffff; --text: #1d2a3a; --muted: #5d6b7c;
  --primary: #2f7de1; --primary-d: #1f5fb3; --accent: #ff9f1c; --ok: #1fa95b; --ok-bg: #e3f7ea;
  --bad: #e0565b; --bad-bg: #fde9e9; --line: #d8e3f0; --shadow: 0 4px 0 rgba(0,0,0,.08), 0 6px 18px rgba(30,60,100,.08);
  --radius: 18px; --flame: #ff6a1a;
}
body.th-forest { --bg: #ecf7ea; --primary: #2e9a55; --primary-d: #1f7440; --accent: #f2b134; --line: #d3e8d0; }
body.th-candy  { --bg: #fff0f7; --primary: #e0569b; --primary-d: #b63c79; --accent: #7c6cf0; --line: #f6d5e6; }
body.th-sunset { --bg: #fff3e8; --primary: #f06b2f; --primary-d: #c24e1b; --accent: #8e44ad; --line: #f6dcc9; }
body.th-ocean  { --bg: #e6f8f8; --primary: #0f9aa8; --primary-d: #0b727c; --accent: #ff7f50; --line: #cdeaea; }
body.th-night  { --bg: #161b2e; --bg2: #20263d; --card: #232a44; --text: #eef1fb; --muted: #a9b1cc; --primary: #8c7cff;
  --primary-d: #6a5ad8; --accent: #ffd166; --line: #343c5c; --ok-bg: #1d3b2c; --bad-bg: #44262a; --shadow: 0 4px 0 rgba(0,0,0,.3); }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, "Noto Color Emoji", sans-serif;
  font-size: 18px; line-height: 1.4; min-height: 100vh; overscroll-behavior-y: none;
}
main { max-width: 760px; margin: 0 auto; padding: 16px 16px 96px; }
h1 { font-size: 1.7rem; margin: .2em 0 .5em; }
h2 { font-size: 1.3rem; margin: 1.2em 0 .5em; }
h3 { font-size: 1.1rem; margin: 1em 0 .4em; }
p { margin: .4em 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spread { justify-content: space-between; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.stack > * + * { margin-top: 12px; }

/* ---------- Buttons ---------- */
button, .btn {
  font: inherit; border: 0; cursor: pointer; border-radius: 16px; min-height: 56px; padding: 12px 18px;
  background: var(--card); color: var(--text); box-shadow: var(--shadow); border: 2px solid var(--line);
  touch-action: manipulation; -webkit-tap-highlight-color: transparent; transition: transform .08s;
}
button:active { transform: translateY(2px); }
button:disabled { opacity: .5; cursor: default; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary-d); font-weight: 700; }
.btn-ok { background: var(--ok); color: #fff; border-color: #17844a; font-weight: 700; }
.btn-bad { background: var(--bad); color: #fff; border-color: #b8393e; }
.btn-ghost { background: transparent; box-shadow: none; border-color: transparent; color: var(--muted); }
.btn-big { width: 100%; font-size: 1.25rem; min-height: 72px; }
.btn-small { min-height: 40px; padding: 6px 12px; font-size: .9rem; border-radius: 12px; }
.tile { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; min-height: 120px; text-align: center; font-weight: 600; }
.tile .ic { font-size: 2.3rem; line-height: 1; }
.tile .sub { font-size: .8rem; color: var(--muted); font-weight: 400; }

/* ---------- Kopfzeile ---------- */
.topbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.avatar { font-size: 2.2rem; width: 56px; height: 56px; display: grid; place-items: center; background: var(--card); border-radius: 50%; box-shadow: var(--shadow); border: 2px solid var(--line); }
.avatar.big { font-size: 3.4rem; width: 96px; height: 96px; }
.pill { display: inline-flex; align-items: center; gap: 4px; background: var(--card); border: 2px solid var(--line); border-radius: 999px; padding: 4px 12px; font-weight: 700; white-space: nowrap; }
.flame { color: var(--flame); }
.flame.off { filter: grayscale(1); opacity: .6; }
.topbar .name { font-weight: 700; font-size: 1.1rem; line-height: 1.1; }
.topbar .lvl { font-size: .8rem; color: var(--muted); }

.bar { height: 16px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--accent)); border-radius: 999px; transition: width .5s; }
.bar.ok > span { background: var(--ok); }
.bar.thin { height: 8px; }

.bottomnav { position: fixed; left: 0; right: 0; bottom: 0; background: var(--bg2, #fff); border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 6px 6px calc(6px + env(safe-area-inset-bottom)); z-index: 5; }
.bottomnav button { flex: 1; max-width: 140px; min-height: 60px; box-shadow: none; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 0; font-size: .75rem; padding: 4px; color: var(--muted); }
.bottomnav button .ic { font-size: 1.5rem; }
.bottomnav button.active { color: var(--primary); font-weight: 700; }

/* ---------- Profile ---------- */
.profile-tile { min-height: 150px; }
.profile-tile .avatar { width: 80px; height: 80px; font-size: 3rem; box-shadow: none; }

/* ---------- Spiel ---------- */
.playhead { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.playhead .bar { flex: 1; }
.combo { color: var(--accent); font-weight: 800; }
.task { min-height: 320px; }
.task .label { font-size: .85rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.prompt { font-size: 1.6rem; font-weight: 700; margin: 6px 0 16px; word-wrap: break-word; }
.lang { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 8px; border-radius: 8px; background: var(--line); margin-right: 6px; vertical-align: middle; }
input.answer, input.gapin {
  font: inherit; font-size: 1.3rem; width: 100%; padding: 14px 16px; border-radius: 14px; border: 3px solid var(--line);
  background: var(--bg2, #fff); color: var(--text); min-height: 60px;
}
input.gapin { width: calc(9ch + 28px); max-width: 100%; font-size: 1.15rem; padding: 6px 10px; min-height: 48px; display: inline-block; margin: 2px 4px; }
input.answer:focus, input.gapin:focus { border-color: var(--primary); outline: none; }
.sentence { font-size: 1.25rem; line-height: 2.3; white-space: pre-wrap; }
.scene { background: var(--bg); border-radius: 14px; padding: 10px 14px; margin-bottom: 12px; white-space: pre-line; font-size: 1.05rem; }
.wordbank { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 14px; }
.wordbank span { background: var(--bg); border: 1px dashed var(--muted); border-radius: 10px; padding: 3px 10px; font-size: .95rem; }
.choices { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .choices { grid-template-columns: 1fr 1fr; } }
.choices button { font-size: 1.15rem; text-align: left; }
.choices button.right { background: var(--ok-bg); border-color: var(--ok); }
.choices button.wrong { background: var(--bad-bg); border-color: var(--bad); }
.actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.actions > * { flex: 1; }

/* Karteikarte */
.flashcard { perspective: 1000px; height: 230px; cursor: pointer; margin-bottom: 8px; }
.flashcard .inner { position: relative; width: 100%; height: 100%; transition: transform .5s; transform-style: preserve-3d; }
.flashcard.flipped .inner { transform: rotateY(180deg); }
.flashcard .face { position: absolute; inset: 0; backface-visibility: hidden; display: grid; place-items: center; text-align: center; padding: 20px;
  font-size: 1.6rem; font-weight: 700; border-radius: var(--radius); background: var(--card); border: 3px solid var(--line); box-shadow: var(--shadow); }
.flashcard .back { transform: rotateY(180deg); background: var(--ok-bg); border-color: var(--ok); }

/* Satzbau */
.dropzone { min-height: 78px; border: 3px dashed var(--line); border-radius: 16px; padding: 10px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; background: var(--bg2, #fff); }
.dropzone.over { border-color: var(--primary); }
.pool { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; min-height: 64px; }
.chip { user-select: none; -webkit-user-select: none; touch-action: none; font-size: 1.15rem; padding: 10px 16px; min-height: 52px; border-radius: 14px; background: var(--card); border: 2px solid var(--primary); box-shadow: var(--shadow); cursor: grab; display: inline-flex; align-items: center; }
.chip.ghost { position: fixed; pointer-events: none; z-index: 50; opacity: .9; transform: rotate(-3deg) scale(1.05); }
.chip.placeholder { opacity: .3; }
.dropzone .hint { color: var(--muted); font-size: .95rem; }

/* Memory */
.memory { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (min-width: 560px) { .memory { grid-template-columns: repeat(4, 1fr); } }
.mcard { min-height: 96px; font-size: 1rem; font-weight: 700; padding: 8px; display: grid; place-items: center; text-align: center; }
.mcard.down { background: var(--primary); color: transparent; border-color: var(--primary-d); }
.mcard.down::after { content: "❓"; color: #fff; font-size: 1.6rem; position: absolute; }
.mcard { position: relative; }
.mcard.open { background: var(--card); }
.mcard.matched { background: var(--ok-bg); border-color: var(--ok); }
.mcard.nomatch { background: var(--bad-bg); border-color: var(--bad); }

/* Feedback */
.feedback { margin-top: 16px; border-radius: var(--radius); padding: 16px; border: 3px solid; animation: pop .25s ease-out; }
.feedback.ok { background: var(--ok-bg); border-color: var(--ok); }
.feedback.bad { background: var(--bad-bg); border-color: var(--bad); }
.feedback .title { font-size: 1.3rem; font-weight: 800; }
.feedback .solution { font-size: 1.2rem; font-weight: 700; margin: 6px 0; }
.diff { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: 1.15rem; letter-spacing: .02em; background: var(--card); padding: 6px 10px; border-radius: 10px; display: inline-block; margin: 2px 0; word-break: break-all; }
.diff .del { background: #ffc9cb; color: #9d1c22; text-decoration: line-through; border-radius: 3px; }
.diff .sub-wrong { background: #ffc9cb; color: #9d1c22; border-radius: 3px; }
.diff .ins, .diff .sub-right { background: #bdf0cf; color: #0c6b34; font-weight: 800; border-radius: 3px; text-decoration: underline; }
.pts { font-weight: 800; color: var(--ok); }
.ptparts { font-size: .85rem; color: var(--muted); }

/* Timer */
.timer { font-size: 2rem; font-weight: 800; text-align: center; }
.timer.low { color: var(--bad); animation: pulse 1s infinite; }
.flashok { animation: okflash .35s; }
.flashbad { animation: badflash .35s; }

/* Overlay / Modals */
.overlay { position: fixed; inset: 0; background: rgba(10,20,40,.45); display: grid; place-items: center; z-index: 40; padding: 16px; }
.modal { background: var(--card); color: var(--text); border-radius: 22px; padding: 22px; max-width: 520px; width: 100%; max-height: 90vh; overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.3); animation: pop .25s ease-out; }
.modal .big-ic { font-size: 4rem; text-align: center; }
.modal h2 { text-align: center; margin-top: .2em; }
.explain-text { white-space: pre-line; font-size: 1.1rem; background: var(--bg); padding: 14px; border-radius: 14px; }

.toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 420px); }
.toast { background: var(--card); color: var(--text); border: 2px solid var(--accent); border-radius: 16px; padding: 12px 16px; box-shadow: var(--shadow); font-weight: 600; animation: slidein .3s ease-out; }

.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 70; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; border-radius: 3px; animation: fall 1.6s ease-in forwards; }

/* Woche */
.weekbars { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; align-items: end; height: 170px; margin-top: 10px; position: relative; }
.weekbars .col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.weekbars .b { width: 100%; max-width: 44px; background: var(--primary); border-radius: 8px 8px 4px 4px; min-height: 4px; }
.weekbars .b.goal { background: var(--ok); }
.weekbars .d { font-size: .8rem; color: var(--muted); }
.weekbars .n { font-size: .8rem; font-weight: 700; }

/* Shop / Abzeichen */
.shopitem { text-align: center; }
.shopitem .ic { font-size: 2.6rem; }
.badge { text-align: center; }
.badge .ic { font-size: 2.6rem; }
.badge.locked { opacity: .45; filter: grayscale(1); }
.stickers { font-size: 2rem; letter-spacing: 4px; }
.tabs { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.tabs button.active { background: var(--primary); color: #fff; border-color: var(--primary-d); }

/* Eltern */
table { width: 100%; border-collapse: collapse; font-size: .95rem; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; max-width: 320px; margin: 0 auto; }
.pinpad button { font-size: 1.5rem; min-height: 68px; }
.pindots { text-align: center; font-size: 2rem; letter-spacing: 10px; min-height: 2.6rem; }
.switch { display: flex; align-items: center; gap: 12px; }
.switch input { width: 28px; height: 28px; }
details summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
textarea { font: inherit; }
.tag { display: inline-block; font-size: .75rem; padding: 2px 8px; border-radius: 8px; background: var(--line); }

@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes slidein { from { transform: translateY(-20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fall { to { transform: translateY(110vh) rotate(540deg); } }
@keyframes pulse { 50% { transform: scale(1.1); } }
@keyframes okflash { 50% { background: var(--ok-bg); } }
@keyframes badflash { 50% { background: var(--bad-bg); } }
body.noanim *, body.noanim *::before, body.noanim *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Fächer-Menü */
.subjects { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin-bottom: 4px; scrollbar-width: thin; }
.subjects .subject { flex: 0 0 auto; min-height: 52px; display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 8px 16px; font-weight: 600; }
.subjects .subject .ic { font-size: 1.3rem; }
.subjects .subject.active { background: var(--primary); color: #fff; border-color: var(--primary-d); }
