:root {
  --night: #1b1430;
  --shade: #2a2047;
  --dusk: #44356a;
  --mist: #9d90c4;
  --pumpkin: #ff8a1f;
  --ember: #ffc46b;
  --poison: #a4e635;
  --bone: #f4ecdb;
  --parchment: #ecd9a8;
  --ink: #2e1f10;
  --stone: #9a92b3;
  --display: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Noto Serif", serif;
  --body: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  --bar: 56px;
  --navh: 72px;
  --top: calc(var(--bar) + env(safe-area-inset-top));
  --bottom: calc(var(--navh) + env(safe-area-inset-bottom));
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(130% 50% at 80% -10%, #30245a 0%, transparent 70%) no-repeat, var(--night);
  color: var(--bone);
  font: 17px/1.55 var(--body);
  overflow-wrap: break-word;
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.defs { position: absolute; width: 0; height: 0; }
h1, h2, h3 { font-family: var(--display); font-weight: 700; line-height: 1.15; margin: 0 0 .4em; }
h2 { font-size: 2.1rem; text-shadow: 0 0 22px rgba(255, 138, 31, .35); }
h3 { font-size: 1.35rem; margin-top: 1.4em; }
h2:focus { outline: none; }
p { margin: 0 0 1em; }
a { color: var(--ember); }
.lead { font-family: var(--display); font-size: 1.6rem; line-height: 1.25; color: var(--ember); margin-bottom: .4em; overflow-wrap: anywhere; }
.intro { color: #d9cfe6; }
.small { font-size: .9rem; color: var(--mist); }
.note { border-left: 3px solid var(--pumpkin); padding: .2em 0 .2em .8em; color: #e4dbef; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: .4em;
  min-height: 48px; padding: 12px 18px;
  font: 600 1rem/1.2 var(--body); color: var(--bone); text-decoration: none; text-align: center;
  background: transparent; border: 2px solid var(--dusk); border-radius: 14px;
  cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.primary { background: var(--pumpkin); border-color: var(--pumpkin); color: #241005; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 3px solid var(--poison); outline-offset: 3px; }
input {
  width: 100%; min-width: 0; min-height: 50px; padding: 12px 14px;
  font: 1rem var(--body); color: var(--bone);
  background: #120d22; border: 2px solid var(--dusk); border-radius: 12px;
}
input:focus { border-color: var(--pumpkin); outline: none; }
.row { display: flex; gap: 8px; }
.row > button { flex: none; }

/* Kopfzeile und Navigation liegen über allem, auch über der Dunkelheit des Dachbodens */
.bar {
  position: fixed; inset: 0 0 auto; z-index: 30;
  height: var(--top); padding: env(safe-area-inset-top) 12px 0;
  display: flex; align-items: center; gap: 10px;
  background: linear-gradient(var(--night) 75%, rgba(27, 20, 48, 0));
}
.bar svg { width: 22px; height: 22px; fill: currentColor; }
.plan-btn { min-height: 42px; padding: 8px 12px; font-size: .95rem; }
.dots { display: flex; gap: 6px; margin: 0 0 0 auto; padding: 0; list-style: none; }
.dots li { width: 10px; height: 10px; border-radius: 50%; border: 2px solid var(--dusk); }
.dots .done { background: var(--dusk); }
.dots .now { background: var(--pumpkin); border-color: var(--pumpkin); }
body[data-mode="door"] .bar, body[data-mode="door"] .nav { display: none; }

main { padding: var(--top) 0 var(--bottom); }
body[data-mode="door"] main { padding: env(safe-area-inset-top) 0 24px; }
.room { max-width: 34rem; margin: 0 auto; padding: 0 16px 28px; }
.scene { display: block; width: calc(100% + 32px); height: auto; margin: 0 -16px 18px; }

.nav {
  position: fixed; inset: auto 0 0; z-index: 30;
  display: flex; gap: 10px; padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: linear-gradient(rgba(27, 20, 48, 0), var(--night) 35%);
}
.nav button { flex: 1; min-height: 52px; padding: 10px 8px; }

/* Eingangstür */
.room-door { text-align: center; }
.knock { display: block; width: calc(100% + 32px); margin: 0 -16px; padding: 0; border: 0; border-radius: 0; }
.door-art { display: block; width: 100%; height: auto; max-height: 62vh; max-height: 62dvh; }
.title { font: 700 42px var(--display); fill: var(--pumpkin); letter-spacing: .5px; }
.title-small { font-size: 23px; fill: var(--ember); letter-spacing: 0; }
.door-panel { padding-top: 6px; }
.door-text { font: 700 1.9rem/1.2 var(--display); color: var(--ember); margin-bottom: .3em; min-height: 1.2em; }
.door-sub { color: #d9cfe6; max-width: 26rem; margin: 0 auto 1em; }
.knocks { display: flex; justify-content: center; gap: 10px; margin-bottom: 10px; }
.knocks i { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--pumpkin); }
#door[data-knocks="1"] .knocks i:nth-child(-n+1),
#door[data-knocks="2"] .knocks i:nth-child(-n+2),
#door[data-knocks="3"] .knocks i { background: var(--pumpkin); }
#door.locked .knocks, #door.open .knocks, #door.locked .knocker, .chains { display: none; }
#door.locked .chains { display: inline; }
#leaf { transform-box: fill-box; transform-origin: left center; transition: transform 1.1s cubic-bezier(.3, .1, .3, 1), filter 1.1s; }
#door.open #leaf { transform: scaleX(.14) skewY(-10deg); filter: brightness(.55); }
.spill { opacity: 0; transition: opacity 1s .4s; }
#door.open .spill { opacity: .45; }
.thud #leaf, .thud .chains { animation: thud .25s; }
@keyframes thud { 30% { translate: -3px 0; } 65% { translate: 3px 0; } }
.who { display: grid; gap: 12px; max-width: 22rem; margin: 0 auto; }
.bubble {
  justify-self: center; position: relative; padding: 10px 18px; margin-bottom: 6px;
  font: italic 700 1.5rem var(--display); color: var(--night); background: var(--bone); border-radius: 18px;
}
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -10px; border: 10px solid transparent; border-bottom: 0; border-top-color: var(--bone); translate: -50% 0; }
.who input { text-align: center; font-size: 1.15rem; }

/* gemeinsame kleine Animationen */
.flicker { animation: flicker 3.2s infinite; }
.f2 { animation-duration: 4.3s; animation-delay: -1.2s; }
.f3 { animation-duration: 2.6s; animation-delay: -.6s; }
@keyframes flicker { 0%, 100% { opacity: 1; } 38% { opacity: .78; } 42% { opacity: .95; } 68% { opacity: .62; } 72% { opacity: 1; } }
.flame { transform-box: fill-box; transform-origin: 50% 100%; animation: flame 1.3s ease-in-out infinite alternate; }
.flame.f2 { animation-duration: 1.7s; }
@keyframes flame { from { transform: scale(1, 1) skewX(0); } to { transform: scale(.9, 1.12) skewX(4deg); } }
.bat { animation: bat 6s ease-in-out infinite; }
@keyframes bat { 50% { translate: -60px 22px; } }
.pendulum { transform-origin: 200px 110px; animation: swing 1.6s ease-in-out infinite alternate; }
@keyframes swing { from { rotate: 9deg; } to { rotate: -9deg; } }
.blink { transform-box: fill-box; transform-origin: center; animation: blink 5s infinite; }
@keyframes blink { 0%, 92%, 100% { scale: 1 1; } 96% { scale: 1 .1; } }

/* Flur */
.countdown { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 1.2em; }
.countdown div {
  display: grid; justify-items: center; padding: 12px 2px 10px;
  background: linear-gradient(#3a2614, #2a1b0d); border: 2px solid #8a6a2f; border-radius: 10px;
}
.countdown b { font: 700 2rem/1 var(--display); color: var(--ember); font-variant-numeric: tabular-nums; }
.countdown span { font-size: .75rem; color: #e2cfa0; margin-top: 6px; }
.started { font: 700 1.3rem/1.3 var(--display); color: var(--poison); }
.rename summary { cursor: pointer; color: var(--mist); text-decoration: underline; text-underline-offset: 3px; padding: 8px 0; }
.rename form { margin-top: 8px; }

/* Wohnzimmer */
.stamp {
  display: block; margin: .2em 0 1.2em; padding: 14px 16px;
  font: 700 1.55rem/1.15 var(--display); text-align: center; color: #241005;
  background: var(--pumpkin); border-radius: 6px; rotate: -1.5deg;
  box-shadow: 0 0 0 3px var(--night), 0 0 0 5px var(--pumpkin), 0 0 30px rgba(255, 138, 31, .35);
}
.facts { margin: 0 0 1.2em; }
.facts > div { padding: 12px 0; border-top: 1px solid var(--shade); }
.facts dt { font-size: .9rem; color: var(--mist); }
.facts dd { margin: 2px 0 0; }
.facts strong { font-size: 1.15rem; }
.maps { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.maps .button { flex: 1 1 9rem; }
.drinks-bar { margin: 0 0 1.4em; padding: 16px 12px 12px; background: linear-gradient(#251b42, #1d1534); border: 2px solid #3a2614; border-radius: 14px; }
.drinks-bar h3 { margin: 0 0 4px; text-align: center; }
.bar-intro { margin: 0 0 6px; text-align: center; color: #e4dbef; }
/* ein Regalbrett pro Kategorie, die Getränke als Flaschenetiketten darauf */
.shelf { margin: 0 0 14px; padding: 0; list-style: none; }
.shelf > li {
  display: grid; grid-template-columns: 40px 1fr; column-gap: 12px; align-items: end;
  padding: 14px 2px 10px; border-bottom: 6px solid #3a2614;
}
.shelf svg { grid-row: 1 / 3; width: 40px; height: 56px; }
.shelf h4 { margin: 0 0 6px; font: 700 1.15rem/1.2 var(--display); }
.shelf .c0 { color: var(--pumpkin); }
.shelf .c1 { color: var(--poison); }
.shelf .c2 { color: var(--ember); }
.shelf .c3 { color: var(--mist); }
.tags { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; margin: 0; padding: 0; list-style: none; }
.tags li { padding: 3px 9px; font-size: .85rem; line-height: 1.35; color: var(--ink); background: var(--parchment); border-radius: 5px 5px 2px 2px; overflow-wrap: anywhere; }
.bar-note { margin: 0; padding: 10px 12px; font-weight: 600; text-align: center; color: var(--ember); border: 2px dashed var(--ember); border-radius: 10px; }
.bring { margin: 0 0 1em; padding: 16px; background: rgba(164, 230, 53, .07); border: 2px dashed var(--poison); border-radius: 14px; }
.bring-text { font: 700 1.35rem/1.25 var(--display); color: var(--poison); margin-bottom: .5em; }
.bring button { width: 100%; border-color: var(--poison); }

/* Küche */
.add-item label { display: block; font: 700 1.25rem var(--display); margin-bottom: 8px; }
.items { margin: 0 0 1.2em; padding: 0; list-style: none; }
.items li { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--shade); }
.items .what { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.items .who-name { display: block; font-size: .85rem; color: var(--mist); }
.items .mine .who-name { color: var(--ember); }
.items li button { min-height: 40px; padding: 6px 10px; font-size: .85rem; }
.items form { flex: 1; min-width: 0; }
.brew { transition: fill .3s; }
.splash .brew { fill: #e3ff9c; }
.bubbles circle { transform-box: fill-box; animation: bubble 2.2s ease-in infinite; }
.bubbles circle:nth-child(2) { animation-delay: -.7s; }
.bubbles circle:nth-child(3) { animation-delay: -1.4s; }
.bubbles circle:nth-child(4) { animation-delay: -1.9s; }
.splash .bubbles circle { animation-duration: .5s; }
@keyframes bubble { from { translate: 0 0; opacity: 1; } to { translate: 0 -34px; opacity: 0; } }
.flying {
  position: fixed; z-index: 40; max-width: 60vw; padding: 6px 12px; pointer-events: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  background: var(--poison); color: var(--night); font-weight: 700; border-radius: 999px;
}

/* Dachboden: der einzige dunkle Raum */
.room-attic { max-width: none; padding: 0; }
.attic-stage {
  position: relative; z-index: 0; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  height: calc(100vh - var(--top) - var(--bottom));
  height: calc(100dvh - var(--top) - var(--bottom));
  --x: 50%; --y: 45%;
}
.attic-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.darkness {
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(circle at var(--x) var(--y), transparent 0, transparent 64px, rgba(7, 4, 16, .8) 112px, rgba(7, 4, 16, .97) 150px);
}
.attic-text { position: absolute; inset: 0 0 auto; z-index: 3; padding: 12px 16px; pointer-events: none; text-align: center; }
.attic-text p { max-width: 24rem; margin: 0 auto; color: #d9cfe6; }
.gramophone {
  position: absolute; z-index: 1; left: 54%; bottom: 11%; width: 100px;
  display: grid; justify-items: center; color: var(--ember); text-decoration: none; font-size: .8rem; font-weight: 700; text-align: center;
}
.gramophone svg { width: 92px; height: 101px; }
.gramophone span { margin-top: -4px; }
.gramophone:focus-visible, .gramophone.glow { z-index: 4; }
.gramophone.glow svg { animation: glow 1.2s ease-in-out 2; }
@keyframes glow { 50% { filter: drop-shadow(0 0 18px var(--ember)) drop-shadow(0 0 6px var(--pumpkin)); } }
.spider { animation: spider 4s ease-in-out infinite alternate; }
@keyframes spider { to { translate: 0 30px; } }

/* Keller */
.parchment {
  position: relative; padding: 20px 18px 18px; color: var(--ink);
  background: radial-gradient(120% 90% at 50% 40%, #f3e4bb 40%, #d8bf85 100%);
  border-radius: 4px 10px 6px 12px; box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}
.parchment h3 { margin-top: 0; font-size: 1.6rem; text-align: center; }
.pact-text { font: italic 1.15rem/1.6 var(--display); }
.sigpad { display: block; width: 100%; height: auto; background: rgba(255, 255, 255, .25); border-radius: 8px; touch-action: none; cursor: crosshair; }
.sig { fill: none; stroke: #4a1a10; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.parchment .small { color: #6b5532; margin: 6px 0 12px; }
.parchment .row button { flex: 1; }
.ink-ghost { color: var(--ink); border-color: #b49660; }
.pact-done { text-align: center; }
.wax { width: 84px; height: 84px; animation: stamp .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes stamp { from { scale: 2.2; opacity: 0; } }
.fate { font: 700 1.5rem var(--display); margin: 6px 0 14px; }
.pact-done .button { width: 100%; }

/* Garten */
.graveyard { position: relative; overflow: hidden; margin: 0 -16px 1.2em; padding: 6px 16px 0; }
.graves { display: flex; flex-wrap: wrap; justify-content: center; gap: 16px 10px; margin: 0; padding: 0; list-style: none; }
.plot { width: calc((100% - 20px) / 3); overflow: hidden; padding-top: 10px; border-bottom: 8px solid #0e0919; }
.stone {
  display: grid; align-content: start; justify-items: center; gap: 2px; min-height: 132px; padding: 18px 6px 8px;
  background: linear-gradient(#a59dbd, #7e7698); color: var(--night); text-align: center;
  border-radius: 50% 50% 6px 6px / 34% 34% 6px 6px;
}
.stone small { font-size: .7rem; letter-spacing: .5px; }
.stone strong { font: 700 .95rem/1.2 var(--display); overflow-wrap: anywhere; }
.stone svg { width: 100%; height: auto; }
.stone path { fill: none; stroke: var(--night); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.mine .stone { box-shadow: inset 0 0 0 3px var(--pumpkin); }
.mine .stone { animation: rise 1.6s cubic-bezier(.2, .7, .2, 1) both; }
@keyframes rise { from { translate: 0 105%; rotate: -5deg; } 70% { translate: 0 -4%; rotate: 2deg; } to { translate: 0 0; rotate: 0deg; } }
.fog {
  position: absolute; left: -50%; bottom: 0; width: 200%; height: 70px; pointer-events: none;
  background: radial-gradient(40% 60% at 25% 100%, rgba(244, 236, 219, .22), transparent), radial-gradient(40% 60% at 75% 100%, rgba(244, 236, 219, .18), transparent);
  animation: fog 14s ease-in-out infinite alternate;
}
@keyframes fog { to { translate: 25% 0; } }
.farewell { font: 700 1.4rem/1.3 var(--display); color: var(--ember); }
#garden-plan { width: 100%; }

/* Hausplan */
dialog { width: min(92vw, 26rem); padding: 20px; color: var(--bone); background: var(--shade); border: 0; border-radius: 20px; }
dialog::backdrop { background: rgba(7, 4, 16, .78); }
.house { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 14px; }
.house button { min-height: 64px; padding: 8px 4px; font-size: .9rem; border-radius: 6px; background: var(--dusk); border-color: var(--dusk); hyphens: manual; }
.house .roof { grid-column: 1 / -1; min-height: 100px; padding-top: 44px; clip-path: polygon(50% 0, 100% 100%, 0 100%); border-radius: 0; }
.house .cellar { grid-column: 1 / -1; background: #241a3d; }
.house .garden { grid-column: 1 / -1; background: #26401a; border-color: #26401a; }
.house [aria-current="page"] { background: var(--pumpkin); border-color: var(--pumpkin); color: #241005; }
.plan-close { width: 100%; }

.toast {
  position: fixed; left: 16px; right: 16px; bottom: calc(var(--bottom) + 10px); z-index: 45; margin: 0 auto; max-width: 30rem;
  padding: 12px 16px; background: var(--bone); color: var(--night); border-radius: 12px; font-weight: 600; text-align: center;
}
.fade { position: fixed; inset: 0; z-index: 50; background: #05030b; opacity: 0; pointer-events: none; transition: opacity .25s; }
.fade.on { opacity: 1; }

/* Admin */
.admin main { padding-top: 24px; }

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