:root {
  --ink: #562139;
  --muted: #8c5a70;
  --pink: #ff6f9c;
  --pink-dark: #dd4778;
  --blush: #fff0f5;
  --cream: #fffaf2;
  --yellow: #ffd76e;
  --paper: rgba(255, 255, 255, 0.82);
  --shadow: 0 22px 70px rgba(128, 40, 75, 0.16);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 10%, rgba(255, 215, 110, 0.42), transparent 24rem),
    radial-gradient(circle at 88% 20%, rgba(255, 130, 171, 0.26), transparent 26rem),
    linear-gradient(145deg, var(--cream), var(--blush));
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.65;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 4px;
}

[hidden] {
  display: none !important;
}

.sparkles {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

.sparkles span {
  position: absolute;
  color: rgba(255, 111, 156, 0.34);
  font-size: clamp(1rem, 2.5vw, 2.2rem);
  animation: float 6s ease-in-out infinite;
}

.sparkles span:nth-child(1) { left: 7%; top: 14%; }
.sparkles span:nth-child(2) { left: 84%; top: 10%; animation-delay: -1s; }
.sparkles span:nth-child(3) { left: 17%; top: 72%; animation-delay: -2.5s; }
.sparkles span:nth-child(4) { left: 89%; top: 76%; animation-delay: -4s; }
.sparkles span:nth-child(5) { left: 68%; top: 46%; animation-delay: -3s; }
.sparkles span:nth-child(6) { left: 31%; top: 43%; animation-delay: -5s; }
.sparkles span:nth-child(7) { left: 4%; top: 91%; animation-delay: -1.5s; }
.sparkles span:nth-child(8) { left: 94%; top: 92%; animation-delay: -3.5s; }

.cover {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding:
    max(1.5rem, env(safe-area-inset-top))
    max(1.5rem, env(safe-area-inset-right))
    max(1.5rem, env(safe-area-inset-bottom))
    max(1.5rem, env(safe-area-inset-left));
}

.cover-card {
  width: min(100%, 34rem);
  padding: clamp(2rem, 7vw, 4.5rem) clamp(1.4rem, 7vw, 4rem);
  text-align: center;
  background: var(--paper);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 2.2rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

h1,
h2,
p {
  margin-top: 0;
}

h1,
h2 {
  line-height: 1.08;
  letter-spacing: -0.035em;
}

.cover h1 {
  margin: 0.5rem 0 0.6rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 12vw, 5.7rem);
  color: var(--pink-dark);
}

.cover-copy {
  margin-bottom: 2rem;
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 0.75rem;
  color: var(--pink-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.song-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 3.2rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  box-shadow: 0 12px 30px rgba(221, 71, 120, 0.28);
  color: white;
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

.song-button:hover {
  transform: translateY(-3px) rotate(-1deg);
  box-shadow: 0 17px 34px rgba(221, 71, 120, 0.35);
}

.envelope-button {
  display: grid;
  justify-items: center;
  width: 100%;
  padding: 1rem 0 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.envelope-button:disabled {
  cursor: default;
}

.envelope {
  position: relative;
  width: min(17rem, 72vw);
  aspect-ratio: 1.48;
  border-radius: 0.5rem;
  background: #f48cab;
  filter: drop-shadow(0 18px 20px rgba(128, 40, 75, 0.2));
  perspective: 900px;
  transition: transform 250ms ease;
}

.envelope-button:not(:disabled):hover .envelope {
  transform: translateY(-5px) rotate(-1deg);
}

.letter-preview {
  position: absolute;
  inset: 9% 8% 7%;
  z-index: 2;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 1rem;
  border: 1px solid #f6d5df;
  border-radius: 0.35rem;
  background:
    repeating-linear-gradient(0deg, transparent 0 25px, rgba(221, 71, 120, 0.08) 26px),
    #fffdf8;
  box-shadow: 0 5px 14px rgba(128, 40, 75, 0.13);
  color: var(--pink-dark);
  font-family: Georgia, "Times New Roman", serif;
  transform: translateY(0);
  transition: transform 850ms cubic-bezier(0.22, 0.8, 0.28, 1) 380ms;
}

.letter-preview strong {
  font-size: clamp(1.45rem, 6vw, 2rem);
}

.letter-preview small {
  margin-top: 0.35rem;
  color: var(--muted);
  font-family: "Segoe Print", "Comic Sans MS", cursive;
}

.envelope-pocket {
  position: absolute;
  inset: 0;
  z-index: 3;
  border-radius: 0 0 0.5rem 0.5rem;
  background: linear-gradient(145deg, #ffb3c8, #f27fa3);
  clip-path: polygon(0 0, 50% 52%, 100% 0, 100% 100%, 0 100%);
}

.envelope-flap {
  position: absolute;
  inset: 0;
  z-index: 4;
  border-radius: 0.5rem 0.5rem 0 0;
  background: linear-gradient(155deg, #ffc4d4, #f993b2);
  clip-path: polygon(0 0, 100% 0, 50% 62%);
  transform-origin: 50% 0;
  transition: transform 600ms cubic-bezier(0.3, 0.7, 0.3, 1), z-index 0ms 300ms;
}

.envelope-seal {
  position: absolute;
  top: 49%;
  left: 50%;
  z-index: 5;
  display: grid;
  width: 3.15rem;
  aspect-ratio: 1;
  place-items: center;
  border: 4px solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: var(--pink-dark);
  box-shadow: 0 6px 14px rgba(128, 40, 75, 0.2);
  color: white;
  font-size: 1.3rem;
  transform: translate(-50%, -50%);
  transition: opacity 180ms ease 180ms, transform 220ms ease 180ms;
}

.open-hint {
  margin-top: 1.5rem;
  color: var(--pink-dark);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cover.opening .envelope-flap {
  z-index: 1;
  transform: rotateX(180deg);
}

.cover.opening .envelope-seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.55);
}

.cover.opening .letter-preview {
  z-index: 5;
  transform: translateY(-52%) rotate(-2deg) scale(1.04);
}

.cover.opening .open-hint {
  opacity: 0;
}

.quiz-screen {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding:
    max(1.5rem, env(safe-area-inset-top))
    max(1.5rem, env(safe-area-inset-right))
    max(1.5rem, env(safe-area-inset-bottom))
    max(1.5rem, env(safe-area-inset-left));
}

.quiz-card {
  position: relative;
  width: min(100%, 40rem);
  min-height: 31rem;
  overflow: hidden;
  padding: clamp(1.6rem, 6vw, 3.6rem);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 2rem;
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.quiz-progress {
  height: 0.55rem;
  margin: 0.7rem 0 2.6rem;
  overflow: hidden;
  border-radius: 999px;
  background: #f5dce5;
}

.quiz-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pink), var(--yellow));
  transition: width 450ms ease;
}

.quiz-card h2 {
  margin-bottom: 1.8rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 7vw, 3.5rem);
}

.answer-grid {
  display: grid;
  gap: 0.8rem;
}

.answer-grid button,
.fill-answer button {
  min-height: 3.2rem;
  padding: 0.8rem 1.1rem;
  border: 2px solid #f3c8d6;
  border-radius: 1rem;
  background: white;
  color: var(--ink);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.answer-grid button:hover,
.fill-answer button:hover {
  border-color: var(--pink);
  background: var(--blush);
  transform: translateY(-2px);
}

.fill-answer label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 750;
}

.fill-answer > div {
  display: flex;
  gap: 0.65rem;
}

.fill-answer input {
  min-width: 0;
  flex: 1;
  padding: 0.8rem 1rem;
  border: 2px solid #f3c8d6;
  border-radius: 1rem;
  background: white;
  color: var(--ink);
  font: inherit;
}

.fill-answer input:focus {
  border-color: var(--pink);
  outline: 3px solid rgba(255, 111, 156, 0.18);
}

.fill-answer button {
  background: var(--pink-dark);
  border-color: var(--pink-dark);
  color: white;
}

.quiz-feedback {
  min-height: 1.7rem;
  margin: 1.2rem 0 0;
  color: var(--pink-dark);
  font-weight: 750;
}

.quiz-feedback.wrong {
  color: #a74747;
}

.answer-celebration {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: inherit;
  visibility: hidden;
  pointer-events: none;
}

.answer-celebration.play {
  visibility: visible;
}

.celebration-ring {
  position: absolute;
  width: 6rem;
  aspect-ratio: 1;
  border: 0.35rem solid rgba(255, 111, 156, 0.75);
  border-radius: 50%;
  opacity: 0;
}

.answer-celebration.play .ring-one {
  animation: celebration-ring 900ms ease-out forwards;
}

.answer-celebration.play .ring-two {
  animation: celebration-ring 900ms 140ms ease-out forwards;
}

.celebration-core {
  z-index: 2;
  display: grid;
  width: 9rem;
  aspect-ratio: 1;
  place-content: center;
  border: 0.4rem solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  background: linear-gradient(145deg, #ff7ba5, var(--pink-dark));
  box-shadow: 0 20px 50px rgba(128, 40, 75, 0.35);
  color: white;
  opacity: 0;
  transform: scale(0.15) rotate(-18deg);
}

.celebration-core strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.75rem;
  line-height: 1;
}

.celebration-core small {
  margin-top: 0.45rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.answer-celebration.play .celebration-core {
  animation: celebration-core 1.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.celebration-particles,
.celebration-particles span {
  position: absolute;
  top: 50%;
  left: 50%;
}

.celebration-particles span {
  color: var(--particle-color, var(--pink-dark));
  font-size: var(--particle-size, 1.5rem);
  line-height: 1;
  text-shadow: 0 3px 9px rgba(255, 255, 255, 0.95);
  opacity: 0;
}

.answer-celebration.play .celebration-particles span {
  animation: celebration-particle 1s var(--delay) cubic-bezier(0.12, 0.8, 0.25, 1) forwards;
}

.quiz-card.celebrating {
  animation: quiz-card-celebrate 1.2s ease;
}

.quiz-card.celebrating .quiz-progress {
  animation: progress-celebrate 1s ease;
}

.correct-choice {
  border-color: var(--pink-dark) !important;
  background: linear-gradient(135deg, var(--pink-dark), var(--pink)) !important;
  box-shadow: 0 10px 28px rgba(221, 71, 120, 0.28);
  color: white !important;
  transform: scale(1.03) !important;
}

.question-enter {
  animation: question-enter 420ms cubic-bezier(0.22, 1, 0.36, 1);
}

.quiz-screen.leaving {
  pointer-events: none;
  animation: quiz-screen-out 600ms ease forwards;
}

.quiz-screen.leaving .quiz-card {
  animation: quiz-card-out 600ms cubic-bezier(0.55, 0, 1, 0.45) forwards;
}

.page-transition {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  overflow: hidden;
  place-items: center;
  background:
    radial-gradient(circle at center, rgba(255, 255, 255, 0.22), transparent 35%),
    linear-gradient(145deg, #ff86ab, #dc3f74);
  clip-path: circle(0 at 50% 50%);
  pointer-events: none;
}

.page-transition.covering {
  animation: transition-cover 650ms cubic-bezier(0.76, 0, 0.24, 1) forwards;
}

.page-transition.uncovering {
  clip-path: circle(150% at 50% 50%);
  animation: transition-uncover 800ms cubic-bezier(0.76, 0, 0.24, 1) forwards;
}

.transition-message {
  position: relative;
  z-index: 2;
  display: grid;
  justify-items: center;
  padding: 2rem;
  color: white;
  text-align: center;
  opacity: 0;
  transform: translateY(2rem) scale(0.88);
}

.covering .transition-message {
  animation: transition-message-in 480ms 170ms cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.uncovering .transition-message {
  animation: transition-message-out 430ms ease forwards;
}

.transition-heart {
  display: grid;
  width: 6.5rem;
  aspect-ratio: 1;
  margin-bottom: 1rem;
  place-items: center;
  border: 0.35rem solid rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  box-shadow: 0 18px 45px rgba(86, 33, 57, 0.25);
  font-size: 3rem;
  backdrop-filter: blur(8px);
}

.transition-message p {
  margin-bottom: 0.25rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 8vw, 4.5rem);
  font-weight: 700;
  line-height: 1.05;
}

.transition-message small {
  font-size: clamp(0.75rem, 2.8vw, 1rem);
  font-weight: 750;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.transition-sparkles {
  position: absolute;
  inset: 0;
}

.transition-sparkles span {
  position: absolute;
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(1.2rem, 5vw, 2.8rem);
  opacity: 0;
}

.covering .transition-sparkles span {
  animation: transition-sparkle 900ms 250ms ease-out forwards;
}

.transition-sparkles span:nth-child(1) { top: 16%; left: 14%; }
.transition-sparkles span:nth-child(2) { top: 25%; right: 12%; animation-delay: 340ms; }
.transition-sparkles span:nth-child(3) { bottom: 18%; left: 18%; animation-delay: 390ms; }
.transition-sparkles span:nth-child(4) { right: 17%; bottom: 22%; animation-delay: 300ms; }
.transition-sparkles span:nth-child(5) { top: 8%; left: 48%; animation-delay: 430ms; }
.transition-sparkles span:nth-child(6) { top: 48%; left: 7%; animation-delay: 360ms; }
.transition-sparkles span:nth-child(7) { top: 54%; right: 7%; animation-delay: 460ms; }
.transition-sparkles span:nth-child(8) { right: 44%; bottom: 7%; animation-delay: 410ms; }

#surprise.main-reveal .date-pill,
#surprise.main-reveal .tiny-heart,
#surprise.main-reveal .hero h1,
#surprise.main-reveal .hero-copy,
#surprise.main-reveal .scroll-cue {
  animation: hero-reveal 780ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

#surprise.main-reveal .tiny-heart { animation-delay: 90ms; }
#surprise.main-reveal .hero h1 { animation-delay: 170ms; }
#surprise.main-reveal .hero-copy { animation-delay: 280ms; }
#surprise.main-reveal .scroll-cue { animation-delay: 380ms; }

.music-toggle {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 20;
  min-height: 2.8rem;
  padding: 0.65rem 1rem;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  background: rgba(86, 33, 57, 0.88);
  box-shadow: 0 10px 25px rgba(86, 33, 57, 0.22);
  color: white;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 750;
  cursor: pointer;
  backdrop-filter: blur(10px);
}

main {
  overflow: hidden;
}

.hero {
  min-height: 100vh;
  min-height: 100svh;
  display: grid;
  align-content: center;
  justify-items: center;
  padding:
    max(4rem, env(safe-area-inset-top))
    max(1.5rem, env(safe-area-inset-right))
    max(4rem, env(safe-area-inset-bottom))
    max(1.5rem, env(safe-area-inset-left));
  text-align: center;
}

.date-pill {
  padding: 0.5rem 1rem;
  border: 1px solid rgba(221, 71, 120, 0.18);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--pink-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.tiny-heart {
  margin: 1.4rem 0 0;
  color: var(--pink);
  font-size: 2rem;
}

.hero h1 {
  max-width: 900px;
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(4rem, 14vw, 9.5rem);
  font-weight: 700;
}

.hero h1 span {
  color: var(--pink-dark);
  text-shadow: 4px 5px 0 rgba(255, 215, 110, 0.72);
}

.hero-copy {
  max-width: 34rem;
  margin: 1.4rem auto 2rem;
  color: var(--muted);
  font-size: clamp(1rem, 3vw, 1.28rem);
}

.scroll-cue {
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
  border-bottom: 2px solid var(--yellow);
}

.section {
  width: min(100% - 2rem, 68rem);
  margin: 0 auto;
  padding: clamp(4rem, 10vw, 7rem) 0;
}

.letter-experience {
  text-align: center;
}

.letter-intro h2 {
  margin: 0 auto 0.8rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.6rem, 8vw, 5.2rem);
}

.letter-instruction {
  min-height: 1.7rem;
  margin-bottom: 1.5rem;
  color: var(--muted);
  font-weight: 650;
}

.after-open {
  display: none;
}

.letter-experience.opened .before-open {
  display: none;
}

.letter-experience.opened .after-open {
  display: inline;
}

.letter-scene {
  display: grid;
  place-items: center;
  perspective: 1200px;
  isolation: isolate;
}

.letter-scene > * {
  grid-area: 1 / 1;
}

.sealed-letter {
  position: relative;
  z-index: 3;
  display: block;
  width: min(100%, 32rem);
  aspect-ratio: 1.22;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  perspective: 1000px;
  filter: drop-shadow(0 22px 24px rgba(128, 40, 75, 0.2));
}

.sealed-letter:disabled {
  cursor: default;
}

.envelope-back,
.envelope-flap,
.envelope-pocket,
.letter-peek,
.letter-seal,
.letter-open-copy {
  position: absolute;
}

.envelope-back {
  inset: 14% 0 14%;
  z-index: 0;
  border-radius: 1rem;
  background: linear-gradient(145deg, #ffb6cd, #f17fa5);
}

.letter-peek {
  top: 17%;
  left: 7%;
  z-index: 2;
  display: grid;
  width: 86%;
  height: 62%;
  align-content: start;
  gap: 0.25rem;
  padding-top: clamp(1.1rem, 5vw, 2rem);
  border-radius: 0.65rem;
  background: #fffdfb;
  box-shadow: 0 4px 18px rgba(89, 34, 58, 0.12);
  font-family: Georgia, "Times New Roman", serif;
  transform: translateY(15%);
  transition: transform 700ms cubic-bezier(0.22, 1, 0.36, 1);
}

.letter-peek strong {
  color: var(--pink-dark);
  font-size: clamp(1.35rem, 5vw, 2.1rem);
}

.letter-peek small {
  color: var(--muted);
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  font-size: clamp(0.7rem, 2.4vw, 0.95rem);
}

.envelope-flap {
  top: 14%;
  left: 0;
  z-index: 4;
  width: 100%;
  height: 48%;
  background: linear-gradient(160deg, #ffbed2, #f58caf);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top;
  transition: transform 650ms cubic-bezier(0.22, 1, 0.36, 1), z-index 0s 320ms;
}

.envelope-pocket {
  inset: 14% 0 14%;
  z-index: 3;
  border-radius: 0 0 1rem 1rem;
  background: linear-gradient(145deg, #f799b8, #ed739c);
  clip-path: polygon(0 0, 50% 47%, 100% 0, 100% 100%, 0 100%);
}

.letter-seal {
  top: 40%;
  left: 50%;
  z-index: 5;
  display: grid;
  width: clamp(3.8rem, 13vw, 5rem);
  aspect-ratio: 1;
  place-items: center;
  border: 0.3rem solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  background: var(--pink-dark);
  color: white;
  font-size: clamp(1.4rem, 5vw, 2rem);
  box-shadow: 0 8px 18px rgba(128, 40, 75, 0.28);
  transform: translate(-50%, -50%);
  animation: seal-pulse 1.6s ease-in-out infinite;
}

.letter-open-copy {
  right: 0;
  bottom: 0;
  left: 0;
  color: var(--pink-dark);
  font-size: 0.78rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.letter-burst {
  position: relative;
  z-index: 5;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.letter-burst span {
  position: absolute;
  color: var(--pink-dark);
  font-size: clamp(1.2rem, 4vw, 2rem);
  opacity: 0;
}

.letter-burst span:nth-child(1) { --x: -13rem; --y: -9rem; --r: -30deg; }
.letter-burst span:nth-child(2) { --x: -8rem; --y: -13rem; --r: 20deg; }
.letter-burst span:nth-child(3) { --x: -4rem; --y: -15rem; --r: -15deg; }
.letter-burst span:nth-child(4) { --x: 4rem; --y: -14rem; --r: 40deg; }
.letter-burst span:nth-child(5) { --x: 9rem; --y: -12rem; --r: -25deg; }
.letter-burst span:nth-child(6) { --x: 13rem; --y: -7rem; --r: 30deg; }
.letter-burst span:nth-child(7) { --x: -11rem; --y: -3rem; --r: -45deg; }
.letter-burst span:nth-child(8) { --x: 11rem; --y: -2rem; --r: 25deg; }

.letter-card {
  position: relative;
  z-index: 2;
  width: min(100%, 58rem);
  max-height: 0;
  overflow: hidden;
  padding: 0 clamp(1.5rem, 7vw, 5rem);
  border: 1px solid rgba(221, 71, 120, 0.15);
  border-radius: 2rem;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  text-align: left;
  visibility: hidden;
  opacity: 0;
  transform: translateY(10rem) scale(0.82) rotate(-2deg);
  transition:
    max-height 900ms 480ms ease,
    padding 700ms 480ms ease,
    opacity 500ms 580ms ease,
    transform 850ms 480ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s 480ms;
}

.letter-card::before {
  content: "♡";
  position: absolute;
  top: 1.2rem;
  right: clamp(1rem, 6vw, 3rem);
  display: grid;
  width: 3.5rem;
  height: 3.5rem;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--pink-dark);
  font-size: 1.8rem;
  transform: rotate(8deg);
}

.letter-experience.opened .envelope-flap {
  z-index: 1;
  transform: rotateX(180deg);
}

.letter-experience.opened .letter-peek {
  transform: translateY(-34%);
}

.letter-experience.opened .letter-seal {
  animation: seal-pop 420ms ease forwards;
}

.letter-experience.opened .sealed-letter {
  animation: envelope-away 650ms 650ms ease forwards;
  pointer-events: none;
}

.letter-experience.opened .letter-burst span {
  animation: letter-burst 900ms 180ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.letter-experience.opened .letter-burst span:nth-child(even) {
  animation-delay: 260ms;
}

.letter-experience.opened .letter-card {
  max-height: 75rem;
  padding: clamp(2.5rem, 7vw, 5rem);
  visibility: visible;
  opacity: 1;
  transform: none;
}

.letter-label {
  color: var(--pink-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.letter-card h2,
.wishes h2,
.song-card h2,
.closing h2 {
  font-family: Georgia, "Times New Roman", serif;
}

.letter-card h2 {
  margin-bottom: 1.4rem;
  font-size: clamp(2.4rem, 7vw, 4rem);
}

.letter-card > p:not(.letter-label, .signature) {
  max-width: 48rem;
  color: #684055;
  font-size: clamp(1rem, 2.2vw, 1.15rem);
}

.signature {
  margin: 2rem 0 0;
  color: var(--pink-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  font-style: italic;
}

.gallery-section {
  text-align: center;
}

.gallery-section h2 {
  margin: 0 auto 2.5rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 7vw, 4.7rem);
}

.album {
  width: min(100%, 62rem);
  margin: 0 auto;
}

.album-tabs {
  display: inline-flex;
  gap: 0.35rem;
  margin-bottom: 1.4rem;
  padding: 0.35rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 28px rgba(128, 40, 75, 0.1);
}

.album-tab {
  min-height: 2.8rem;
  padding: 0.55rem 1.15rem;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 750;
  cursor: pointer;
}

.album-tab[aria-selected="true"] {
  background: var(--pink-dark);
  color: white;
}

.album-stage {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(0.5rem, 2vw, 1.25rem);
  touch-action: pan-y;
}

.album-stage:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 8px;
  border-radius: 1rem;
}

.album-arrow {
  width: clamp(2.8rem, 6vw, 3.6rem);
  aspect-ratio: 1;
  border: 0;
  border-radius: 50%;
  background: var(--pink-dark);
  color: white;
  box-shadow: 0 10px 24px rgba(128, 40, 75, 0.22);
  font: 400 clamp(2rem, 6vw, 2.8rem) / 1 Georgia, serif;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease;
}

.album-arrow:hover {
  background: var(--pink);
  transform: scale(1.07);
}

.album-photo {
  margin: 0;
  padding: clamp(0.55rem, 2vw, 0.85rem) clamp(0.55rem, 2vw, 0.85rem) 1rem;
  overflow: hidden;
  border-radius: 1.2rem;
  background: white;
  box-shadow: 0 18px 50px rgba(128, 40, 75, 0.18);
}

.album-photo img {
  display: block;
  width: 100%;
  height: clamp(24rem, 57vw, 40rem);
  border-radius: 0.75rem;
  background: var(--blush);
  object-fit: contain;
  user-select: none;
}

.album-photo figcaption {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0.4rem 0;
  color: var(--muted);
  font-family: "Segoe Print", "Comic Sans MS", cursive;
  text-align: left;
}

.album-photo small {
  flex: none;
  font-family: "Segoe UI", system-ui, sans-serif;
  font-weight: 750;
}

.album-hint {
  margin: 1rem 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.wishes {
  text-align: center;
}

.wishes h2 {
  margin-bottom: 2.4rem;
  font-size: clamp(2.4rem, 7vw, 4.4rem);
}

.wish-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.wish-grid article {
  padding: 2rem 1.25rem;
  border: 1px solid rgba(221, 71, 120, 0.12);
  border-radius: 1.5rem;
  background: rgba(255, 255, 255, 0.65);
}

.wish-grid article > span {
  display: block;
  margin-bottom: 0.6rem;
  font-size: 2.4rem;
}

.wish-grid strong {
  display: block;
  color: var(--pink-dark);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.3rem;
}

.wish-grid p {
  margin: 0.45rem 0 0;
  color: var(--muted);
}

.song-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: clamp(1.5rem, 5vw, 3rem);
  align-items: center;
  padding: clamp(1.5rem, 6vw, 3.5rem);
  border-radius: 2rem;
  background: var(--ink);
  box-shadow: var(--shadow);
  color: white;
}

.record {
  display: grid;
  width: clamp(7rem, 22vw, 11rem);
  aspect-ratio: 1;
  place-items: center;
  border: 9px solid #24101a;
  border-radius: 50%;
  background: repeating-radial-gradient(circle, #3c1d2c 0 6px, #27131c 7px 12px);
  box-shadow: inset 0 0 0 9px #171015, 0 12px 28px rgba(0, 0, 0, 0.25);
  animation: spin 9s linear infinite;
}

.record span {
  display: grid;
  width: 43%;
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  background: var(--yellow);
  color: var(--pink-dark);
  font-size: 1.5rem;
}

.song-card .eyebrow {
  color: #ff9cba;
}

.song-card h2 {
  margin-bottom: 0.55rem;
  font-size: clamp(2rem, 6vw, 3.5rem);
}

.song-card p:not(.eyebrow) {
  color: #efdbe4;
}

.song-button {
  margin-top: 0.6rem;
  padding: 0.72rem 1.2rem;
  font-size: 0.92rem;
}

.closing {
  min-height: 85vh;
  min-height: 85svh;
  display: grid;
  align-content: center;
  justify-items: center;
  padding:
    max(5rem, env(safe-area-inset-top))
    max(1.5rem, env(safe-area-inset-right))
    max(5rem, env(safe-area-inset-bottom))
    max(1.5rem, env(safe-area-inset-left));
  text-align: center;
}

.closing-hearts {
  margin-bottom: 0.6rem;
  color: var(--pink);
  font-size: 1.8rem;
  letter-spacing: 0.5rem;
}

.closing h2 {
  margin-bottom: 1rem;
  font-size: clamp(3.4rem, 11vw, 7rem);
  color: var(--pink-dark);
}

.closing > p:not(.closing-hearts, .made-by) {
  color: var(--muted);
  font-size: 1.2rem;
}

.made-by {
  margin-top: 3rem;
  font-size: 0.8rem;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-18px) rotate(7deg); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes seal-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.08); }
}

@keyframes seal-pop {
  0% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  55% { opacity: 1; transform: translate(-50%, -50%) scale(1.3) rotate(10deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(0); }
}

@keyframes envelope-away {
  to { opacity: 0; transform: translateY(5rem) scale(0.88); }
}

@keyframes letter-burst {
  0% { opacity: 0; transform: translate(0) scale(0.2); }
  18% { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--x), var(--y)) rotate(var(--r)) scale(0.9); }
}

@keyframes celebration-ring {
  0% { opacity: 0.85; transform: scale(0.35); }
  100% { opacity: 0; transform: scale(5.2); }
}

@keyframes celebration-core {
  0% { opacity: 0; transform: scale(0.15) rotate(-18deg); }
  18% { opacity: 1; transform: scale(1.18) rotate(5deg); }
  60% { opacity: 1; transform: scale(1) rotate(0); }
  82% { opacity: 1; transform: scale(1.04); }
  100% { opacity: 0; transform: scale(0.86); }
}

@keyframes celebration-particle {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.15) rotate(0); }
  16% { opacity: 1; }
  78% { opacity: 1; }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--spin)) scale(0.9);
  }
}

@keyframes quiz-card-celebrate {
  0%, 100% { transform: scale(1); box-shadow: var(--shadow); }
  18% { transform: scale(1.018); box-shadow: 0 26px 80px rgba(221, 71, 120, 0.3); }
  42% { transform: scale(0.995); }
  68% { transform: scale(1.006); }
}

@keyframes progress-celebrate {
  0%, 100% { box-shadow: none; }
  35% { box-shadow: 0 0 0.8rem rgba(255, 215, 110, 0.9); }
}

@keyframes question-enter {
  from { opacity: 0; transform: translateY(1.2rem) scale(0.98); }
  to { opacity: 1; transform: none; }
}

@keyframes quiz-screen-out {
  to { background-color: rgba(255, 240, 245, 0.7); }
}

@keyframes quiz-card-out {
  to { opacity: 0; transform: translateY(-2.5rem) scale(0.9); filter: blur(8px); }
}

@keyframes transition-cover {
  from { clip-path: circle(0 at 50% 50%); }
  to { clip-path: circle(150% at 50% 50%); }
}

@keyframes transition-uncover {
  from { clip-path: circle(150% at 50% 50%); opacity: 1; }
  to { clip-path: circle(0 at 50% 50%); opacity: 0; }
}

@keyframes transition-message-in {
  0% { opacity: 0; transform: translateY(2rem) scale(0.88); }
  70% { opacity: 1; transform: translateY(0) scale(1.04); }
  100% { opacity: 1; transform: none; }
}

@keyframes transition-message-out {
  to { opacity: 0; transform: translateY(-1.5rem) scale(1.08); }
}

@keyframes transition-sparkle {
  0% { opacity: 0; transform: translateY(1.5rem) scale(0.3) rotate(-20deg); }
  45% { opacity: 1; }
  100% { opacity: 0.35; transform: translateY(-1.5rem) scale(1.15) rotate(12deg); }
}

@keyframes hero-reveal {
  from { opacity: 0; transform: translateY(2.5rem) scale(0.96); filter: blur(8px); }
  to { opacity: 1; transform: none; filter: blur(0); }
}

@media (max-width: 620px) {
  .letter-burst span:nth-child(1) { --x: -8rem; --y: -7rem; }
  .letter-burst span:nth-child(2) { --x: -6rem; --y: -10rem; }
  .letter-burst span:nth-child(3) { --x: -3rem; --y: -11rem; }
  .letter-burst span:nth-child(4) { --x: 3rem; --y: -11rem; }
  .letter-burst span:nth-child(5) { --x: 6rem; --y: -9rem; }
  .letter-burst span:nth-child(6) { --x: 8rem; --y: -6rem; }
  .letter-burst span:nth-child(7) { --x: -7rem; --y: -2rem; }
  .letter-burst span:nth-child(8) { --x: 7rem; --y: -2rem; }

  .album-tabs {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    width: 100%;
  }

  .album-tab {
    padding-inline: 0.45rem;
    font-size: 0.78rem;
  }

  .album-stage {
    position: relative;
    display: block;
  }

  .album-arrow {
    position: absolute;
    top: 44%;
    z-index: 1;
    width: 2.8rem;
  }

  .album-previous {
    left: 0.9rem;
  }

  .album-next {
    right: 0.9rem;
  }

  .album-photo img {
    height: min(66svh, 31rem);
  }

  .wish-grid {
    grid-template-columns: 1fr;
  }

  .song-card {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .record {
    margin: 0 auto;
  }

  .fill-answer > div {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .answer-celebration.play .celebration-core {
    animation: none !important;
    opacity: 1;
    transform: none;
  }

  .answer-celebration.play .celebration-ring,
  .answer-celebration.play .celebration-particles {
    display: none;
  }
}
