/* ============================================================================
   Happy Birthday, Kashish — a story told one screen at a time.

   Mobile-first (390px portrait). Every screen fills the viewport and never
   scrolls; screens cross-fade with a little scale and blur. Motion uses the
   easing tokens below so the whole thing moves with one personality.
   ========================================================================== */

@property --spin {
  syntax: "<angle>";
  initial-value: 0deg;
  inherits: false;
}

:root {
  --plum-0: #1a0b1e;
  --plum-1: #4a1238;
  --plum-2: #8a2350;
  --pink: #ff6b9d;
  --pink-soft: #ff9ec0;
  --gold: #f5c76b;
  --gold-deep: #e0a947;
  --cream: #fdf6ec;
  --ink: #3a1530;
  --ink-soft: #7a5468;
  --crimson: #c8102e;

  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --script: "Dancing Script", "Caveat", cursive;
  --hand: "Caveat", "Dancing Script", cursive;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  /* One personality: quick out of the gate, long soft landing. */
  --ease: cubic-bezier(.22, 1, .36, 1);
  --ease-in: cubic-bezier(.64, 0, .78, 0);
  --ease-io: cubic-bezier(.65, 0, .35, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  --spring-soft: cubic-bezier(.3, 1.35, .6, 1);

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --vh: 100vh;
}
@supports (height: 100dvh) { :root { --vh: 100dvh; } }

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--sans);
  color: var(--cream);
  background: linear-gradient(160deg, var(--plum-0) 0%, var(--plum-1) 55%, var(--plum-2) 100%) fixed;
  background-color: var(--plum-0);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
img { -webkit-user-drag: none; user-select: none; }
[hidden] { display: none !important; }

.script { font-family: var(--script); font-weight: 700; }

/* ---------------------------------------------------------------------------
   The sky: stars on a canvas, plus three slow aurora blobs for depth.
   --------------------------------------------------------------------------- */
.sky, .fx {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}
.sky { z-index: 0; }
.fx { z-index: 60; }

.aurora { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.aurora span {
  position: absolute;
  width: 70vmax;
  height: 70vmax;
  border-radius: 50%;
  filter: blur(60px);
  opacity: .35;
  animation: drift 26s var(--ease-io) infinite alternate;
}
.aurora span:nth-child(1) { background: radial-gradient(closest-side, #ff6b9d, transparent); left: -30vmax; top: -25vmax; }
.aurora span:nth-child(2) { background: radial-gradient(closest-side, #7b2a8c, transparent); right: -35vmax; top: 10vmax; animation-duration: 32s; animation-delay: -8s; }
.aurora span:nth-child(3) { background: radial-gradient(closest-side, #f5c76b, transparent); left: 10vmax; bottom: -45vmax; opacity: .18; animation-duration: 38s; animation-delay: -14s; }
@keyframes drift {
  0%   { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(8vmax, 6vmax, 0) scale(1.15); }
}

/* ---------------------------------------------------------------------------
   Loader
   --------------------------------------------------------------------------- */
.loader {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  background: linear-gradient(160deg, var(--plum-0), var(--plum-1));
  transition: opacity .8s var(--ease), visibility 0s .8s;
}
.loader.is-done { opacity: 0; visibility: hidden; }
.loader.is-done .loader-heart { transform: scale(2.4); opacity: 0; transition: transform .8s var(--ease), opacity .6s; }
.loader-heart {
  width: 58px;
  fill: var(--pink);
  filter: drop-shadow(0 0 18px rgba(255, 107, 157, .7));
  animation: lub 1.1s var(--ease-io) infinite;
}
.loader-text {
  margin: 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1rem;
  color: rgba(253, 246, 236, .7);
  animation: breathe 2.2s var(--ease-io) infinite;
}
@keyframes lub {
  0%, 100% { transform: scale(1); }
  14% { transform: scale(1.18); }
  28% { transform: scale(1); }
  42% { transform: scale(1.12); }
  70% { transform: scale(1); }
}
@keyframes breathe { 50% { opacity: .45; } }

/* ---------------------------------------------------------------------------
   Stage and scenes. One .is-active at a time; the outgoing one gets
   .is-leaving for the length of the cross-fade.
   --------------------------------------------------------------------------- */
.stage { position: fixed; inset: 0; z-index: 1; }

.scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(10px, 2.2vh, 22px);
  padding: calc(var(--safe-t) + 64px) 16px calc(var(--safe-b) + 58px);
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transform: scale(1.04);
  filter: blur(8px);
  pointer-events: none;
  transition:
    opacity .85s var(--ease),
    transform 1s var(--ease),
    filter .85s var(--ease),
    visibility 0s 1s;
}
.scene.is-active {
  opacity: 1;
  visibility: visible;
  transform: none;
  filter: none;
  pointer-events: auto;
  transition-delay: .12s, .12s, .12s, 0s;
}
.scene.is-leaving {
  opacity: 0;
  visibility: visible;
  transform: scale(.96);
  filter: blur(8px);
  transition-delay: 0s;
}
.scene.is-light { background: var(--cream); color: var(--ink); }

.heading {
  margin: 0;
  max-width: 22ch;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.55rem, 6.4vw, 2.6rem);
  line-height: 1.15;
  letter-spacing: -.01em;
  text-wrap: balance;
  text-shadow: 0 0 30px rgba(255, 107, 157, .35);
}
.subtext {
  margin: 6px 0 0;
  font-size: clamp(.92rem, 3.6vw, 1.05rem);
  color: rgba(253, 246, 236, .72);
}
.sub-head { flex: none; }

/* Staggered entrance for whatever sits at the top of a scene. */
.scene.is-active > .heading,
.scene.is-active .sub-head > * {
  animation: rise 1s var(--ease) both;
}
.scene.is-active .sub-head > :nth-child(2) { animation-delay: .15s; }
@keyframes rise {
  from { opacity: 0; transform: translateY(18px); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: none; }
}
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------------------------------------------------------------------------
   Buttons
   --------------------------------------------------------------------------- */
.pill {
  position: relative;
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  padding: 14px 28px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: .01em;
  color: #fff;
  background: linear-gradient(135deg, #ff6b9d 0%, #ff8fab 45%, #f5b062 100%);
  box-shadow:
    0 10px 30px -8px rgba(255, 107, 157, .75),
    inset 0 1px 0 rgba(255, 255, 255, .45);
  text-shadow: 0 1px 2px rgba(120, 20, 60, .35);
  transition: transform .45s var(--spring), box-shadow .45s var(--ease), opacity .6s var(--ease);
}
.pill::after {
  /* the sheen that sweeps across every few seconds */
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, .55) 50%, transparent 65%);
  transform: translateX(-120%);
  animation: sheen 3.6s var(--ease-io) infinite 1.2s;
}
.pill:hover { transform: translateY(-2px) scale(1.02); box-shadow: 0 16px 40px -8px rgba(255, 107, 157, .9), inset 0 1px 0 rgba(255, 255, 255, .45); }
.pill:active { transform: scale(.95); transition-duration: .12s; }
@keyframes sheen {
  0% { transform: translateX(-120%); }
  45%, 100% { transform: translateX(120%); }
}
.pill-dark {
  background: linear-gradient(135deg, var(--plum-1), var(--plum-2));
  box-shadow: 0 10px 30px -10px rgba(74, 18, 56, .7), inset 0 1px 0 rgba(255, 255, 255, .2);
}
.pill-ghost {
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .25);
  box-shadow: none;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.pill-ghost::after { display: none; }

/* A [data-next] that is "waiting" sits invisible until its moment. */
.is-waiting { opacity: 0; transform: translateY(14px) scale(.96); pointer-events: none; }

/* ---------------------------------------------------------------------------
   Page control and mute
   --------------------------------------------------------------------------- */
.dots {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-b) + 18px);
  z-index: 40;
  display: flex;
  gap: 2px;
  padding: 6px 8px;
  border-radius: 999px;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, .14);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: opacity .6s var(--ease), background .6s;
}
.dots.is-hidden { opacity: 0; pointer-events: none; }
.dot {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  background: none;
  transition: width .55s var(--spring);
}
.dot::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: rgba(253, 246, 236, .38);
  transition: width .55s var(--spring), background .4s;
}
.dot.is-current { width: 32px; }
.dot.is-current::before { width: 22px; background: var(--cream); }
body[data-light] .dots { background: rgba(58, 21, 48, .07); }
body[data-light] .dot::before { background: rgba(58, 21, 48, .25); }
body[data-light] .dot.is-current::before { background: var(--ink); }

.mute {
  position: fixed;
  top: calc(var(--safe-t) + 14px);
  right: 14px;
  z-index: 70;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(26, 11, 30, .35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--cream);
  animation: pop-in .6s var(--spring) both;
  transition: transform .35s var(--spring), background .4s, color .4s, border-color .4s;
}
.mute:active { transform: scale(.88); }
.mute svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.mute-spk { fill: currentColor; stroke: none; }
.mute-off { display: none; }
.mute[aria-pressed="true"] .mute-on { display: none; }
.mute[aria-pressed="true"] .mute-off { display: inline; }
.mute:not([aria-pressed="true"]) .mute-on { animation: waves 1.6s var(--ease-io) infinite; }
body[data-light] .mute { background: rgba(255, 255, 255, .6); color: var(--ink); border-color: rgba(58, 21, 48, .12); }
@keyframes waves { 50% { opacity: .35; } }
@keyframes pop-in { from { opacity: 0; transform: scale(.4); } }

/* ===========================================================================
   1 · GIFT
   =========================================================================== */
.gift-card {
  position: relative;
  width: min(100%, 340px);
  padding: 30px 26px 30px;
  border-radius: 30px;
  background: linear-gradient(160deg, rgba(255, 255, 255, .11), rgba(255, 255, 255, .03));
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  box-shadow:
    0 40px 80px -30px rgba(0, 0, 0, .6),
    0 0 80px -10px rgba(255, 107, 157, .35),
    inset 0 1px 0 rgba(255, 255, 255, .18);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.gift-card::before {
  /* a glint that travels round the card's edge */
  content: "";
  position: absolute;
  inset: 0;
  padding: 1.5px;
  border-radius: inherit;
  background: conic-gradient(from var(--spin), rgba(255, 255, 255, .12) 0deg, var(--pink) 60deg, var(--gold) 110deg, rgba(255, 255, 255, .12) 170deg, rgba(255, 255, 255, .12) 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  animation: spin 5s linear infinite;
  pointer-events: none;
}
@keyframes spin { to { --spin: 360deg; } }

.scene-gift.is-active .gift-card { animation: card-in 1.2s var(--ease) both .15s; }
@keyframes card-in {
  from { opacity: 0; transform: translateY(30px) scale(.92); filter: blur(10px); }
  to   { opacity: 1; transform: none; filter: none; }
}

.intro-eyebrow {
  font-family: var(--sans);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .22em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: .9;
}

.gift { position: relative; width: 132px; height: 132px; margin: 4px 0 -4px; }
.gift svg { position: relative; z-index: 1; width: 100%; height: 100%; overflow: visible; }
.gift-shadow { fill: #000; opacity: .3; transform-box: fill-box; transform-origin: center; animation: shadow 2.4s var(--ease-io) infinite; }
.gift-body, .gift-lid { transform-box: view-box; transform-origin: 60px 108px; }
.gift svg > g { animation: bob 2.4s var(--ease-io) infinite; }
.gift-lid { transform-origin: 60px 46px; animation: lid 2.4s var(--ease-io) infinite !important; }
.gift-glow {
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(255, 199, 107, .55), transparent);
  filter: blur(14px);
  animation: breathe 2.4s var(--ease-io) infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  40%      { transform: translateY(-10px) scale(.98, 1.02); }
  70%      { transform: translateY(0) scale(1.04, .96); }
  80%      { transform: translateY(0) scale(1, 1); }
}
@keyframes lid {
  0%, 100% { transform: translateY(0) rotate(0); }
  40%      { transform: translateY(-15px) rotate(-4deg); }
  55%      { transform: translateY(-12px) rotate(3deg); }
  70%      { transform: translateY(0) rotate(0); }
}
@keyframes shadow {
  0%, 100% { transform: scaleX(1); opacity: .3; }
  40%      { transform: scaleX(.75); opacity: .16; }
}
.gift.is-open .gift-lid {
  animation: lid-off .9s var(--ease) forwards !important;
}
.gift.is-open svg > g.gift-body { animation: body-squash .6s var(--spring) forwards; }
.gift.is-open .gift-glow { animation: glow-burst .9s var(--ease) forwards; }
@keyframes lid-off {
  0%   { transform: translateY(0) rotate(0); }
  25%  { transform: translateY(4px) rotate(0); }
  100% { transform: translate(40px, -150px) rotate(40deg); opacity: 0; }
}
@keyframes body-squash {
  0%   { transform: scale(1, 1); }
  30%  { transform: scale(1.12, .86); }
  100% { transform: scale(1, 1); }
}
@keyframes glow-burst { to { transform: scale(3); opacity: 0; } }

.gift-name {
  margin: 0;
  font-size: clamp(3rem, 15vw, 4.2rem);
  line-height: 1.05;
  color: var(--cream);
  text-shadow: 0 0 24px rgba(255, 107, 157, .6);
}
.gift-name .ch, .beat-words .ch, .finale-title .ch { display: inline-block; white-space: pre; }
.scene-gift.is-active .gift-name .ch { animation: letter-in 1s var(--ease) both; animation-delay: calc(.55s + var(--i) * .07s); }
@keyframes letter-in {
  from { opacity: 0; transform: translateY(.4em) scale(.8); filter: blur(8px); }
  to   { opacity: 1; transform: none; filter: none; }
}
.gift-sub {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.08rem;
  color: rgba(253, 246, 236, .78);
}
.scene-gift.is-active .gift-sub { animation: rise 1s var(--ease) both 1.2s; }
.scene-gift.is-active #openGift { animation: rise 1s var(--ease) both 1.45s; }
.gift-card.is-opening { animation: card-out 1s var(--ease-in) forwards !important; }
@keyframes card-out {
  0% { transform: scale(1); }
  30% { transform: scale(.97); }
  100% { transform: scale(1.12); opacity: 0; filter: blur(10px); }
}

/* ===========================================================================
   2 · HEARTBEAT
   =========================================================================== */
.scene-beat { overflow: hidden; cursor: pointer; }
.beat-flood {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 45%, #e3173c 0%, #b00f2c 55%, #6e0a1f 100%);
  clip-path: circle(0% at 50% 46%);
}
.beat-heart {
  position: relative;
  width: 118px;
  margin-top: -6vh;
}
.beat-heart svg { display: block; width: 100%; overflow: visible; filter: drop-shadow(0 6px 26px rgba(224, 30, 60, .55)); }
.beat-heart::before, .beat-heart::after {
  /* rings that ripple out on each beat */
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  border: 2px solid rgba(224, 30, 60, .45);
  opacity: 0;
}
.scene-beat.is-active .beat-heart { animation: beat-in .9s var(--spring) both .2s; }
.scene-beat.is-beating .beat-heart svg { animation: beat .5s var(--ease-io) infinite; }
.scene-beat.is-beating .beat-heart::before { animation: ripple 1s var(--ease) infinite; }
.scene-beat.is-beating .beat-heart::after { animation: ripple 1s var(--ease) infinite .5s; }
@keyframes beat-in { from { opacity: 0; transform: scale(.3); } }
@keyframes beat {
  0%   { transform: scale(1); }
  25%  { transform: scale(1.15); }
  55%  { transform: scale(1); }
  100% { transform: scale(1); }
}
@keyframes ripple {
  from { opacity: .9; transform: scale(.6); }
  to   { opacity: 0; transform: scale(2.4); }
}
.beat-caption {
  margin: 8px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--ink-soft);
  transition: opacity .5s var(--ease), transform .5s var(--ease);
}
.scene-beat.is-active .beat-caption { animation: rise 1s var(--ease) both .7s; }

.scene-beat.is-flooding .beat-flood { clip-path: circle(150% at 50% 46%); transition: clip-path 1.1s cubic-bezier(.55, 0, .25, 1); }
.scene-beat.is-flooding .beat-heart svg { animation: none; transform: scale(5); opacity: 0; transition: transform 1s var(--ease-in), opacity .5s .5s; }
.scene-beat.is-flooding .beat-heart::before, .scene-beat.is-flooding .beat-heart::after { animation: none; }
.scene-beat.is-flooding .beat-caption { opacity: 0; transform: translateY(10px); animation: none; }

.beat-title {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.beat-words {
  margin: 0;
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(2.6rem, 13vw, 6rem);
  line-height: 1;
  color: #fff;
  text-shadow: 0 4px 40px rgba(80, 0, 20, .45);
  white-space: nowrap;
}
.beat-words .ch { opacity: 0; }
.scene-beat.is-titled .beat-words .ch { animation: letter-in 1.1s var(--ease) both; animation-delay: calc(var(--i) * .055s); }
.beat-line {
  display: block;
  width: min(72%, 380px);
  height: 2px;
  margin-top: 18px;
  border-radius: 2px;
  background: linear-gradient(90deg, transparent, var(--gold) 15%, #fff1c9 50%, var(--gold) 85%, transparent);
  box-shadow: 0 0 12px rgba(245, 199, 107, .8);
  transform: scaleX(0);
  transform-origin: left;
}
.scene-beat.is-titled .beat-line { transform: scaleX(1); transition: transform 1.2s var(--ease-io) .7s; }
.beat-hint {
  margin: 26px 0 0;
  font-size: .8rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, .6);
  opacity: 0;
}
.scene-beat.is-titled .beat-hint { animation: fade-in 1s var(--ease) both 1.8s, breathe 2.2s var(--ease-io) infinite 2.8s; }

/* ===========================================================================
   3 · HEART TREE
   =========================================================================== */
.scene-tree { gap: 4px; }
.tree-wrap {
  flex: none;
  width: min(92vw, calc((var(--vh) - 290px) * .83), 460px);
}
.tree { display: block; width: 100%; height: auto; overflow: visible; }
.tree-ground { fill: #e9dccb; transform-box: fill-box; transform-origin: center; transform: scaleX(0); }
.scene-tree.is-growing .tree-ground { transform: scaleX(1); transition: transform 1s var(--ease); }
.tree-branches path {
  fill: none;
  stroke: #5e3a28;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
}
.scene-tree.is-growing .tree-branches path {
  animation: draw var(--dur, 1s) var(--ease-io) forwards;
  animation-delay: var(--d, 0s);
}
@keyframes draw { to { stroke-dashoffset: 0; } }

.th { transform: scale(0); transform-box: fill-box; transform-origin: center; }
.scene-tree.is-blooming .th { animation: heart-pop .7s var(--spring) forwards; animation-delay: var(--d); }
@keyframes heart-pop {
  0%   { transform: scale(0) rotate(-30deg); }
  100% { transform: scale(var(--s)) rotate(0); }
}
.tree-hearts { transform-box: view-box; transform-origin: 200px 300px; }
.scene-tree.is-swaying .tree-hearts { animation: sway 5s var(--ease-io) infinite; }
@keyframes sway {
  0%, 100% { transform: rotate(-1deg); }
  50%      { transform: rotate(1deg); }
}
.tf {
  transform-box: fill-box;
  transform-origin: center;
  animation: fall var(--dur) linear forwards;
}
@keyframes fall {
  0%   { transform: translate(0, 0) rotate(0) scale(var(--s)); opacity: 1; }
  25%  { transform: translate(calc(var(--dx) * .5), 60px) rotate(calc(var(--rot) * .3)) scale(var(--s)); }
  50%  { transform: translate(calc(var(--dx) * -.3), 130px) rotate(calc(var(--rot) * .6)) scale(var(--s)); }
  75%  { transform: translate(var(--dx), 200px) rotate(var(--rot)) scale(var(--s)); opacity: .9; }
  100% { transform: translate(calc(var(--dx) * .4), 260px) rotate(var(--rot)) scale(var(--s)); opacity: 0; }
}

.tree-text { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.tree-title {
  margin: 0;
  font-size: clamp(2.1rem, 9.6vw, 3.6rem);
  line-height: 1.1;
  background: linear-gradient(90deg, #c2185b, #ff6b9d 50%, #e0803a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  padding: 0 .2em;
  clip-path: inset(0 100% 0 0);
}
.scene-tree.is-written .tree-title { clip-path: inset(-20% -5% -20% 0); transition: clip-path 2s var(--ease-io); }
.tree-line {
  margin: 0 0 12px;
  max-width: 30ch;
  font-family: var(--serif);
  font-style: italic;
  font-size: 1.05rem;
  color: var(--ink-soft);
  opacity: 0;
  transform: translateY(8px);
}
.scene-tree.is-written .tree-line { opacity: 1; transform: none; transition: opacity 1s var(--ease) 1.2s, transform 1s var(--ease) 1.2s; }

@media (min-width: 860px) and (min-aspect-ratio: 5/4) {
  .scene-tree { flex-direction: row; gap: 48px; }
  .tree-wrap { width: min(46vw, calc((var(--vh) - 140px) * .83)); }
  .tree-text { align-items: flex-start; text-align: left; max-width: 420px; }
}

/* ===========================================================================
   4 · CAKE
   =========================================================================== */
.cake-stage { position: relative; flex: none; }
.cake-stage::before {
  /* the candle's warmth on the room */
  content: "";
  position: absolute;
  left: 50%;
  top: 30%;
  width: 150%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(255, 190, 110, .28), transparent);
  opacity: 0;
  transition: opacity 1.4s var(--ease);
  pointer-events: none;
}
.scene-cake.is-lit .cake-stage::before { opacity: 1; animation: breathe 3s var(--ease-io) infinite; }
.scene-cake.is-out .cake-stage::before { opacity: 0; animation: none; }

.cake-btn { display: block; padding: 0; border: 0; background: none; border-radius: 24px; }
.cake { display: block; width: min(74vw, 320px, calc(var(--vh) * .4)); height: auto; overflow: visible; }

.cake-body { transform: translateY(330px); }
.scene-cake.is-in .cake-body { animation: cake-up 1.2s var(--spring-soft) forwards; }
@keyframes cake-up {
  from { transform: translateY(330px); }
  to   { transform: translateY(0); }
}
.candle { transform: translateY(-340px); }
.scene-cake.is-candle .candle { animation: candle-drop .9s forwards; }
@keyframes candle-drop {
  0%   { transform: translateY(-340px); animation-timing-function: var(--ease-in); }
  60%  { transform: translateY(0); animation-timing-function: var(--ease); }
  75%  { transform: translateY(-16px); animation-timing-function: var(--ease-in); }
  88%  { transform: translateY(0); animation-timing-function: var(--ease); }
  94%  { transform: translateY(-4px); }
  100% { transform: translateY(0); }
}
.flame-ign, .flame { transform-box: fill-box; transform-origin: 50% 100%; }
.flame-ign { transform: scale(0); opacity: 0; }
.flame-glow { opacity: 0; transform-box: fill-box; transform-origin: center; }
.scene-cake.is-lit .flame-ign { animation: ignite .7s var(--spring) forwards; }
.scene-cake.is-lit .flame { animation: flicker 1.6s ease-in-out infinite; }
.scene-cake.is-lit .flame-glow { animation: glow 2.2s var(--ease-io) infinite; opacity: 1; }
@keyframes ignite {
  0%   { transform: scale(0, 0); opacity: 0; }
  40%  { transform: scale(.6, 1.3); opacity: 1; }
  100% { transform: scale(1, 1); opacity: 1; }
}
@keyframes flicker {
  0%, 100% { transform: scale(1, 1) skewX(0); }
  20% { transform: scale(.96, 1.06) skewX(2deg); }
  40% { transform: scale(1.03, .95) skewX(-2deg); }
  60% { transform: scale(.98, 1.04) skewX(1deg); }
  80% { transform: scale(1.02, .97) skewX(-1.5deg); }
}
@keyframes glow {
  0%, 100% { transform: scale(1); opacity: .9; }
  50% { transform: scale(1.12); opacity: 1; }
}
.scene-cake.is-out .flame-ign { animation: snuff .45s var(--ease-in) forwards; }
.scene-cake.is-out .flame-glow { animation: none; opacity: 0; transition: opacity .5s; }
@keyframes snuff {
  0%   { transform: scale(1, 1); opacity: 1; }
  40%  { transform: scale(1.3, .5) skewX(-20deg); opacity: .8; }
  100% { transform: scale(0, 0); opacity: 0; }
}
.smoke path {
  stroke-width: 3;
  stroke-dasharray: .35 1;
  stroke-dashoffset: .35;
  opacity: 0;
}
.scene-cake.is-out .smoke path { animation: smoke 2.6s var(--ease) forwards; }
.scene-cake.is-out .smoke path:nth-child(2) { animation-delay: .25s; }
.scene-cake.is-out .smoke path:nth-child(3) { animation-delay: .45s; }
@keyframes smoke {
  0%   { stroke-dashoffset: .35; opacity: 0; transform: translateY(0); }
  15%  { opacity: .85; }
  100% { stroke-dashoffset: -.75; opacity: 0; transform: translateY(-26px); stroke-width: 7; }
}

.cake-copy { display: grid; }
.cake-instr, .cake-done { grid-area: 1 / 1; }
.cake-instr {
  margin: 0;
  max-width: 30ch;
  font-size: clamp(.95rem, 3.8vw, 1.08rem);
  line-height: 1.5;
  color: rgba(253, 246, 236, .82);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .8s var(--ease), transform .8s var(--ease);
}
.scene-cake.is-lit .cake-instr { opacity: 1; transform: none; }
.scene-cake.is-out .cake-instr { opacity: 0; transform: translateY(-10px); }

.mic-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: .82rem;
  background: rgba(255, 255, 255, .08);
  border: 1px solid rgba(255, 255, 255, .15);
  animation: rise .7s var(--ease) both;
  transition: opacity .5s;
}
.scene-cake.is-out .mic-chip { opacity: 0; }
.mic-dot { width: 8px; height: 8px; border-radius: 50%; background: #ff4d6d; animation: breathe 1.2s infinite; }
.mic-meter { width: 46px; height: 4px; border-radius: 4px; background: rgba(255, 255, 255, .15); overflow: hidden; }
.mic-meter span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--pink)); border-radius: inherit; transition: width .08s linear; }

.cake-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  opacity: 0;
  pointer-events: none;
}
.scene-cake.is-done .cake-done { opacity: 1; pointer-events: auto; }
.cake-wish {
  margin: 0;
  font-size: clamp(2rem, 9vw, 3rem);
  line-height: 1.1;
  background: linear-gradient(90deg, #f5c76b, #fff1c9 45%, #e0a947);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 18px rgba(245, 199, 107, .55));
  opacity: 0;
}
.scene-cake.is-done .cake-wish { animation: wish-in 1.3s var(--ease) both; }
.scene-cake.is-done .cake-done .pill { animation: rise 1s var(--ease) both .8s; }
@keyframes wish-in {
  from { opacity: 0; transform: scale(.7); filter: blur(10px) drop-shadow(0 0 18px rgba(245, 199, 107, .55)); }
  to   { opacity: 1; transform: none; filter: drop-shadow(0 0 18px rgba(245, 199, 107, .55)); }
}

/* ===========================================================================
   5 · VIDEO
   =========================================================================== */
.video-card {
  position: relative;
  flex: none;
  width: min(100%, 720px, calc((var(--vh) - 300px) * 16 / 9));
  padding: 3px;
  border-radius: 24px;
  background: conic-gradient(from var(--spin), var(--pink), var(--gold), #4fd1c5, var(--pink));
  box-shadow: 0 0 50px -6px rgba(255, 107, 157, .65), 0 30px 60px -25px rgba(0, 0, 0, .7);
  animation: spin 6s linear infinite;
}
.scene-video.is-active .video-card { animation: spin 6s linear infinite, card-in 1.2s var(--ease) both .25s; }
.video-card video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 21px;
  background: #000;
  object-fit: cover;
}
.video-play {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  place-items: center;
  width: 74px;
  height: 74px;
  margin: -37px 0 0 -37px;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, .4);
  border-radius: 50%;
  background: rgba(255, 255, 255, .2);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .35);
  transition: transform .4s var(--spring), opacity .4s var(--ease);
  animation: halo 2s var(--ease-io) infinite;
}
.video-play svg { width: 30px; fill: #fff; margin-left: 4px; }
.video-play:active { transform: scale(.9); }
.video-card.is-playing .video-play { opacity: 0; transform: scale(1.4); pointer-events: none; animation: none; }
@keyframes halo {
  0%, 100% { box-shadow: 0 10px 30px rgba(0, 0, 0, .35), 0 0 0 0 rgba(255, 255, 255, .35); }
  50%      { box-shadow: 0 10px 30px rgba(0, 0, 0, .35), 0 0 0 16px rgba(255, 255, 255, 0); }
}
.video-note { margin: 0; font-size: .82rem; letter-spacing: .08em; color: rgba(253, 246, 236, .55); }
.scene-video.is-active .video-note { animation: fade-in 1s both .9s; }
.scene-video.is-active [data-next] { animation: rise 1s var(--ease) both 1.1s; }

/* ===========================================================================
   6 · BALLOONS
   =========================================================================== */
.scene-balloons { justify-content: flex-start; gap: 12px; }
.balloon-field {
  position: relative;
  flex: none;
  width: min(100%, 560px);
  height: min(40vh, 330px);
  height: min(calc(var(--vh) * .4), 330px);
  transition: height 1s var(--ease-io), opacity .6s;
}
.scene-balloons.is-done .balloon-field { height: 0; opacity: 0; }
.balloon {
  position: absolute;
  bottom: var(--y);
  left: var(--x);
  width: var(--w, 68px);
  margin-left: calc(var(--w, 68px) / -2);
  padding: 0;
  border: 0;
  background: none;
  transform: translateY(110vh);
  -webkit-tap-highlight-color: transparent;
}
.scene-balloons.is-active .balloon { animation: balloon-rise 2.2s var(--ease) forwards; animation-delay: var(--d); }
@keyframes balloon-rise {
  from { transform: translateY(110vh) rotate(-8deg); }
  to   { transform: translateY(0) rotate(0); }
}
.balloon-bob { display: block; animation: balloon-bob var(--bob, 4s) var(--ease-io) infinite; animation-delay: var(--d); transform-origin: 50% 100%; }
@keyframes balloon-bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-12px) rotate(3deg); }
}
.balloon svg { display: block; width: 100%; overflow: visible; filter: drop-shadow(0 10px 14px rgba(0, 0, 0, .25)); }
.balloon:hover .balloon-bob svg { transform: scale(1.05); }
.balloon svg { transition: transform .4s var(--spring); }
.balloon.is-popped { pointer-events: none; }
.balloon.is-popped svg { animation: pop .22s var(--ease) forwards; }
@keyframes pop {
  0%   { transform: scale(1); opacity: 1; }
  60%  { transform: scale(1.35, 1.25); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

.balloons-done {
  display: grid;
  grid-template-rows: 0fr;
  flex: none;
  opacity: 0;
  transition: grid-template-rows 1s var(--ease-io), opacity .8s var(--ease) .4s;
}
.balloons-done-in { min-height: 0; overflow: hidden; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.scene-balloons.is-done .balloons-done { grid-template-rows: 1fr; opacity: 1; }
.balloons-more {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(1.15rem, 5vw, 1.5rem);
  color: var(--cream);
  text-shadow: 0 0 20px rgba(255, 107, 157, .6);
}
.balloons-done .pill { margin-bottom: 10px; }

.reasons {
  flex: 1 1 auto;
  min-height: 0;
  width: min(100%, 520px);
  margin: 0;
  padding: 4px 4px 16px;
  list-style: none;
  overflow-y: auto;
  scrollbar-width: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-mask-image: linear-gradient(#000 calc(100% - 22px), transparent);
  mask-image: linear-gradient(#000 calc(100% - 22px), transparent);
}
.reasons::-webkit-scrollbar { display: none; }
/* The list: one compact row per opened reason; tap to read it again. */
.reason { animation: reason-in .8s var(--spring-soft) both; }
.reason-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 14px;
  border-radius: 16px;
  text-align: left;
  font-size: clamp(.9rem, 3.7vw, 1rem);
  font-weight: 500;
  line-height: 1.3;
  background: linear-gradient(135deg, rgba(255, 255, 255, .13), rgba(255, 255, 255, .05));
  border: 1px solid rgba(255, 255, 255, .16);
  box-shadow: 0 0 26px -10px var(--c), inset 0 1px 0 rgba(255, 255, 255, .12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform .35s var(--spring), background .3s;
}
.reason-btn:hover { background: linear-gradient(135deg, rgba(255, 255, 255, .18), rgba(255, 255, 255, .08)); }
.reason-btn:active { transform: scale(.97); }
.reason-btn .reason-t { flex: 1; }
.reason-btn .reason-go { opacity: .45; font-size: 1.1rem; }
.reason.is-bonus .reason-btn {
  border-color: rgba(245, 199, 107, .55);
  box-shadow: 0 0 30px -6px rgba(245, 199, 107, .6), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.reason-n {
  flex: none;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-size: .78rem;
  font-weight: 600;
  color: #2a0d22;
  background: var(--c);
  box-shadow: 0 0 14px var(--c);
}
@keyframes reason-in {
  from { opacity: 0; transform: translateY(-18px) scale(.9); filter: blur(8px); }
  to   { opacity: 1; transform: none; filter: none; }
}

/* The open message. */
.rpop {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 66px) 16px calc(var(--safe-b) + 64px);
  background: rgba(20, 6, 22, .55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: fade-in .45s var(--ease) both;
}
.rpop.is-closing { opacity: 0; transition: opacity .4s var(--ease) .1s; }
.rpop-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(100%, 460px);
  max-height: 100%;
  padding: 30px 22px 20px;
  border-radius: 26px;
  text-align: center;
  color: var(--cream);
  background:
    radial-gradient(120% 70% at 50% 0%, color-mix(in srgb, var(--c, #ff6b9d) 30%, transparent), transparent 70%),
    linear-gradient(160deg, #3a1232, #1f0a1e);
  border: 1px solid color-mix(in srgb, var(--c, #ff6b9d) 55%, transparent);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .85), 0 0 60px -12px var(--c, #ff6b9d);
}
.rpop-n {
  position: absolute;
  top: -20px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: -20px;
  border-radius: 50%;
  font-weight: 700;
  color: #2a0d22;
  background: var(--c, #ff6b9d);
  box-shadow: 0 0 22px var(--c, #ff6b9d), 0 6px 14px rgba(0, 0, 0, .35);
  animation: badge-in .7s var(--spring) both .25s;
}
@keyframes badge-in { from { transform: scale(0) rotate(-90deg); } }
.rpop-title {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-weight: 700;
  font-size: clamp(1.3rem, 5.6vw, 1.7rem);
  line-height: 1.2;
  text-wrap: balance;
  animation: rise .8s var(--ease) both .2s;
}
.rpop-body {
  min-height: 0;
  overflow-y: auto;
  scrollbar-width: none;
  font-size: clamp(.96rem, 3.9vw, 1.06rem);
  line-height: 1.6;
  color: rgba(253, 246, 236, .9);
  -webkit-user-select: text;
  user-select: text;
}
.rpop-body::-webkit-scrollbar { display: none; }
.rpop-body p { margin: 0 0 .8em; }
.rpop-body p:last-child { margin-bottom: 0; }
.rpop-body em { font-family: var(--serif); font-style: italic; color: #ffd9e6; }
.rpop-body .w { display: inline-block; animation: word-in .55s var(--ease) both; animation-delay: calc(.4s + var(--i) * var(--step, 14ms)); }
@keyframes word-in {
  from { opacity: 0; transform: translateY(6px); filter: blur(4px); }
  to   { opacity: 1; transform: none; filter: none; }
}
.rpop-card .pill { margin-top: 4px; animation: rise .8s var(--ease) both var(--btn-d, 1s); }
.rpop-card.is-bonus { --c: #f5c76b; }
.rpop-card.is-bonus .rpop-title {
  background: linear-gradient(100deg, #e0a947, #fff1c9 40%, #f5c76b 60%, #ff9ec0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* The bonus balloon: a heart, bigger, gilded, and a little bit extra. */
.balloon.is-bonus svg { filter: drop-shadow(0 0 18px rgba(245, 199, 107, .65)) drop-shadow(0 10px 14px rgba(0, 0, 0, .25)); animation: bonus-glow 2.2s var(--ease-io) infinite; }
.balloon.is-bonus.is-popped svg { animation: pop .22s var(--ease) forwards; }
@keyframes bonus-glow {
  50% { filter: drop-shadow(0 0 30px rgba(245, 199, 107, .95)) drop-shadow(0 10px 14px rgba(0, 0, 0, .25)); }
}
.bonus-tag {
  position: absolute;
  left: 50%;
  top: 36%;
  transform: translate(-50%, -50%);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: #5a1630;
  background: linear-gradient(135deg, #fff1c9, #f5c76b);
  box-shadow: 0 2px 8px rgba(0, 0, 0, .25);
  pointer-events: none;
}
.balloon.is-popped .bonus-tag { opacity: 0; transition: opacity .15s; }
#balloonSub { transition: opacity .4s var(--ease); }
#balloonSub.is-swapping { opacity: 0; }

/* ===========================================================================
   7 · MEMORY LANE
   =========================================================================== */
.scene-memories { gap: 10px; }
.lane {
  position: relative;
  flex: none;
  width: 100vw;
  margin: 0 -16px;
  height: var(--laneH, 420px);
  touch-action: pan-y;
  cursor: grab;
  overflow: hidden;
}
.lane.is-dragging { cursor: grabbing; }
.lights { position: absolute; left: 0; top: 0; width: 100%; height: 90px; overflow: visible; pointer-events: none; }
.lights .wire { fill: none; stroke: rgba(253, 246, 236, .35); stroke-width: 1.3; }
.lights .bulb { animation: twinkle var(--t, 2s) var(--ease-io) infinite; animation-delay: var(--d, 0s); }
@keyframes twinkle {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}
.scene-memories.is-active .lights { animation: fade-in 1.2s var(--ease) both .3s; }

.lane-track { position: absolute; inset: 0; perspective: 1400px; }
.polaroid {
  position: absolute;
  left: 50%;
  top: 0;
  width: var(--cardW, 240px);
  margin: 0 0 0 calc(var(--cardW, 240px) / -2);
  transform-origin: 50% 0;
  will-change: transform, opacity;
}
.pol-pin {
  position: absolute;
  left: 50%;
  top: -16px;
  z-index: 2;
  width: 12px;
  height: 32px;
  margin-left: -6px;
  border-radius: 3px;
  background: linear-gradient(90deg, #b7835a, #dcae84 45%, #a8754d);
  box-shadow: 0 2px 4px rgba(0, 0, 0, .35);
}
.pol-pin::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: 13px;
  height: 3px;
  border-radius: 2px;
  background: #8a5d3c;
}
.pol-frame {
  display: block;
  padding: 10px 10px 0;
  border-radius: 4px;
  background: #fffdf8;
  box-shadow: 0 22px 40px -16px rgba(0, 0, 0, .65), 0 2px 6px rgba(0, 0, 0, .2);
}
.pol-img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: #2a1a24;
  filter: brightness(2.2) contrast(.45) sepia(.6) saturate(.3) blur(1px);
  transition: filter 2.2s var(--ease);
}
.polaroid.is-developed .pol-img { filter: none; }
.pol-cap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 4px 6px 6px;
  font-family: var(--hand);
  font-weight: 600;
  font-size: clamp(1.15rem, 4.8vw, 1.4rem);
  line-height: 1.1;
  color: #3a2533;
}
.lane-arrow {
  position: absolute;
  top: 46%;
  z-index: 5;
  display: none;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0 0 4px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .25);
  background: rgba(255, 255, 255, .1);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 1.8rem;
  line-height: 1;
  transition: transform .35s var(--spring), opacity .3s, background .3s;
}
.lane-arrow:hover { background: rgba(255, 255, 255, .2); transform: scale(1.08); }
.lane-arrow:active { transform: scale(.9); }
.lane-arrow:disabled { opacity: .25; pointer-events: none; }
.lane-arrow.is-prev { left: max(16px, calc(50% - var(--cardW) * 1.25 - 60px)); }
.lane-arrow.is-next { right: max(16px, calc(50% - var(--cardW) * 1.25 - 60px)); }
@media (hover: hover) and (pointer: fine) { .lane-arrow { display: grid; } }

.lane-dots { display: flex; gap: 8px; margin: 0; padding: 0; list-style: none; flex: none; }
.lane-dots li {
  width: 6px;
  height: 6px;
  border-radius: 6px;
  background: rgba(253, 246, 236, .3);
  transition: width .5s var(--spring), background .4s;
}
.lane-dots li.is-current { width: 18px; background: var(--gold); }
.scene-memories.is-active [data-next] { animation: rise 1s var(--ease) both 1s; }

/* ===========================================================================
   8 · THE LETTER
   =========================================================================== */
.scene-letter { gap: clamp(18px, 4vh, 40px); }
.envelope {
  position: relative;
  flex: none;
  width: min(80vw, 330px);
  aspect-ratio: 3 / 2;
  padding: 0;
  border: 0;
  background: none;
  perspective: 1000px;
  animation: env-float 4s var(--ease-io) infinite;
}
.scene-letter.is-active .envelope { animation: env-in 1.2s var(--spring-soft) both .2s, env-float 4s var(--ease-io) infinite 1.4s; }
@keyframes env-in { from { opacity: 0; transform: translateY(60px) rotate(-6deg) scale(.85); } }
@keyframes env-float {
  0%, 100% { transform: translateY(0) rotate(0); }
  50% { transform: translateY(-8px) rotate(-1deg); }
}
.envelope.is-open { animation: none !important; }
.envelope > span { position: absolute; display: block; }
.env-back {
  inset: 0;
  border-radius: 10px;
  background: linear-gradient(160deg, #d9a441, #b9832b);
  box-shadow: 0 30px 60px -25px rgba(0, 0, 0, .7), 0 0 60px -10px rgba(245, 199, 107, .45);
}
.env-paper {
  left: 7%;
  right: 7%;
  top: 7%;
  height: 86%;
  z-index: 2;
  border-radius: 6px;
  background: var(--cream);
  box-shadow: 0 -4px 14px rgba(0, 0, 0, .12);
  transition: transform 1s var(--ease);
}
.env-paper-lines {
  position: absolute;
  inset: 18% 12% 20%;
  background: repeating-linear-gradient(transparent 0 11px, rgba(58, 21, 48, .14) 11px 12px);
}
.env-front {
  inset: 0;
  z-index: 3;
  border-radius: 10px;
  background: linear-gradient(170deg, #f9d98e, #e9b252 70%, #dda040);
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
  box-shadow: inset 0 -10px 30px rgba(140, 90, 20, .25);
}
.env-flap {
  left: 0;
  right: 0;
  top: 0;
  height: 58%;
  z-index: 4;
  border-radius: 10px 10px 0 0;
  background: linear-gradient(180deg, #fbe2a4, #eebc5c);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transition: transform .8s var(--ease-io), z-index 0s .4s;
  filter: drop-shadow(0 4px 6px rgba(120, 70, 10, .3));
}
.env-seal {
  left: 50%;
  top: 58%;
  z-index: 5;
  display: grid !important;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #e0344f, #a0122b 70%, #7d0c20);
  box-shadow: 0 4px 10px rgba(80, 0, 15, .45), inset 0 -3px 6px rgba(0, 0, 0, .25), inset 0 2px 3px rgba(255, 255, 255, .25);
  transition: transform .5s var(--ease-in), opacity .4s;
}
.env-seal::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255, 210, 210, .35);
}
.env-seal svg { width: 24px; fill: #7d0c20; filter: drop-shadow(0 1px 0 rgba(255, 255, 255, .3)); }
.envelope:not(.is-open) .env-seal { animation: seal-pulse 2.4s var(--ease-io) infinite; }
@keyframes seal-pulse {
  0%, 100% { box-shadow: 0 4px 10px rgba(80, 0, 15, .45), 0 0 0 0 rgba(224, 52, 79, .5), inset 0 -3px 6px rgba(0, 0, 0, .25); }
  50% { box-shadow: 0 4px 10px rgba(80, 0, 15, .45), 0 0 0 12px rgba(224, 52, 79, 0), inset 0 -3px 6px rgba(0, 0, 0, .25); }
}
.envelope.is-open .env-seal { transform: scale(1.4) rotate(25deg); opacity: 0; }
.envelope.is-open .env-flap { transform: rotateX(180deg); z-index: 1; transition-delay: .3s, .7s; }
.envelope.is-out .env-paper { transform: translateY(-62%); }
.envelope.is-gone { transform: translateY(40px) scale(.9); opacity: 0; transition: transform .9s var(--ease), opacity .7s var(--ease); }
.envelope.is-gone .env-paper { opacity: 0; transition: opacity .2s; }
.env-hint { margin: 0; font-size: .8rem; letter-spacing: .14em; text-transform: uppercase; color: rgba(253, 246, 236, .6); animation: breathe 2.2s infinite; transition: opacity .4s; }
.scene-letter.is-opened .env-hint { opacity: 0; animation: none; }
.scene-letter .sub-head { transition: opacity .6s var(--ease), transform .6s var(--ease); }
.scene-letter.is-opened .sub-head { opacity: 0; transform: translateY(-12px); }
.scene-letter.is-opened .sub-head > * { animation: none; }

.sheet-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-t) + 66px) 16px calc(var(--safe-b) + 64px);
  background: rgba(26, 11, 30, 0);
  transition: background .8s var(--ease);
}
.sheet-layer.is-on { background: rgba(26, 11, 30, .55); }
.sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(100%, 560px);
  height: min(100%, 720px);
  padding: 26px 24px 18px;
  border-radius: 16px;
  color: var(--ink);
  background:
    radial-gradient(120% 60% at 50% 0%, rgba(255, 255, 255, .7), transparent),
    repeating-linear-gradient(transparent 0 33px, rgba(58, 21, 48, .07) 33px 34px),
    var(--cream);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .8), 0 0 0 1px rgba(245, 199, 107, .35);
  transform-origin: 0 0;
}
.sheet::before {
  /* a pressed gold rule down the left margin */
  content: "";
  position: absolute;
  left: 14px;
  top: 18px;
  bottom: 18px;
  width: 1px;
  background: rgba(224, 52, 79, .25);
}
.sheet-scroll { flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none; padding: 0 2px 0 10px; text-align: left; -webkit-user-select: text; user-select: text; }
.sheet-scroll::-webkit-scrollbar { display: none; }
.sheet-text {
  font-family: var(--hand);
  font-weight: 500;
  font-size: clamp(1.28rem, 5.2vw, 1.5rem);
  line-height: 34px;
  white-space: pre-wrap;
}
.sheet-text .caret {
  display: inline-block;
  width: 2px;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: -3px;
  background: var(--pink);
  animation: caret 1s steps(1) infinite;
}
@keyframes caret { 50% { opacity: 0; } }
.sheet-text .verse {
  display: block;
  margin: 0 0 14px;
  text-align: center;
  font-size: .94em;
  line-height: 30px;
  color: #8a1c4a;
}
.sheet-text .verse::before {
  content: "✦ ✦ ✦";
  display: block;
  margin-bottom: 6px;
  font-size: .6em;
  letter-spacing: .4em;
  color: var(--gold-deep);
}
.sheet-text .verse-line { display: block; text-wrap: balance; }
.sheet-text .verse-gap { display: block; height: 14px; }
.sheet-text .sign { display: block; margin-top: 10px; font-family: var(--script); font-size: 1.15em; color: #b0174a; }
.sheet-skip { margin: 8px 0 0; font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); opacity: .7; transition: opacity .4s; }
.sheet-close { align-self: center; margin-top: 10px; }
.sheet .is-waiting { display: none; }

/* ===========================================================================
   9 · FINALE
   =========================================================================== */
.scene-finale { padding-top: calc(var(--safe-t) + 56px); }
.fireworks { position: absolute; inset: 0; width: 100%; height: 100%; }
.finale-body { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.finale-title {
  margin: 0;
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(1.9rem, 8.6vw, 6.2rem);
  line-height: 1;
  letter-spacing: .02em;
  color: var(--cream);
  text-shadow: 0 0 30px rgba(255, 107, 157, .55), 0 0 60px rgba(245, 199, 107, .25);
  perspective: 600px;
  white-space: nowrap;
}
.finale-title .ch { opacity: 0; transform-origin: 50% 100%; }
.scene-finale.is-active .finale-title .ch { animation: drop-in 1.1s var(--spring) both; animation-delay: calc(.3s + var(--i) * .06s); }
@keyframes drop-in {
  from { opacity: 0; transform: translateY(-60px) rotateX(90deg) scale(.6); filter: blur(6px); }
  to   { opacity: 1; transform: none; filter: none; }
}
.finale-name {
  margin: 0;
  font-size: clamp(3.2rem, 17vw, 6.5rem);
  line-height: 1.15;
  background: linear-gradient(100deg, #e0a947 0%, #fff1c9 25%, #f5c76b 50%, #fff1c9 75%, #e0a947 100%);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 22px rgba(245, 199, 107, .6));
  opacity: 0;
}
.scene-finale.is-active .finale-name { animation: wish-in 1.4s var(--ease) both 1.3s, shimmer 4s linear infinite 2.6s; }
@keyframes shimmer { to { background-position: -200% 0; } }
.finale-made { margin: 4px 0 18px; font-size: .95rem; color: rgba(253, 246, 236, .78); opacity: 0; }
.scene-finale.is-active .finale-made { animation: rise 1s var(--ease) both 2.2s; }
.finale-actions { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.scene-finale.is-active #replay { animation: rise 1s var(--ease) both 2.5s; }

.prank-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 320px;
  padding: 12px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 77, 109, .55);
  background: linear-gradient(135deg, rgba(60, 8, 24, .85), rgba(30, 6, 22, .85));
  color: #ffd6de;
  font-size: .9rem;
  font-weight: 600;
  text-align: left;
  line-height: 1.3;
  opacity: 0;
  transform: translateY(16px) scale(.9);
  pointer-events: none;
  transition: opacity .8s var(--ease), transform .8s var(--spring);
}
.prank-btn small { display: block; font-weight: 400; font-size: .74rem; opacity: .7; }
.prank-btn.is-shown { opacity: 1; transform: none; pointer-events: auto; animation: prank-pulse 1.8s var(--ease-io) infinite .8s; }
.prank-btn:active { transform: scale(.95); }
.prank-lock { font-size: 1.2rem; display: inline-block; }
.prank-btn.is-shown .prank-lock { animation: lock-wiggle 2.6s var(--ease-io) infinite 1.2s; }
@keyframes prank-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 77, 109, .5), 0 10px 30px -10px rgba(255, 77, 109, .6); }
  50%      { box-shadow: 0 0 0 10px rgba(255, 77, 109, 0), 0 10px 30px -10px rgba(255, 77, 109, .6); }
}
@keyframes lock-wiggle {
  0%, 70%, 100% { transform: rotate(0); }
  75% { transform: rotate(-14deg); }
  82% { transform: rotate(12deg); }
  89% { transform: rotate(-6deg); }
}

/* ---------------------------------------------------------------------------
   The prank overlay
   --------------------------------------------------------------------------- */
.prank {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 3, 10, .72);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  animation: fade-in .4s var(--ease) both;
}
.prank-modal {
  position: relative;
  width: min(100%, 340px);
  padding: 26px 22px 22px;
  border-radius: 24px;
  text-align: center;
  background: linear-gradient(160deg, #2a0e1f, #170816);
  border: 1px solid rgba(255, 77, 109, .4);
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .9), 0 0 50px -10px rgba(255, 77, 109, .45);
  animation: modal-in .6s var(--spring) both;
}
@keyframes modal-in { from { opacity: 0; transform: scale(.8) translateY(20px); } }
.prank-modal.is-wobble { animation: wobble .6s var(--ease); }
@keyframes wobble {
  0%, 100% { transform: translateX(0) rotate(0); }
  15% { transform: translateX(-14px) rotate(-3deg); }
  30% { transform: translateX(12px) rotate(2.5deg); }
  45% { transform: translateX(-9px) rotate(-1.5deg); }
  60% { transform: translateX(6px) rotate(1deg); }
  75% { transform: translateX(-3px); }
}
.prank-warn { margin: 0; font-size: 2.4rem; animation: lock-wiggle 1.6s infinite; }
.prank-title { margin: 6px 0 4px; font-family: var(--serif); font-size: 1.5rem; color: #ff8fa3; }
.prank-q { margin: 0 0 20px; min-height: 1.5em; color: rgba(253, 246, 236, .85); transition: color .3s; }
.prank-q.is-liar { color: var(--gold); font-weight: 600; }
.prank-choices { position: relative; display: flex; flex-direction: column; gap: 10px; }
#prankNo { transition: transform .45s var(--spring); }

.decrypt { width: min(100%, 320px); text-align: left; font-family: ui-monospace, "SF Mono", Menlo, monospace; animation: modal-in .5s var(--spring) both; }
.decrypt-title { margin: 0 0 12px; font-size: .95rem; color: #ffd6de; }
.decrypt-bar { height: 8px; border-radius: 8px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.decrypt-bar span { display: block; height: 100%; width: 0; border-radius: inherit; background: linear-gradient(90deg, var(--pink), var(--gold)); box-shadow: 0 0 12px var(--pink); }
.decrypt-file { margin: 10px 0 0; font-size: .78rem; color: rgba(253, 246, 236, .55); }

.meme { position: relative; display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
.meme-stack { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.meme-img {
  display: block;
  width: auto;
  max-width: min(92vw, 520px);
  max-height: calc((var(--vh) - 300px) / 2);
  border-radius: 14px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .8);
  animation: slam .55s cubic-bezier(.5, 0, .75, 0) both var(--d, 0s);
}
@keyframes slam {
  0%   { transform: scale(3) rotate(-8deg); opacity: 0; }
  70%  { transform: scale(.94) rotate(1deg); opacity: 1; animation-timing-function: var(--ease); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.meme-caption {
  margin: 0;
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(2.6rem, 13vw, 4.5rem);
  line-height: 1;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #fff1c9;
  text-shadow: 0 0 18px rgba(255, 77, 109, .9), 0 0 50px rgba(255, 77, 109, .55), 0 4px 0 #8e0b25;
  animation: caption-slam .5s cubic-bezier(.5, 0, .75, 0) both var(--d, .75s);
}
.meme-caption:empty { display: none; }
@keyframes caption-slam {
  0%   { transform: scale(2.6) rotate(-6deg); opacity: 0; }
  70%  { transform: scale(.92) rotate(1deg); opacity: 1; animation-timing-function: var(--ease); }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.meme-flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.meme-flash.is-on { animation: flash .5s var(--ease) both; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }
.meme .pill { animation: rise .8s var(--ease) both var(--d, 1.6s); }
.prank.is-shaking { animation: shake .45s linear; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  10% { transform: translate(-12px, 6px) rotate(-1deg); }
  20% { transform: translate(10px, -8px) rotate(1deg); }
  30% { transform: translate(-8px, -4px); }
  40% { transform: translate(8px, 6px) rotate(.5deg); }
  50% { transform: translate(-6px, 2px); }
  60% { transform: translate(5px, -4px); }
  70% { transform: translate(-3px, 3px); }
  80% { transform: translate(2px, -1px); }
}

/* ---------------------------------------------------------------------------
   No JS
   --------------------------------------------------------------------------- */
.nojs { position: fixed; inset: 0; z-index: 200; display: grid; place-content: center; gap: 8px; padding: 24px; text-align: center; background: var(--plum-0); }
.nojs .script { font-size: 2.4rem; margin: 0; }

/* ---------------------------------------------------------------------------
   Reduced motion: keep the story, drop the theatrics. Everything still fades.
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
  }
  .scene, .scene.is-active, .scene.is-leaving { transform: none; filter: none; transition: opacity .5s ease, visibility 0s .5s; }
  .scene.is-active { transition: opacity .5s ease .1s, visibility 0s; }
  .aurora { display: none; }
  .pol-img { transition-duration: .4s; }
}
