/* spur. — Aquarell-Oberfläche */

:root {
  --paper: #fbf6ea;
  --paper-dark: #e9dcc3;
  --ink: #3b2a1a;
  --muted: #7a6450;
  --faint: #c9b59a;
  --orange: #f0923f; --red: #d9553a; --yellow: #f2c14e; --green: #6a9a4f;
  --blue: #6fb3d2; --purple: #9b8afb; --brown: #8b4a21;
  --hand: 'Patrick Hand', 'Comic Sans MS', cursive;
  --body: 'Nunito', system-ui, sans-serif;
  --wash: var(--orange);
  --wash-o: 0.4;
  --r: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  min-height: 100dvh;
}
.paper-bg { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 0; }
#app { position: relative; z-index: 1; overflow-x: clip; }
html, body { overscroll-behavior-y: none; }
a, button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
.tabbar, .album-arrow, .cam { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
/* Übergänge wie in einer App: vor = von rechts, zurück = von links, Reiter = blenden */
#app[data-nav="push"] > .screen { animation: navIn 0.24s cubic-bezier(.2,.8,.2,1) both; }
#app[data-nav="pop"] > .screen { animation: navBack 0.24s cubic-bezier(.2,.8,.2,1) both; }
#app[data-nav="tab"] > .screen { animation: navFade 0.18s ease-out both; }
@keyframes navIn { from { transform: translateX(28%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes navBack { from { transform: translateX(-20%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes navFade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #app > .screen { animation: none !important; } }

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
svg { display: block; }
h1, h2, h3 { margin: 0; font-family: var(--hand); font-weight: 400; line-height: 1.05; }
h1 { font-size: 36px; }
h2 { font-size: 26px; }
h3 { font-size: 21px; }
.hand { font-family: var(--hand); }
.muted { color: var(--muted); }
.small { font-size: 13px; font-weight: 800; }
.center { text-align: center; }

/* ---------- Aquarell-Flächen ---------- */
.wash { position: relative; isolation: isolate; }
.wash::before {
  content: ""; position: absolute; inset: 0; z-index: -1;
  background: var(--wash); opacity: var(--wash-o);
  border-radius: var(--r);
  filter: url(#wash);
}
.inkline::after {
  content: ""; position: absolute; inset: 1px; z-index: -1; pointer-events: none;
  border: 1.6px solid var(--ink); border-radius: var(--r);
  filter: url(#ink);
}
.wash.white { --wash: #ffffff; --wash-o: 0.7; }
.wash.solid { --wash-o: 0.9; }

/* ---------- Layout ---------- */
.screen {
  max-width: 480px; margin: 0 auto; min-height: 100dvh;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 18px;
}
.row { display: flex; align-items: center; gap: 12px; }
.row.between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 4px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 6px; }
.stack { display: flex; flex-direction: column; gap: 12px; }

/* ---------- Buttons ---------- */
.btn {
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 56px; padding: 10px 20px;
  font-family: var(--hand); font-size: 22px;
  --r: 16px;
}
.btn.block { width: 100%; }
.btn.primary { --wash: var(--green); --wash-o: 0.9; color: var(--paper); }
.btn.orange { --wash: var(--orange); --wash-o: 0.9; }
.btn.quiet { --wash: #ffffff; --wash-o: 0.8; }
.btn.ghost { min-height: 44px; font-size: 16px; font-family: var(--body); font-weight: 800; color: var(--muted); }
.btn:active { transform: scale(0.97); }
.btn svg { flex: none; }
.icon-btn {
  position: relative; isolation: isolate;
  width: 44px; height: 44px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  --r: 50%; --wash: #ffffff; --wash-o: 0.85;
}
.pill {
  position: relative; isolation: isolate;
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; --r: 999px;
  font-family: var(--hand); font-size: 16px; white-space: nowrap;
}
.pill.dark { --wash: var(--ink); --wash-o: 0.85; color: var(--paper); }
.pill.outline::before { opacity: 0; }
.pill.outline { --wash-o: 0; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 999px; font-family: var(--hand); font-size: 13px; color: #fff; background: var(--red); }
.chip.selten { background: #7b67e8; }
.chip.legendaer { background: var(--red); }
.chip.normal { background: var(--orange); }

/* ---------- Karten ---------- */
.card { position: relative; isolation: isolate; padding: 16px 18px; --r: 20px; }
.card.link { display: flex; align-items: center; gap: 14px; }
.world {
  position: relative; isolation: isolate;
  padding: 16px; min-height: 170px; display: flex; flex-direction: column; gap: 8px; --r: 22px;
}
.world .badge { position: absolute; top: 10px; right: 10px; }
.world .name { font-family: var(--hand); font-size: 26px; line-height: 1; margin-top: auto; }
.world .count { font-size: 13px; font-weight: 800; }
.world.locked { opacity: 0.85; }

.task {
  position: relative; isolation: isolate;
  padding: 16px 12px 14px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  --r: 20px; --wash: #ffffff; --wash-o: 0.6;
}
.task.active { --wash: var(--orange); --wash-o: 0.35; }
.task.selten { --wash: var(--purple); --wash-o: 0.3; }
.task.legendaer { --wash: var(--red); --wash-o: 0.25; }
.task .name { font-family: var(--hand); font-size: 20px; text-align: center; line-height: 1.1; }
.task .state { font-size: 12px; font-weight: 800; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.task .state.done { color: #3c6a2a; }
.task .thumb { position: absolute; top: 8px; right: 8px; width: 42px; height: 42px; border-radius: 50%; background: #fff; padding: 3px; box-shadow: 0 2px 6px rgba(59,42,26,0.3); transform: rotate(10deg); overflow: hidden; }
.task .thumb img, .task .thumb svg { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; }
.task .rarity { position: absolute; top: 8px; left: 8px; }
.task.locked { --wash-o: 0.35; }
.task.locked > svg:not(.rarity) { opacity: 0.45; filter: grayscale(0.6); }
.task.locked .name { color: var(--muted); }

/* ---------- Fortschritt ---------- */
.bar { height: 12px; position: relative; }
.bar svg { width: 100%; height: 12px; }

/* ---------- Welt-Banner ---------- */
.banner {
  position: relative; isolation: isolate;
  margin: -16px -20px 0; padding: calc(16px + env(safe-area-inset-top)) 20px 24px;
  display: flex; flex-direction: column; gap: 16px;
}
.banner::before {
  content: ""; position: absolute; inset: -20px -10px 0; z-index: -1;
  background: var(--wash); opacity: 0.55;
  border-radius: 0 0 40% 30% / 0 0 40px 40px;
  filter: url(#wash);
}
.banner .deco { position: absolute; right: -10px; top: 40px; opacity: 0.6; pointer-events: none; }

/* ---------- Sticker ---------- */
.diecut, .photosticker { filter: drop-shadow(0 6px 12px rgba(59,42,26,0.25)); }
.sticker-stage { display: flex; justify-content: center; padding: 10px 0; }
.label-pill { align-self: center; }
.label-pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--orange); }

/* ---------- Album ---------- */
.album-screen { background: var(--paper-dark); margin: 0 -20px; padding: calc(16px + env(safe-area-inset-top)) 16px 24px; min-height: 100dvh; display: flex; flex-direction: column; }
.tabs { display: flex; gap: 4px; padding: 0 10px; align-items: flex-end; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { position: relative; isolation: isolate; padding: 8px 11px 12px; font-family: var(--hand); font-size: 15px; white-space: nowrap; flex: none; }
.tab::before { content: ""; position: absolute; inset: 0; z-index: -1; background: var(--wash); opacity: 0.45; border-radius: 14px 14px 0 0; filter: url(#wash); }
.tab.on { padding: 10px 13px 16px; font-size: 17px; }
.tab.on::before { opacity: 0.65; }
.page {
  position: relative; isolation: isolate; flex: 1;
  background: var(--paper); border-radius: 6px; padding: 18px 12px 16px;
  box-shadow: 0 10px 30px rgba(59,42,26,0.2);
  display: flex; flex-direction: column; gap: 16px;
}
.page .paper-bg { position: absolute; z-index: 0; }
.page > * { position: relative; z-index: 1; }
.page::after { content: ""; position: absolute; inset: 3px; border: 0.8px solid rgba(59,42,26,0.45); border-radius: 3px; filter: url(#ink); pointer-events: none; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.slot .name { font-family: var(--hand); font-size: 16px; text-align: center; line-height: 1.1; }
.slot.empty .name { color: #a8906f; }
.slot .photosticker { width: 80px; height: 80px; }
.slot .name { font-size: 14px; }
.dots { display: flex; justify-content: center; gap: 8px; padding-top: 14px; }
.dots button { width: 10px; height: 10px; border-radius: 5px; background: var(--faint); }
.dots button.on { width: 28px; background: var(--orange); }

/* ---------- Belohnung ---------- */
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti i { position: absolute; width: 12px; height: 12px; border-radius: 3px; animation: fall 2.6s ease-in forwards; opacity: 0.9; }
.confetti i.round { border-radius: 50%; }
@keyframes fall { 0% { transform: translateY(-40px) rotate(0); opacity: 0; } 10% { opacity: 1; } 100% { transform: translateY(100vh) rotate(540deg); opacity: 0.6; } }
.pop { animation: pop 0.6s cubic-bezier(.2,1.4,.4,1) both; }
@keyframes pop { from { transform: scale(0.4) rotate(-20deg); opacity: 0; } to { transform: scale(1) rotate(-4deg); opacity: 1; } }

/* ---------- Formulare (Elternmodus) ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-family: var(--hand); font-size: 18px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border: 1.6px solid var(--ink); border-radius: 12px; background: #fff; font-size: 16px;
}
.field textarea { min-height: 80px; resize: vertical; }
.iconpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.iconpick button { border-radius: 12px; padding: 3px; border: 2px solid transparent; background: rgba(255,255,255,0.6); min-width: 0; }
.iconpick button svg { width: 100%; height: auto; }
.iconpick button.on { border-color: var(--ink); background: #fff; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list .item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: rgba(255,255,255,0.6); border-radius: 12px; }
.list .item .grow { font-weight: 600; }
.danger { color: var(--red); }
.notice { font-size: 13px; font-weight: 600; color: var(--muted); }

/* ---------- Camera overlay ---------- */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(251,246,234,0.92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; font-family: var(--hand); font-size: 24px; }
.spin { width: 48px; height: 48px; border-radius: 50%; border: 5px solid var(--faint); border-top-color: var(--orange); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Eigene Kamera ---------- */
.cam { position: fixed; inset: 0; z-index: 60; background: #1f170f; color: var(--paper); display: flex; flex-direction: column;
  padding: calc(12px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); }
.cam.flash::after { content: ""; position: absolute; inset: 0; background: #fff; animation: flash 0.35s ease-out forwards; pointer-events: none; }
@keyframes flash { from { opacity: 0.9; } to { opacity: 0; } }
.cam-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.cam-hint { font-family: var(--hand); font-size: 22px; text-align: center; }
.cam-round { width: 52px; height: 52px; border-radius: 50%; border: 0; background: rgba(251,246,234,0.14); color: var(--paper); display: grid; place-items: center; }
.cam-view { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; min-height: 0; }
.cam-box { position: relative; width: min(100%, 62dvh); aspect-ratio: 1; border-radius: 22px; overflow: hidden; background: #000; }
.cam-box video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.cam-box video.mirror { transform: scaleX(-1); }
.cam-ring { position: absolute; left: 9%; top: 9%; width: 82%; height: 82%; border-radius: 50%;
  border: 3px dashed rgba(251,246,234,0.85); box-shadow: 0 0 0 999px rgba(31,23,15,0.35); pointer-events: none; }
.cam-fail { text-align: center; font-weight: 700; line-height: 1.5; max-width: 22em; opacity: 0.9; }
.cam-bar { display: flex; align-items: center; justify-content: space-around; padding-top: 14px; }
.cam-shutter { width: 84px; height: 84px; border-radius: 50%; border: 6px solid var(--paper); background: var(--orange); box-shadow: 0 0 0 4px rgba(240,146,63,0.35); }
.cam-shutter:active { transform: scale(0.92); }
.cam-side { width: 84px; display: flex; flex-direction: column; align-items: center; gap: 4px; border: 0; background: none; color: var(--paper); font: 800 13px var(--body); }

.synccode { font: 800 26px ui-monospace, 'JetBrains Mono', monospace; letter-spacing: 0.06em; text-align: center; padding: 10px;
  border: 2px dashed var(--faint); border-radius: 14px; background: rgba(255,255,255,0.7); -webkit-user-select: all; user-select: all; }

/* ---------- Leiste unten ---------- */
.tabbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; display: flex; justify-content: center; gap: 6px;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); background: rgba(251,246,234,0.96);
  border-top: 1.5px solid rgba(59,42,26,0.18); box-shadow: 0 -6px 20px rgba(59,42,26,0.08); }
.tabbar-item { flex: 1; max-width: 160px; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; border-radius: 16px; color: var(--muted); font-family: var(--hand); font-size: 17px; text-decoration: none; }
.tabbar-item.on { color: var(--ink); background: rgba(240,146,63,0.22); }
.tabbar-item:active { transform: scale(0.96); }
body.has-tabbar #app { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
body.has-tabbar .screen { min-height: calc(100dvh - 76px - env(safe-area-inset-bottom)); }
body.has-tabbar .album-screen { min-height: calc(100dvh - 76px - env(safe-area-inset-bottom)); }
@media print { .tabbar { display: none; } }

/* ---------- Album: Blättern ---------- */
.album-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.album-nav .dots { padding-top: 0; flex-wrap: wrap; justify-content: center; }
.album-arrow { --wash: #ffffff; --wash-o: 0.85; --r: 999px; display: inline-flex; align-items: center; gap: 4px; flex: none;
  min-height: 48px; min-width: 104px; padding: 0 14px; font-family: var(--hand); font-size: 18px; color: var(--ink); text-decoration: none; }
.album-arrow.prev { padding-left: 8px; }
.album-arrow.next { padding-right: 8px; justify-content: flex-end; }
.album-arrow:active { transform: scale(0.96); }
.album-arrow.off { visibility: hidden; }
body.has-tabbar .album-screen { min-height: 0; }

/* ---------- Druckbogen ---------- */
.sheet-wrap { display: flex; justify-content: center; }
.sheet {
  background: #fff; color: var(--ink); width: 210mm; min-height: 297mm; flex: none;
  padding: 12mm 14mm; box-shadow: 0 8px 30px rgba(59,42,26,0.2); border-radius: 4px;
  display: flex; flex-direction: column; gap: 8mm;
  transform-origin: top center;
}
.sheet-head { display: flex; justify-content: space-between; align-items: flex-end; padding-bottom: 4mm; border-bottom: 1.5px dashed var(--ink); }
.sheet-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8mm 6mm; }
.cut { display: flex; flex-direction: column; align-items: center; gap: 2mm; }
.cut .ring { width: 49mm; height: 49mm; border-radius: 50%; border: 0.4mm dashed var(--faint); display: flex; align-items: center; justify-content: center; }
.cut .photosticker { width: 45mm; height: 45mm; filter: none; }
.cut .name { font-family: var(--hand); font-size: 16px; line-height: 1.1; }
.cut .date { font-size: 11px; font-weight: 800; color: var(--muted); }
.sheet-foot { display: flex; justify-content: space-between; padding-top: 4mm; border-top: 1.5px dashed var(--ink); font-size: 11px; font-weight: 800; color: var(--muted); }
.print-actions { display: flex; gap: 10px; justify-content: center; }

@media print {
  @page { size: A4 portrait; margin: 0; }
  body { background: #fff; }
  .paper-bg, .print-actions, .no-print { display: none !important; }
  .screen { padding: 0; max-width: none; min-height: auto; gap: 0; }
  .sheet-wrap { display: block; height: auto !important; }
  .sheet { box-shadow: none; border-radius: 0; transform: none !important; height: 297mm; min-height: 0; overflow: hidden; page-break-after: always; }
  .sheet-wrap:last-of-type .sheet { page-break-after: auto; }
  .photosticker, .diecut { filter: none !important; }
}

/* ---------- Kleinigkeiten ---------- */
.fade { animation: fade 0.25s ease both; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.footer-brand { text-align: center; font-family: 'JetBrains Mono', ui-monospace, monospace; font-size: 11px; color: var(--faint); letter-spacing: 1px; padding-top: 8px; }
.goal { display: flex; gap: 6px; }
.goal i { width: 18px; height: 18px; border-radius: 50%; border: 2.5px dashed var(--faint); }
.goal i.on { border-style: solid; border-color: var(--green); background: var(--green); }
.welcome { min-height: 100dvh; justify-content: center; text-align: center; }
.welcome .field input { text-align: center; font-family: var(--hand); font-size: 26px; }
.deco-leaf { position: absolute; pointer-events: none; }
.rot-3 { transform: rotate(-3deg); } .rot3 { transform: rotate(3deg); } .rot-6 { transform: rotate(-6deg); } .rot5 { transform: rotate(5deg); }
