:root {
  --creme: #f6ebd9;
  --creme-dark: #efddc0;
  --card: #fff8ec;
  --rot: #8b1e2d;
  --rot-hell: #a8273a;
  --gruen: #1f4d3a;
  --gruen-hell: #2a6a4e;
  --gold: #c9a227;
  --gold-hell: #f2c14e;
  --braun: #3b2415;
  --braun-mittel: #7a5a3a;
  --braun-hell: #9a7b5b;
  --linie: #dccbb0;
  --chip-dash: #b9a48c;
  --frost: #e3e9ee;
  --frost-rand: #eef3f6;
  --frost-text: #7a8a98;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--creme);
  color: var(--braun);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; }

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(260px 260px at -30px -40px, var(--creme-dark) 0 50%, transparent 51%),
    radial-gradient(320px 320px at calc(100% + 60px) calc(100% + 80px), var(--creme-dark) 0 50%, transparent 51%),
    var(--creme);
}

/* Header */
.hdr { padding: calc(env(safe-area-inset-top, 0px) + 18px) 20px 0; display: flex; flex-direction: column; gap: 12px; flex: 0 0 auto; }
.hdr-row { display: flex; justify-content: space-between; align-items: baseline; }
.title { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 800; color: var(--rot); }
.hdr-date { font-size: 13px; font-weight: 700; color: var(--braun-mittel); }

.strip { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 4px 2px 6px; margin: 0 -2px; }
.strip::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 17px; border: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; background: transparent; transition: transform .15s;
}
.chip.done { background: var(--gruen); color: var(--creme); }
.chip.open { background: var(--card); color: var(--braun-mittel); box-shadow: inset 0 0 0 2px var(--linie); }
.chip.today { background: var(--rot); color: #fff6e8; font-weight: 800; box-shadow: 0 4px 12px rgba(139, 30, 45, .35); }
.chip.locked { border: 2px dashed var(--chip-dash); color: var(--chip-dash); }
.chip.current { transform: scale(1.18); }

/* Track + panels */
.track {
  flex: 1 1 auto; min-height: 0;
  display: flex; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain;
}
.track::-webkit-scrollbar { display: none; }
.panel {
  flex: 0 0 100%; width: 100%; height: 100%; scroll-snap-align: start; scroll-snap-stop: always;
  display: flex; align-items: center; justify-content: center; padding: 8px 20px 12px;
}
.scene { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; width: 100%; max-width: 340px; }

.hint-big { margin: 0; font-family: var(--serif); font-size: 20px; font-weight: 600; text-align: center; }
.hint-small { margin: 0; font-size: 13px; font-weight: 700; color: var(--braun-hell); min-height: 20px; text-align: center; }

/* Doors (shared frame) */
.door {
  position: relative; width: min(300px, 100%); aspect-ratio: 300 / 420; max-height: 56dvh;
  border-radius: 28px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 18px 40px rgba(59, 36, 21, .25);
  perspective: 1000px;
}
.door.closed { background: transparent; box-shadow: none; }
.door-face {
  position: absolute; inset: 0; border-radius: 28px; overflow: hidden;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 18px 40px rgba(59, 36, 21, .25);
  transform-origin: left center; backface-visibility: hidden;
  transition: transform .6s cubic-bezier(.4, .1, .3, 1);
}
.door.flipping .door-face { transform: perspective(900px) rotateY(-108deg); }
.door-num { position: relative; font-family: var(--serif); font-size: clamp(120px, 42vw, 168px); font-weight: 800; line-height: 1; }
.door-knob { position: absolute; right: 30px; top: 50%; width: 14px; height: 14px; border-radius: 7px; background: var(--gold); box-shadow: inset 0 2px 3px rgba(0, 0, 0, .25); }

/* Open door: colored frame + card, with a thin leaf on the left */
.door.open { padding: 14px; }
.door-leaf {
  position: absolute; left: -12px; top: 42%; width: 48px; height: 52%; border-radius: 24px 8px 8px 24px;
  background: inherit; box-shadow: inset -6px 0 10px rgba(0, 0, 0, .25);
  transform: perspective(600px) rotateY(55deg); transform-origin: left;
}
.card {
  position: relative; flex: 1 1 auto; align-self: stretch; border-radius: 18px; background: var(--card);
  padding: 26px 20px 20px; display: flex; flex-direction: column; gap: 12px;
  box-shadow: inset 0 0 0 2px #e8d7b8;
}
.card-label { font-family: var(--serif); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--braun-hell); font-weight: 600; }
.card-text { margin: 0; font-family: var(--serif); font-size: clamp(20px, 6vw, 26px); font-weight: 600; line-height: 1.25; }
.spacer { flex: 1 1 auto; }
.card-dots { display: flex; justify-content: center; gap: 8px; }
.card-dots i { width: 8px; height: 8px; border-radius: 4px; background: var(--gold); }
.card-dots i:nth-child(2) { background: var(--rot); }
.stamp {
  position: absolute; top: -8px; right: -10px; width: 88px; height: 88px; border-radius: 44px;
  border: 4px solid var(--gruen); color: var(--gruen); transform: rotate(-14deg);
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-family: var(--serif); font-size: 12px; font-weight: 800; line-height: 1.1; letter-spacing: .06em;
  background: rgba(255, 255, 255, .75);
}

/* Frost door (future) */
.door.frost {
  background: var(--frost); border: 2px solid #fff; overflow: hidden;
  box-shadow: 0 18px 40px rgba(59, 36, 21, .18), inset 0 0 70px rgba(255, 255, 255, .9), inset 0 0 0 10px var(--frost-rand);
}
.frost-shine { position: absolute; top: 0; left: 0; right: 0; height: 60px; background: linear-gradient(180deg, rgba(255, 255, 255, .95), rgba(255, 255, 255, 0)); }
.frost-ice { position: absolute; width: 140px; height: 140px; }
.frost-ice::before, .frost-ice::after, .frost-ice i { content: ""; position: absolute; height: 3px; border-radius: 2px; background: #fff; }
.frost-ice.tl { top: 0; left: 0; }
.frost-ice.tl::before { top: 14px; left: 14px; width: 70px; transform: rotate(35deg); transform-origin: left; }
.frost-ice.tl::after { top: 16px; left: 12px; width: 46px; transform: rotate(62deg); transform-origin: left; }
.frost-ice.br { bottom: 0; right: 0; }
.frost-ice.br::before { bottom: 14px; right: 14px; width: 70px; transform: rotate(35deg); transform-origin: right; }
.frost-ice.br::after { bottom: 16px; right: 12px; width: 46px; transform: rotate(62deg); transform-origin: right; }
.qmark { font-family: var(--serif); font-size: clamp(140px, 48vw, 190px); font-weight: 800; line-height: 1; color: #fff; text-shadow: 0 2px 0 #c7d3dc, 0 0 24px rgba(255, 255, 255, .9); }
.frost-label { position: absolute; bottom: 96px; font-family: var(--serif); font-size: 15px; letter-spacing: .14em; text-transform: uppercase; color: var(--frost-text); font-weight: 600; }
.seal {
  position: absolute; bottom: 28px; width: 64px; height: 64px; border-radius: 32px; background: var(--rot); color: var(--creme);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 16px rgba(139, 30, 45, .35), inset 0 0 0 4px var(--rot-hell);
}

/* Buttons */
.btn {
  min-height: 52px; padding: 0 28px; border: 0; border-radius: 26px;
  display: flex; align-items: center; justify-content: center; gap: 10px; font-size: 17px; font-weight: 700;
}
.btn.primary { background: var(--rot); color: #fff6e8; box-shadow: 0 8px 20px rgba(139, 30, 45, .3); }
.btn.primary.green { background: var(--gruen); color: #fff6e8; box-shadow: none; min-height: 50px; font-size: 16px; }
.btn.done-state { background: #e7f1e9; color: var(--gruen); min-height: 50px; font-size: 15px; }
.btn:disabled { opacity: .6; }
.link {
  min-height: 44px; padding: 0 16px; border: 0; background: transparent; color: var(--braun-hell);
  font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 8px;
  text-decoration: underline; text-underline-offset: 3px;
}

/* Footer */
.foot {
  flex: 0 0 auto; padding: 0 20px calc(env(safe-area-inset-bottom, 0px) + 14px);
  display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 700; color: var(--braun-hell);
}
.foot-btn { border: 0; background: transparent; min-height: 44px; display: flex; align-items: center; gap: 6px; color: inherit; font-size: 12px; font-weight: 700; padding: 0 4px; }
.foot-btn:disabled { visibility: hidden; }
.foot-dots { display: flex; gap: 5px; }
.foot-dots i { width: 6px; height: 6px; border-radius: 3px; background: var(--linie); }
.foot-dots i.on { background: var(--rot); }

.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--braun); color: var(--creme); padding: 10px 16px; border-radius: 20px; font-size: 14px; font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25); z-index: 20; max-width: 90vw; text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .door-face { transition: none; }
  .chip { transition: none; }
}
@media (min-width: 600px) {
  #app { max-width: 430px; margin: 0 auto; box-shadow: 0 0 0 1px var(--linie); }
}
