/* ============================================================ Basis */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.5;
  color: var(--color-text);
  background: var(--color-bg);
  background-image:
    linear-gradient(var(--cp-lavender-200) 2px, transparent 2px),
    linear-gradient(90deg, var(--cp-lavender-200) 2px, transparent 2px);
  background-size: 48px 48px;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4, .pixel { font-family: var(--font-pixel); font-weight: 600; line-height: 1.15; letter-spacing: .5px; margin: 0 0 var(--space-3); }
h1 { font-size: clamp(1.6rem, 4vw, 2.4rem); color: var(--cp-violet-700); }
h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); color: var(--cp-violet-700); }
h3 { font-size: 1.25rem; }
p { margin: 0 0 var(--space-3); }
a { color: var(--cp-violet-700); }
img.sprite, .sprite img, svg { image-rendering: pixelated; image-rendering: crisp-edges; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: calc(2 * var(--px)) solid var(--cp-sky-400); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--color-text-soft); }
.center { text-align: center; }
.stack > * + * { margin-top: var(--space-4); }
.row { display: flex; gap: var(--space-3); align-items: center; flex-wrap: wrap; }
.row--between { justify-content: space-between; }
.grow { flex: 1; }
.grid { display: grid; gap: var(--space-4); }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.grid--4 { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }

/* ============================================================ Pixelrahmen */
.px-frame {
  --frame-color: var(--cp-ink);
  position: relative;
  box-shadow:
    0 calc(-1 * var(--px)) 0 0 var(--frame-color),
    0 var(--px) 0 0 var(--frame-color),
    calc(-1 * var(--px)) 0 0 0 var(--frame-color),
    var(--px) 0 0 0 var(--frame-color),
    0 calc(3 * var(--px)) 0 0 rgba(74, 47, 39, .22);
  margin: var(--px);
}

/* ============================================================ Karten */
.card {
  --frame-color: var(--cp-ink);
  background: var(--color-surface);
  padding: var(--space-4);
  position: relative;
  box-shadow:
    inset 0 var(--px) 0 0 #fff,
    inset 0 calc(-1 * var(--px)) 0 0 var(--cp-beige-200),
    0 calc(-1 * var(--px)) 0 0 var(--frame-color),
    0 var(--px) 0 0 var(--frame-color),
    calc(-1 * var(--px)) 0 0 0 var(--frame-color),
    var(--px) 0 0 0 var(--frame-color),
    0 calc(3 * var(--px)) 0 0 rgba(74, 47, 39, .2);
  margin: var(--px);
}
.card--wood { background: var(--cp-wood-300); --frame-color: var(--cp-wood-700); box-shadow:
    inset 0 var(--px) 0 0 #f0c896, inset 0 calc(-1 * var(--px)) 0 0 var(--cp-wood-500),
    0 calc(-1 * var(--px)) 0 0 var(--frame-color), 0 var(--px) 0 0 var(--frame-color),
    calc(-1 * var(--px)) 0 0 0 var(--frame-color), var(--px) 0 0 0 var(--frame-color), 0 calc(3 * var(--px)) 0 0 rgba(74,47,39,.25); }
.card--rose { background: var(--cp-rose-50); --frame-color: var(--cp-rose-600); }
.card--lavender { background: var(--cp-lavender-50); }
.card--sky { background: var(--cp-sky-200); }
.card--locked { filter: saturate(.25); opacity: .75; }
.card__title { font-family: var(--font-pixel); font-size: 1.2rem; margin-bottom: var(--space-2); color: var(--cp-violet-700); }
.card__cat { position: absolute; top: calc(-16px * var(--sprite-scale) + 6px); right: var(--space-4); }
.card--clickable { cursor: pointer; transition: transform 80ms steps(2); text-decoration: none; color: inherit; display: block; }
.card--clickable:hover { transform: translateY(calc(-1 * var(--px))); }
.card--clickable:active { transform: translateY(var(--px)); }

/* ============================================================ Buttons */
.btn {
  --btn-bg: var(--cp-lavender-200);
  --btn-edge: var(--cp-violet-500);
  --btn-frame: var(--cp-ink);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  min-height: var(--touch); padding: 0 var(--space-5);
  font-family: var(--font-pixel); font-size: 1.15rem; font-weight: 600; letter-spacing: .5px;
  color: var(--cp-ink); background: var(--btn-bg); border: 0; cursor: pointer; text-decoration: none;
  margin: var(--px); position: relative; user-select: none; touch-action: manipulation;
  box-shadow:
    inset 0 calc(-1 * var(--px)) 0 0 var(--btn-edge),
    inset 0 var(--px) 0 0 rgba(255,255,255,.55),
    0 calc(-1 * var(--px)) 0 0 var(--btn-frame),
    0 var(--px) 0 0 var(--btn-frame),
    calc(-1 * var(--px)) 0 0 0 var(--btn-frame),
    var(--px) 0 0 0 var(--btn-frame),
    0 calc(2 * var(--px)) 0 var(--px) rgba(74, 47, 39, .3);
  transition: transform 80ms steps(2), filter 80ms steps(2);
}
.btn:hover { transform: translateY(calc(-1 * var(--px))); filter: brightness(1.04); }
.btn:active { transform: translateY(var(--px)); box-shadow:
    inset 0 var(--px) 0 0 var(--btn-edge),
    0 calc(-1 * var(--px)) 0 0 var(--btn-frame), 0 var(--px) 0 0 var(--btn-frame),
    calc(-1 * var(--px)) 0 0 0 var(--btn-frame), var(--px) 0 0 0 var(--btn-frame); }
.btn[disabled], .btn.is-disabled { filter: saturate(.3); opacity: .6; cursor: not-allowed; transform: none; }
.btn--primary { --btn-bg: var(--cp-rose-400); --btn-edge: var(--cp-rose-600); }
.btn--secondary { --btn-bg: var(--cp-lavender-300); --btn-edge: var(--cp-violet-500); }
.btn--wood { --btn-bg: var(--cp-wood-300); --btn-edge: var(--cp-wood-500); }
.btn--success { --btn-bg: var(--cp-mint-300); --btn-edge: var(--cp-mint-600); }
.btn--sky { --btn-bg: var(--cp-sky-200); --btn-edge: var(--cp-sky-400); }
.btn--ghost { --btn-bg: transparent; --btn-edge: transparent; box-shadow: 0 0 0 var(--px) var(--cp-ink); }
.btn--sm { min-height: 40px; padding: 0 var(--space-3); font-size: 1rem; }
.btn--lg { min-height: var(--touch-lg); padding: 0 var(--space-6); font-size: 1.35rem; }
.btn--xl { min-height: 72px; padding: 0 var(--space-7); font-size: 1.7rem; }
.btn--icon { padding: 0; width: var(--touch); }
.btn--block { width: calc(100% - 2 * var(--px)); }
.btn img { width: 24px; height: 24px; }
.btn--xl img { width: 32px; height: 32px; }

/* ============================================================ Formulare */
.field { display: flex; flex-direction: column; gap: var(--space-1); margin-bottom: var(--space-4); }
.field label { font-weight: 800; }
.field small { color: var(--color-text-soft); }
.input, .field input, .field select, .field textarea {
  min-height: var(--touch); padding: var(--space-2) var(--space-3);
  background: var(--cp-cream-100); border: 0; color: var(--cp-ink);
  box-shadow: inset 0 var(--px) 0 0 var(--cp-beige-200), 0 0 0 var(--px) var(--cp-ink);
  margin: var(--px);
}
.field textarea { min-height: 120px; resize: vertical; }
.field textarea.mono, .mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: .95rem; }
.check { display: flex; gap: var(--space-2); align-items: center; min-height: var(--touch); }
.check input { width: 24px; height: 24px; accent-color: var(--cp-rose-400); }
.validation-message, .form-error { color: var(--cp-rose-600); font-weight: 700; }
.alert { padding: var(--space-3) var(--space-4); margin: var(--space-2) var(--px) var(--space-4); font-weight: 700; box-shadow: 0 0 0 var(--px) var(--cp-ink); }
.alert--error { background: var(--cp-rose-50); }
.alert--success { background: var(--cp-mint-300); }
.alert--info { background: var(--cp-sky-200); }

/* ============================================================ Fortschritt, Sterne, Abzeichen */
.progress { height: calc(4 * var(--px)); background: var(--cp-lavender-200); box-shadow: 0 0 0 var(--px) var(--cp-ink); margin: var(--px); position: relative; overflow: hidden; }
.progress__bar { height: 100%; background: repeating-linear-gradient(90deg, var(--cp-rose-400) 0 calc(4 * var(--px)), var(--cp-rose-200) calc(4 * var(--px)) calc(5 * var(--px))); transition: width 400ms steps(8); }
.progress--xp .progress__bar { background: repeating-linear-gradient(90deg, #9fe3e0 0 calc(4 * var(--px)), #cff3f1 calc(4 * var(--px)) calc(5 * var(--px))); }
.stars { display: inline-flex; gap: 2px; vertical-align: middle; }
.stars img { width: 22px; height: 22px; }
.stars--lg img { width: 40px; height: 40px; }
.stars img.pop { animation: pop 500ms steps(5) both; }
.badge { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--space-1); }
.badge img { width: 72px; height: 72px; }
.badge--locked img { filter: grayscale(1) opacity(.45); }
.chip { display: inline-flex; align-items: center; gap: var(--space-1); padding: 2px var(--space-2); font-family: var(--font-pixel); font-size: .95rem; background: var(--cp-cream-50); box-shadow: 0 0 0 2px var(--cp-ink); margin: 2px; }
.chip img { width: 18px; height: 18px; }

/* ============================================================ Sprites & Katzen */
.sprite { display: inline-block; image-rendering: pixelated; flex-shrink: 0; }
.cat { --s: var(--sprite-scale); width: calc(16px * var(--s)); height: calc(16px * var(--s)); background-size: auto 100%; background-repeat: no-repeat; image-rendering: pixelated; display: inline-block; }
.cat--sit { animation: catFrames 2.4s steps(1) infinite; }
.cat--walk { animation: catFrames .5s steps(1) infinite; }
.cat--sleep { animation: breathe 2.4s ease-in-out infinite; transform-origin: bottom; }
.cat--flip { transform: scaleX(-1); }
.cat.cat--still { animation: none; background-position: 0 0; }
@keyframes catFrames { 0%, 90% { background-position: 0 0; } 91%, 100% { background-position: 100% 0; } }
.cat--walk { animation-name: walkFrames; }
@keyframes walkFrames { 0%, 49% { background-position: 0 0; } 50%, 100% { background-position: 100% 0; } }
@keyframes breathe { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(.94); } }
@keyframes pop { 0% { transform: scale(.2); } 60% { transform: scale(1.3); } 100% { transform: scale(1); } }
@keyframes hop { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(calc(-2 * var(--px))); } }
@keyframes sparkle { 0%, 100% { opacity: 0; transform: scale(.5); } 50% { opacity: 1; transform: scale(1); } }
@keyframes zzz { 0% { opacity: 0; transform: translate(0, 0); } 30% { opacity: 1; } 100% { opacity: 0; transform: translate(12px, -28px); } }
@keyframes bump { 0%, 100% { transform: translate(0, 0); } 30% { transform: translate(var(--bx, 6px), var(--by, 0)); } 60% { transform: translate(calc(var(--bx, 6px) * -.3), 0); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.sparkle { position: absolute; width: 21px; height: 21px; background: url("../assets/icons/sparkle.svg") center / contain no-repeat; image-rendering: pixelated; animation: sparkle 1.6s steps(4) infinite; pointer-events: none; }
.zzz { position: absolute; font-family: var(--font-pixel); color: var(--cp-violet-500); animation: zzz 2.4s steps(6) infinite; pointer-events: none; font-weight: 700; }

/* Katzenporträt + Sprechblase */
.speech { display: flex; gap: var(--space-3); align-items: flex-end; }
.speech__portrait { display: flex; flex-direction: column; align-items: center; gap: 2px; flex-shrink: 0; }
.speech__name { font-family: var(--font-pixel); font-size: .9rem; padding: 0 var(--space-2); background: var(--cat-color, var(--cp-rose-400)); box-shadow: 0 0 0 2px var(--cp-ink); color: var(--cp-ink); }
.speech__bubble { position: relative; flex: 1; background: var(--cp-cream-50); padding: var(--space-3) var(--space-4); font-size: 1.1rem; font-weight: 600; box-shadow: 0 0 0 var(--px) var(--cp-ink), 0 calc(3 * var(--px)) 0 var(--px) rgba(74,47,39,.2); margin: var(--px) var(--px) var(--px) calc(3 * var(--px)); max-width: 60ch; }
.speech__bubble::before { content: ""; position: absolute; left: calc(-3 * var(--px) - var(--px)); bottom: calc(3 * var(--px)); width: calc(3 * var(--px)); height: calc(3 * var(--px)); background: var(--cp-cream-50); box-shadow: 0 calc(-1 * var(--px)) 0 0 var(--cp-ink), 0 var(--px) 0 0 var(--cp-ink), calc(-1 * var(--px)) 0 0 0 var(--cp-ink); }
.speech__text { display: block; animation: typeIn 500ms steps(8) both; }
@keyframes typeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* Spielfigur */
.avatar { position: relative; display: inline-block; width: calc(16px * var(--s, 4)); height: calc(20px * var(--s, 4)); }
.avatar > span, .avatar > .avatar__layer { position: absolute; inset: 0; }
.avatar svg { width: 100%; height: 100%; display: block; }
.avatar__companion { position: absolute; width: calc(8px * var(--s, 4)); height: calc(8px * var(--s, 4)); right: calc(-9px * var(--s, 4)); bottom: calc(6px * var(--s, 4)); animation: hop 1.6s steps(3) infinite; }
.skin-light { --av-skin: #f6d2b8; --av-skin-d: #e2b394; }
.skin-warm { --av-skin: #f0c39e; --av-skin-d: #d8a37e; }
.skin-tan { --av-skin: #d9a377; --av-skin-d: #bd875e; }
.skin-brown { --av-skin: #a8754b; --av-skin-d: #8e5b33; }
.skin-dark { --av-skin: #7d5232; --av-skin-d: #5f3c22; }
.hair-brown { --av-hair: #8a5a36; --av-hair-d: #6b4426; }
.hair-blonde { --av-hair: #f2d27a; --av-hair-d: #d8b35a; }
.hair-black { --av-hair: #3d2f3c; --av-hair-d: #2a1f29; }
.hair-red { --av-hair: #d2643a; --av-hair-d: #a84a2a; }
.hair-lilac { --av-hair: #b89be0; --av-hair-d: #9b7fc6; }
.hair-pink { --av-hair: #f5a3c0; --av-hair-d: #e07ea2; }
.hair-mint { --av-hair: #9fdcb8; --av-hair-d: #6fbf92; }
.outfit-rose { --av-outfit: #ee9ab6; --av-outfit-d: #cf6c8f; }
.outfit-lavender { --av-outfit: #c6b2de; --av-outfit-d: #9b7fc6; }
.outfit-sky { --av-outfit: #8cc6ea; --av-outfit-d: #5f9fc9; }
.outfit-mint { --av-outfit: #bfe6c8; --av-outfit-d: #5fa873; }
.outfit-honey { --av-outfit: #f2b84b; --av-outfit-d: #c98f2c; }
.outfit-cream { --av-outfit: #fbf1e1; --av-outfit-d: #e0c8a5; }

/* ============================================================ Spiel-Layout */
.game { min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.game__main { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: var(--space-4) max(var(--space-4), env(safe-area-inset-right)) var(--space-4) max(var(--space-4), env(safe-area-inset-left)); }
.hud { position: sticky; top: 0; z-index: 20; background: var(--cp-wood-300); box-shadow: inset 0 calc(-1 * var(--px)) 0 0 var(--cp-wood-500), 0 var(--px) 0 0 var(--cp-wood-700), 0 calc(3 * var(--px)) 0 0 rgba(74,47,39,.2); padding: var(--space-2) var(--space-4); padding-top: max(var(--space-2), env(safe-area-inset-top)); }
.hud__inner { max-width: 1400px; margin: 0 auto; display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.hud__player { display: flex; align-items: center; gap: var(--space-2); min-width: 0; text-decoration: none; color: inherit; }
.hud__name { font-family: var(--font-pixel); font-size: 1.15rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud__level { font-size: .85rem; color: var(--cp-ink); opacity: .85; white-space: nowrap; }
.hud__xp { flex: 1; min-width: 120px; max-width: 320px; }
.hud__stats { display: flex; gap: var(--space-2); margin-left: auto; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--cp-cream-50); box-shadow: 0 calc(-1 * var(--px)) 0 0 var(--cp-ink), 0 calc(-3 * var(--px)) 0 0 rgba(74,47,39,.12); padding: var(--space-2) var(--space-2) calc(var(--space-2) + env(safe-area-inset-bottom)); }
.nav__inner { display: flex; justify-content: space-around; max-width: 720px; margin: 0 auto; gap: var(--space-1); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: var(--space-1); min-height: 60px; text-decoration: none; color: var(--cp-ink); font-family: var(--font-pixel); font-size: .9rem; }
.nav a img { width: 32px; height: 32px; transition: transform 80ms steps(2); }
.nav a.active { background: var(--cp-rose-200); box-shadow: 0 0 0 2px var(--cp-ink); }
.nav a:hover img { transform: translateY(-3px); }
.page-title { display: flex; align-items: center; gap: var(--space-3); margin-bottom: var(--space-4); flex-wrap: wrap; }
.page-title h1 { margin: 0; }

/* ============================================================ Zimmer (Szene im Stil des Referenzbildes) */
.room {
  --cell: calc(100% / 12);
  position: relative; width: 100%; aspect-ratio: 12 / 6.2; overflow: hidden;
  background:
    linear-gradient(to bottom, transparent 0 36.5%, var(--cp-wood-500) 36.5% 38%, var(--cp-wood-700) 38% 39%, transparent 39%),
    linear-gradient(to bottom, #e6d8f2 0 36.5%, transparent 36.5%),
    repeating-linear-gradient(to bottom, var(--cp-wood-300) 0 calc(var(--px) * 9), #d49d61 calc(var(--px) * 9) calc(var(--px) * 10), var(--cp-wood-700) calc(var(--px) * 10) calc(var(--px) * 10.6)),
    var(--cp-wood-300);
  background-repeat: no-repeat, no-repeat, repeat, no-repeat;
  box-shadow: 0 0 0 calc(2 * var(--px)) var(--cp-wood-700), 0 0 0 calc(3 * var(--px)) var(--cp-ink), 0 calc(5 * var(--px)) 0 calc(3 * var(--px)) rgba(74,47,39,.2);
  margin: calc(3 * var(--px));
}
.room::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 36.5%; background: radial-gradient(circle at 50% 50%, #f1c3d6 0 1.5px, transparent 2px) 0 0 / 28px 28px; pointer-events: none; }
.room::before { content: ""; position: absolute; inset: 0; background-image: repeating-linear-gradient(90deg, transparent 0 calc(var(--px) * 40), rgba(142,91,51,.35) calc(var(--px) * 40) calc(var(--px) * 41)); top: 39%; pointer-events: none; }
.room__item { position: absolute; display: flex; align-items: flex-end; justify-content: center; transition: left 200ms steps(4), top 200ms steps(4); }
.room__item img { width: 100%; height: auto; image-rendering: pixelated; display: block; }
.room__item--flip img { transform: scaleX(-1); }
.room__item.is-selected { outline: var(--px) dashed var(--cp-rose-600); outline-offset: 2px; animation: hop 1s steps(2) infinite; }
.room__cat { position: absolute; transition: left 1.6s steps(12), top 1.6s steps(12); z-index: 5; }
.room__slot { position: absolute; border: 2px dashed rgba(207,108,143,.6); background: rgba(248,201,216,.25); cursor: pointer; }
.room__slot:hover { background: rgba(248,201,216,.55); }

/* ============================================================ Weltkarte */
.worldmap { position: relative; width: 100%; aspect-ratio: 16 / 10; overflow: hidden;
  background:
    radial-gradient(ellipse at 30% 40%, rgba(255,255,255,.35), transparent 60%),
    repeating-linear-gradient(0deg, #a9d4ef 0 6px, #9ccbea 6px 8px);
  box-shadow: 0 0 0 calc(2 * var(--px)) var(--cp-wood-700), 0 0 0 calc(3 * var(--px)) var(--cp-ink);
  margin: calc(3 * var(--px)); }
.worldmap__path { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.worldmap__spot { position: absolute; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: center; text-decoration: none; color: inherit; width: clamp(80px, 15%, 150px); }
.worldmap__spot img.landmark { width: 100%; image-rendering: pixelated; transition: transform 100ms steps(2); }
.worldmap__spot:hover img.landmark { transform: translateY(-4px); }
.worldmap__label { font-family: var(--font-pixel); font-size: clamp(.75rem, 1.6vw, 1rem); background: var(--cp-cream-50); padding: 0 var(--space-2); box-shadow: 0 0 0 2px var(--cp-ink); white-space: nowrap; margin-top: -6px; }
.worldmap__spot--locked img.landmark { filter: grayscale(.9) brightness(1.15) opacity(.55); }
.worldmap__spot--locked .worldmap__label { opacity: .7; }
.worldmap__fog { position: absolute; inset: -10%; background: radial-gradient(circle, rgba(246,241,251,.95) 30%, rgba(246,241,251,0) 70%); pointer-events: none; }
.worldmap__fog--reveal { animation: fogAway 2.2s steps(10) forwards; }
@keyframes fogAway { to { opacity: 0; transform: scale(1.6); } }
.worldmap__current { position: absolute; top: -18px; }
.worldmap__lock { position: absolute; top: 30%; width: 32px; height: 32px; }

/* ============================================================ Lektion & Editor */
.lesson-steps { display: flex; gap: var(--space-2); flex-wrap: wrap; margin-bottom: var(--space-4); }
.lesson-steps span { font-family: var(--font-pixel); font-size: .9rem; padding: 2px var(--space-2); background: var(--cp-lavender-50); box-shadow: 0 0 0 2px var(--cp-ink); }
.lesson-steps span.is-active { background: var(--cp-rose-200); }
.lesson-steps span.is-done { background: var(--cp-mint-300); }
.story { font-size: 1.15rem; }
.codebox { background: var(--cp-night-800); color: #f3e9ff; padding: var(--space-3) var(--space-4); font-family: ui-monospace, Consolas, monospace; white-space: pre; overflow-x: auto; box-shadow: 0 0 0 var(--px) var(--cp-ink); margin: var(--px); font-size: .95rem; }

.play { display: grid; gap: var(--space-4); grid-template-columns: 1fr; }
@media (min-width: 900px) { .play { grid-template-columns: minmax(320px, 1fr) minmax(400px, 1.25fr); align-items: start; } }
.play__board { position: sticky; top: 76px; }
.play__tabs { display: none; }
@media (max-width: 899px) {
  .play__tabs { display: flex; gap: var(--space-2); position: sticky; top: 64px; z-index: 10; background: var(--color-bg); padding: var(--space-2) 0; }
  .play__tabs .btn { flex: 1; }
  .play[data-tab="board"] .play__editor { display: none; }
  .play[data-tab="code"] .play__board { display: none; }
  .play__board { position: static; }
}
.controls { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.controls .btn { min-width: var(--touch-lg); }
.blockly-host { width: 100%; height: clamp(360px, 62vh, 760px); background: var(--cp-cream-50); box-shadow: 0 0 0 var(--px) var(--cp-ink), 0 calc(3 * var(--px)) 0 var(--px) rgba(74,47,39,.2); margin: var(--px); position: relative; overflow: hidden; }
@media (max-width: 899px) { .blockly-host { height: calc(100dvh - 300px); min-height: 380px; } }
.blocks-counter { font-family: var(--font-pixel); }
.blocks-counter.is-over { color: var(--cp-rose-600); animation: shake 300ms steps(3); }
.variables { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.variables .chip { background: var(--cp-lavender-50); }

/* Spielfeld */
.board-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); }
.board { position: relative; display: grid; box-shadow: 0 0 0 calc(2 * var(--px)) var(--cp-wood-700), 0 0 0 calc(3 * var(--px)) var(--cp-ink), 0 calc(5 * var(--px)) 0 calc(3 * var(--px)) rgba(74,47,39,.2); margin: calc(3 * var(--px)); background: var(--cp-cream-50); max-width: 100%; }
.board__tile { width: var(--tile); height: var(--tile); position: relative; }
.board__tile img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.board__item { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.board__item img { width: 100%; height: 100%; image-rendering: pixelated; }
.board__item--bob { animation: hop 1.4s steps(2) infinite; }
.board__item--gone { animation: pop 300ms steps(3) reverse both; opacity: 0; transition: opacity 200ms steps(2); }
.board__actor { position: absolute; top: 0; left: 0; width: var(--tile); height: var(--tile); transition: transform var(--step-ms, 280ms) steps(4); z-index: 3; display: flex; align-items: center; justify-content: center; }
.board__actor .cat { --s: calc(var(--tile) / 16px); width: var(--tile); height: var(--tile); }
.board__actor--bump .cat { animation: bump 300ms steps(3); }
.board__dir { position: absolute; width: calc(var(--tile) * .32); height: calc(var(--tile) * .32); pointer-events: none; z-index: 4; }
.board__dir::before { content: ""; position: absolute; inset: 0; background: var(--cp-rose-400); clip-path: polygon(0 0, 100% 50%, 0 100%); box-shadow: 0 0 0 2px var(--cp-ink); }
.board__label { font-family: var(--font-pixel); }
.board--compact { --tile: 40px; }
@media (max-width: 599px) { .board { --tile: min(calc((100vw - 48px) / var(--cols)), 44px); } }
.variants { display: flex; gap: var(--space-2); }
.variants button { min-width: 40px; }
.variants .is-current { --btn-bg: var(--cp-rose-200); }
.variants .is-ok { --btn-bg: var(--cp-mint-300); }
.variants .is-fail { --btn-bg: var(--cp-sun-300); }

/* Dialoge */
.dialog-backdrop { position: fixed; inset: 0; background: rgba(220, 205, 236, .7); z-index: 100; display: flex; align-items: center; justify-content: center; padding: var(--space-4); animation: fadeIn 160ms steps(3); }
.dialog { width: min(560px, 100%); max-height: calc(100dvh - 32px); overflow: auto; background: var(--cp-cream-50); padding: var(--space-5); box-shadow: 0 0 0 var(--px) var(--cp-ink), 0 0 0 calc(3 * var(--px)) var(--cp-wood-300), 0 0 0 calc(4 * var(--px)) var(--cp-ink), 0 calc(7 * var(--px)) 0 calc(4 * var(--px)) rgba(74,47,39,.25); animation: popIn 200ms steps(4); }
.dialog__title { font-family: var(--font-pixel); font-size: 1.6rem; color: var(--cp-violet-700); margin-bottom: var(--space-3); }
@media (max-width: 599px) { .dialog-backdrop { align-items: flex-end; padding: 0; } .dialog { width: 100%; padding-bottom: calc(var(--space-5) + env(safe-area-inset-bottom)); } }
@keyframes fadeIn { from { opacity: 0; } }
@keyframes popIn { from { transform: scale(.85); opacity: 0; } }
.reward-burst { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: center; }
.reward-burst img { width: 64px; height: 64px; animation: pop 600ms steps(6) both; }

/* ============================================================ Anmeldung */
.auth { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: var(--space-4); }
.auth__card { width: min(460px, 100%); }
.auth__logo { display: flex; flex-direction: column; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); }
.auth__logo h1 { margin: 0; font-size: clamp(1.8rem, 6vw, 2.6rem); text-align: center; }
.auth__cats { display: flex; gap: var(--space-2); justify-content: center; }
.pinpad { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-2); margin-top: var(--space-3); }
.pinpad .btn { min-height: 64px; font-size: 1.6rem; }
.pin-dots { display: flex; gap: var(--space-3); justify-content: center; margin: var(--space-3) 0; }
.pin-dots span { width: 22px; height: 22px; background: var(--cp-lavender-200); box-shadow: 0 0 0 3px var(--cp-ink); }
.pin-dots span.is-filled { background: var(--cp-rose-400); }

/* ============================================================ Elternbereich */
.admin { display: grid; grid-template-columns: 1fr; min-height: 100dvh; }
@media (min-width: 1000px) { .admin { grid-template-columns: 260px 1fr; } }
.admin__side { background: var(--cp-wood-300); box-shadow: inset calc(-1 * var(--px)) 0 0 var(--cp-wood-700); padding: var(--space-4); }
.admin__side nav { display: flex; flex-direction: column; gap: var(--space-1); }
@media (max-width: 999px) { .admin__side nav { flex-direction: row; flex-wrap: wrap; } }
.admin__side a { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-2) var(--space-3); text-decoration: none; color: var(--cp-ink); font-family: var(--font-pixel); font-size: 1.05rem; min-height: var(--touch); }
.admin__side a.active, .admin__side a:hover { background: var(--cp-cream-50); box-shadow: 0 0 0 2px var(--cp-ink); }
.admin__side a img { width: 24px; height: 24px; }
.admin__main { padding: var(--space-5); max-width: 1200px; width: 100%; }
.table-wrap { overflow-x: auto; margin: var(--px); }
table.table { width: 100%; border-collapse: collapse; background: var(--cp-cream-50); box-shadow: 0 0 0 var(--px) var(--cp-ink); }
.table th, .table td { padding: var(--space-2) var(--space-3); text-align: left; border-bottom: 2px solid var(--cp-beige-200); vertical-align: middle; }
.table th { background: var(--cp-beige-200); font-family: var(--font-pixel); font-weight: 600; }
.stat { display: flex; flex-direction: column; }
.stat__value { font-family: var(--font-pixel); font-size: 2rem; color: var(--cp-violet-700); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; }
.bars__bar { flex: 1; background: var(--cp-rose-400); box-shadow: 0 0 0 2px var(--cp-ink); min-height: 2px; position: relative; }
.bars__bar span { position: absolute; bottom: -22px; left: 50%; transform: translateX(-50%); font-size: .7rem; }
.skill { display: grid; grid-template-columns: 1fr auto; gap: var(--space-1) var(--space-3); padding: var(--space-3) 0; border-bottom: 2px dashed var(--cp-beige-200); }
.tag { display: inline-block; padding: 0 var(--space-2); font-size: .85rem; font-weight: 800; box-shadow: 0 0 0 2px var(--cp-ink); background: var(--cp-lavender-50); }
.tag--ok { background: var(--cp-mint-300); }
.tag--warn { background: var(--cp-sun-300); }
.tag--off { background: var(--cp-beige-200); }

/* ============================================================ Zertifikat */
.certificate { background: var(--cp-cream-50); padding: var(--space-7) var(--space-6); text-align: center; position: relative; box-shadow: 0 0 0 calc(2 * var(--px)) var(--cp-ink), 0 0 0 calc(5 * var(--px)) var(--cp-sun-300), 0 0 0 calc(6 * var(--px)) var(--cp-ink); margin: calc(8 * var(--px)) auto; max-width: 880px; }
.certificate h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
.certificate__name { font-family: var(--font-pixel); font-size: clamp(2rem, 6vw, 3.6rem); color: var(--cp-rose-600); margin: var(--space-4) 0; }
@media print {
  body { background: #fff; }
  .hud, .nav, .no-print { display: none !important; }
  .game { padding: 0; }
}

/* ============================================================ Verbindungsfenster (Blazor) */
#components-reconnect-modal { display: none; }
#components-reconnect-modal.components-reconnect-show, #components-reconnect-modal.components-reconnect-failed, #components-reconnect-modal.components-reconnect-rejected,
#components-reconnect-modal.components-reconnect-retrying, #components-reconnect-modal.components-reconnect-paused, #components-reconnect-modal.components-reconnect-resume-failed { display: flex; }

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

/* Blockly-Anpassungen */
.cp-error > .blocklyPath, .cp-error.blocklyPath { stroke: #f2b84b !important; stroke-width: 5px !important; }
.blocklyTreeLabel, .blocklyToolboxCategoryLabel { font-family: var(--font-pixel) !important; font-size: 1.05rem !important; }
.blocklyToolboxCategory { padding: 6px 4px !important; }
.blocklyFlyoutButton { fill: var(--cp-rose-200) !important; }
.blocklyWidgetDiv .blocklyMenu, .blocklyDropDownDiv { font-family: var(--font-body) !important; }

/* Zuhause: Zimmer + Aktionsspalte (iPad quer: „Weiter geht's!“ sofort sichtbar) */
.home { display: grid; gap: var(--space-4); grid-template-columns: 1fr; align-items: start; }
.home__side { order: -1; }
@media (min-width: 900px) { .home { grid-template-columns: minmax(0, 1.65fr) minmax(300px, 1fr); } .home__side { order: 0; } }

/* Projekt-Werkstatt */
.workshop-grid { display: grid; margin: calc(3 * var(--px)) auto; width: max-content; max-width: 100%; box-shadow: 0 0 0 calc(2 * var(--px)) var(--cp-wood-700), 0 0 0 calc(3 * var(--px)) var(--cp-ink); }
.workshop-cell { position: relative; width: var(--tile); height: var(--tile); padding: 0; border: 0; cursor: pointer; background: none; }
.workshop-cell img { width: 100%; height: 100%; display: block; image-rendering: pixelated; }
.workshop-cell__over { position: absolute; inset: 0; }
.workshop-cell:hover { outline: 3px solid var(--cp-rose-400); outline-offset: -3px; z-index: 1; }

/* Vorlesen */
.speech__speak { float: right; margin: -4px -6px 4px 8px; width: 40px; height: 40px; border: 0; background: var(--cp-sky-200); box-shadow: 0 0 0 2px var(--cp-ink); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.speech__speak img { width: 24px; height: 24px; }
.speech__speak:active { transform: translateY(2px); }
.speech__speak.is-speaking { background: var(--cp-rose-200); animation: speakPulse 1s steps(2) infinite; }
@keyframes speakPulse { 50% { box-shadow: 0 0 0 2px var(--cp-ink), 0 0 0 5px var(--cp-rose-200); } }

@media print { .admin__side { display: none !important; } .admin { display: block; } .report { box-shadow: none; } }

.cat--back { animation: walkFrames 1.2s steps(1) infinite; }
.cat--hop { animation-name: walkFrames, hop; animation-duration: .5s, .5s; animation-iteration-count: infinite; }

.speech__cat { background: none; border: 0; padding: 0; cursor: pointer; }
.speech__cat:active { transform: scale(.95); }

/* Lunas Webstuhl */
.loom-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); }
.loom__cat { display: flex; align-items: center; gap: var(--space-3); }
.loom { --cell: min(34px, calc((100cqw - 32px) / var(--cols))); display: flex; flex-direction: column; gap: 3px; padding: 12px; background: #b98a5e; box-shadow: 0 0 0 var(--px) var(--cp-ink), inset 0 0 0 4px #9a6f47; container-type: normal; }
.loom-wrap { container-type: inline-size; width: 100%; }
.loom__row { display: grid; grid-template-columns: repeat(var(--cols), var(--cell)); gap: 3px; padding: 2px; }
.loom__row.is-current { outline: 2px dashed var(--cp-cream-50); outline-offset: 1px; }
.loom__cell { width: var(--cell); height: var(--cell); display: inline-flex; align-items: center; justify-content: center; font-size: calc(var(--cell) * .5); line-height: 1; color: rgba(74,47,39,.55); background: var(--yarn, #eee); box-shadow: inset 0 0 0 2px rgba(74,47,39,.35); }
.loom__cell--none { background: transparent; box-shadow: none; }
.loom__cell--ghost { background: color-mix(in srgb, var(--yarn) 30%, #fff8ee); color: color-mix(in srgb, var(--yarn) 70%, #4a2f27); box-shadow: inset 0 0 0 2px rgba(74,47,39,.2); }
.loom__cell--done { color: rgba(255,255,255,.9); box-shadow: inset 0 -4px 0 rgba(0,0,0,.15), inset 0 0 0 2px rgba(74,47,39,.6); }
.loom__cell--done.is-new { animation: pop 300ms steps(3) both; }
.loom__cell--wrong { box-shadow: 0 0 0 3px var(--cp-rose-600, #d0436f); animation: shake 300ms steps(3) 2; color: #fff; }
.loom__cell--mini { --cell: 22px; margin-right: 4px; vertical-align: middle; }
.loom__legend { display: flex; flex-wrap: wrap; gap: var(--space-3); justify-content: center; font-size: .9rem; }
.yarn--rose { --yarn: #f28cb1; }
.yarn--blue { --yarn: #6fb3de; }
.yarn--yellow { --yarn: #f2c94c; }
.yarn--lilac { --yarn: #a78bda; }

/* Katzenkonzert */
.concert-wrap { display: flex; flex-direction: column; align-items: center; gap: var(--space-3); width: 100%; }
.concert__band { display: flex; align-items: center; gap: var(--space-3); }
.concert { --note: 30px; --step: 9px; display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 6px; padding: 10px 12px; background: #fffaf0; box-shadow: 0 0 0 var(--px) var(--cp-ink), 0 calc(3 * var(--px)) 0 var(--px) rgba(74,47,39,.2); max-width: 100%; }
.concert__slot { position: relative; width: var(--note); height: calc(var(--note) + 7 * var(--step)); background: repeating-linear-gradient(to top, transparent 0 calc(2 * var(--step) - 1px), rgba(74,47,39,.18) calc(2 * var(--step) - 1px) calc(2 * var(--step))); background-position: 0 calc(-1 * var(--step) + var(--note) / 2); }
.concert__slot.is-current { background-color: rgba(242,201,76,.25); }
.concert__note { position: absolute; left: 0; bottom: calc((var(--lvl) + 1) * var(--step)); width: var(--note); height: var(--note); display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-pixel); font-size: 11px; color: #fff; background: var(--note-color, #ccc); border-radius: 50%; box-shadow: inset 0 -3px 0 rgba(0,0,0,.18), 0 0 0 2px rgba(74,47,39,.55); }
.concert__note.is-ghost { background: color-mix(in srgb, var(--note-color) 28%, #fffaf0); color: color-mix(in srgb, var(--note-color) 75%, #4a2f27); box-shadow: 0 0 0 2px color-mix(in srgb, var(--note-color) 45%, transparent); }
.concert__note.is-done.is-new { animation: pop 300ms steps(3) both; }
.concert__note.is-wrong { box-shadow: 0 0 0 3px var(--cp-rose-600, #d0436f); animation: shake 300ms steps(3) 2; }
.note--do { --note-color: #e86a6a; }
.note--re { --note-color: #ef9548; }
.note--mi { --note-color: #e3b62f; }
.note--fa { --note-color: #6cbb6c; }
.note--so { --note-color: #5aa6d6; }
.note--la { --note-color: #9b7fd3; }
.note--rest { --note-color: #b9aab0; font-size: 16px; }
.note--drum { --note-color: #b98a5e; font-size: 15px; }

/* Cookies Katzencafé */
.cafe-wrap { display: flex; flex-direction: column; gap: var(--space-3); width: 100%; padding: 10px; background: linear-gradient(#f6e3c8 0 62%, #c98a5a 62% 64%, #e8c9a3 64%); box-shadow: 0 0 0 var(--px) var(--cp-ink); }
.cafe__queue { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 10px; min-height: 110px; align-items: flex-end; }
.cafe__guest { display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform 200ms steps(3), opacity 200ms; }
.cafe__guest.is-counter { transform: translateY(-6px); }
.cafe__guest.is-counter .cafe__bubble { background: #fff3b0; box-shadow: 0 0 0 2px var(--cp-ink), 0 0 0 5px #f2c94c; }
.cafe__guest.is-served { opacity: .55; }
.cafe__guest.is-wrong { animation: shake 300ms steps(3) 2; }
.cafe__guest.is-wrong .cafe__bubble { box-shadow: 0 0 0 3px var(--cp-rose-600, #d0436f); }
.cafe__bubble { padding: 2px 8px; background: #fff; box-shadow: 0 0 0 2px var(--cp-ink); font-size: .95rem; white-space: nowrap; }
.cafe__counter { display: flex; align-items: center; justify-content: center; gap: var(--space-3); flex-wrap: wrap; }
.cafe__plate { min-width: 140px; min-height: 52px; padding: 6px 12px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px; background: #fffdf8; border-radius: 50%; box-shadow: 0 0 0 2px var(--cp-ink), inset 0 0 0 6px #f1e6d6; }
.cafe__plate.is-wrong { animation: shake 300ms steps(3) 2; }
.cafe__dish { font-size: 1.3rem; animation: pop 250ms steps(3) both; }

/* Geschichtenbühne */
.stage-wrap { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: var(--space-3); width: 100%; }
@media (max-width: 1100px) { .stage-wrap { grid-template-columns: 1fr; } }
.stage { display: flex; flex-direction: column; background: #3b2a4a; box-shadow: 0 0 0 var(--px) var(--cp-ink); padding: 0 0 10px; background-image: repeating-linear-gradient(90deg, #b8425f 0 14px, #9c3550 14px 18px); background-size: 100% 22px; background-repeat: no-repeat; }
.stage__scene { display: flex; gap: 6px; justify-content: flex-end; padding: 28px 8px 0; }
.stage__floor { flex: 1; min-height: 150px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: center; gap: 10px; padding: 34px 8px 6px; margin: 0 8px; background: linear-gradient(transparent 70%, #a8784f 70%); }
.stage__empty { color: #f6e3c8; font-style: italic; align-self: center; }
.stage__actor { position: relative; display: flex; flex-direction: column; align-items: center; animation: pop 300ms steps(3) both; transition: transform 200ms steps(2); }
.stage__actor.is-bowing { transform: translateY(6px) scaleY(.85); }
.stage__name { font-family: var(--font-pixel); font-size: 10px; color: #fff; }
.stage__bubble { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); width: max-content; max-width: 170px; padding: 4px 8px; background: #fff; box-shadow: 0 0 0 2px var(--cp-ink); font-size: .85rem; text-align: center; animation: pop 250ms steps(3) both; }
.script { list-style: none; margin: 0; padding: 8px 10px; background: #fffaf0; box-shadow: 0 0 0 var(--px) var(--cp-ink); font-size: .9rem; display: flex; flex-direction: column; gap: 3px; }
.script__title { font-family: var(--font-pixel); margin-bottom: 4px; }
.script__line { display: flex; gap: 6px; align-items: baseline; padding: 2px 4px; }
.script__mark { width: 1.1em; flex: none; text-align: center; }
.script__line.is-done { color: var(--cp-green-700, #3c7a43); }
.script__line.is-current { background: rgba(242,201,76,.35); }
.script__line.is-wrong { background: rgba(208,67,111,.15); box-shadow: inset 3px 0 0 var(--cp-rose-600, #d0436f); animation: shake 300ms steps(3) 2; }

/* Einführung / Was ist neu? */
.dialog.intro { max-width: 560px; width: calc(100vw - 32px); display: flex; flex-direction: column; gap: var(--space-3); }
.intro__cats { display: flex; justify-content: center; gap: var(--space-3); min-height: 90px; align-items: flex-end; }
.intro__cat { animation: pop 350ms steps(4) both; }
.intro__body { font-size: 1.15rem; line-height: 1.55; }
.intro__body p { margin: 0 0 var(--space-2); }
.intro__title { font-family: var(--font-pixel); font-size: 1.35rem; margin: 0 0 var(--space-2); color: var(--cp-lavender-700, #6b4f9a); }
.intro__dots { display: flex; justify-content: center; gap: 6px; }
.intro__dots span { width: 10px; height: 10px; background: var(--cp-lavender-200, #ddd0ef); box-shadow: 0 0 0 2px var(--cp-ink); }
.intro__dots span.is-active { background: var(--cp-rose-400, #f28cb1); }
.intro__actions { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
