:root {
  color-scheme: dark;
  color: #f7e6c9;
  background: #142325;
  font: 16px/1.5 "Segoe UI", "Microsoft YaHei UI", "PingFang SC", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body {
  margin: 0; overflow: hidden;
}
.porch {
  position: relative; isolation: isolate; height: 100vh; height: 100dvh; overflow: hidden;
  background: linear-gradient(#92b3bf 38%, #5f713e 65%);
  --light: 1; --color: 1.07; --wash: transparent; --weather-light: 1;
}
.landscape, .landscape picture, .landscape img, #outdoor-animation, .landscape::after { position: absolute; inset: 0; width: 100%; height: 100%; }
.landscape img { object-fit: cover; image-rendering: pixelated; filter: brightness(calc(var(--light) * var(--weather-light))) saturate(var(--color)); transition: filter 1.2s ease; }
.landscape::after { content: ""; pointer-events: none; background: var(--wash); transition: background 1.2s ease; }
.landscape::before { position: absolute; inset: 0; z-index: 2; content: ""; background: linear-gradient(180deg, #17262b31, transparent 20%, transparent 78%, #16252658); pointer-events: none; }
#outdoor-animation { z-index: 1; image-rendering: pixelated; pointer-events: none; }
.porch[data-period=dawn] { --light: .72; --color: .83; --wash: linear-gradient(#8c6b9f60, #f7a76c3e 47%, #36283c20); }
.porch[data-period=morning] { --light: .97; --wash: linear-gradient(#ffeabc27, #f4b57d28 48%, transparent); }
.porch[data-period=afternoon] { --light: .95; --color: 1.13; --wash: linear-gradient(#f6af5622, #eca94829 58%, transparent); }
.porch[data-period=dusk] { --light: .65; --color: .9; --wash: linear-gradient(#90597c68, #f48d5256 43%, #44345c48 77%); }
.porch[data-period=night] { --light: .46; --color: .61; --wash: linear-gradient(#142749b0, #28365a88 43%, #15233b75); }
.porch:is([data-weather=overcast], [data-weather=fog], [data-weather=rain], [data-weather=snow]) { --weather-light: .9; }
.porch:is([data-weather=storm], [data-weather=hail], [data-weather=dust]) { --weather-light: .78; }
h1, .local-weather { position: absolute; z-index: 3; margin: 0; left: max(1.2rem, env(safe-area-inset-left)); }
h1 {
  top: max(1.3rem, env(safe-area-inset-top)); color: #fff0cd;
  font-size: clamp(1.3rem, 3.5vw, 2.25rem); letter-spacing: .07em;
  text-shadow: 0 2px #282720, 2px 3px #282720ad, 0 0 12px #181d22d9; pointer-events: none;
}
.local-weather {
  bottom: max(1.15rem, env(safe-area-inset-bottom)); max-width: calc(100% - 2.4rem); padding: .4rem .65rem;
  border: 1px solid #ffe8bd55; background: #1d2927e9; box-shadow: 3px 3px #20232164; color: #fff0d1;
  font-size: .84rem; font-variant-numeric: tabular-nums;
}
.local-weather time { margin-inline-start: .55rem; font-weight: 700; }
.local-weather small, .local-weather a { display: block; color: #eedcc0; }
.local-weather a { color: #ffe3a0; font-size: .77rem; }
.local-weather .weather-source { display: inline-block; margin-inline-start: .6rem; font-size: .67rem; color: #dfcfb5; }
.local-weather [hidden] { display: none; }
#front-entry {
  position: absolute; z-index: 3; left: 50%; top: 63%; width: 54px; height: 88px;
  transform: translate(-50%, -50%); padding: 0; border: 0; border-radius: 0; background: transparent;
}
#front-entry:hover { outline: 2px dashed #ffe7a2; outline-offset: 3px; background: #fff4ce10; }
#front-entry span {
  position: absolute; top: 100%; left: 50%; transform: translate(-50%, .38rem); white-space: nowrap;
  padding: .12rem .46rem; color: #fff0cb; border: 1px solid #f4d488a3;
  background: #30271ff0; box-shadow: 2px 2px #20190ca0; font-size: .79rem;
}
.arrival {
  display: none; position: absolute; inset: 0; z-index: 4;
  place-content: center; justify-items: center; text-align: center;
  background: radial-gradient(ellipse at center, #151a1866, #101714ed);
  overflow: hidden;
}
body[data-opening=true] .arrival { display: grid; }
body[data-opening=true] #front-entry { display: none; }
.door-scene {
  position: relative; isolation: isolate; display: grid; place-items: center;
  width: min(100%, 29rem); padding-block: .5rem 1rem;
}
.door-scene::after {
  position: absolute; z-index: -1; inset: auto 4% .35rem; height: 13%;
  border: 1px solid #785c49; border-radius: 50%; background: #583c2d55; content: "";
}
.threshold {
  position: relative; width: min(15rem, 54vw, 33svh); aspect-ratio: 2 / 3;
  border: clamp(7px, 2.4vw, 12px) solid #372922; border-bottom-width: 6px;
  outline: 2px solid #a17552; perspective: 740px; perspective-origin: 50% 46%;
  background: #0d1517; box-shadow: 0 8px 30px #0d1516c4;
}
.inside-light { position: absolute; inset: 0; background: radial-gradient(ellipse at 55% 45%, #fff3b4, #e6a960 52%, #775035 88%); }
.door-leaf {
  position: absolute; inset: 0; transform-origin: left center; backface-visibility: hidden;
  border: 1px solid #3b2419; background: #825433 url("/wood-door.webp") center / 100% 100% no-repeat;
  image-rendering: pixelated; box-shadow: inset -7px 0 0 #21170e52;
}
.hand {
  display: none; position: absolute; z-index: 2; top: 52%; left: 61%; width: clamp(6rem, 32vw, 12rem);
  height: clamp(2.5rem, 12vw, 4.9rem); filter: drop-shadow(2px 3px #382319);
}
.palm, .sleeve { position: absolute; top: 0; bottom: 0; display: block; }
.palm {
  left: 0; width: 61%; background: linear-gradient(0deg,#b8724d 0 19%,#eab189 19% 67%,#f7cda1 67%);
  clip-path: polygon(3% 24%, 13% 24%, 13% 13%, 47% 13%, 47% 23%, 60% 23%, 60% 30%, 97% 30%, 97% 73%, 67% 73%, 67% 88%, 44% 88%, 44% 78%, 15% 78%, 15% 68%, 3% 68%);
}
.sleeve {
  left: 48%; right: 0; background: repeating-linear-gradient(0deg,#303f48 0 6px,#485f67 6px 12px);
  clip-path: polygon(0 29%,28% 29%,28% 20%,100% 13%,100% 92%,28% 82%,28% 72%,0 72%);
}
#key-dialog {
  width: min(25rem, calc(100% - 2rem)); padding: 1.1rem 1.2rem 1.2rem; color: #f7e6c9;
  border: 2px solid #c69d64; background: #251f19; box-shadow: 0 0 0 4px #3e3024, 7px 10px #130e0acc;
}
#key-dialog::backdrop { background: #111c1a95; }
#key-heading { margin: 0 0 .7rem; font-size: 1.2rem; }
#key-panel { display: grid; gap: .5rem; }
label { color: #f7e7c7; font-weight: 670; }
.key-actions { display: flex; gap: .5rem; justify-content: end; margin-top: .35rem; }
input, button, .opening-controls a { font: inherit; }
input[type=file] { min-width: 0; width: 100%; padding: .4rem; color: #f0dcbb; border: 1px solid #73654e; background: #2d332a; border-radius: 3px; }
input::file-selector-button { border: 0; padding: .3rem .45rem; margin-right: .4rem; background: #d8bc85; color: #2e261a; border-radius: 3px; font: inherit; cursor: pointer; }
button, .opening-controls a {
  display: inline-block; padding: .52rem .85rem; border: 1px solid #dec086; border-radius: 5px;
  background: #efce8e; color: #312618; font-weight: 740; text-decoration: none; cursor: pointer;
}
button:hover, .opening-controls a:hover { background: #ffe4a9; }
button.quiet { background: #42372b; color: #f7e7c7; border-color: #72604d; }
button.quiet:hover { background: #564736; }
button:disabled { opacity: .65; cursor: default; }
:focus-visible { outline: 3px solid #e8c17d; outline-offset: 3px; }
.error { margin: 0; max-width: 26rem; color: #ffd0b2; font-size: .88rem; }
.opening-controls { min-height: 5rem; }
.opening-controls p { margin: 0 0 .4rem; }
body[data-play=true] .hand { display: block; animation: push-hand 1.45s ease both; }
body[data-play=true] .door-leaf { animation: swing-door 1s .40s ease-in-out both; }
@keyframes push-hand {
  0% { transform: translate(100%,36%); opacity: 0; }
  33% { transform: translate(0,0); opacity: 1; }
  69% { transform: translate(-18%,-7%) scale(.75); opacity: 1; }
  100% { transform: translate(27%,60%) scale(.65); opacity: 0; }
}
@keyframes swing-door {
  0% { transform: rotateY(0); }
  100% { transform: rotateY(-89deg); }
}
@media (prefers-reduced-motion: reduce) {
  .landscape img, .landscape::after { transition: none; }
  body[data-opening=true] .hand { display: none; }
  body[data-opening=true] .door-leaf { animation: none; transform: rotateY(-89deg); }
}
