:root {
  --gold: #f3c969;
  --gold-2: #ffe7a8;
  --gold-deep: #b8862b;
  --red: #d7263d;
  --green: #2f9e6e;
  --snow: #f4f7ff;
  --night: #0b1530;
  --night-2: #13224a;
  --ink: #e9eefc;
  --muted: #9fb0d9;
  --panel: rgba(255, 255, 255, .06);
  --line: rgba(255, 255, 255, .12);
  --font-display: "Cormorant Garamond", "Playfair Display", "Palatino Linotype", "Book Antiqua", Georgia, "Times New Roman", serif;
  --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --radius: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  background: radial-gradient(1200px 700px at 70% -10%, #23336b 0%, transparent 60%),
              linear-gradient(180deg, #060b1d 0%, #0b1530 45%, #13224a 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body.modal-open { overflow: hidden; }

#sky { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; pointer-events: none; }
#village { position: fixed; left: 0; right: 0; bottom: 0; height: 26vh; z-index: 0; pointer-events: none; opacity: .95; }
#village svg { width: 100%; height: 100%; display: block; }
#fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 1000; pointer-events: none; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer;
  font: 600 15px/1 var(--font-body);
  padding: 12px 20px; border-radius: 999px;
  color: #3a2603;
  background: linear-gradient(180deg, var(--gold-2), var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 6px 18px rgba(243, 201, 105, .25), inset 0 1px 0 rgba(255,255,255,.7);
  transition: transform .15s ease, box-shadow .2s ease, filter .2s;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); box-shadow: 0 10px 24px rgba(243,201,105,.35), inset 0 1px 0 rgba(255,255,255,.7); }
.btn:active { transform: translateY(1px) scale(.98); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.ghost { background: var(--panel); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.btn.ghost:hover { background: rgba(255,255,255,.1); }
.btn:focus-visible, .icon-btn:focus-visible, .door:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.icon-btn {
  appearance: none; border: 0; cursor: pointer;
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-grid; place-items: center;
  font-size: 18px; color: var(--ink);
  background: rgba(255,255,255,.07);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: background .2s, transform .15s, opacity .2s;
}
.icon-btn:hover { background: rgba(255,255,255,.14); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.off { opacity: .45; }
.icon-btn:disabled { opacity: .25; cursor: default; }

/* ---------- Hero ---------- */
.hero { position: relative; z-index: 2; text-align: center; padding: 96px 16px 18px; }
.toolbar { position: absolute; top: 14px; right: 16px; display: flex; gap: 8px; z-index: 3; }
#garland { position: absolute; top: 0; left: 0; width: 100%; height: 90px; overflow: visible; }
.overline { margin: 0; letter-spacing: .32em; text-transform: uppercase; font-size: 12px; color: var(--muted); }
h1 {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: clamp(44px, 9vw, 104px);
  line-height: 1;
  letter-spacing: .01em;
  background: linear-gradient(180deg, #fff6d8 0%, var(--gold) 45%, #c08a2a 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 4px 24px rgba(243, 201, 105, .25));
}
.for { margin: 10px 0 0; font-family: var(--font-display); font-style: italic; font-size: clamp(18px, 3vw, 26px); color: var(--gold-2); min-height: 0; }
.for:empty { display: none; }
.countdown { margin: 18px auto 0; display: inline-flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.countdown .cd-label { width: 100%; font-size: 13px; color: var(--muted); letter-spacing: .08em; }
.cd-box { min-width: 64px; padding: 10px 8px 8px; border-radius: 12px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); backdrop-filter: blur(6px); }
.cd-box b { display: block; font: 600 26px/1 var(--font-display); color: var(--snow); font-variant-numeric: tabular-nums; }
.cd-box span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; }
.cd-msg { font-family: var(--font-display); font-size: 26px; color: var(--gold-2); }
.progress { margin-top: 14px; font-size: 13px; color: var(--muted); }
.progress b { color: var(--gold); }

/* Garland bulbs */
.bulb { transition: fill .6s, filter .6s, opacity .6s; }
.bulb.on { filter: url(#glow); }
.bulb.solved { animation: twinkle 2.4s ease-in-out infinite; }
@keyframes twinkle { 0%,100% { opacity: 1; } 50% { opacity: .65; } }

/* ---------- Grid ---------- */
main { position: relative; z-index: 2; padding: 18px 16px 40px; }
.grid {
  max-width: 1120px; margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-auto-rows: 138px;
  grid-auto-flow: dense;
  gap: 14px;
}
.c2 { grid-column: span 2; }
.r2 { grid-row: span 2; }

.door {
  position: relative;
  appearance: none; border: 0; padding: 0; margin: 0; cursor: pointer;
  background: transparent; color: inherit; font: inherit;
  perspective: 900px;
  border-radius: 14px;
  opacity: 0; transform: translateY(18px) scale(.96);
  animation: doorIn .7s cubic-bezier(.2,.8,.2,1) forwards;
  animation-delay: var(--delay, 0s);
}
@keyframes doorIn { to { opacity: 1; transform: none; } }

.door-inside {
  position: absolute; inset: 0; border-radius: 14px; overflow: hidden;
  background: radial-gradient(circle at 50% 45%, #fff2c4 0%, #f3b54a 22%, #7a3a12 62%, #2a1206 100%);
  box-shadow: inset 0 0 30px rgba(0,0,0,.7);
  display: grid; place-items: center; text-align: center;
}
.door-inside .in-icon { font-size: clamp(30px, 5vw, 54px); filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); transform: scale(.6); opacity: 0; transition: transform .6s .25s cubic-bezier(.2,1.6,.4,1), opacity .4s .25s; }
.door-inside .in-title { position: absolute; left: 8px; right: 8px; bottom: 8px; font-size: 12px; font-weight: 600; color: #fff7e0; text-shadow: 0 1px 4px rgba(0,0,0,.6); opacity: 0; transition: opacity .4s .4s; }
.door-inside .in-check { position: absolute; top: 8px; right: 8px; width: 22px; height: 22px; border-radius: 50%; background: var(--green); color: #fff; font-size: 13px; display: none; place-items: center; box-shadow: 0 0 0 2px rgba(255,255,255,.6); }
.door.solved .in-check { display: grid; }

.door-leaf {
  position: absolute; inset: 0; border-radius: 14px;
  transform-origin: 0% 50%;
  transform-style: preserve-3d;
  transition: transform 1.1s cubic-bezier(.3,1.25,.4,1);
}
.leaf-face, .leaf-back { position: absolute; inset: 0; border-radius: 14px; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.leaf-back { transform: rotateY(180deg); background: linear-gradient(90deg, #3b230f, #5a3517); box-shadow: inset 0 0 0 2px rgba(255,255,255,.08); }
.leaf-face {
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(0,0,0,.35), inset 0 0 0 1px rgba(255,255,255,.14), inset 0 -40px 60px rgba(0,0,0,.18);
  display: grid; place-items: center;
}
.leaf-face::after { /* Glanz */
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(125deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,0) 35%, rgba(255,255,255,0) 70%, rgba(255,255,255,.08) 100%);
  pointer-events: none;
}
.leaf-face .knob { position: absolute; right: 10px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: radial-gradient(circle at 35% 35%, #fff6d0, var(--gold) 50%, #8a5d16); box-shadow: 0 1px 3px rgba(0,0,0,.5); }
.num {
  position: relative; z-index: 1;
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(40px, 6vw, 64px); line-height: 1;
  background: linear-gradient(180deg, #fffbe9 0%, var(--gold) 50%, #a8741f 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.45));
}
.r2 .num, .c2.r2 .num { font-size: clamp(54px, 8vw, 96px); }
.lock { position: absolute; z-index: 1; bottom: 8px; left: 0; right: 0; font-size: 11px; color: rgba(255,255,255,.8); letter-spacing: .06em; text-shadow: 0 1px 2px rgba(0,0,0,.6); opacity: 0; transition: opacity .25s; }
.door.locked:hover .lock, .door.locked:focus-visible .lock { opacity: 1; }
.door.locked .leaf-face { filter: saturate(.75) brightness(.86); }
.door.locked::after {
  content: ""; position: absolute; inset: 0; border-radius: 14px; pointer-events: none;
  background: linear-gradient(180deg, rgba(220,235,255,.22), rgba(220,235,255,0) 30%);
  box-shadow: inset 0 3px 0 rgba(255,255,255,.35);
}

/* Muster */
.p0 .leaf-face { background: repeating-linear-gradient(45deg, #b3122a 0 16px, #c81d36 16px 32px); }
.p1 .leaf-face { background: radial-gradient(rgba(255,255,255,.35) 2px, transparent 2.5px) 0 0/18px 18px, linear-gradient(160deg, #1f7a52, #135238); }
.p2 .leaf-face { background: radial-gradient(rgba(255,230,160,.8) 1px, transparent 1.6px) 0 0/22px 22px, radial-gradient(rgba(255,255,255,.4) 1px, transparent 1.4px) 11px 11px/22px 22px, linear-gradient(160deg, #1d2f6b, #0f1a45); }
.p3 .leaf-face { background:
  repeating-linear-gradient(0deg, rgba(20,80,50,.55) 0 8px, transparent 8px 24px),
  repeating-linear-gradient(90deg, rgba(20,80,50,.55) 0 8px, transparent 8px 24px),
  repeating-linear-gradient(0deg, rgba(255,255,255,.12) 0 1px, transparent 1px 6px),
  #a4142c; }
.p4 .leaf-face { background: repeating-linear-gradient(90deg, rgba(180,30,40,.55) 0 3px, transparent 3px 14px), linear-gradient(160deg, #f6e7c4, #dcc08a); }
.p4 .num { background: linear-gradient(180deg, #e0394f, #8e0f22); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 1px 0 rgba(255,255,255,.6)); }
.p5 .leaf-face { background: radial-gradient(circle at 30% 20%, rgba(255,255,255,.15), transparent 40%), conic-gradient(from 0deg at 50% 50%, #0f5560, #127080, #0f5560, #0c4450, #0f5560); }
/* Schleife (Geschenk-Optik) */
.ribbon .leaf-face::before {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(90deg, transparent calc(50% - 7px), rgba(243,201,105,.95) calc(50% - 7px), #ffe7a8 50%, rgba(200,150,50,.95) calc(50% + 7px), transparent calc(50% + 7px)),
              linear-gradient(0deg, transparent calc(50% - 7px), rgba(243,201,105,.95) calc(50% - 7px), #ffe7a8 50%, rgba(200,150,50,.95) calc(50% + 7px), transparent calc(50% + 7px));
  opacity: .85;
}
.ribbon .num { background: linear-gradient(180deg, #fff, #f1f1f1 60%, #c9c9c9); -webkit-background-clip: text; background-clip: text; filter: drop-shadow(0 2px 3px rgba(0,0,0,.6)); }

/* Zustände */
.door.available .door-leaf { animation: breathe 3.2s ease-in-out infinite; }
@keyframes breathe { 0%,100% { transform: rotateY(0); } 50% { transform: rotateY(-4deg); } }
.door.available:hover .door-leaf { animation: none; transform: rotateY(-16deg); }
.door.available .door-inside { box-shadow: inset 0 0 30px rgba(0,0,0,.7), 0 0 0 0 rgba(243,201,105,0); }
.door.today { z-index: 2; }
.door.today::before {
  content: ""; position: absolute; inset: -6px; border-radius: 20px; pointer-events: none;
  box-shadow: 0 0 0 2px var(--gold), 0 0 30px 6px rgba(243,201,105,.55);
  animation: halo 2s ease-in-out infinite;
}
@keyframes halo { 0%,100% { opacity: .55; } 50% { opacity: 1; } }
.today-badge { position: absolute; z-index: 3; top: -10px; left: 50%; transform: translateX(-50%); padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #3a2603; background: linear-gradient(180deg, var(--gold-2), var(--gold)); box-shadow: 0 4px 12px rgba(0,0,0,.4); pointer-events: none; }

.door.opened .door-leaf { transform: rotateY(-78deg); animation: none; }
.door.opened .in-icon { transform: none; opacity: 1; }
.door.opened .in-title { opacity: 1; }
.door.opening .door-leaf { transform: rotateY(-105deg); animation: none; transition-duration: .9s; }
.door.opening .door-inside::after { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(255,245,200,.9), transparent 60%); animation: flash .9s ease-out forwards; }
@keyframes flash { from { opacity: 0; } 40% { opacity: 1; } to { opacity: 0; } }

.door.shake { animation: shake .5s ease; opacity: 1; transform: none; }
@keyframes shake { 0%,100% { transform: translateX(0); } 20% { transform: translateX(-6px) rotate(-1deg); } 40% { transform: translateX(6px) rotate(1deg); } 60% { transform: translateX(-4px); } 80% { transform: translateX(4px); } }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; z-index: 500; display: grid; place-items: center; padding: 16px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(3,6,18,.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade .35s ease; }
@keyframes fade { from { opacity: 0; } }
.modal-card {
  position: relative; width: min(980px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px);
  display: flex; flex-direction: column;
  border-radius: 22px; overflow: hidden;
  background: radial-gradient(800px 400px at 50% -10%, rgba(80,110,200,.35), transparent 70%), linear-gradient(180deg, #121f47, #0b1530);
  box-shadow: 0 30px 80px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,255,255,.1);
  transform-origin: var(--ox, 50%) var(--oy, 50%);
  animation: pop .55s cubic-bezier(.2,1,.3,1);
}
@keyframes pop { from { transform: scale(.2); opacity: 0; } to { transform: none; opacity: 1; } }
.modal.closing .modal-card { animation: popOut .3s ease forwards; }
.modal.closing .modal-backdrop { animation: fade .3s ease reverse forwards; }
@keyframes popOut { to { transform: scale(.85); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-bottom: 1px solid var(--line); background: rgba(0,0,0,.15); }
.m-day { flex: 0 0 auto; width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; font: 700 28px/1 var(--font-display); color: #3a2603; background: linear-gradient(180deg, var(--gold-2), var(--gold) 55%, var(--gold-deep)); box-shadow: 0 6px 16px rgba(0,0,0,.35); }
.m-titles { flex: 1; min-width: 0; }
.m-titles h2 { margin: 0; font: 600 clamp(20px, 3vw, 28px)/1.15 var(--font-display); color: var(--snow); }
.m-titles p { margin: 2px 0 0; color: var(--muted); font-size: 14px; }
.m-nav { display: flex; gap: 6px; }
.modal-body { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; padding: 16px; overscroll-behavior: contain; }
.door-stage { position: relative; min-height: 60vh; }
.door-error { text-align: center; padding: 40px 10px; color: var(--muted); }

/* Belohnung */
.reward {
  position: relative; margin: 18px auto 4px; max-width: 640px; padding: 22px 22px 20px; text-align: center;
  border-radius: 18px; color: #3a2603;
  background: radial-gradient(circle at 50% 0%, #fffaf0, #fbe5ad 60%, #e9c06a);
  box-shadow: 0 16px 40px rgba(0,0,0,.45), inset 0 0 0 2px rgba(255,255,255,.6), inset 0 0 0 6px rgba(184,134,43,.35);
  animation: rewardIn .8s cubic-bezier(.2,1.4,.4,1);
}
@keyframes rewardIn { from { transform: translateY(20px) scale(.9); opacity: 0; } }
.reward .r-star { font-size: 34px; line-height: 1; }
.reward h3 { margin: 6px 0 6px; font: 700 24px/1.2 var(--font-display); color: #8e0f22; }
.reward .r-msg { font-size: 16px; line-height: 1.55; }
.reward img { display: block; max-width: 100%; max-height: 50vh; margin: 14px auto 0; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,.3); }

/* Toast */
.toast { position: fixed; z-index: 900; left: 50%; bottom: 28px; transform: translate(-50%, 30px); opacity: 0; pointer-events: none; padding: 12px 18px; border-radius: 999px; background: rgba(15,25,60,.92); color: var(--ink); box-shadow: 0 10px 30px rgba(0,0,0,.5), inset 0 0 0 1px var(--line); font-size: 14px; transition: .35s cubic-bezier(.2,1.2,.4,1); max-width: calc(100vw - 32px); text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.foot { position: relative; z-index: 2; text-align: center; color: var(--muted); font-size: 13px; padding: 0 16px 28vh; }

/* ---------- Responsive ---------- */
@media (max-width: 860px) {
  .grid { grid-template-columns: repeat(4, 1fr); grid-auto-rows: 120px; gap: 12px; }
}
@media (max-width: 560px) {
  .hero { padding-top: 80px; }
  .grid { grid-template-columns: repeat(3, 1fr); grid-auto-rows: 104px; gap: 10px; }
  .cd-box { min-width: 56px; }
  .cd-box b { font-size: 22px; }
  .modal { padding: 0; }
  .modal-card { width: 100%; max-height: 100vh; max-height: 100dvh; height: 100%; border-radius: 0; }
  .modal-head { padding: 10px 12px; gap: 10px; }
  .m-day { width: 42px; height: 42px; font-size: 22px; border-radius: 12px; }
  .m-titles p { display: none; }
  .modal-body { padding: 12px; }
  .icon-btn { width: 36px; height: 36px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
