:root {
  --midnight: #060b1a;
  --night: #0b1631;
  --ice: #bcd6f5;
  --snow: #f5f9ff;
  --rose: #f3a7b9;
  --rose-deep: #e27b95;
  --red: #d6455c;
  --gold: #f6c36a;
  --gold-soft: #ffe3ad;
  --ink: #3a2a3c;
  --text: #eef4ff;
  --text-dim: rgba(226, 236, 255, 0.72);

  --vh: 1vh;
  --pw: clamp(92px, min(30vw, calc(var(--vh) * 21)), 190px);
  --ground: 10%;
  --moon-size: clamp(56px, 11vmin, 118px);
  --moon-final: clamp(84px, 17vmin, 180px);

  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Manrope", system-ui, -apple-system, "Segoe UI", sans-serif;
  --hand: "Caveat", "Segoe Script", cursive;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--midnight);
  color: var(--text);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

button { font: inherit; color: inherit; }
p { margin: 0; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.noscript {
  position: fixed;
  inset: auto 16px 40px;
  text-align: center;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.4rem;
}

/* ---------- Stage & sky ---------- */

.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(120% 70% at 76% 6%, rgba(58, 88, 152, 0.34), transparent 60%),
    radial-gradient(90% 55% at 18% 100%, rgba(38, 66, 126, 0.4), transparent 70%),
    linear-gradient(180deg, #050a18 0%, #091430 44%, #142757 76%, #1f3770 100%);
}

.no-anim, .no-anim * { transition: none !important; }

.camera {
  position: absolute;
  inset: 0;
  transform-origin: 50% 86%;
  transition: transform 2.8s var(--ease-in-out);
  will-change: transform;
}
.camera.zoom { transform: scale(1.38); }
.camera.wide { transform: translateY(6%); }

.sky-canvas, .snow-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
}

.moon {
  position: absolute;
  left: 76%;
  top: 10%;
  width: var(--moon-size);
  aspect-ratio: 1;
  border-radius: 50%;
  transform: translateX(-50%);
  background:
    radial-gradient(circle at 64% 62%, rgba(214, 196, 150, 0.45) 0 9%, transparent 10%),
    radial-gradient(circle at 34% 70%, rgba(214, 196, 150, 0.35) 0 6%, transparent 7%),
    radial-gradient(circle at 56% 28%, rgba(214, 196, 150, 0.3) 0 5%, transparent 6%),
    radial-gradient(circle at 36% 34%, #fffdf5 0%, #fbf1d8 48%, #ead9ad 100%);
  box-shadow:
    0 0 36px 8px rgba(255, 236, 190, 0.22),
    0 0 120px 48px rgba(255, 236, 190, 0.09);
  transition:
    opacity 2.6s var(--ease-out),
    left 3.2s var(--ease-in-out),
    top 3.2s var(--ease-in-out),
    width 3.2s var(--ease-in-out),
    box-shadow 3.2s var(--ease-in-out);
}

.stage[data-scene="final"] .moon {
  left: 50%;
  top: 2.5%;
  width: var(--moon-final);
  box-shadow:
    0 0 50px 14px rgba(255, 236, 190, 0.3),
    0 0 180px 80px rgba(255, 220, 190, 0.12);
}

.aurora {
  position: absolute;
  inset: 0 0 38% 0;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  transition: opacity 5s var(--ease-out);
}
.aurora span {
  position: absolute;
  left: -20%;
  width: 140%;
  height: 32%;
  border-radius: 50%;
  filter: blur(38px);
  opacity: 0.6;
  animation: aurora 17s ease-in-out infinite alternate;
}
.aurora span:nth-child(1) {
  top: 8%;
  rotate: -6deg;
  background: linear-gradient(90deg, transparent, rgba(110, 220, 205, 0.32), rgba(140, 170, 255, 0.24), transparent);
}
.aurora span:nth-child(2) {
  top: 22%;
  rotate: 4deg;
  animation-duration: 22s;
  background: linear-gradient(90deg, transparent, rgba(243, 167, 185, 0.3), rgba(255, 214, 170, 0.16), transparent);
}
.aurora span:nth-child(3) {
  top: 0;
  animation-duration: 27s;
  background: linear-gradient(90deg, transparent, rgba(160, 140, 255, 0.2), transparent);
}
.stage[data-scene="final"] .aurora { opacity: 1; }

@keyframes aurora {
  from { translate: -6% 0; }
  to { translate: 6% 5%; }
}

/* ---------- Parallax layers ---------- */

.layer {
  position: absolute;
  left: 0;
  bottom: 0;
  background-repeat: repeat-x;
  background-size: auto 100%;
  background-position: 0 100%;
  will-change: transform;
  transition: opacity 2.6s var(--ease-out);
}
.layer-far { bottom: 13%; height: 38%; opacity: 0.92; }
.layer-mid { bottom: 9%; height: 27%; }
.layer-near { height: 30%; }

.is-dark .layer,
.is-dark .moon { opacity: 0; }

/* ---------- Penguins ---------- */

.world {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.penguin {
  position: absolute;
  left: 0;
  bottom: var(--ground);
  width: var(--pw);
  opacity: 0;
  cursor: pointer;
  pointer-events: none;
  will-change: transform;
  transition: opacity 1.3s var(--ease-out);
  --blush: 0.28;
}
.penguin.her { width: calc(var(--pw) * 0.9); --blush: 0.5; }
.penguin.on { opacity: 1; pointer-events: auto; }
.penguin.shy, .penguin.r-shy { --blush: 1; }

.pg-motion { transform-origin: 50% 100%; transition: transform 0.8s var(--spring); }
.pg-waddle { transform-origin: 50% 100%; }
.pg-breathe { transform-origin: 50% 100%; animation: breathe 3.6s ease-in-out infinite; }
.her .pg-breathe { animation-duration: 4.4s; }

.pg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
  transition: transform 0.5s var(--ease-out);
}
.face-left .pg { transform: scaleX(-1); }

.pg-shadow { fill: rgba(16, 34, 72, 0.22); }

.pg .eyes {
  transform: translate(var(--lx, 0px), var(--ly, 0px));
  transition: transform 0.55s var(--ease-out);
}
.pg .eye {
  transform-box: fill-box;
  transform-origin: center;
  transition: transform 0.09s ease, opacity 0.25s ease;
}
.blink .pg .eye { transform: scaleY(0.08); }
.pg .eye-happy { opacity: 0; transition: opacity 0.25s ease; }
.happy .pg .eye, .r-happy .pg .eye { opacity: 0; }
.happy .pg .eye-happy, .r-happy .pg .eye-happy { opacity: 1; }
.pg .smile { opacity: 0; transition: opacity 0.3s ease; }
.happy .pg .smile, .r-happy .pg .smile { opacity: 0.75; }
.pg .blush { opacity: var(--blush); transition: opacity 0.7s ease; }

.pg .flip { transform-box: fill-box; transition: transform 0.6s var(--spring); }
.pg .flip-front { transform-origin: 20% 6%; }
.pg .flip-back { transform-origin: 80% 6%; }
.pg .foot { transform-box: fill-box; transform-origin: 50% 50%; }
.pg .tuft { transform-box: fill-box; transform-origin: 30% 100%; }
.pg .scarf-tail { transform-box: fill-box; transform-origin: 60% 0%; }

.enter .pg-motion { animation: enter 1.6s var(--ease-out); }

.walking .pg-waddle { animation: waddle 0.8s linear infinite; }
.walking .pg-breathe { animation: none; }
.walking .foot-l { animation: step 0.8s linear infinite; }
.walking .foot-r { animation: step 0.8s linear infinite -0.4s; }
.walking .tuft { animation: tuft 0.4s ease-in-out infinite alternate; }
.walking .scarf-tail { animation: flutter 0.8s ease-in-out infinite alternate; }

.hop .pg-motion { animation: hop 0.7s var(--ease-out); }
.stumble .pg-motion { animation: stumble 1.1s var(--ease-out); }
.stumble .flip-front { animation: flap-front 0.22s ease-in-out 4 alternate; }
.stumble .flip-back { animation: flap-back 0.22s ease-in-out 4 alternate; }
.wave .flip-front { animation: wave 0.42s ease-in-out 4 alternate; }
.hold .flip-front { transform: rotate(-58deg); }

.her.tilt .pg-motion { transform: rotate(5deg) translateX(3%); }
.him.lean .pg-motion { transform: rotate(5deg) translateY(2%); }
.her.lean .pg-motion { transform: rotate(-5deg) translateY(2%); }

@keyframes breathe {
  0%, 100% { transform: scale(1, 1); }
  50% { transform: scale(0.992, 1.014); }
}
@keyframes enter {
  from { transform: translateY(-12%) scale(0.9); }
  to { transform: none; }
}
@keyframes waddle {
  0% { transform: rotate(-6deg); }
  25% { transform: translateY(-5%) rotate(0deg); }
  50% { transform: rotate(6deg); }
  75% { transform: translateY(-5%) rotate(0deg); }
  100% { transform: rotate(-6deg); }
}
@keyframes step {
  0%, 50%, 100% { transform: translateY(0); }
  25% { transform: translateY(-7px) rotate(-10deg); }
}
@keyframes tuft {
  from { transform: rotate(-6deg); }
  to { transform: rotate(10deg); }
}
@keyframes flutter {
  from { transform: rotate(6deg); }
  to { transform: rotate(-12deg); }
}
@keyframes hop {
  0%, 100% { transform: translateY(0) scale(1); }
  15% { transform: translateY(0) scale(1.06, 0.92); }
  45% { transform: translateY(-20%) scale(0.96, 1.05); }
  75% { transform: translateY(0) scale(1.05, 0.94); }
}
@keyframes stumble {
  0% { transform: none; }
  16% { transform: rotate(16deg) translateY(2%); }
  34% { transform: rotate(-8deg); }
  52% { transform: rotate(4deg); }
  70% { transform: rotate(-2deg); }
  100% { transform: none; }
}
@keyframes flap-front { from { transform: rotate(0deg); } to { transform: rotate(-60deg); } }
@keyframes flap-back { from { transform: rotate(0deg); } to { transform: rotate(60deg); } }
@keyframes wave { from { transform: rotate(-20deg); } to { transform: rotate(-78deg); } }

/* ---------- Floating hearts ---------- */

.hearts { position: absolute; inset: 0; pointer-events: none; }
.heart-f {
  position: absolute;
  width: var(--s, 18px);
  height: var(--s, 18px);
  margin: calc(var(--s, 18px) / -2) 0 0 calc(var(--s, 18px) / -2);
  color: var(--c, var(--rose));
  filter: drop-shadow(0 0 6px rgba(243, 167, 185, 0.55));
  animation: heart-up var(--d, 2.8s) var(--ease-out) forwards;
}
.heart-f svg { display: block; width: 100%; height: 100%; }
@keyframes heart-up {
  0% { opacity: 0; transform: translate(0, 0) scale(0.3); }
  14% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), calc(var(--dy) * -1)) scale(1) rotate(var(--r)); }
}

/* ---------- Atmosphere overlays ---------- */

.warmth {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  background:
    radial-gradient(70% 45% at 50% 88%, rgba(255, 186, 120, 0.3), transparent 70%),
    radial-gradient(90% 60% at 50% 100%, rgba(243, 167, 185, 0.18), transparent 70%);
  transition: opacity 3.5s var(--ease-out);
}
.warm .warmth { opacity: 1; }

.grain {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.07;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 .6 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(2, 6, 18, 0.55) 100%);
}

/* ---------- UI ---------- */

.ui { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

.top {
  position: absolute;
  left: 50%;
  top: clamp(58px, calc(var(--vh) * 13), 150px);
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 42rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(16px, 2.6vh, 26px);
  text-align: center;
}

.story {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.6rem, 1.05rem + 2.3vw, 2.7rem);
  line-height: 1.22;
  color: var(--text);
  text-shadow: 0 2px 30px rgba(3, 8, 24, 0.6);
  min-height: 2.5em;
  text-wrap: balance;
  transition: opacity 0.7s var(--ease-out), filter 0.7s var(--ease-out);
}
.story:empty { display: none; }
.story.out { opacity: 0; filter: blur(6px); }
.story .line { display: block; }

.w {
  display: inline-block;
  opacity: 0;
  transform: translateY(0.32em);
  filter: blur(10px);
  animation: word-in 1.1s var(--ease-out) forwards;
  animation-delay: calc(var(--i) * 85ms);
}
@keyframes word-in { to { opacity: 1; transform: none; filter: blur(0); } }

.hint, .phrase, .dots { display: none; }
.stage[data-scene="things"] .hint,
.stage[data-scene="things"] .dots { display: flex; }

.hint {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
  opacity: 0;
  transition: opacity 1s var(--ease-out);
}
.hint.in { opacity: 1; }

.phrase {
  width: min(100%, 31rem);
  min-height: calc(2.6em + 32px);
  padding: 16px 22px;
  border-radius: 20px;
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(1.2rem, 1rem + 1.1vw, 1.65rem);
  line-height: 1.3;
  color: var(--text);
  background: rgba(11, 22, 50, 0.3);
  box-shadow: 0 0 0 1px rgba(214, 228, 255, 0.14) inset, 0 20px 50px -30px rgba(0, 0, 0, 0.8);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
  place-items: center;
  text-wrap: balance;
}
.stage[data-scene="things"] .phrase { display: grid; }
.phrase.in { opacity: 1; transform: none; }

.dots { gap: 9px; }
.dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  transition: background 0.4s, box-shadow 0.4s, transform 0.4s var(--spring);
}
.dots i.on { background: var(--rose); box-shadow: 0 0 10px var(--rose); transform: scale(1.25); }

.actions { display: flex; justify-content: center; gap: 12px; min-height: 54px; }

/* ---------- Buttons ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6em;
  border: 0;
  border-radius: 999px;
  padding: 15px 28px;
  cursor: pointer;
  pointer-events: auto;
  overflow: hidden;
  font-family: var(--sans);
  font-weight: 600;
  font-size: clamp(0.95rem, 0.9rem + 0.25vw, 1.05rem);
  letter-spacing: 0.02em;
  -webkit-user-select: none;
  user-select: none;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transition:
    opacity 0.9s var(--ease-out),
    transform 0.6s var(--ease-out),
    box-shadow 0.4s ease,
    background-color 0.4s ease;
}
.btn.in { opacity: 1; transform: translate(var(--mx, 0px), var(--my, 0px)); }
.btn:disabled { pointer-events: none; }
.btn:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 4px; }
.btn svg { width: 1.05em; height: 1.05em; flex: none; }

.btn-love {
  color: #3b1424;
  background: linear-gradient(180deg, #f9c1cd, #ec90a7);
  box-shadow:
    0 14px 36px -14px rgba(236, 144, 167, 0.95),
    0 0 0 1px rgba(255, 255, 255, 0.28) inset,
    0 1px 0 rgba(255, 255, 255, 0.6) inset;
}
.btn-love::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(110deg, transparent 30%, rgba(255, 255, 255, 0.6) 50%, transparent 70%);
  transform: translateX(-130%);
  transition: transform 1s var(--ease-out);
  pointer-events: none;
}
.btn-love .beat { color: var(--red); animation: beat 1.8s ease-in-out infinite; }

.btn-ghost {
  color: var(--text);
  background: rgba(10, 20, 46, 0.4);
  box-shadow: 0 0 0 1px rgba(214, 228, 255, 0.3) inset, 0 12px 30px -16px rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.btn-ink {
  color: var(--ink);
  background: rgba(58, 42, 60, 0.05);
  box-shadow: 0 0 0 1px rgba(58, 42, 60, 0.22) inset;
}

.btn .arr { transition: transform 0.35s var(--spring); }
.btn .spin { transition: transform 0.6s var(--ease-out); }

@keyframes beat {
  0%, 100% { transform: scale(1); }
  12% { transform: scale(1.2); }
  24% { transform: scale(1); }
  36% { transform: scale(1.12); }
  48% { transform: scale(1); }
}

/* ---------- Little things ---------- */

.things { position: absolute; inset: 0; pointer-events: none; }

.thing {
  --ts: 62px;
  position: absolute;
  left: 0;
  top: 0;
  width: var(--ts);
  height: var(--ts);
  margin: calc(var(--ts) / -2) 0 0 calc(var(--ts) / -2);
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 34% 28%, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.05) 62%),
    rgba(16, 30, 64, 0.38);
  box-shadow:
    0 0 0 1px rgba(220, 234, 255, 0.24) inset,
    0 0 26px -4px var(--glow),
    0 10px 24px -12px rgba(0, 0, 0, 0.7);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  opacity: 0;
  transform: scale(0.3);
  transition:
    opacity 0.7s var(--ease-out) var(--appear, 0ms),
    transform 0.8s var(--spring) var(--appear, 0ms),
    box-shadow 0.4s ease;
}
.thing.in { opacity: 1; transform: scale(1); }
.thing.in:focus-visible { transform: scale(1.12); transition-delay: 0ms; }
.thing:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 5px; }
.thing.active {
  box-shadow:
    0 0 0 1.5px rgba(255, 255, 255, 0.6) inset,
    0 0 44px 2px var(--glow),
    0 10px 24px -12px rgba(0, 0, 0, 0.7);
}
.thing.seen::after {
  content: "";
  position: absolute;
  right: 6px;
  top: 6px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--rose);
  box-shadow: 0 0 8px var(--rose);
}
.thing-in {
  display: grid;
  place-items: center;
  animation: float 4.2s ease-in-out infinite;
  animation-delay: var(--fd, 0s);
}
.thing svg { width: 31px; height: 31px; overflow: visible; }
.thing .steam { animation: steam 2.4s ease-in-out infinite; }
.thing .steam:nth-of-type(2) { animation-delay: -1.2s; }

@keyframes float {
  0%, 100% { transform: translateY(-4px) rotate(-3deg); }
  50% { transform: translateY(5px) rotate(3deg); }
}
@keyframes steam {
  0% { opacity: 0; transform: translateY(3px); }
  40% { opacity: 0.9; }
  100% { opacity: 0; transform: translateY(-5px); }
}

/* ---------- Letter ---------- */

.letter-wrap { position: absolute; inset: 0; pointer-events: none; }
.letter-wrap::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 45%, rgba(4, 9, 24, 0.12), rgba(4, 9, 24, 0.62));
  opacity: 0;
  transition: opacity 1.8s var(--ease-out);
}
.letter-wrap.dim::before { opacity: 1; }

.envelope {
  --ew: min(74vw, 300px);
  position: absolute;
  left: 50%;
  top: 40%;
  width: var(--ew);
  height: calc(var(--ew) / 1.5);
  transform: translate(-50%, -50%);
  perspective: 1000px;
  opacity: 0;
  filter: drop-shadow(0 24px 30px rgba(0, 0, 0, 0.45));
}
.envelope.fall { opacity: 1; animation: env-fall 3.4s var(--ease-out) both; }
.envelope.rest { opacity: 1; }
.envelope.away {
  opacity: 0;
  transform: translate(-50%, -50%) translateY(26vh) scale(0.9);
  transition: transform 1.1s var(--ease-in-out), opacity 0.9s ease;
}

.env-back, .env-front, .env-flap, .env-paper { position: absolute; }
.env-back { inset: 0; z-index: 0; border-radius: 10px; background: linear-gradient(#e9d1c6, #dfbfb2); }
.env-paper {
  left: 7%;
  right: 7%;
  top: 7%;
  height: 86%;
  z-index: 1;
  border-radius: 6px;
  background:
    repeating-linear-gradient(180deg, transparent 0 14px, rgba(120, 100, 130, 0.14) 14px 15px) 18px 22px / calc(100% - 36px) 60% no-repeat,
    #fbf5ec;
  transition: transform 1.1s var(--ease-out) 0.35s;
}
.env-front {
  inset: 0;
  z-index: 2;
  border-radius: 10px;
  background: linear-gradient(165deg, #f7e8df, #eed4c7);
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
}
.env-flap {
  left: 0;
  right: 0;
  top: 0;
  height: 60%;
  z-index: 3;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(#f3dfd5, #e6c6b8);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transition: transform 0.85s var(--ease-in-out), z-index 0s linear 0.42s;
}
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .env-paper { transform: translateY(-50%); }

.seal {
  position: absolute;
  left: 50%;
  top: 58%;
  z-index: 4;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  pointer-events: auto;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 34% 30%, #f07a8d, #c9324c 56%, #9b1d36);
  box-shadow:
    0 5px 12px rgba(90, 10, 30, 0.45),
    inset 0 -3px 6px rgba(0, 0, 0, 0.25),
    inset 0 2px 3px rgba(255, 255, 255, 0.35);
  transition: transform 0.5s var(--spring), opacity 0.4s ease;
}
.seal svg { width: 25px; height: 25px; fill: rgba(122, 16, 38, 0.7); filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.35)); }
.seal::before {
  content: "";
  position: absolute;
  inset: -9px;
  border-radius: 50%;
  border: 2px solid rgba(243, 167, 185, 0.7);
  animation: ring 2.2s ease-out infinite;
}
.seal:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 6px; }
.envelope.open .seal { transform: scale(1.6); opacity: 0; pointer-events: none; }

@keyframes ring {
  0% { transform: scale(0.85); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}
@keyframes env-fall {
  0% { transform: translate(-50%, -50%) translateY(-75vh) rotate(-14deg); }
  35% { transform: translate(-50%, -50%) translateY(-38vh) rotate(9deg); }
  65% { transform: translate(-50%, -50%) translateY(-12vh) rotate(-5deg); }
  85% { transform: translate(-50%, -50%) translateY(-2vh) rotate(2deg); }
  100% { transform: translate(-50%, -50%); }
}

.env-hint {
  position: absolute;
  left: 50%;
  top: calc(40% + min(74vw, 300px) / 3 + 30px);
  transform: translateX(-50%);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.8s var(--ease-out);
}
.env-hint.in { opacity: 1; }

.card {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(calc(100% - 32px), 470px);
  max-height: calc(100% - 48px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding: clamp(28px, 6vw, 44px) clamp(22px, 6vw, 42px) clamp(22px, 5vw, 32px);
  border-radius: 14px;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 0% 0%, rgba(255, 255, 255, 0.9), transparent 52%),
    radial-gradient(100% 80% at 100% 100%, rgba(240, 212, 198, 0.55), transparent 60%),
    #fbf4ea;
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(120, 80, 60, 0.08) inset;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -44%) scale(0.88);
  transition: transform 1.2s var(--ease-out), opacity 1s ease, box-shadow 2s ease;
}
.card.show { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%); }
.card.glow {
  box-shadow:
    0 30px 80px -30px rgba(0, 0, 0, 0.75),
    0 0 70px -6px rgba(255, 196, 150, 0.45),
    0 0 0 1px rgba(120, 80, 60, 0.08) inset;
}
.card.leave {
  opacity: 0;
  transform: translate(-50%, -62%) scale(0.86) rotate(-3deg);
  transition: transform 1.2s var(--ease-in-out), opacity 1s ease;
}

.card p {
  font-family: var(--hand);
  font-weight: 500;
  font-size: clamp(1.5rem, 1.2rem + 1.2vw, 1.95rem);
  line-height: 1.28;
  margin: 0 0 0.5em;
  text-wrap: pretty;
}
.card p:empty { display: none; }
.card .to { color: #9a6e7e; padding-right: 56px; }
.card .to:empty + p { padding-right: 56px; }
.card .last {
  margin-top: 0.75em;
  font-weight: 600;
  font-size: clamp(1.8rem, 1.35rem + 1.9vw, 2.45rem);
  line-height: 1.15;
  color: #b8344f;
}
.card .lw {
  display: inline-block;
  opacity: 0;
  transform: translateY(3px);
  filter: blur(4px);
  transition: opacity 0.5s ease, transform 0.6s var(--ease-out), filter 0.6s ease;
}
.card .lw.on { opacity: 1; transform: none; filter: blur(0); }

.draw-heart { width: 0.85em; height: 0.85em; vertical-align: -0.08em; overflow: visible; }
.draw-heart path {
  fill: transparent;
  stroke: #d6455c;
  stroke-width: 1.8;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  transition: stroke-dashoffset 1.3s var(--ease-in-out), fill 0.8s ease 1.1s;
}
.draw-heart.on path { stroke-dashoffset: 0; fill: #d6455c; }

.stamp {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 50px;
  height: 60px;
  padding: 5px;
  background: #fff;
  rotate: 6deg;
  box-shadow: 0 1px 3px rgba(60, 30, 40, 0.18);
}
.stamp::before {
  content: "";
  position: absolute;
  inset: -3px;
  border: 4px dotted #fbf4ea;
  pointer-events: none;
}
.stamp svg { display: block; width: 100%; height: 100%; }

.card-actions { display: flex; justify-content: flex-end; min-height: 50px; margin-top: 10px; }
.card-actions .btn { padding: 12px 22px; }

/* ---------- Final ---------- */

.final {
  position: absolute;
  left: 50%;
  top: calc(8.5% + var(--moon-final) + var(--vh) * 4);
  transform: translateX(-50%);
  width: min(calc(100% - 32px), 40rem);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}
.final-line {
  font-family: var(--serif);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(2.1rem, 1.2rem + 3.4vw, 3.7rem);
  line-height: 1.1;
  text-wrap: balance;
  color: #fff;
  text-shadow: 0 0 40px rgba(255, 214, 170, 0.35), 0 2px 22px rgba(3, 8, 24, 0.65);
}
.final-line .ic-heart {
  display: inline-block;
  width: 0.72em;
  height: 0.72em;
  vertical-align: -0.04em;
  color: var(--red);
  filter: drop-shadow(0 0 12px rgba(214, 69, 92, 0.65));
}
.final-line .ic-heart svg { display: block; width: 100%; height: 100%; animation: beat 2.2s ease-in-out infinite 1.5s; }
.final-sign {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--hand);
  font-weight: 500;
  font-size: clamp(1.3rem, 1.1rem + 0.8vw, 1.75rem);
  color: var(--gold-soft);
  text-shadow: 0 2px 16px rgba(3, 8, 24, 0.7);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 1.6s var(--ease-out), transform 1.6s var(--ease-out);
}
.final-sign.in { opacity: 1; transform: none; }
.mini-pg { width: 22px; height: 26px; flex: none; }
.final-actions { min-height: 56px; margin-top: 10px; }

/* ---------- Music ---------- */

.music {
  position: absolute;
  z-index: 8;
  top: max(14px, env(safe-area-inset-top));
  right: max(14px, env(safe-area-inset-right));
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px 9px 11px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-dim);
  background: rgba(10, 20, 46, 0.36);
  box-shadow: 0 0 0 1px rgba(214, 228, 255, 0.2) inset;
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.2s var(--ease-out), color 0.3s, background 0.3s, box-shadow 0.3s;
}
.music.in { opacity: 1; pointer-events: auto; }
.music:focus-visible { outline: 2px solid var(--gold-soft); outline-offset: 3px; }
.music .spk { width: 17px; height: 17px; }
.music .wave1, .music .wave2 { opacity: 0.35; transition: opacity 0.3s; }
.music[aria-pressed="true"] { color: #fff; background: rgba(214, 69, 92, 0.22); box-shadow: 0 0 0 1px rgba(243, 167, 185, 0.45) inset; }
.music[aria-pressed="true"] .wave1 { opacity: 1; animation: pulse 1.6s ease-in-out infinite; }
.music[aria-pressed="true"] .wave2 { opacity: 1; animation: pulse 1.6s ease-in-out infinite 0.4s; }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

.curtain {
  position: absolute;
  inset: 0;
  z-index: 9;
  background: var(--midnight);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.9s var(--ease-in-out);
}
.curtain.on { opacity: 1; pointer-events: auto; }

/* ---------- Hover only for real pointers (no sticky hover after a tap on iOS) ---------- */

@media (hover: hover) and (pointer: fine) {
  .btn-love:hover {
    box-shadow:
      0 18px 46px -12px rgba(236, 144, 167, 1),
      0 0 40px -6px rgba(243, 167, 185, 0.7),
      0 0 0 1px rgba(255, 255, 255, 0.35) inset,
      0 1px 0 rgba(255, 255, 255, 0.6) inset;
  }
  .btn-love:hover::after { transform: translateX(130%); }
  .btn-ghost:hover { background: rgba(22, 40, 84, 0.55); box-shadow: 0 0 0 1px rgba(214, 228, 255, 0.5) inset, 0 0 30px -8px rgba(188, 214, 245, 0.45); }
  .btn-ink:hover { background: rgba(214, 69, 92, 0.08); box-shadow: 0 0 0 1px rgba(214, 69, 92, 0.4) inset; }
  .btn:hover .arr { transform: translateX(4px); }
  .btn:hover .spin { transform: rotate(-200deg); }
  .seal:hover { transform: scale(1.08); }
  .music:hover { color: #fff; box-shadow: 0 0 0 1px rgba(214, 228, 255, 0.4) inset; }
  .thing.in:hover { transform: scale(1.12); transition-delay: 0ms; }
}

/* ---------- Small and landscape screens ---------- */

@media (max-aspect-ratio: 3/4) {
  :root { --moon-size: clamp(46px, 14vw, 92px); }
  .moon { left: 21%; top: 5.5%; }
  .top { top: max(calc(var(--vh) * 16), 118px); }
  .final { top: 30%; }
}

@media (max-width: 420px) {
  .thing { --ts: 56px; }
  .thing svg { width: 28px; height: 28px; }
  .btn { padding: 14px 24px; }
}

@media (max-height: 520px) and (orientation: landscape) {
  :root { --pw: clamp(70px, calc(var(--vh) * 24), 130px); --ground: 6%; --moon-final: clamp(54px, calc(var(--vh) * 15), 84px); }
  .moon { left: 9%; top: 9%; }
  .top { top: 14px; gap: 10px; }
  .story { font-size: clamp(1.3rem, 0.9rem + 2vw, 1.9rem); min-height: 0; }
  .phrase { min-height: 0; padding: 10px 18px; font-size: 1.1rem; }
  .actions { min-height: 48px; }
  .final { top: calc(9% + var(--moon-final) + 2vh); gap: 8px; }
  .final-line { font-size: clamp(1.6rem, 1rem + 2.6vw, 2.4rem); }
  .thing { --ts: 50px; }
}

@media (prefers-reduced-motion: reduce) {
  .pg-breathe, .thing-in, .aurora span, .seal::before, .btn-love .beat, .final-line .ic-heart svg { animation: none !important; }
  .w { animation-duration: 0.6s; filter: none; transform: none; }
}

@supports (height: 1svh) {
  :root { --vh: 1svh; }
}
