/* Santas 1x1-Express – Nachtblau, Schneeweiß, Gold als einziger Akzent. */
:root {
  color-scheme: dark;
  --bg: #0a1430;
  --bg-deep: #060d22;
  --s1: #111d42;
  --s2: #18275a;
  --s3: #22356f;
  --line: rgb(190 205 255 / 0.12);
  --text: #f3f5fb;
  --text-2: #b9c3de;
  --text-3: #8d99bd;
  --gold: #f7c64f;
  --gold-2: #ffdc80;
  --gold-ink: #2b1d00;
  --gold-soft: rgb(247 198 79 / 0.14);
  --red: #d9443b;
  --calm: #8fb4ff;

  --font: ui-rounded, "SF Pro Rounded", -apple-system, "SF Pro", "Segoe UI Variable", Inter, system-ui, sans-serif;
  --t-12: 0.75rem; --t-14: 0.875rem; --t-17: 1.0625rem; --t-20: 1.25rem; --t-24: 1.5rem;
  --t-32: 2rem; --t-48: 3rem; --t-task: 6rem;

  --r-sm: 12px; --r: 16px; --r-lg: 24px;
  --sh-1: 0 1px 2px rgb(0 0 0 / 0.35), 0 4px 12px rgb(0 0 0 / 0.22);
  --sh-2: 0 2px 6px rgb(0 0 0 / 0.35), 0 16px 40px rgb(0 0 0 / 0.35);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --key: 88px;
  --gap: 12px;
  --pad-x: max(24px, env(safe-area-inset-left));
  --pad-r: max(24px, env(safe-area-inset-right));
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--t-17);
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  font-variant-numeric: tabular-nums;
}
::selection { background: var(--gold); color: var(--gold-ink); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; border-radius: 8px; }
h1, h2, h3 { margin: 0; line-height: 1.15; text-wrap: balance; letter-spacing: -0.01em; }
p { margin: 0; }
.icon { width: 24px; height: 24px; flex: none; }
.art { display: block; width: 100%; height: 100%; }
.fig { display: block; width: 100%; height: 100%; object-fit: contain; user-select: none; -webkit-user-select: none; -webkit-user-drag: none; pointer-events: none; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Sternenhimmel als Hintergrund der Spielwelt */
#app {
  min-height: 100dvh;
  background:
    radial-gradient(1.5px 1.5px at 12% 18%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 28% 72%, #fff6 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 47% 12%, #fff7 50%, transparent 51%),
    radial-gradient(1px 1px at 63% 38%, #fff5 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 78% 8%, #fff8 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 56%, #fff5 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 88%, #fff5 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 94% 92%, #fff6 50%, transparent 51%),
    radial-gradient(120% 80% at 50% 0%, #13235a 0%, var(--bg) 55%, var(--bg-deep) 100%);
  background-attachment: fixed;
}
.screen {
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) var(--pad-r) max(16px, env(safe-area-inset-bottom)) var(--pad-x);
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.screen--fixed { height: 100dvh; overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px;
  border: 0; border-radius: 14px;
  background: var(--s2); color: var(--text);
  font-weight: 600; font-size: var(--t-17);
  box-shadow: var(--sh-1);
  transition: transform 140ms var(--ease-out), background-color 160ms ease, opacity 160ms ease;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; pointer-events: none; }
.btn--primary { background: var(--gold); color: var(--gold-ink); }
.btn--quiet { background: transparent; box-shadow: none; color: var(--text-2); }
.btn--danger { background: #a3352f; color: #fff; }
.btn--big { min-height: 72px; padding: 0 32px; font-size: var(--t-24); border-radius: 20px; }
.btn--icon { width: 48px; padding: 0; }
.btn.is-loading { pointer-events: none; opacity: 0.7; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { background: var(--s3); }
  .btn--primary:hover { background: var(--gold-2); }
  .btn--quiet:hover { background: var(--s1); }
}
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 40px; padding: 0 14px; border-radius: 999px;
  background: var(--s1); font-weight: 700; font-size: var(--t-20);
}
.pill .icon { color: var(--gold); width: 20px; height: 20px; }

/* ---------- Topbar / Navigation ---------- */
.topbar { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.topbar h1 { font-size: var(--t-24); font-weight: 800; }
.topbar .spacer { flex: 1; }
.countdown { color: var(--text-2); font-size: var(--t-17); }
.countdown b { color: var(--gold); font-size: var(--t-24); font-weight: 800; }
.nav { display: flex; gap: 8px; }
.nav-btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  min-width: 72px; min-height: 56px; padding: 4px 8px;
  border: 0; border-radius: 14px; background: var(--s1); color: var(--text-2);
  font-size: var(--t-12); font-weight: 600;
  transition: transform 140ms var(--ease-out), background-color 160ms ease;
}
.nav-btn .icon { color: var(--text); }
.nav-btn:active { transform: scale(0.96); background: var(--s2); }
.back-btn { width: 56px; min-width: 56px; }

/* ---------- Home ---------- */
.home-grid { flex: 1; display: grid; grid-template-columns: minmax(340px, 5fr) 7fr; gap: 24px; min-height: 0; }
.card { background: var(--s1); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.santa-card { padding: 24px; display: flex; flex-direction: column; gap: 20px; position: relative; overflow: hidden; }
.santa-row { display: flex; gap: 16px; align-items: flex-start; }
.santa-row .figure { width: 196px; height: 214px; flex: none; margin: -12px 0 -12px -12px; }
.bubble {
  position: relative; flex: 1;
  background: var(--s2); border-radius: 18px; padding: 14px 16px;
  font-size: var(--t-20); line-height: 1.35;
}
.bubble::before {
  content: ""; position: absolute; left: -8px; top: 26px;
  border: 8px solid transparent; border-right-color: var(--s2); border-left: 0;
}
.bubble .speak { position: absolute; right: 6px; bottom: 6px; width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--text-3); display: grid; place-items: center; }
.bubble .speak:active { background: var(--s3); }
.bubble p { padding-right: 36px; }
.mission-line { display: flex; align-items: center; gap: 12px; font-size: var(--t-20); color: var(--text-2); }
.mission-line .icon { color: var(--gold); width: 28px; height: 28px; }
.mission-line b { color: var(--text); }
.santa-card .btn--big { width: 100%; }
.done-badge { display: flex; align-items: center; gap: 12px; padding: 16px 20px; border-radius: 18px; background: var(--gold-soft); color: var(--gold-2); font-weight: 700; font-size: var(--t-20); }
.done-badge .icon { width: 28px; height: 28px; }
.streak { display: flex; align-items: center; gap: 12px; margin-top: auto; color: var(--text-2); }
.candles { display: flex; gap: 4px; }
.candles .icon { width: 28px; height: 28px; color: #3a4a80; }
.candles .icon.is-lit { color: var(--red); }
.candles .icon:not(.is-lit) path { fill: transparent; }
.bear-corner { position: absolute; right: 12px; bottom: 8px; width: 104px; height: 104px; }

.calendar { padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 16px; min-height: 0; }
.calendar header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.calendar h2 { font-size: var(--t-24); }
.calendar header span { color: var(--text-3); font-size: var(--t-14); }
.doors { flex: 1; display: grid; grid-template-columns: repeat(6, 1fr); grid-template-rows: repeat(4, 1fr); gap: 10px; min-height: 0; }
.door {
  position: relative; border: 0; border-radius: 14px;
  background: var(--s2); color: var(--text-2);
  display: grid; place-items: center; min-height: 72px;
  font-size: var(--t-24); font-weight: 800;
  box-shadow: inset 0 0 0 1px var(--line);
  transition: transform 160ms var(--ease-out), background-color 200ms ease;
}
.door.is-locked { color: var(--text-3); background: #142250; }
.door.is-ready { background: var(--s3); color: var(--gold); box-shadow: inset 0 0 0 2px var(--gold); }
.door.is-open { background: #0d1838; box-shadow: inset 0 0 0 1px var(--line); }
.door.is-open .item { width: 44px; height: 44px; }
.door .num-mini { position: absolute; left: 8px; top: 6px; font-size: var(--t-12); color: var(--text-3); font-weight: 700; }
.door .rare { position: absolute; right: 6px; top: 6px; width: 8px; height: 8px; border-radius: 50%; background: var(--gold); }
.door.just-opened { animation: door-pop 520ms var(--ease-out); }
@keyframes door-pop { 0% { transform: scale(0.9); opacity: 0.4; } 60% { transform: scale(1.06); } 100% { transform: none; opacity: 1; } }
.prolog-note { color: var(--text-2); font-size: var(--t-17); }

/* ---------- Mission ---------- */
.mbar { display: flex; align-items: center; gap: 16px; min-height: 56px; }
.phase-chip { display: flex; align-items: center; gap: 10px; height: 48px; padding: 0 16px 0 6px; border-radius: 999px; background: var(--s1); font-weight: 700; white-space: nowrap; }
.phase-chip .mini { width: 38px; height: 38px; border-radius: 50%; background: var(--s2); overflow: hidden; position: relative; }
.phase-chip .mini .fig { position: absolute; width: 76px; height: 76px; max-width: none; left: -19px; top: -2px; object-fit: cover; object-position: 50% 0; }
.phase-chip small { color: var(--text-3); font-weight: 600; font-size: var(--t-14); }
.timebar { flex: 1; height: 12px; border-radius: 6px; background: var(--s1); overflow: hidden; }
.timebar i { display: block; height: 100%; width: 100%; background: var(--gold); border-radius: 6px; transform-origin: left; transition: transform 1s linear; }
.mgrid { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(220px, 1fr) minmax(360px, 1.6fr) auto; gap: 24px; align-items: stretch; }
.world { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 12px; position: relative; padding-bottom: 8px; }
.world .bear-wrap { width: min(230px, 100%); aspect-ratio: 1; }
.world .bear-wrap .fig { transition: transform 200ms var(--ease-out); }
.world .bear-wrap.is-bounce .fig { animation: hop 380ms var(--ease-out); }
@keyframes hop { 40% { transform: translateY(-14px) scale(1.03); } }
.world .say {
  align-self: stretch; text-align: center;
  background: var(--s1); border-radius: 16px; padding: 10px 14px; min-height: 48px;
  font-size: var(--t-17); color: var(--text-2);
  display: grid; place-items: center;
}
.combo { display: flex; align-items: center; gap: 6px; height: 40px; }
.combo i { width: 16px; height: 16px; border-radius: 50%; background: var(--s2); transition: background-color 150ms ease, transform 200ms var(--ease-out); }
.combo i.on { background: var(--gold); transform: scale(1.1); }
.combo b { margin-left: 6px; color: var(--gold); font-size: var(--t-24); font-weight: 800; opacity: 0; transform: scale(0.9); transition: opacity 160ms ease, transform 200ms var(--ease-out); }
.combo.is-hot b { opacity: 1; transform: none; }
.combo.is-hot i { background: var(--gold); }

.stage { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; min-width: 0; }
.task { font-size: var(--t-task); font-weight: 800; letter-spacing: -0.02em; line-height: 1; white-space: nowrap; }
.task .op { color: var(--text-3); padding: 0 0.12em; font-weight: 700; }
.answer {
  min-width: 220px; height: 112px; padding: 0 24px; border-radius: 24px;
  background: var(--s1); box-shadow: inset 0 0 0 2px var(--line);
  display: grid; place-items: center;
  font-size: var(--t-task); font-weight: 800; line-height: 1;
  transition: background-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
}
.answer .ph { color: var(--s3); }
.answer.is-correct { background: var(--gold); color: var(--gold-ink); box-shadow: var(--sh-1); }
.answer.is-wrong { background: var(--s2); color: var(--text-3); text-decoration: line-through; text-decoration-thickness: 4px; }
.answer.is-entering { animation: slot-in 220ms var(--ease-out); }
@keyframes slot-in { from { transform: scale(0.96); opacity: 0.6; } }
.task.is-entering { animation: task-in 240ms var(--ease-out); }
@keyframes task-in { from { transform: translateY(10px); opacity: 0; filter: blur(4px); } }
.reveal { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; max-width: 520px; }
.reveal .solution { font-size: var(--t-48); font-weight: 800; color: var(--calm); }
.reveal .hint { font-size: var(--t-20); color: var(--text-2); }
.reveal .tap-on { font-size: var(--t-14); color: var(--text-3); }
.helpbox { display: flex; align-items: center; gap: 20px; padding: 16px 20px; border-radius: 20px; background: var(--s1); max-width: 560px; }
.helpbox .dots { width: auto; height: 150px; max-width: 220px; }
.helpbox .help-fig { width: 96px; height: 96px; flex: none; margin: -8px 0; }
.helpbox p { font-size: var(--t-20); color: var(--text-2); }
.helpbox b { color: var(--gold); }

.pad { display: flex; align-items: center; justify-content: center; }
.keypad { display: grid; grid-template-columns: repeat(3, var(--key)); grid-auto-rows: var(--key); gap: var(--gap); }
.key {
  border: 0; border-radius: 22px;
  background: var(--s2); color: var(--text);
  font-size: 2.5rem; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 2px 0 rgb(0 0 0 / 0.25), var(--sh-1);
  transition: transform 120ms var(--ease-out), background-color 120ms ease;
}
.key .icon { width: 34px; height: 34px; }
.key--fn { background: var(--s1); color: var(--text-2); }
.key--ok { background: var(--gold); color: var(--gold-ink); }
.key--ok .icon { stroke-width: 3; }
.key:active, .key.is-pressed { transform: scale(0.95); }
.key:active { background: var(--s3); }
.key--ok:active { background: var(--gold-2); }
.keypad.is-disabled .key { opacity: 0.5; }

/* Boss */
.boss-hp { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.boss-hp .bar { height: 16px; border-radius: 8px; background: var(--s1); overflow: hidden; }
.boss-hp .bar i { display: block; height: 100%; background: linear-gradient(90deg, #8fb4ff, #d9e6ff); transform-origin: left; transition: transform 260ms var(--ease-out); }
.boss-hp span { font-size: var(--t-14); color: var(--text-3); text-align: center; }
.world .snow-wrap { width: min(220px, 100%); aspect-ratio: 468/512; }
.snow-wrap.is-hit .snowman { animation: shake 300ms var(--ease-out); }
@keyframes shake { 20% { transform: translateX(-8px) rotate(-3deg); } 50% { transform: translateX(6px) rotate(2deg); } 80% { transform: translateX(-3px); } }
.snowball { position: fixed; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: inset -4px -4px 0 #d9e2f5; pointer-events: none; z-index: 40; }

/* Zwischen-Screens */
.interlude {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: rgb(6 13 34 / 0.78);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: fade-in 200ms ease-out;
}
.interlude .panel { width: min(560px, 92vw); padding: 32px; border-radius: 28px; background: var(--s1); box-shadow: var(--sh-2); display: flex; flex-direction: column; align-items: center; gap: 16px; text-align: center; animation: panel-in 260ms var(--ease-out); }
.interlude .panel .figure { width: 168px; height: 168px; margin-top: -16px; }
.interlude h2 { font-size: var(--t-32); }
.interlude p { font-size: var(--t-20); color: var(--text-2); }
@keyframes fade-in { from { opacity: 0; } }
@keyframes panel-in { from { opacity: 0; transform: translateY(12px) scale(0.97); } }

/* ---------- Belohnung ---------- */
.reward { align-items: center; justify-content: center; text-align: center; gap: 24px; }
.reward h1 { font-size: var(--t-48); font-weight: 800; }
.reward .stats { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }
.reward .stat { min-width: 150px; padding: 16px 20px; border-radius: 20px; background: var(--s1); }
.reward .stat b { display: block; font-size: var(--t-32); color: var(--gold); }
.reward .stat span { color: var(--text-2); font-size: var(--t-14); }
.reward .door-reveal { display: flex; align-items: center; gap: 20px; padding: 16px 24px; border-radius: 24px; background: var(--s2); text-align: left; }
.reward .door-reveal .item { width: 72px; height: 72px; animation: door-pop 600ms var(--ease-out) 300ms both; }
.reward .door-bear { width: 84px; height: 84px; margin: -12px -8px -12px -12px; }
.reward-fig { width: 168px; height: 168px; margin-bottom: -8px; }
.trophy-line { display: inline-flex; align-items: center; gap: 8px; }
.trophy-line .item { width: 32px; height: 32px; }
.reward .door-reveal p { color: var(--text-2); }
.reward .door-reveal strong { font-size: var(--t-24); display: block; color: var(--text); }
.reward .actions { display: flex; gap: 12px; }
.news { color: var(--gold-2); font-size: var(--t-20); font-weight: 600; }

/* ---------- Effekte ---------- */
.fx-layer { position: fixed; z-index: 50; pointer-events: none; width: 0; height: 0; }
.fx-spark { position: absolute; left: -10px; top: -10px; width: 20px; height: 20px; color: var(--gold); animation: spark-fly 650ms var(--ease-out) forwards; }
.fx-spark .icon { width: 20px; height: 20px; }
@keyframes spark-fly { to { transform: translate(var(--dx), var(--dy)) scale(0.4) rotate(90deg); opacity: 0; } }
.fx-plus { position: absolute; transform: translate(-50%, -50%); font-size: var(--t-32); font-weight: 800; color: var(--gold); white-space: nowrap; animation: plus-up 700ms var(--ease-out) forwards; text-shadow: 0 2px 8px rgb(0 0 0 / 0.4); }
@keyframes plus-up { from { transform: translate(-50%, -20%); opacity: 0; } 25% { opacity: 1; } to { transform: translate(-50%, -160%); opacity: 0; } }
.fx-rain { position: fixed; inset: 0; pointer-events: none; z-index: 45; overflow: hidden; }
.fx-drop { position: absolute; top: -30px; color: var(--gold); width: var(--size); height: var(--size); animation: drop 1100ms ease-in forwards; }
.fx-drop .icon { width: 100%; height: 100%; }
@keyframes drop { to { transform: translateY(110vh) rotate(200deg); opacity: 0.2; } }

/* ---------- Sheet / Toast ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgb(6 13 34 / 0.7); animation: fade-in 160ms ease-out; }
.sheet-backdrop.is-leaving { opacity: 0; transition: opacity 150ms ease; }
.sheet { width: min(460px, 92vw); padding: 24px; border-radius: 24px; background: var(--s1); box-shadow: var(--sh-2); display: flex; flex-direction: column; gap: 12px; animation: panel-in 220ms var(--ease-out); }
.sheet h2 { font-size: var(--t-24); }
.sheet p { color: var(--text-2); }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 70; padding: 12px 20px; border-radius: 14px; background: var(--s3); box-shadow: var(--sh-2); font-weight: 600; animation: toast-in 200ms var(--ease-out); }
.toast.is-leaving { opacity: 0; transition: opacity 180ms ease; }
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 10px); } }

/* ---------- Querformat-Hinweis ---------- */
.rotate-hint { display: none; }
@media (orientation: portrait) and (max-width: 1100px) {
  body:not(.allow-portrait) .rotate-hint {
    display: grid; place-items: center; position: fixed; inset: 0; z-index: 100;
    background: var(--bg); text-align: center; padding: 32px; font-size: var(--t-24);
  }
  .rotate-hint .figure { width: 180px; height: 180px; margin: 0 auto 16px; }
}

/* Kleinere iPads (1024×768 / 1080×810) */
@media (max-height: 800px) {
  :root { --key: 80px; --t-task: 5.25rem; }
  .answer { height: 100px; }
}
@media (max-width: 1100px) {
  .mgrid { grid-template-columns: minmax(180px, 0.8fr) minmax(320px, 1.5fr) auto; gap: 16px; }
  .home-grid { grid-template-columns: minmax(320px, 5fr) 7fr; gap: 16px; }
  .nav-btn span { display: none; }
  .nav-btn { min-width: 56px; }
}

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