:root { color-scheme: dark; font-family: Georgia, "Songti SC", "SimSun", serif; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: #19212d; }
button, a { font: inherit; }
button { cursor: pointer; }
#viewport { width: 100%; height: 100dvh; display: grid; place-items: center; position: relative; overflow: hidden; }
#scene { position: absolute; left: 50%; top: 50%; width: 1440px; height: 810px; transform: translate(-50%, -50%) scale(var(--scene-scale, 1)); isolation: isolate; overflow: hidden; background: #202738; }
.layer-stack { position: absolute; inset: 0; pointer-events: none; }
#spring-wide { transform-origin: 78% 50%; }
#spring-middle { transform-origin: 70% 46%; }
#spring-approach { transform-origin: 62% 48%; }
#room { transform-origin: 68% 46%; }
#home-title { position: absolute; z-index: 1; left: 5.4%; top: 45%; margin: 0; color: #62472f; font-size: 64px; font-weight: normal; line-height: 1; letter-spacing: -.035em; text-shadow: 0 1px 0 #fff4d8; animation: title-arrival 650ms ease-out both; }
@keyframes title-arrival { from { opacity: 0; translate: 0 10px; } to { opacity: var(--title-opacity, 1); translate: 0 0; } }
#light-wash { background: radial-gradient(ellipse at 57% 48%, #fff8dd 1%, #ffdf9bbf 30%, transparent 74%); mix-blend-mode: screen; opacity: 0; }
.picture { position: absolute; margin: 0; border: 0; padding: 0; background: transparent; transform: rotate(var(--rotation, 0deg)); }
.picture img { display: block; width: 100%; height: 100%; user-select: none; pointer-events: none; }
.picture.flipped img { transform: scaleX(-1); }
.envelope { pointer-events: auto; }
.envelope .envelope-art { display: block; width: 100%; height: 100%; }
.envelope-art.is-raised { filter: drop-shadow(0 7px 5px #6e43184a); }
.envelope:focus-visible { outline: 2px dashed #65452e; outline-offset: 3px; }
.letter-title { position: absolute; display: grid; place-items: center; color: #f7e5ce; font-size: var(--letter-font-size, 64px); line-height: 1; text-shadow: 0 2px 15px #151b24; }
#home-title.letter-title {
  font: italic 400 var(--letter-font-size, 64px)/1.12 "Palatino Linotype", "Book Antiqua", Palatino, Georgia, serif;
  letter-spacing: -.055em;
  color: #68432e;
  text-shadow: 0 1px #fff3db, 0 2px 10px #fff4dbb0;
}
#home-title .opening-glyph { pointer-events: auto; touch-action: manipulation; }
#home-title .opening-glyph img { pointer-events: none; }
.opening-words, .opening-word { display: flex; align-items: center; }
.opening-words { gap: .24em; }
.opening-glyph { position: relative; display: grid; place-items: center; padding-inline: 0; transition: padding 280ms cubic-bezier(.22,1,.36,1); }
.opening-glyph.active { padding-inline: .075em; }
.opening-glyph.active .opening-character { opacity: 0; }
.opening-glyph img { position: absolute; width: auto; height: 1.52em; max-width: none; }
.opening-light img { transition: scale 420ms cubic-bezier(.22,1,.36,1), filter 420ms ease; }
.opening-light::after {
  content: "";
  position: absolute;
  inset: 30%;
  border: 1px solid #ffdc9cd0;
  border-radius: 50%;
  opacity: 0;
}
.opening-light.is-lit img, #viewport:has(#enter:focus-visible) .opening-light img {
  scale: 1.2;
  filter: brightness(1.3) drop-shadow(0 0 16px #ffcc8080);
}
.opening-light.is-lit::after, #viewport:has(#enter:focus-visible) .opening-light::after {
  animation: invitation 1.45s ease-out infinite;
}
#enter { position: absolute; inset: 0; width: 100%; border: 0; background: transparent; color: #f7e5ce; touch-action: manipulation; }
#enter span { position: absolute; top: calc(50% + 40px); left: 50%; transform: translateX(-50%); font-size: 17px; letter-spacing: .12em; white-space: nowrap; text-shadow: 0 2px 12px #151b24; }
#enter span.visually-hidden { width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@keyframes invitation { 0% { transform: scale(.85); opacity: .85; } 85%, 100% { transform: scale(2.3); opacity: 0; } }
.controls { position: absolute; right: max(14px, env(safe-area-inset-right)); bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 8px; }
.controls button, .controls a { color: #f7ede1; background: #28231dcc; border: 1px solid #fff3; padding: 8px 13px; border-radius: 18px; text-decoration: none; font-size: 14px; }
.controls button:disabled { opacity: .5; cursor: default; }
#letter { width: min(660px, 90vw); min-height: min(450px, 77dvh); max-height: 86dvh; padding: 50px 42px; border: 0; border-radius: 8px; background: #f7edda var(--paper) center / cover; color: #57402e; box-shadow: 0 22px 75px #25170c65; }
#letter::backdrop { background: #30241e6e; opacity: var(--backdrop-opacity, 1); }
#letter.native-letter-motion[open]::backdrop { animation: letter-backdrop-in .42s ease-out both; }
#letter.native-letter-motion.is-closing::backdrop { animation: letter-backdrop-out .24s ease-in both; }
@keyframes letter-backdrop-in { from { opacity: 0; } }
@keyframes letter-backdrop-out { to { opacity: 0; } }
#letter form { position: absolute; right: 13px; top: 11px; }
#letter form button { background: #fff5e6df; border: 1px solid #7b5b3d38; border-radius: 50%; font-size: 22px; width: 32px; height: 32px; color: inherit; }
#letter h1 { font-size: clamp(24px, 4.5vw, 40px); margin: 12px 0; font-weight: normal; }
#letter-body { margin: 0; font-size: 1rem; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) {
  .opening-glyph, .opening-light img { transition: none; }
  .opening-light.is-lit img, #viewport:has(#enter:focus-visible) .opening-light img { scale: 1; }
  .opening-light::after, #home-title { animation: none !important; }
}
