/* ZSharp – ein Stylesheet für SuS-App, Spiele und Lehrerbereich. Hell/Dunkel über prefers-color-scheme. */

:root {
  --brand: #6d28d9;
  --brand-strong: #5b21b6;
  --brand-soft: #ede9fe;
  --brand-ink: #ffffff;
  --accent: #0d9488;
  --accent-soft: #ccfbf1;
  --ok: #15803d;
  --ok-soft: #dcfce7;
  --bad: #b91c1c;
  --bad-soft: #fee2e2;
  --warn: #b45309;
  --warn-soft: #fef3c7;
  --gold: #f59e0b;

  --bg: #f6f5fb;
  --surface: #ffffff;
  --surface-2: #f1eff8;
  --text: #1c1830;
  --muted: #625c7a;
  --border: #ddd8ec;
  --shadow: 0 1px 2px rgb(28 24 48 / 6%), 0 4px 16px rgb(28 24 48 / 8%);
  --shadow-lg: 0 10px 40px rgb(28 24 48 / 22%);

  --code-bg: #1e1b2e;
  --code-text: #e8e6f3;
  /* Token-Farben für Code auf hellem Grund (Spiele, Optionen) – auf dunklem Code-Grund siehe unten */
  --tk-kw: #7c3aed;
  --tk-type: #0f766e;
  --tk-fn: #1d4ed8;
  --tk-str: #15803d;
  --tk-num: #c2410c;
  --tk-com: #6b7280;
  --tk-op: #0369a1;

  --radius: 14px;
  --radius-sm: 9px;
  --gap: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #8b5cf6;
    --brand-strong: #a78bfa;
    --brand-soft: #2e2550;
    --brand-ink: #ffffff;
    --accent: #2dd4bf;
    --accent-soft: #123d3a;
    --ok: #4ade80;
    --ok-soft: #143323;
    --bad: #f87171;
    --bad-soft: #3d1a1d;
    --warn: #fbbf24;
    --warn-soft: #3b2f12;
    --bg: #12101c;
    --surface: #1c1929;
    --surface-2: #252137;
    --text: #ece9f7;
    --muted: #a59fbe;
    --border: #353049;
    --shadow: 0 1px 2px rgb(0 0 0 / 30%), 0 4px 16px rgb(0 0 0 / 30%);
    --code-bg: #0f0d18;
    --tk-kw: #c792ea;
    --tk-type: #4fd6be;
    --tk-fn: #82aaff;
    --tk-str: #c3e88d;
    --tk-num: #f78c6c;
    --tk-com: #8f8aa9;
    --tk-op: #89ddff;
    color-scheme: dark;
  }
}

@media (prefers-color-scheme: dark) {
  .btn.ok, .btn.bad { color: #12101c; }
  .code, .ts-value, .ih-query, .order-line { box-shadow: inset 0 0 0 1px var(--border); }
}

/* Dunkle Code-Flächen: immer die hellen Token-Farben */
.code, .code-inline, .ts-value, .ih-query, .order-line, .mem-card .code-face, .tf-state {
  --tk-kw: #c792ea;
  --tk-type: #4fd6be;
  --tk-fn: #82aaff;
  --tk-str: #c3e88d;
  --tk-num: #f78c6c;
  --tk-com: #8f8aa9;
  --tk-op: #89ddff;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.45;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--brand); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .75em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- App-Rahmen ---------- */
#app { min-height: 100dvh; display: flex; flex-direction: column; overflow-x: clip; }
.screen { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 640px; margin: 0 auto; padding: 0 16px calc(24px + var(--safe-bottom)); }
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.topbar .title { font-weight: 700; font-size: 1.05rem; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px;
  border: none; background: transparent; color: var(--text); font-size: 1.25rem;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:focus-visible, .btn:focus-visible, .tile:focus-visible { outline: 3px solid var(--brand-2, #a78bfa); outline-offset: 2px; }

.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: -.02em; }
.brand svg { width: 28px; height: 28px; }
.logo-big svg { width: 96px; height: 96px; }

.pill { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 999px; background: var(--surface); box-shadow: var(--shadow); font-weight: 700; font-size: .9rem; }
.pill.streak { color: #ea580c; }
.pill.xp { color: var(--brand); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 10px 20px;
  border: none; border-radius: var(--radius); font-weight: 700; font-size: 1rem;
  background: var(--brand); color: var(--brand-ink);
  box-shadow: 0 3px 0 var(--brand-strong);
  transition: transform .06s ease, box-shadow .06s ease, background .15s;
  text-decoration: none; user-select: none; -webkit-user-select: none;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--brand-strong); }
.btn[disabled] { background: var(--surface-2); color: var(--muted); box-shadow: none; cursor: not-allowed; }
.btn.block { width: 100%; }
.btn.big { min-height: 64px; font-size: 1.15rem; }
.btn.secondary { background: var(--surface); color: var(--text); box-shadow: 0 3px 0 var(--border); border: 1px solid var(--border); }
.btn.ghost { background: transparent; color: var(--brand); box-shadow: none; }
.btn.ok { background: var(--ok); box-shadow: 0 3px 0 color-mix(in srgb, var(--ok) 70%, black); color: #fff; }
.btn.bad { background: var(--bad); box-shadow: 0 3px 0 color-mix(in srgb, var(--bad) 70%, black); color: #fff; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .9rem; border-radius: 10px; }

/* ---------- Karten & Kacheln ---------- */
.card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card + .card { margin-top: 12px; }
.hero {
  background: linear-gradient(135deg, var(--brand) 0%, #9333ea 60%, var(--accent) 140%);
  color: #fff; border-radius: 20px; padding: 20px; box-shadow: var(--shadow);
}
.hero h2 { margin-bottom: 4px; }
.hero .btn { background: #fff; color: var(--brand-strong); box-shadow: 0 3px 0 rgb(0 0 0 / 20%); }
.hero .btn[disabled] { opacity: .7; }

.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.tile {
  position: relative; display: flex; flex-direction: column; gap: 6px; text-align: left;
  padding: 14px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow);
  border: 2px solid transparent; color: var(--text); text-decoration: none; min-height: 110px;
}
.tile .ico { font-size: 1.7rem; line-height: 1; }
.tile .name { font-weight: 700; }
.tile.focus { border-color: var(--accent); }
.tile.locked { opacity: .5; filter: grayscale(.8); }
.tile .badge { position: absolute; top: 8px; right: 8px; font-size: .7rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; background: var(--accent); color: #fff; }
.tile .bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-top: auto; }
.tile .bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius);
  background: var(--surface); box-shadow: var(--shadow); text-decoration: none; color: var(--text); border: 2px solid transparent; text-align: left; width: 100%;
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item .num { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; background: var(--brand-soft); color: var(--brand); font-weight: 800; flex: none; }
.list-item.boss .num { background: #fef3c7; color: #b45309; }
.list-item.locked { opacity: .5; }

.stars { letter-spacing: 1px; color: var(--gold); white-space: nowrap; }
.stars .off { color: var(--border); }

.section-title { display: flex; align-items: center; justify-content: space-between; margin: 22px 0 10px; font-size: 1.05rem; font-weight: 800; }

/* ---------- Formular ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 600; font-size: .9rem; }
.input, select.input, textarea.input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 2px solid var(--border); background: var(--surface); color: var(--text);
}
.input:focus { outline: none; border-color: var(--brand); }
.input.code-input { font-family: var(--mono); letter-spacing: .08em; text-transform: uppercase; font-size: 1.25rem; text-align: center; }
.error-msg { color: var(--bad); font-weight: 600; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.notice.info { background: var(--brand-soft); color: var(--brand); }
.notice.bad { background: var(--bad-soft); color: var(--bad); }
.notice.ok { background: var(--ok-soft); color: var(--ok); }

/* ---------- Code ---------- */
.code {
  font-family: var(--mono); font-size: 14.5px; line-height: 1.55;
  background: var(--code-bg); color: var(--code-text);
  border-radius: var(--radius); padding: 12px 14px; overflow-x: auto;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  white-space: pre; tab-size: 4;
}
.code .ln { display: flex; min-height: 1.55em; border-radius: 6px; }
.code .ln-no { flex: none; width: 1.8em; margin-right: .8em; text-align: right; color: var(--tk-com); opacity: .7; }
.code .ln-code { flex: 1; }
.tk-kw { color: var(--tk-kw); }
.tk-type { color: var(--tk-type); }
.tk-fn { color: var(--tk-fn); }
.tk-str, .tk-chr { color: var(--tk-str); }
.tk-num { color: var(--tk-num); }
.tk-com { color: var(--tk-com); font-style: italic; }
.tk-op { color: var(--tk-op); }
.code-inline { font-family: var(--mono); font-size: .95em; background: var(--code-bg); color: var(--code-text); padding: 2px 7px; border-radius: 7px; white-space: pre-wrap; user-select: none; -webkit-user-select: none; }
.code.selectable-lines .ln { cursor: pointer; }
.code.selectable-lines .ln:hover { background: rgb(255 255 255 / 6%); }
.code .ln.sel { background: rgb(139 92 246 / 40%); }
.code .ln.right { background: rgb(34 197 94 / 35%); }
.code .ln.wrong { background: rgb(239 68 68 / 40%); }
.code [data-ti] { cursor: pointer; border-radius: 4px; padding: 1px 0; }
.code [data-ti].sel { background: rgb(139 92 246 / 55%); outline: 2px solid #a78bfa; }
.code [data-ti].right { background: rgb(34 197 94 / 45%); }
.code [data-ti].wrong { background: rgb(239 68 68 / 50%); }
.code .gap {
  display: inline-block; min-width: 2.4em; padding: 0 6px; margin: 0 1px; text-align: center;
  border-radius: 6px; border: 2px dashed #a78bfa; color: #fff; cursor: pointer; line-height: 1.35;
}
.code .gap.active { border-style: solid; background: rgb(139 92 246 / 35%); }
.code .gap.filled { border-style: solid; border-color: #4fd6be; }
.code .gap.right { border-color: #22c55e; background: rgb(34 197 94 / 30%); }
.code .gap.wrong { border-color: #ef4444; background: rgb(239 68 68 / 35%); }

/* ---------- Aufgaben-Screen ---------- */
.task-screen { flex: 1; display: flex; flex-direction: column; }
.task-head { display: flex; align-items: center; gap: 12px; padding: 10px 0; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
.progress { flex: 1; height: 12px; border-radius: 6px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: 6px; transition: width .3s ease; }
.timer { height: 5px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin-bottom: 12px; }
.timer > i { display: block; height: 100%; width: 100%; background: var(--brand); transform-origin: left; }
.timer.low > i { background: var(--bad); }
.task-body { flex: 1; display: flex; flex-direction: column; gap: 14px; }
.task-prompt { font-size: 1.1rem; font-weight: 700; }
.task-answer { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding-top: 8px; }
.task-actions { padding: 12px 0 calc(8px + var(--safe-bottom)); }
.type-label { font-size: .75rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); }

.options { display: flex; flex-direction: column; gap: 10px; }
.option {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 56px; padding: 12px 14px; text-align: left;
  border-radius: var(--radius); border: 2px solid var(--border); background: var(--surface); box-shadow: 0 2px 0 var(--border);
  user-select: none; -webkit-user-select: none;
}
.option .mark { flex: none; display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; border: 2px solid var(--border); font-weight: 800; font-size: .85rem; color: var(--muted); }
.option.sel { border-color: var(--brand); background: var(--brand-soft); box-shadow: 0 2px 0 var(--brand); }
.option.sel .mark { border-color: var(--brand); background: var(--brand); color: #fff; }
.option.right { border-color: var(--ok); background: var(--ok-soft); box-shadow: 0 2px 0 var(--ok); }
.option.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 2px 0 var(--bad); }
.option[disabled] { cursor: default; }
.option .why { display: block; font-size: .85rem; color: var(--muted); margin-top: 4px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.chip {
  min-height: 44px; min-width: 44px; padding: 8px 14px; border-radius: 12px;
  border: 2px solid var(--border); background: var(--surface); box-shadow: 0 2px 0 var(--border);
  font-family: var(--mono); font-weight: 600; user-select: none; -webkit-user-select: none;
}
.chip.used { opacity: .35; }
.chip:active { transform: translateY(1px); }
.chip.kw { font-family: var(--font); }

/* Zifferntastatur */
.keypad { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; user-select: none; -webkit-user-select: none; }
.keypad button {
  min-height: 52px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface);
  box-shadow: 0 2px 0 var(--border); font-size: 1.25rem; font-weight: 700; touch-action: manipulation;
}
.keypad button:active { transform: translateY(1px); background: var(--surface-2); }
.keypad .wide { grid-column: span 2; }
.answer-fields { display: flex; flex-direction: column; gap: 8px; }
.answer-field {
  display: flex; align-items: center; min-height: 52px; padding: 8px 14px; border-radius: 12px;
  border: 2px solid var(--border); background: var(--surface); font-family: var(--mono); font-size: 1.25rem; cursor: text;
}
.answer-field.active { border-color: var(--brand); }
.answer-field.right { border-color: var(--ok); background: var(--ok-soft); }
.answer-field.wrong { border-color: var(--bad); background: var(--bad-soft); }
.answer-field .caret { display: inline-block; width: 2px; height: 1.2em; background: var(--brand); margin-left: 2px; animation: blink 1s steps(1) infinite; }
.answer-field .ph { color: var(--muted); font-family: var(--font); font-size: .95rem; }
@keyframes blink { 50% { opacity: 0; } }

/* Parsons */
.order-area { display: flex; flex-direction: column; gap: 6px; min-height: 60px; padding: 8px; border-radius: var(--radius); background: var(--surface-2); border: 2px dashed var(--border); }
.order-area.answer { border-color: var(--brand); background: var(--brand-soft); }
.order-line {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--code-bg); color: var(--code-text);
  font-family: var(--mono); font-size: 14px; white-space: pre; overflow-x: auto; user-select: none; -webkit-user-select: none;
  touch-action: none; cursor: grab; box-shadow: 0 2px 0 rgb(0 0 0 / 25%);
}
.order-line .grip { opacity: .5; flex: none; }
.order-line.dragging { opacity: .9; box-shadow: var(--shadow-lg); z-index: 50; cursor: grabbing; position: relative; }
.order-line.right { outline: 3px solid #22c55e; }
.order-line.wrong { outline: 3px solid #ef4444; }
.order-placeholder { height: 38px; border-radius: 10px; border: 2px dashed var(--brand); }
.order-hint { font-size: .85rem; color: var(--muted); text-align: center; }

/* Swipe-Karten */
.swipe-stage { position: relative; height: 260px; margin: 8px 0; touch-action: none; overflow: visible; contain: layout; }
.swipe-card {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; gap: 10px;
  padding: 16px; border-radius: 18px; background: var(--surface); box-shadow: var(--shadow); border: 2px solid var(--border);
  user-select: none; -webkit-user-select: none; will-change: transform; touch-action: none;
}
.swipe-card .code { font-size: 15px; }
.swipe-card .stamp { position: absolute; top: 14px; padding: 4px 12px; border-radius: 8px; font-weight: 900; font-size: 1.2rem; border: 3px solid; opacity: 0; transform: rotate(-10deg); }
.swipe-card .stamp.yes { right: 14px; color: var(--ok); border-color: var(--ok); }
.swipe-card .stamp.no { left: 14px; color: var(--bad); border-color: var(--bad); transform: rotate(10deg); }
.swipe-count { text-align: center; color: var(--muted); font-weight: 600; }
.swipe-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Trace-Tabelle */
.trace-wrap { overflow-x: auto; }
table.trace { border-collapse: separate; border-spacing: 4px; margin: 0 auto; }
table.trace th { font-family: var(--mono); color: var(--muted); font-weight: 700; padding: 4px 8px; }
table.trace td { padding: 0; }
.trace-cell {
  min-width: 56px; height: 44px; display: grid; place-items: center; padding: 0 6px; border-radius: 10px;
  border: 2px solid var(--border); background: var(--surface); font-family: var(--mono); font-size: 1.05rem; cursor: pointer;
}
.trace-cell.given { background: var(--surface-2); color: var(--muted); cursor: default; border-style: dotted; }
.trace-cell.active { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.trace-cell.right { border-color: var(--ok); background: var(--ok-soft); }
.trace-cell.wrong { border-color: var(--bad); background: var(--bad-soft); }
.trace-cell .sol { display: block; font-size: .7rem; color: var(--ok); }
table.trace.grid th { font-size: .8rem; }
.list-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.list-chips span { padding: 2px 8px; border-radius: 6px; background: var(--brand-soft); color: var(--brand); font-family: var(--mono); font-size: .9rem; }

/* Zuordnen */
.match-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-col { display: flex; flex-direction: column; gap: 8px; }
.match-item {
  position: relative; min-height: 52px; padding: 8px 10px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); box-shadow: 0 2px 0 var(--border); font-family: var(--mono); font-size: .95rem; text-align: center;
  user-select: none; -webkit-user-select: none; overflow-wrap: anywhere;
}
.match-item.sel { border-color: var(--brand); background: var(--brand-soft); }
.match-item[data-pair] { border-style: solid; }
.match-item .tag { position: absolute; top: -8px; left: -8px; width: 22px; height: 22px; border-radius: 50%; color: #fff; font: 800 .75rem/22px var(--font); text-align: center; }
.match-item.right { border-color: var(--ok); background: var(--ok-soft); }
.match-item.wrong { border-color: var(--bad); background: var(--bad-soft); }

/* Einzeiler */
.line-input {
  width: 100%; min-height: 56px; padding: 12px 14px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--code-bg); color: var(--code-text); font-family: var(--mono); font-size: 16px;
}
.line-input:focus { outline: none; border-color: var(--brand); }
.token-bar { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 6px; scrollbar-width: none; }
.token-bar .chip { flex: none; min-height: 40px; padding: 6px 12px; }

/* Feedback-Sheet */
.sheet-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 0); pointer-events: none; z-index: 40; transition: background .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; max-height: 75dvh; overflow-y: auto;
  padding: 18px 16px calc(16px + var(--safe-bottom)); border-radius: 22px 22px 0 0;
  background: var(--surface); box-shadow: var(--shadow-lg); transform: translateY(105%); transition: transform .25s cubic-bezier(.2, .9, .3, 1.1);
}
.sheet.open { transform: none; }
.sheet-inner { max-width: 640px; margin: 0 auto; }
.sheet.ok { background: var(--ok-soft); }
.sheet.bad { background: var(--bad-soft); }
.sheet h2 { display: flex; align-items: center; gap: 8px; }
.sheet.ok h2 { color: var(--ok); }
.sheet.bad h2 { color: var(--bad); }
.sheet .explain { margin: 8px 0 12px; }
.sheet .solution { margin: 8px 0 12px; }
.sheet .notes { margin: 0 0 12px; padding-left: 20px; }
.sheet .xp-gain { font-weight: 800; color: var(--brand); }

/* Mini-Lesson */
.lesson-stage { position: relative; flex: 1; display: flex; flex-direction: column; justify-content: center; touch-action: pan-y; }
.lesson-card { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 22px 18px; display: flex; flex-direction: column; gap: 12px; }
.lesson-card h2 { color: var(--brand); }
.dots { display: flex; justify-content: center; gap: 6px; margin: 14px 0; }
.dots i { width: 8px; height: 8px; border-radius: 4px; background: var(--border); transition: width .2s; }
.dots i.on { width: 22px; background: var(--brand); }

/* Ergebnis */
.result-hero { text-align: center; padding: 28px 0 10px; }
.result-hero .big-stars { font-size: 3rem; letter-spacing: 6px; }
.result-hero .score { font-size: 2.6rem; font-weight: 900; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 16px 0; }
.stat { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 12px; text-align: center; }
.stat b { display: block; font-size: 1.35rem; }
.stat span { font-size: .8rem; color: var(--muted); }

/* Toast & Banner */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translateX(-50%) translateY(20px);
  padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 600; opacity: 0;
  transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100% - 32px); pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%); }
.update-banner {
  position: fixed; left: 12px; right: 12px; top: calc(12px + env(safe-area-inset-top, 0px)); z-index: 90; display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-radius: 14px; background: var(--brand); color: #fff; box-shadow: var(--shadow-lg); max-width: 616px; margin: 0 auto;
}
.update-banner .btn { min-height: 36px; background: #fff; color: var(--brand); box-shadow: none; padding: 6px 12px; }
.offline-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--warn); display: inline-block; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgb(10 8 20 / 55%); z-index: 60; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 20px; width: 100%; max-width: 440px; max-height: 90dvh; overflow: auto; }

/* ---------- Spiele ---------- */
.game-screen { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; background: var(--bg); }
.game-hud {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top, 0px));
  font-weight: 800; font-variant-numeric: tabular-nums; background: var(--surface); box-shadow: var(--shadow); z-index: 2;
}
.game-hud .hud-item { display: inline-flex; align-items: center; gap: 4px; }
.game-hud .lives { color: var(--bad); letter-spacing: 2px; }
.game-hud .combo { color: var(--accent); }
.game-field { position: relative; flex: 1; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.game-overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: color-mix(in srgb, var(--bg) 82%, transparent); }
.game-overlay .panel { width: 100%; max-width: 440px; background: var(--surface); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 22px; text-align: center; max-height: 100%; overflow: auto; }
.countdown { font-size: 6rem; font-weight: 900; color: var(--brand); animation: pop .9s ease both; }
@keyframes pop { 0% { transform: scale(.4); opacity: 0; } 30% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); opacity: 1; } }
.rule-banner {
  position: absolute; left: 10px; right: 10px; top: 10px; z-index: 3; padding: 10px 12px; border-radius: 12px;
  background: var(--brand); color: #fff; font-weight: 700; text-align: center; box-shadow: var(--shadow);
}
.rule-banner.flash { animation: flash 1s ease 2; }
@keyframes flash { 50% { background: var(--accent); } }
.mistake-list { text-align: left; margin: 10px 0; padding: 0; list-style: none; }
.mistake-list li { padding: 8px 10px; border-radius: 10px; background: var(--surface-2); margin-bottom: 6px; font-size: .9rem; }
.mistake-list li b { font-family: var(--mono); }

/* Bug Blaster */
.bb-item {
  position: absolute; left: 0; top: 0; padding: 8px 14px; border-radius: 14px; font-family: var(--mono); font-weight: 700; font-size: 1rem;
  background: var(--surface); border: 2px solid var(--border); box-shadow: var(--shadow); white-space: nowrap; will-change: transform; cursor: crosshair;
}
.bb-item.pop { transition: transform .25s, opacity .25s; opacity: 0; }
.bb-item.hit-ok { border-color: var(--ok); background: var(--ok-soft); }
.bb-item.hit-bad { border-color: var(--bad); background: var(--bad-soft); }
.bb-ground { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: repeating-linear-gradient(90deg, var(--bad) 0 12px, transparent 12px 24px); opacity: .5; }
.float-text { position: absolute; font-weight: 900; pointer-events: none; animation: floatUp .8s ease forwards; z-index: 4; }
@keyframes floatUp { to { transform: translateY(-40px); opacity: 0; } }

/* Type Sorter */
.ts-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; }
.ts-top { flex: 1; display: grid; place-items: center; position: relative; }
.ts-value {
  padding: 16px 24px; border-radius: 18px; background: var(--code-bg); color: var(--code-text); font-family: var(--mono); font-size: 1.6rem;
  font-weight: 700; box-shadow: var(--shadow-lg); touch-action: none; cursor: grab; will-change: transform; position: relative; z-index: 3;
}
.ts-value.sel { outline: 4px solid var(--accent); }
.ts-buckets { display: grid; gap: 8px; padding: 10px; padding-bottom: calc(10px + var(--safe-bottom)); }
.ts-bucket {
  min-height: 84px; border-radius: 16px; border: 3px dashed var(--border); background: var(--surface); display: grid; place-items: center;
  font-family: var(--mono); font-weight: 800; font-size: 1.05rem; transition: background .15s, border-color .15s; padding: 4px;
}
.ts-bucket.hover { border-color: var(--brand); background: var(--brand-soft); }
.ts-bucket.flash-ok { border-color: var(--ok); background: var(--ok-soft); border-style: solid; }
.ts-bucket.flash-bad { border-color: var(--bad); background: var(--bad-soft); border-style: solid; }

/* True/False Rush */
.tf-state { margin: 10px; }
.tf-lane { position: absolute; left: 0; right: 0; top: 0; bottom: 96px; overflow: hidden; }
.tf-cond {
  position: absolute; left: 50%; top: 0; transform: translateX(-50%); padding: 12px 18px; border-radius: 14px; background: var(--surface);
  border: 2px solid var(--border); box-shadow: var(--shadow); font-family: var(--mono); font-weight: 700; font-size: 1.15rem; white-space: nowrap;
}
.tf-buttons { position: absolute; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; padding-bottom: calc(10px + var(--safe-bottom)); }
.tf-buttons .btn { min-height: 72px; font-size: 1.2rem; font-family: var(--mono); }

/* Index Hunter */
.ih-wrap { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 12px; }
.ih-decl { font-family: var(--mono); font-size: .95rem; color: var(--muted); text-align: center; }
.ih-query { font-family: var(--mono); font-size: 1.5rem; font-weight: 800; padding: 10px 18px; border-radius: 14px; background: var(--code-bg); color: var(--code-text); }
.ih-cells { display: grid; gap: 6px; }
.ih-cell {
  min-width: 48px; min-height: 48px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface); box-shadow: 0 2px 0 var(--border);
  font-family: var(--mono); font-weight: 700; font-size: 1.05rem; display: grid; place-items: center; position: relative;
}
.ih-cell .idx { position: absolute; bottom: -18px; font-size: .7rem; color: var(--muted); font-weight: 600; }
.ih-cell.flash-ok { border-color: var(--ok); background: var(--ok-soft); }
.ih-cell.flash-bad { border-color: var(--bad); background: var(--bad-soft); }

/* Code Memory */
.mem-grid { position: absolute; inset: 0; display: grid; gap: 8px; padding: 10px; align-content: center; grid-template-columns: repeat(3, 1fr); }
.mem-card { perspective: 600px; min-height: 84px; border: none; padding: 0; background: none; }
.mem-card .inner { position: relative; width: 100%; height: 100%; min-height: 84px; transition: transform .35s; transform-style: preserve-3d; }
.mem-card.open .inner, .mem-card.done .inner { transform: rotateY(180deg); }
.mem-card .face {
  position: absolute; inset: 0; display: grid; place-items: center; border-radius: 12px; backface-visibility: hidden; padding: 6px;
  font-family: var(--mono); font-size: .8rem; font-weight: 700; overflow-wrap: anywhere; text-align: center;
}
.mem-card .back { background: linear-gradient(135deg, var(--brand), #9333ea); color: #fff; font-size: 1.5rem; }
.mem-card .front { background: var(--surface); border: 2px solid var(--border); transform: rotateY(180deg); color: var(--text); }
.mem-card .front.code-face { background: var(--code-bg); color: var(--code-text); border-color: transparent; }
.mem-card.done .front { border-color: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); }

@media (min-width: 560px) {
  .mem-grid { grid-template-columns: repeat(4, 1fr); }
  .mem-card .face { font-size: .9rem; }
}

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

/* ---------- Lehrerbereich ---------- */
body.teacher .screen { max-width: 1180px; }
.t-layout { display: grid; grid-template-columns: 1fr; gap: 16px; }
.t-nav { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 16px; }
.t-nav a, .t-nav button { padding: 8px 14px; border-radius: 10px; text-decoration: none; color: var(--text); background: var(--surface); border: 1px solid var(--border); font-weight: 600; }
.t-nav .active { background: var(--brand); color: #fff; border-color: var(--brand); }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); font-size: .92rem; }
table.data th, table.data td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data th { background: var(--surface-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
table.data tr.inactive td { opacity: .5; }
table.data td.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
.status { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .78rem; font-weight: 700; }
.status.new { background: var(--ok-soft); color: var(--ok); }
.status.unchanged { background: var(--surface-2); color: var(--muted); }
.status.renamed { background: var(--warn-soft); color: var(--warn); }
.status.ambiguous { background: var(--bad-soft); color: var(--bad); }
.status.missing { background: var(--bad-soft); color: var(--bad); }
.dropzone { border: 3px dashed var(--border); border-radius: var(--radius); padding: 28px; text-align: center; background: var(--surface); }
.dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.heatmap { border-collapse: separate; border-spacing: 2px; font-size: .78rem; }
.heatmap th { font-weight: 600; color: var(--muted); padding: 2px 4px; white-space: nowrap; }
.heatmap th.rot { height: 110px; vertical-align: bottom; }
.heatmap th.rot span { display: inline-block; writing-mode: vertical-rl; transform: rotate(180deg); }
.heatmap td { width: 34px; height: 26px; text-align: center; border-radius: 4px; font-weight: 700; color: #fff; }
.heatmap td.empty { background: var(--surface-2); }
.chapter-row { display: grid; grid-template-columns: 1fr auto auto; gap: 12px; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 44px; height: 26px; border-radius: 13px; background: var(--border); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 3px rgb(0 0 0 / 30%); }
.switch input:checked + .track { background: var(--brand); }
.switch input:checked + .track::after { transform: translateX(18px); }
.switch input:focus-visible + .track { outline: 3px solid var(--brand); outline-offset: 2px; }
.chart svg { width: 100%; height: auto; display: block; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr; }
@media (min-width: 900px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* Code-Kärtchen (Druck) */
.print-sheet { display: none; }
@media print {
  @page { size: A4; margin: 10mm; }
  body { background: #fff; color: #000; }
  body.printing #app, body.printing .toast { display: none !important; }
  body.printing .print-sheet { display: grid !important; grid-template-columns: 1fr 1fr; gap: 6mm; }
  .print-card { break-inside: avoid; border: 1px dashed #888; border-radius: 4mm; padding: 5mm; height: 62mm; display: grid; grid-template-columns: 1fr 34mm; gap: 4mm; align-items: center; font-family: var(--font); }
  .print-card .pc-brand { display: flex; align-items: center; gap: 2mm; font-weight: 800; font-size: 13pt; color: #5b21b6; }
  .print-card .pc-brand svg { width: 9mm; height: 9mm; }
  .print-card .pc-name { font-size: 14pt; font-weight: 700; margin: 3mm 0 1mm; }
  .print-card .pc-class { font-size: 10pt; color: #444; }
  .print-card .pc-code { font-family: var(--mono); font-size: 15pt; font-weight: 800; letter-spacing: .5mm; margin-top: 3mm; }
  .print-card .pc-hint { font-size: 7.5pt; color: #555; margin-top: 2mm; }
  .print-card .pc-qr svg { width: 34mm; height: 34mm; }
}
