:root {
  --blush: #ffd9e6;
  --blush-2: #ffc7dd;
  --lavender: #e3d3f7;
  --lavender-2: #d6c1f2;
  --peach: #ffe3d1;
  --rose: #f2b8c6;
  --cream: #fff7f0;
  --gold: #e8b86d;
  --gold-2: #f6d8a8;
  --ink: #5b3a4b;
  --ink-soft: #7a5566;
  --white-soft: #fffaf7;
  --night: #3c3160;
  --night-2: #6a5296;
  --card-ink: #5b3a4b;
  --card-ink-soft: #7a5566;
}

:root[data-theme="night"] {
  --blush: #2a2350;
  --blush-2: #3a3068;
  --lavender: #4b3f78;
  --lavender-2: #6a5296;
  --peach: #4a3560;
  --rose: #8f6fae;
  --cream: #1c1738;
  --gold: #f0c987;
  --gold-2: #ffe1a8;
  --ink: #f3ecff;
  --ink-soft: #cbb8e8;
  --white-soft: #fdf6ff;
  --night: #141026;
  --night-2: #241c46;
}

:root[data-theme="sunset"] {
  --blush: #ffd9a8;
  --blush-2: #ffc178;
  --lavender: #ffb199;
  --lavender-2: #ff9a76;
  --peach: #ffe3c2;
  --rose: #ff8a65;
  --cream: #fff4e0;
  --gold: #e08d3c;
  --gold-2: #f4b860;
  --ink: #5b3320;
  --ink-soft: #8a5a35;
  --white-soft: #fffaf0;
  --night: #3d2317;
  --night-2: #5c3a22;
}

:root[data-theme="playful"] {
  --blush: #ffd166;
  --blush-2: #ff8fa3;
  --lavender: #4ecdc4;
  --lavender-2: #7bdff2;
  --peach: #ffa69e;
  --rose: #ff6b9d;
  --cream: #fff8e7;
  --gold: #f7b731;
  --gold-2: #ffd93d;
  --ink: #2d3047;
  --ink-soft: #585b70;
  --white-soft: #ffffff;
  --night: #241b4e;
  --night-2: #3a2b7a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior-y: none;
  background: var(--cream);
  color: var(--ink);
  font-family: 'Quicksand', sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  max-width: 100vw;
  overflow-x: hidden;
  transition: background 0.4s ease, color 0.4s ease;
}

button {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  font-family: inherit;
}

/* ---------- theme change flash ---------- */
body.theme-flash::after {
  content: '';
  position: fixed;
  inset: 0;
  background: var(--white-soft);
  opacity: 0;
  pointer-events: none;
  z-index: 70;
  animation: themeFlash 0.5s ease;
}
@keyframes themeFlash {
  0% { opacity: 0; }
  40% { opacity: 0.5; }
  100% { opacity: 0; }
}

.script-title {
  font-family: 'Great Vibes', cursive;
  font-weight: 400;
  line-height: 1.25;
  margin: 0 0 0.4em;
  color: var(--ink);
}

h1.script-title { font-size: clamp(2.2rem, 7vw, 3.6rem); }
h2.script-title { font-size: clamp(2rem, 6vw, 3rem); }

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ink-soft);
  opacity: 0.75;
  margin: 0 0 0.8em;
}

.chapter-text, .reveal-text {
  font-size: clamp(1rem, 2.4vw, 1.15rem);
  line-height: 1.7;
  max-width: 34em;
  margin: 0 auto 1em;
  color: var(--ink);
}

.chapter-date {
  font-size: 0.9rem;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  margin: -0.4em 0 1.4em;
}

.reveal-text {
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.7s ease, transform 0.7s ease;
  font-weight: 600;
}
.reveal-text.visible { opacity: 1; transform: translateY(0); }

/* ---------- petals ---------- */
.petal-field {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}
.petal {
  position: absolute;
  top: -5vh;
  border-radius: 0% 100% 0% 100%;
  opacity: 0.75;
  animation: drift linear forwards;
  will-change: transform, opacity;
}
@keyframes drift {
  0%   { transform: translate(0, 0) rotate(0deg); opacity: 0; }
  8%   { opacity: 0.75; }
  100% { transform: translate(var(--drift-x), 115vh) rotate(300deg); opacity: 0; }
}

/* ---------- scroll progress bar ---------- */
.progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, var(--rose), var(--lavender-2), var(--gold));
  z-index: 60;
  transition: width 0.15s ease-out;
}

/* ---------- floating control buttons (theme / music) ---------- */
.control-stack {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 55;
  display: flex;
  flex-direction: column;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
  padding-top: env(safe-area-inset-top);
}
.control-stack.visible { opacity: 1; pointer-events: auto; }
.control-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(6px);
  box-shadow: 0 6px 16px -8px rgba(0,0,0,0.35);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.25s ease, background 0.3s ease;
}
.control-btn:active { transform: scale(0.9); }

.theme-toast {
  position: fixed;
  left: 12px;
  top: 60px;
  z-index: 55;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(6px);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--ink);
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  pointer-events: none;
  margin-top: env(safe-area-inset-top);
}
.theme-toast.show { opacity: 1; transform: translateY(0); }

/* ---------- progress dots ---------- */
.dots {
  position: fixed;
  right: 18px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  gap: 12px;
  opacity: 0;
  transition: opacity 0.6s ease;
  pointer-events: none;
}
.dots.visible { opacity: 1; pointer-events: auto; }
.dots button {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  border: 1px solid var(--ink-soft);
  background: transparent;
  padding: 0;
  cursor: pointer;
  opacity: 0.5;
  transition: all 0.3s ease;
}
.dots button.active {
  background: var(--rose);
  border-color: var(--rose);
  opacity: 1;
  transform: scale(1.3);
}
@media (max-width: 640px) {
  .dots { right: 8px; gap: 9px; }
  .dots button { width: 7px; height: 7px; }
}

/* ---------- cover / envelope ---------- */
.cover {
  position: fixed;
  inset: 0;
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  height: 100dvh;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--cream), var(--blush) 70%);
  background-size: 160% 160%;
  animation: driftGradient 14s ease-in-out infinite;
  transition: opacity 1s ease, visibility 1s ease;
}
.cover.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

@keyframes driftGradient {
  0%, 100% { background-position: 0% 0%; }
  50% { background-position: 60% 40%; }
}

.cover-inner {
  text-align: center;
  padding: 0 max(24px, env(safe-area-inset-right)) 0 max(24px, env(safe-area-inset-left));
}
.cover-label {
  font-family: 'Great Vibes', cursive;
  font-size: 1.6rem;
  color: var(--ink-soft);
  margin: 0 0 28px;
  letter-spacing: 0.03em;
}

.envelope {
  position: relative;
  width: 220px;
  height: 148px;
  margin: 0 auto 40px;
  perspective: 800px;
}
.envelope-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, var(--white-soft), var(--blush));
  border-radius: 8px;
  box-shadow: 0 18px 40px -18px rgba(0, 0, 0, 0.45);
}
.letter {
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 6%;
  top: 10%;
  background: var(--white-soft);
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px;
  opacity: 0;
  transform: translateY(16px);
  transition: transform 1.1s cubic-bezier(.2,.9,.3,1) 0.5s, opacity 0.8s ease 0.5s;
  z-index: 1;
}
.letter p { margin: 0 0 6px; font-size: 0.85rem; line-height: 1.4; color: var(--ink); }
.letter-sub { font-family: 'Great Vibes', cursive; font-size: 1.1rem; color: var(--rose); }

.envelope-flap {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 78px;
  background: linear-gradient(200deg, var(--blush-2), var(--lavender));
  clip-path: polygon(0 0, 100% 0, 50% 88%);
  transform-origin: top center;
  transition: transform 0.9s cubic-bezier(.3,.8,.3,1);
  z-index: 3;
  border-radius: 8px 8px 0 0;
}
.envelope-seal {
  position: absolute;
  top: 58px;
  left: 50%;
  width: 34px;
  height: 34px;
  transform: translate(-50%, 0);
  background: radial-gradient(circle at 35% 30%, var(--rose), #d98ca4);
  border-radius: 50%;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  z-index: 4;
  transition: opacity 0.4s ease, transform 0.6s ease;
}
.envelope-seal::after {
  content: '\2764';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--white-soft);
  font-size: 0.85rem;
}

.envelope.open .envelope-flap { transform: rotateX(150deg); }
.envelope.open .envelope-seal { opacity: 0; transform: translate(-50%, -10px) scale(0.6); }
.envelope.open .letter { opacity: 1; transform: translateY(-56px); }

.open-btn, .replay-btn {
  font-family: 'Quicksand', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  letter-spacing: 0.03em;
  padding: 12px 34px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(120deg, var(--rose), var(--lavender-2));
  color: var(--white-soft);
  cursor: pointer;
  box-shadow: 0 10px 24px -10px rgba(0,0,0,0.55);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.open-btn:hover, .replay-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 28px -10px rgba(0,0,0,0.6); }
.open-btn:active, .replay-btn:active { transform: translateY(0); }

/* ---------- story scroll container ---------- */
.story {
  height: 100%;
  height: calc(var(--vh, 1vh) * 100);
  height: 100dvh;
  overflow-y: scroll;
  overflow-x: hidden;
  overscroll-behavior-y: contain;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

.chapter {
  min-height: 100%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: 60px max(24px, env(safe-area-inset-right)) 60px max(24px, env(safe-area-inset-left));
  text-align: center;
  background: linear-gradient(160deg, var(--cream), var(--blush) 90%);
  transition: background 0.3s ease;
}
#ch1 { background: linear-gradient(160deg, var(--blush), var(--lavender) 90%); }
#ch2 { background: linear-gradient(160deg, var(--lavender), var(--blush-2) 90%); }
#ch3 { background: linear-gradient(160deg, var(--rose), var(--peach) 90%); }
#ch4 { background: linear-gradient(160deg, var(--night), var(--night-2) 90%); }
#ch4 .script-title, #ch4 .eyebrow, #ch4 .chapter-text { color: var(--white-soft); }
#ch4 .eyebrow { opacity: 0.85; }
#ch5 { background: linear-gradient(160deg, var(--peach), var(--cream) 90%); }
.finale-chapter {
  background: linear-gradient(160deg, var(--gold-2), var(--rose) 85%);
  background-size: 160% 160%;
  animation: driftGradient 16s ease-in-out infinite;
}

.chapter-inner {
  position: relative;
  z-index: 2;
  max-width: 640px;
  width: 100%;
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
.chapter-inner.visible { opacity: 1; transform: translateY(0); }

.scroll-hint, .next-chapter-btn {
  margin-top: 30px;
  font-size: 1.6rem;
  color: var(--ink-soft);
  background: none;
  border: none;
  cursor: pointer;
  animation: bob 2.2s ease-in-out infinite;
  display: block;
  margin-left: auto;
  margin-right: auto;
  padding: 8px 20px;
}
@keyframes bob { 0%,100% { transform: translateY(0); opacity: 0.5; } 50% { transform: translateY(10px); opacity: 1; } }

.tap-hint {
  display: block;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  opacity: 0.7;
  margin-top: 6px;
}

/* ---------- flip card ---------- */
.flip-card {
  background: none;
  border: none;
  cursor: pointer;
  perspective: 900px;
  width: min(320px, 82vw);
  height: 175px;
  margin: 10px auto 22px;
  padding: 0;
}
.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  display: block;
  transform-style: preserve-3d;
  transition: transform 0.8s cubic-bezier(.3,.8,.3,1);
}
.flip-card.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 16px;
  background: var(--white-soft);
  box-shadow: 0 12px 30px -14px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 18px;
  font-weight: 600;
  color: var(--card-ink);
}
.flip-face .tap-hint { color: var(--card-ink-soft); }
.flip-back {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, var(--white-soft), var(--rose));
  font-family: 'Great Vibes', cursive;
  font-size: 1.3rem;
  line-height: 1.35;
  font-weight: 400;
}

/* ---------- gift box + ring emoji ---------- */
.gift-box {
  position: relative;
  width: 130px;
  height: 110px;
  margin: 14px auto 22px;
  background: none;
  border: none;
  cursor: pointer;
}
.gift-base {
  position: absolute;
  left: 10px; right: 10px; bottom: 0;
  height: 62px;
  background: linear-gradient(160deg, var(--rose), var(--gold));
  border-radius: 6px;
  box-shadow: 0 12px 24px -12px rgba(0,0,0,0.5);
}
.gift-ribbon {
  position: absolute;
  left: 50%; bottom: 0;
  width: 14px; height: 62px;
  background: var(--white-soft);
  transform: translateX(-50%);
  opacity: 0.9;
}
.gift-lid {
  position: absolute;
  left: 4px; right: 4px; bottom: 58px;
  height: 22px;
  background: linear-gradient(160deg, var(--gold), var(--rose));
  border-radius: 6px;
  transform-origin: bottom center;
  transition: transform 0.6s cubic-bezier(.3,.8,.3,1), opacity 0.6s ease;
  box-shadow: 0 6px 14px -8px rgba(0,0,0,0.5);
}
.ring-icon {
  position: absolute;
  left: 50%; bottom: 62px;
  transform: translateX(-50%) scale(0) rotate(-30deg);
  opacity: 0;
  font-size: 2.4rem;
  line-height: 1;
  transition: transform 0.8s cubic-bezier(.3,1.7,.3,1) 0.25s, opacity 0.4s ease 0.25s;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.35));
}
.gift-box.open .gift-lid { transform: translateY(-46px) scale(1.05); opacity: 0; }
.gift-box.open .ring-icon { transform: translateX(-50%) scale(1) rotate(0deg); opacity: 1; animation: ringShine 1.8s ease 1s 1; }
@keyframes ringShine {
  0%, 100% { filter: drop-shadow(0 6px 10px rgba(0,0,0,0.35)) brightness(1); }
  50% { filter: drop-shadow(0 6px 14px rgba(232,184,109,0.7)) brightness(1.35); }
}

/* ---------- chapter 1: meet scene (real photos) ---------- */
.meet-scene {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 34px;
  width: 100%;
  max-width: 300px;
  margin: 14px auto 4px;
  padding: 12px;
  position: relative;
}
.photo-figure {
  height: 175px;
  width: auto;
  max-width: 45%;
  object-fit: contain;
  filter: drop-shadow(0 10px 16px rgba(0,0,0,0.3));
  transition: transform 0.9s cubic-bezier(.3,.8,.3,1);
  transform: translateX(0);
}
.meet-scene.together .photo-anjali { transform: translateX(20px); }
.meet-scene.together .photo-mayur { transform: translateX(-20px); }
.photo-spark {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  color: var(--gold);
  font-size: 1.3rem;
  opacity: 0;
  transition: transform 0.5s cubic-bezier(.3,1.6,.4,1) 0.7s, opacity 0.4s ease 0.7s;
}
.meet-scene.together .photo-spark { transform: translate(-50%, -50%) scale(1); opacity: 1; }
.meet-scene .tap-hint { flex-basis: 100%; margin-top: 8px; }

/* ---------- chapter 4: garden + bike + stars ---------- */
.garden {
  background: none;
  border: none;
  cursor: pointer;
  display: block;
  margin: 8px auto 18px;
  padding: 14px 26px;
  color: var(--white-soft);
}
.garden-emoji {
  display: inline-block;
  font-size: 2.4rem;
  transition: transform 0.5s cubic-bezier(.3,1.6,.4,1);
}
.garden.bloom .garden-emoji { transform: scale(1.35) rotate(-6deg); }
.garden-caption {
  display: block;
  margin-top: 8px;
  font-size: 0.85rem;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.6s ease, transform 0.6s ease;
}
.garden.bloom .garden-caption { opacity: 0.9; transform: translateY(0); }

.bike-track {
  position: relative;
  width: 100%;
  max-width: 420px;
  height: 40px;
  margin: 10px auto 0;
  overflow: hidden;
}
.bike {
  position: absolute;
  left: -10%;
  top: 0;
  font-size: 1.6rem;
  animation: ride 9s ease-in-out infinite alternate;
}
@keyframes ride { 0% { left: -8%; } 100% { left: 92%; } }

.stars {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}
.stars::before, .stars::after {
  content: '';
  position: absolute;
  width: 2px; height: 2px;
  background: transparent;
  box-shadow:
    10% 15% var(--white-soft), 22% 40% var(--white-soft), 35% 8% var(--white-soft),
    48% 55% var(--white-soft), 60% 22% var(--white-soft), 72% 68% var(--white-soft),
    85% 12% var(--white-soft), 92% 45% var(--white-soft), 15% 75% var(--white-soft),
    30% 88% var(--white-soft), 55% 78% var(--white-soft), 78% 90% var(--white-soft),
    5% 92% var(--white-soft), 65% 5% var(--white-soft), 40% 30% var(--white-soft);
  animation: twinkle 3.5s ease-in-out infinite alternate;
}
.stars::after { animation-delay: 1.2s; opacity: 0.5; }
@keyframes twinkle { 0% { opacity: 0.3; } 100% { opacity: 1; } }

/* ---------- chapter 5: together scene (circular photo) ---------- */
.together-scene {
  background: none;
  border: none;
  cursor: pointer;
  display: block;
  margin: 14px auto 4px;
  padding: 10px;
}
.circle-photo {
  position: relative;
  display: block;
  width: 150px;
  height: 150px;
  margin: 0 auto;
  border-radius: 50%;
  overflow: hidden;
  border: 4px solid var(--white-soft);
  box-shadow: 0 12px 28px -12px rgba(0,0,0,0.4);
  transition: transform 0.6s cubic-bezier(.3,1.6,.4,1), box-shadow 0.6s ease;
}
.circle-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.together-scene.merged .circle-photo { transform: scale(1.08); box-shadow: 0 18px 34px -10px rgba(232,184,109,0.6); }
.circle-photo-ring {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid var(--gold);
  opacity: 0;
}
.together-scene.merged .circle-photo-ring { animation: ringPulse 1.4s ease 1; }
@keyframes ringPulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  100% { transform: scale(1.3); opacity: 0; }
}
.together-scene .tap-hint { margin-top: 8px; }

/* ---------- finale: idle photo ---------- */
.finale-photo {
  width: 100px;
  height: 100px;
  margin: 6px auto 0;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid var(--white-soft);
  box-shadow: 0 10px 22px -10px rgba(0,0,0,0.45);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 1s ease, transform 1s ease;
}
.finale-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.finale-photo.visible { opacity: 1; animation: idleFloat 3.2s ease-in-out infinite; }
@keyframes idleFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

/* ---------- finale ---------- */
.finale-chapter { color: var(--card-ink); }
.finale-chapter .eyebrow { transition: opacity 0.6s ease; color: var(--card-ink-soft); }
.finale-chapter .eyebrow.hide { opacity: 0; }
.finale-chapter .tap-hint { color: var(--card-ink-soft); }

.cake {
  position: relative;
  width: 140px;
  height: 110px;
  margin: 10px auto 6px;
  cursor: pointer;
}
.cake-tier {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 8px;
  background: linear-gradient(160deg, var(--white-soft), var(--blush-2));
  box-shadow: 0 10px 20px -12px rgba(0,0,0,0.5);
}
.tier-bottom { width: 130px; height: 46px; bottom: 0; }
.tier-top { width: 92px; height: 38px; bottom: 40px; background: linear-gradient(160deg, var(--white-soft), var(--rose)); }
.candle {
  position: absolute;
  left: 50%;
  bottom: 78px;
  width: 8px;
  height: 26px;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  transform: translateX(-50%);
  border-radius: 2px;
}
.flame {
  position: absolute;
  left: 50%;
  bottom: 100%;
  width: 12px;
  height: 18px;
  transform: translateX(-50%);
  background: radial-gradient(circle at 50% 70%, #fff2c4, #f6a63c 60%, #e8622a);
  border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%;
  animation: flicker 0.4s ease-in-out infinite alternate;
  transform-origin: bottom center;
  transition: opacity 0.4s ease, transform 0.4s ease;
}
@keyframes flicker {
  0% { transform: translateX(-50%) scale(1, 1) rotate(-2deg); }
  100% { transform: translateX(-50%) scale(0.92, 1.08) rotate(3deg); }
}
.flame.out {
  opacity: 0;
  transform: translateX(-50%) scale(0.4, 0.2) translateY(6px);
  animation: none;
}
#cakeHint.hide { opacity: 0; }

.finale-title {
  font-family: 'Pacifico', cursive;
  font-size: clamp(1.9rem, 6.5vw, 3.2rem);
  color: var(--card-ink);
  min-height: 1.5em;
  margin: 18px 0 10px;
  text-shadow: 0 2px 12px rgba(255,255,255,0.5);
}
.finale-message {
  opacity: 0;
  transform: translateY(14px);
  transition: opacity 1s ease, transform 1s ease;
  max-width: 34em;
  margin: 0 auto;
  color: var(--card-ink);
}
.finale-message.visible { opacity: 1; transform: translateY(0); }
.finale-message p { margin: 0 0 0.9em; line-height: 1.7; }
.finale-message .signature {
  font-family: 'Pacifico', cursive;
  font-size: 1.4rem;
  margin-top: 0.6em;
}
.replay-btn {
  margin-top: 22px;
  opacity: 0;
  transition: opacity 1s ease 0.3s;
  pointer-events: none;
}
.replay-btn.visible { opacity: 1; pointer-events: auto; }

/* ---------- finale: floating balloons + hearts ---------- */
.finale-decor {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}
.fd {
  position: absolute;
  bottom: -60px;
  opacity: 0;
  font-size: 1.8rem;
  animation: floatUp 7s ease-in infinite;
}
.fd-heart { font-size: 1.3rem; }
.fd-1 { left: 6%;  animation-delay: 0s;    --sway: 26px; }
.fd-2 { left: 20%; animation-delay: 1.3s;  --sway: -18px; font-size: 1.5rem; }
.fd-3 { left: 36%; animation-delay: 2.6s;  --sway: 16px; }
.fd-4 { left: 58%; animation-delay: 0.7s;  --sway: -24px; font-size: 2rem; }
.fd-5 { left: 74%; animation-delay: 2s;    --sway: 20px; }
.fd-6 { left: 88%; animation-delay: 3.4s;  --sway: -14px; font-size: 1.7rem; }
@keyframes floatUp {
  0% { transform: translateY(0) translateX(0) rotate(0deg); opacity: 0; }
  12% { opacity: 0.9; }
  85% { opacity: 0.85; }
  100% { transform: translateY(-70vh) translateX(var(--sway, 20px)) rotate(10deg); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .finale-decor { display: none; }
}

#confettiCanvas {
  position: fixed;
  inset: 0;
  z-index: 40;
  pointer-events: none;
}

/* ---------- tap sparkle trail ---------- */
.tap-sparkle {
  position: fixed;
  z-index: 45;
  pointer-events: none;
  font-size: 1.1rem;
  color: var(--rose);
  transform: translate(-50%, -50%);
  animation: sparkleUp 0.9s ease-out forwards;
}
@keyframes sparkleUp {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(0.6); }
  100% { opacity: 0; transform: translate(-50%, calc(-50% - 34px)) scale(1.15); }
}

@media (max-width: 480px) {
  .chapter { padding: 44px 18px; }
  .envelope { width: 180px; height: 128px; }
  .meet-scene { max-width: 220px; }
  .photo-figure { height: 140px; }
  .circle-photo { width: 130px; height: 130px; }
  .finale-photo { width: 84px; height: 84px; }
}

@media (max-width: 360px) {
  .photo-figure { height: 120px; }
  .circle-photo { width: 116px; height: 116px; }
  .control-btn { width: 36px; height: 36px; font-size: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .bike { animation: none; left: 40%; }
  .stars::before, .stars::after { animation: none; opacity: 0.7; }
  .flame { animation: none; }
  .petal { animation-duration: 1ms !important; }
  .cover, .finale-chapter { animation: none; }
  .finale-photo.visible { animation: none; }
  .tap-sparkle { animation-duration: 0.01ms; }
  .scroll-hint, .next-chapter-btn { animation: none; }
  body.theme-flash::after { animation: none; }
  .ring-icon { animation: none !important; }
}
