/* ============================================================
   BIRTHDAY CARD – STYLE SYSTEM
   Cartoon / Doodle aesthetic — Pastel Blue & Cream
   ============================================================ */

/* ————— TOKENS ————— */
:root {
  /* palette */
  --cream:        #FAF7F2;
  --cream-dark:   #F0EDE6;
  --blue-100:     #E8F1FF;
  --blue-200:     #C5DCFF;
  --blue-300:     #A0C4FF;
  --blue-400:     #6FA8FF;
  --blue-500:     #4A90E2;
  --blue-600:     #2E6FCF;
  --pink-soft:    #FFD6E0;
  --pink-hot:     #FF6B8A;
  --yellow-soft:  #FFF3C4;
  --yellow:       #FFD666;
  --green-soft:   #C1F0C1;
  --red-heart:    #E84057;
  --ink:          #2B2B2B;
  --ink-light:    #5A5A5A;

  /* typography */
  --ff-heading: 'Fredoka', sans-serif;
  --ff-body:    'Quicksand', sans-serif;
  --ff-hand:    'Caveat', cursive;

  /* doodle border */
  --doodle-radius: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --doodle-radius-alt: 15px 255px 15px 225px / 225px 15px 255px 15px;
  --doodle-shadow: 4px 4px 0px var(--ink);

  /* transitions */
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-smooth: cubic-bezier(0.4, 0, 0.2, 1);
}

/* ————— RESET ————— */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  font-family: var(--ff-body);
  background: var(--cream);
  background-image:
    radial-gradient(ellipse at 50% 5%, var(--blue-100) 0%, transparent 30%),
    radial-gradient(ellipse at 20% 35%, var(--blue-100) 0%, transparent 22%),
    radial-gradient(ellipse at 80% 35%, var(--yellow-soft) 0%, transparent 18%),
    radial-gradient(ellipse at 50% 55%, var(--blue-100) 0%, transparent 20%),
    radial-gradient(ellipse at 30% 75%, var(--yellow-soft) 0%, transparent 18%),
    radial-gradient(ellipse at 70% 90%, var(--blue-100) 0%, transparent 22%);
  background-attachment: fixed;
  color: var(--ink);
  overflow-x: hidden;
  line-height: 1.6;
}

img { max-width: 100%; display: block; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ============================================================
   PRELOADER
   ============================================================ */
#preloader {
  position: fixed; inset: 0; z-index: 10000;
  background: var(--blue-100);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.6s var(--ease-smooth), visibility 0.6s;
}
#preloader.hidden {
  opacity: 0; visibility: hidden; pointer-events: none;
}

.preloader-inner { text-align: center; }

.preloader-cake {
  display: flex; flex-direction: column; align-items: center;
  animation: preloaderBounce 1s var(--ease-bounce) infinite;
}
.preloader-candle { width: 10px; height: 30px; background: repeating-linear-gradient(135deg, var(--blue-300), var(--blue-300) 3px, white 3px, white 6px); border-radius: 3px; margin-bottom: -2px; position: relative; }
.preloader-flame {
  width: 12px; height: 16px;
  background: radial-gradient(ellipse, var(--yellow) 30%, var(--pink-hot) 70%, transparent 100%);
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  animation: flameFlicker 0.3s ease-in-out infinite alternate;
}
.preloader-layer { border-radius: var(--doodle-radius); border: 3px solid var(--ink); }
.preloader-layer--top { width: 60px; height: 24px; background: var(--blue-200); }
.preloader-layer--mid { width: 80px; height: 28px; background: var(--yellow-soft); margin-top: -4px; }
.preloader-layer--bot { width: 100px; height: 32px; background: var(--pink-soft); margin-top: -4px; }

.preloader-text {
  font-family: var(--ff-hand);
  font-size: 1.4rem;
  color: var(--blue-600);
  margin-top: 1.5rem;
}
.preloader-dots { display: flex; gap: 6px; justify-content: center; margin-top: 0.8rem; }
.preloader-dots span {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--blue-400);
  animation: dotPulse 1.2s ease-in-out infinite;
}
.preloader-dots span:nth-child(2) { animation-delay: 0.2s; }
.preloader-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes preloaderBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}
@keyframes dotPulse {
  0%, 100% { transform: scale(1); opacity: 0.5; }
  50% { transform: scale(1.4); opacity: 1; }
}

/* ============================================================
   FX CANVAS (confetti / particles)
   ============================================================ */
#fx-canvas {
  position: fixed; inset: 0; z-index: 9998;
  pointer-events: none;
  width: 100vw; height: 100vh;
}

/* ============================================================
   FLOATING DECORATIONS
   ============================================================ */
#floating-deco {
  position: fixed; inset: 0; z-index: 1;
  pointer-events: none; overflow: hidden;
}
.float-item {
  position: absolute;
  font-size: 1.4rem;
  opacity: 0.35;
  animation: floatUp linear infinite;
  pointer-events: none;
  user-select: none;
}
@keyframes floatUp {
  0% { transform: translateY(100vh) rotate(0deg) scale(0.8); opacity: 0; }
  10% { opacity: 0.35; }
  90% { opacity: 0.35; }
  100% { transform: translateY(-10vh) rotate(360deg) scale(1.1); opacity: 0; }
}

/* ============================================================
   SECTIONS
   ============================================================ */
.section {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 5rem 1.5rem;
  position: relative;
  z-index: 2;
}
#hero { min-height: 100vh; }
#hero, #gallery, #letter, #wishes, #closing {
  padding-top: 4rem;
  padding-bottom: 4rem;
}

.section-header { text-align: center; margin-bottom: 3rem; }
.section-title {
  font-family: var(--ff-heading);
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  color: var(--blue-600);
  display: inline-block;
  position: relative;
}
.doodle-underline::after {
  content: '';
  position: absolute; left: -5%; bottom: -6px;
  width: 110%; height: 8px;
  background: var(--yellow);
  border-radius: var(--doodle-radius);
  transform: rotate(-1deg);
}
.section-sub {
  font-family: var(--ff-hand);
  font-size: 1.2rem;
  color: var(--ink-light);
  margin-top: 0.8rem;
}

/* ============================================================
   HERO SECTION
   ============================================================ */
#hero {
  overflow: hidden;
}

.hero-content {
  text-align: center;
  display: flex; flex-direction: column;
  align-items: center; gap: 1rem;
}

/* stars */
.hero-stars { position: absolute; inset: 0; pointer-events: none; }
.star {
  position: absolute;
  animation: starTwinkle 2s ease-in-out infinite;
}
.star polygon { fill: var(--yellow); stroke: var(--ink); stroke-width: 1; }
.star--1 { width: 32px; top: 12%; left: 10%; animation-delay: 0s; }
.star--2 { width: 22px; top: 8%; left: 35%; animation-delay: 0.5s; }
.star--2 polygon { fill: var(--blue-300); }
.star--3 { width: 18px; top: 25%; left: 75%; animation-delay: 1s; }
.star--3 polygon { fill: var(--pink-soft); }
.star--4 { width: 26px; top: 15%; right: 12%; animation-delay: 1.5s; }
.star--4 polygon { fill: var(--green-soft); }

@keyframes starTwinkle {
  0%, 100% { transform: scale(1) rotate(0deg); opacity: 0.7; }
  50% { transform: scale(1.25) rotate(15deg); opacity: 1; }
}

/* title */
.hero-title {
  font-family: var(--ff-heading);
  font-size: clamp(2.8rem, 10vw, 5.5rem);
  line-height: 1.1;
  color: var(--ink);
}
.hero-line { display: block; }
.hero-line--1 { transform: rotate(-3deg); color: var(--blue-500); }
.hero-line--2 { transform: rotate(1deg); }
.hero-line--3 {
  color: var(--pink-hot);
  font-family: var(--ff-hand);
  font-size: clamp(2.2rem, 8vw, 4.5rem);
  transform: rotate(2deg);
}

.hero-line {
  opacity: 0;
  animation: heroLineIn 0.8s var(--ease-bounce) forwards;
}
.hero-line--1 { animation-delay: 0.3s; }
.hero-line--2 { animation-delay: 0.6s; }
.hero-line--3 { animation-delay: 0.9s; }

@keyframes heroLineIn {
  from { opacity: 0; transform: translateY(30px) rotate(-2deg) scale(0.8); }
  to   { opacity: 1; transform: translateY(0) rotate(var(--r, 0deg)) scale(1); }
}
.hero-line--1 { --r: -3deg; }
.hero-line--2 { --r: 1deg; }
.hero-line--3 { --r: 2deg; }

/* ============================================================
   CAKE
   ============================================================ */
#cake-wrapper {
  margin-top: 1rem;
  display: flex; flex-direction: column; align-items: center;
  cursor: pointer;
  animation: cakeBounceIn 1s var(--ease-bounce) 1.2s both;
}
@keyframes cakeBounceIn {
  from { opacity: 0; transform: scale(0.3) translateY(60px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.cake {
  position: relative;
  display: flex; flex-direction: column; align-items: center;
  filter: drop-shadow(3px 5px 0px rgba(0,0,0,0.12));
  transition: transform 0.3s var(--ease-bounce);
}
#cake-wrapper:hover .cake { transform: scale(1.04) rotate(-1deg); }

/* candle */
.candle {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: -4px; position: relative; z-index: 3;
}
.candle-body {
  width: 14px; height: 44px;
  background: repeating-linear-gradient(135deg, var(--blue-300), var(--blue-300) 4px, #fff 4px, #fff 8px);
  border: 2.5px solid var(--ink);
  border-radius: 4px 4px 2px 2px;
}
.candle-wick {
  width: 3px; height: 10px;
  background: var(--ink);
  border-radius: 2px;
  margin-bottom: -1px;
}

.flame-group {
  position: absolute;
  top: -30px; left: 50%; transform: translateX(-50%);
  transition: opacity 0.4s;
}
.flame {
  position: absolute;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
}
.flame-outer {
  width: 18px; height: 26px;
  background: radial-gradient(ellipse at 50% 80%, var(--yellow) 0%, #ff9f43 50%, transparent 100%);
  top: 0; left: 50%; transform: translateX(-50%);
  animation: flameFlicker 0.4s ease-in-out infinite alternate;
}
.flame-inner {
  width: 10px; height: 16px;
  background: radial-gradient(ellipse at 50% 80%, #fff8dc 0%, var(--yellow) 100%);
  top: 6px; left: 50%; transform: translateX(-50%);
  animation: flameFlicker 0.3s ease-in-out infinite alternate-reverse;
}
.flame-glow {
  width: 50px; height: 50px;
  background: radial-gradient(circle, rgba(255,214,102,0.4) 0%, transparent 70%);
  border-radius: 50%;
  position: absolute; top: -12px; left: 50%; transform: translateX(-50%);
  animation: glowPulse 1.5s ease-in-out infinite;
}

@keyframes flameFlicker {
  0% { transform: translateX(-50%) scaleY(1) scaleX(1) rotate(-2deg); }
  100% { transform: translateX(-50%) scaleY(1.15) scaleX(0.9) rotate(2deg); }
}
@keyframes glowPulse {
  0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1); }
  50% { opacity: 1; transform: translateX(-50%) scale(1.15); }
}

/* smoke */
.smoke {
  position: absolute;
  width: 8px; height: 8px;
  background: rgba(200, 200, 200, 0.6);
  border-radius: 50%;
  left: 50%; transform: translateX(-50%);
}
.smoke--1 { animation: smokeRise 1s ease-out forwards; }
.smoke--2 { animation: smokeRise 1.2s ease-out 0.15s forwards; }
.smoke--3 { animation: smokeRise 1.4s ease-out 0.3s forwards; }

@keyframes smokeRise {
  0% { opacity: 0.8; transform: translateX(-50%) translateY(0) scale(0.5); }
  100% { opacity: 0; transform: translateX(calc(-50% + 15px)) translateY(-50px) scale(2); }
}

/* tiers */
.cake-tier {
  border: 3px solid var(--ink);
  position: relative;
}
.cake-tier--top {
  width: 100px; height: 50px;
  background: var(--blue-200);
  border-radius: var(--doodle-radius);
  z-index: 2;
  overflow: visible;
}
.cake-drip {
  position: absolute; bottom: -10px;
  width: 14px; height: 16px;
  background: var(--blue-300);
  border-radius: 0 0 50% 50%;
  border: 2px solid var(--ink);
  border-top: none;
}
.cake-drip--1 { left: 15%; }
.cake-drip--2 { left: 50%; transform: translateX(-50%); height: 20px; }
.cake-drip--3 { right: 15%; height: 12px; }

.cake-deco {
  position: absolute; font-size: 0.9rem;
  animation: decoFloat 2s ease-in-out infinite;
}
.cake-deco--star { top: 8px; left: 12px; color: var(--yellow); }
.cake-deco--heart { top: 10px; right: 12px; color: var(--pink-hot); animation-delay: 0.5s; }

@keyframes decoFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.cake-tier--mid {
  width: 140px; height: 55px;
  background: var(--yellow-soft);
  border-radius: var(--doodle-radius-alt);
  margin-top: -6px; z-index: 1;
  position: relative;
  overflow: hidden;
}
.cake-scallop {
  position: absolute; top: 0; left: 0; right: 0;
  height: 16px;
  background: repeating-radial-gradient(circle at 12px 0, var(--green-soft) 10px, transparent 10px);
  border-bottom: 2px solid var(--ink);
}
.cake-flower {
  position: absolute; bottom: 8px;
  font-size: 1rem;
}
.cake-flower--1 { left: 15%; color: var(--red-heart); }
.cake-flower--2 { left: 48%; color: var(--blue-400); }
.cake-flower--3 { right: 15%; color: var(--pink-hot); }

.cake-tier--bot {
  width: 180px; height: 60px;
  background: var(--pink-soft);
  border-radius: var(--doodle-radius);
  margin-top: -6px;
  position: relative;
  overflow: hidden;
}
.cake-hearts {
  display: flex; justify-content: space-around;
  padding: 8px 20px 0;
  font-size: 1rem; color: var(--red-heart);
}
.cake-ruffle {
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 14px;
  background: repeating-conic-gradient(var(--blue-200) 0% 25%, transparent 25% 50%);
  opacity: 0.6;
}

.cake-plate {
  width: 200px; height: 14px;
  background: var(--yellow);
  border: 3px solid var(--ink);
  border-radius: var(--doodle-radius);
  margin-top: -3px;
}

.cake-hint {
  font-family: var(--ff-hand);
  font-size: 1.1rem;
  color: var(--blue-500);
  margin-top: 1.2rem;
  animation: hintPulse 2s ease-in-out infinite;
}
.cake-hint.hidden { display: none; }

@keyframes hintPulse {
  0%, 100% { opacity: 0.7; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.05); }
}

/* scroll indicator */
.scroll-indicator {
  margin-top: 2rem;
  display: flex; flex-direction: column; align-items: center;
  gap: 0.3rem;
  color: var(--ink-light);
  font-family: var(--ff-hand);
  font-size: 1rem;
  animation: scrollBounce 2s ease-in-out infinite;
  opacity: 0;
  transition: opacity 0.5s;
}
.scroll-indicator.visible { opacity: 1; }
.scroll-arrow svg { width: 24px; height: 24px; }

@keyframes scrollBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(8px); }
}

/* ============================================================
   POLAROID GALLERY
   ============================================================ */
#gallery {
  padding-bottom: 5rem;
}

.polaroid-board {
  position: relative;
  width: 100%;
  max-width: 900px;
  height: 600px;
  margin: 0 auto;
}

.polaroid {
  position: absolute;
  left: var(--x); top: var(--y);
  width: 200px;
  perspective: 800px;
  cursor: grab;
  z-index: 10;
  transform: rotate(var(--rot, 0deg));
  transition: z-index 0s, box-shadow 0.3s var(--ease-smooth);
  user-select: none;
  -webkit-user-select: none;
}
.polaroid:active { cursor: grabbing; }
.polaroid.dragging {
  z-index: 1000 !important;
  transition: none;
}

.polaroid-inner {
  position: relative;
  width: 100%;
  transition: transform 0.7s var(--ease-bounce);
  transform-style: preserve-3d;
}
.polaroid.flipped .polaroid-inner {
  transform: rotateY(180deg);
}

.polaroid-front, .polaroid-back {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--doodle-radius);
  border: 3px solid var(--ink);
  box-shadow: var(--doodle-shadow);
}

.polaroid-front {
  background: #fff;
  padding: 12px 12px 40px;
}

.polaroid-photo {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, var(--blue-100), var(--blue-200));
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid var(--cream-dark);
}
.polaroid-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.polaroid-caption {
  font-family: var(--ff-hand);
  font-size: 1rem;
  color: var(--ink);
  text-align: center;
  margin-top: 8px;
  line-height: 1.3;
}

.polaroid-back {
  position: absolute; inset: 0;
  background: var(--blue-100);
  transform: rotateY(180deg);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 24px;
  text-align: center;
}
.polaroid-back-text {
  font-family: var(--ff-hand);
  font-size: 1.2rem;
  color: var(--blue-600);
  line-height: 1.4;
}
.polaroid-date {
  font-family: var(--ff-body);
  font-size: 0.85rem;
  color: var(--ink-light);
  margin-top: 12px;
}

/* tape decor on polaroids */
.polaroid::before {
  content: '';
  position: absolute;
  width: 50px; height: 18px;
  background: rgba(255, 243, 196, 0.85);
  border: 1.5px solid rgba(0,0,0,0.1);
  top: -10px; left: 50%; transform: translateX(-50%) rotate(var(--tape-rot, 2deg));
  z-index: 5;
  border-radius: 2px;
}
.polaroid:nth-child(odd)::before { --tape-rot: -3deg; }
.polaroid:nth-child(even)::before { --tape-rot: 4deg; }

/* ============================================================
   LOVE LETTER
   ============================================================ */
#letter {
}

.envelope-wrapper {
  perspective: 600px;
  cursor: pointer;
  transition: transform 0.3s var(--ease-bounce);
}
.envelope-wrapper:hover { transform: scale(1.05) rotate(-1deg); }
.envelope-wrapper.opened { pointer-events: none; }

.envelope {
  position: relative;
  width: 280px; height: 180px;
  transition: transform 0.6s var(--ease-smooth), opacity 0.4s;
}
.envelope-wrapper.opened .envelope {
  transform: scale(0.6) translateY(-40px);
  opacity: 0;
}

.envelope-body {
  width: 100%; height: 100%;
  background: var(--blue-200);
  border: 3px solid var(--ink);
  border-radius: var(--doodle-radius);
  box-shadow: var(--doodle-shadow);
  position: relative;
  overflow: hidden;
}
.envelope-body::before {
  content: '';
  position: absolute;
  top: 0; left: 50%; transform: translateX(-50%);
  border-left: 140px solid transparent;
  border-right: 140px solid transparent;
  border-top: 80px solid var(--blue-300);
}
.envelope-body::after {
  content: '';
  position: absolute;
  top: 0; left: 50%; transform: translateX(-50%);
  border-left: 140px solid transparent;
  border-right: 140px solid transparent;
  border-top: 80px solid transparent;
  filter: drop-shadow(0 2px 0 var(--ink));
}

.envelope-flap {
  position: absolute;
  top: 0; left: 50%; transform: translateX(-50%) rotateX(0deg);
  transform-origin: top center;
  width: 0; height: 0;
  border-left: 140px solid transparent;
  border-right: 140px solid transparent;
  border-top: 90px solid var(--blue-300);
  z-index: 2;
  filter: drop-shadow(0 2px 0 var(--ink));
  transition: transform 0.5s var(--ease-smooth);
}
.envelope-wrapper.opened .envelope-flap {
  transform: translateX(-50%) rotateX(180deg);
}

.wax-seal {
  position: absolute;
  bottom: 20px; left: 50%; transform: translateX(-50%);
  width: 50px; height: 50px;
  background: var(--red-heart);
  border: 3px solid #c4354a;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  z-index: 3;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.2);
  animation: sealWiggle 2s ease-in-out infinite;
}
.wax-seal span {
  color: #fff;
  font-size: 1.4rem;
}
.envelope-wrapper:hover .wax-seal {
  animation: sealWiggleFast 0.3s ease-in-out infinite;
}

@keyframes sealWiggle {
  0%, 100% { transform: translateX(-50%) rotate(0deg); }
  25% { transform: translateX(-50%) rotate(3deg); }
  75% { transform: translateX(-50%) rotate(-3deg); }
}
@keyframes sealWiggleFast {
  0%, 100% { transform: translateX(-50%) rotate(-5deg); }
  50% { transform: translateX(-50%) rotate(5deg); }
}

/* letter paper */
.letter-paper {
  max-width: 560px;
  width: 90%;
  margin: 0 auto;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--doodle-radius);
  box-shadow: var(--doodle-shadow);
  padding: 2.5rem 2rem;
  opacity: 0;
  transform: translateY(40px) scale(0.9);
  transition: all 0.8s var(--ease-bounce);
  pointer-events: none;
  position: relative;
  background-image:
    repeating-linear-gradient(transparent, transparent 31px, var(--blue-100) 31px, var(--blue-100) 32px);
}
.letter-paper.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.letter-paper::before {
  content: '';
  position: absolute;
  left: 40px; top: 0; bottom: 0;
  width: 2px;
  background: var(--pink-soft);
}

.letter-content { padding-left: 20px; }

.letter-greeting {
  font-family: var(--ff-hand);
  font-size: 1.6rem;
  color: var(--blue-600);
  margin-bottom: 1rem;
}

.letter-body {
  font-family: var(--ff-hand);
  font-size: 1.2rem;
  line-height: 2;
  color: var(--ink);
  min-height: 100px;
}
.letter-body .letter-char {
  opacity: 0;
  display: inline;
  transition: opacity 0.05s;
}
.letter-body .letter-char.visible { opacity: 1; }

.letter-sign {
  font-family: var(--ff-hand);
  font-size: 1.3rem;
  color: var(--pink-hot);
  margin-top: 1.5rem;
  text-align: right;
}
.letter-name {
  font-size: 1.5rem;
  font-weight: 700;
}

/* ============================================================
   WISH MAILER (Interactive Envelope)
   ============================================================ */
#wishes {
  padding-bottom: 4rem;
}

.wish-mailer-wrapper {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  min-height: 380px;
  position: relative;
}

/* ---------- ENVELOPE CONTAINER ---------- */
.wish-mailer {
  position: relative;
  width: 100%;
  height: 360px;
  margin: 0 auto;
  perspective: 1000px;
}

/* ---------- ENVELOPE BACK WALL ---------- */
.wish-envelope-back {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 140px;
  background: var(--blue-300);
  border: 3px solid var(--ink);
  border-radius: var(--doodle-radius);
  z-index: 1;
}

/* ---------- ENVELOPE FLAP (triangle pointing UP when open) ---------- */
.wish-flap {
  position: absolute;
  bottom: 137px;
  left: 0;
  width: 100%;
  height: 85px;
  background: var(--blue-400);
  clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
  transform-origin: bottom center;
  transform: rotateX(0deg);
  z-index: 1;
  transition: transform 0.5s var(--ease-smooth);
}
.wish-mailer.sending .wish-flap {
  transform: rotateX(180deg);
  z-index: 10;
  transition-delay: 0.6s;
}

/* ---------- PAPER (sticks out from envelope pocket) ---------- */
.wish-paper {
  position: absolute;
  bottom: 85px;
  left: 50%;
  transform: translateX(-50%);
  width: 86%;
  background: #fff;
  border: 2.5px solid var(--ink);
  border-radius: 12px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  padding: 1.2rem 1rem 1rem;
  z-index: 3;
  transition: transform 0.6s var(--ease-smooth);
  background-image:
    repeating-linear-gradient(transparent, transparent 27px, var(--blue-100) 27px, var(--blue-100) 28px);
}
/* Paper slides DOWN inside the pocket when sending */
.wish-mailer.sending .wish-paper {
  transform: translateX(-50%) translateY(140px);
}

/* Hide button instantly when sending starts */
.wish-mailer.sending .wish-paper-btn {
  opacity: 0;
  visibility: hidden;
  height: 0;
  margin: 0;
  padding: 0;
  border: none;
  transition: opacity 0.2s, height 0.2s;
}

.wish-envelope-front {
  position: absolute;
  bottom: 0; left: 0;
  width: 100%; height: 100px;
  background: var(--blue-200);
  border: 3px solid var(--ink);
  border-radius: 0 0 var(--doodle-radius) var(--doodle-radius);
  box-shadow: var(--doodle-shadow);
  z-index: 4;
  clip-path: polygon(0 0, 50% 20px, 100% 0, 100% 100%, 0 100%);
}

.wish-paper-label {
  font-family: var(--ff-hand);
  font-size: 1.1rem;
  color: var(--blue-600);
  margin-bottom: 0.6rem;
}

.wish-paper-textarea {
  width: 100%;
  font-family: var(--ff-hand);
  font-size: 1.05rem;
  padding: 10px 12px;
  border: none;
  background: transparent;
  color: var(--ink);
  outline: none;
  resize: none;
  min-height: 80px;
  line-height: 1.7;
}
.wish-paper-textarea::placeholder {
  color: var(--ink-light);
  opacity: 0.5;
}

.wish-paper-btn {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  font-family: var(--ff-heading);
  font-size: 1rem;
  padding: 12px 20px;
  background: var(--blue-400);
  color: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--doodle-radius);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
}
.wish-paper-btn:hover {
  background: var(--blue-500);
  transform: translateY(-2px);
  box-shadow: 4px 5px 0 var(--ink);
}
.wish-paper-btn:active {
  transform: translateY(1px);
  box-shadow: 1px 1px 0 var(--ink);
}

/* ---------- FLY AWAY ANIMATION ---------- */
.wish-mailer.fly-away {
  animation: envelopeFly 1s var(--ease-smooth) forwards;
  animation-delay: 0.2s;
}

@keyframes envelopeFly {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  40% {
    transform: translateY(-30px) rotate(-5deg) scale(1.05);
    opacity: 1;
  }
  100% {
    transform: translateY(-300px) rotate(8deg) scale(0.3);
    opacity: 0;
  }
}

/* ---------- SUCCESS STATE ---------- */
.wish-success {
  display: none;
  text-align: center;
  animation: successPop 0.6s var(--ease-bounce);
}
.wish-success.visible {
  display: block;
}

.wish-success-emoji {
  font-size: 3.5rem;
  margin-bottom: 0.5rem;
  animation: successSpin 0.8s var(--ease-bounce);
}
@keyframes successSpin {
  0% { transform: scale(0) rotate(-180deg); }
  60% { transform: scale(1.2) rotate(10deg); }
  100% { transform: scale(1) rotate(0deg); }
}
@keyframes successPop {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

.wish-success-text {
  font-family: var(--ff-hand);
  font-size: 1.4rem;
  color: var(--blue-600);
  margin-bottom: 1rem;
}

.wish-again-btn {
  font-family: var(--ff-heading);
  font-size: 0.95rem;
  padding: 10px 24px;
  background: var(--pink-soft);
  color: var(--ink);
  border: 2.5px solid var(--ink);
  border-radius: var(--doodle-radius);
  box-shadow: 3px 3px 0 var(--ink);
  cursor: pointer;
  transition: all 0.2s var(--ease-bounce);
}
.wish-again-btn:hover {
  transform: translateY(-2px);
  box-shadow: 4px 5px 0 var(--ink);
}


/* ============================================================
   PHOTO SCATTER FOOTER
   ============================================================ */
.photo-scatter {
  position: absolute;
  top: 40%;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  pointer-events: none;
  z-index: 5;
  overflow: hidden;
}

.scatter-photo {
  position: absolute;
  left: var(--x, 10%);
  top: var(--y, 0);
  width: 100px;
  padding: 6px 6px 20px;
  background: #fff;
  border: 2px solid var(--ink);
  border-radius: 4px;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.08);
  /* Start high up and invisible */
  transform: translateY(-200px) rotate(0deg) scale(0.5);
  opacity: 0;
  transition: all 0.7s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transition-delay: var(--delay, 0s);
  pointer-events: auto;
}
.photo-scatter.scattered .scatter-photo {
  /* Drop down into messy position */
  transform: translateY(0) rotate(var(--rot, 0deg)) scale(1);
  opacity: 1;
}
.scatter-photo img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 2px;
  display: block;
}

/* ============================================================
   CLOSING
   ============================================================ */
#closing {
  text-align: center;
  position: relative;
  min-height: 85vh;
  padding-top: 4rem;
  padding-bottom: 2rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
}
.closing-content {
  position: relative;
  animation: closingFadeIn 1s ease-out;
  z-index: 10;
}
.closing-title {
  font-family: var(--ff-heading);
  font-size: clamp(2rem, 6vw, 3.2rem);
  color: var(--blue-600);
  margin-bottom: 1rem;
}
.closing-message {
  font-family: var(--ff-hand);
  font-size: clamp(1.2rem, 3vw, 1.6rem);
  color: var(--ink);
  line-height: 1.8;
  max-width: 500px;
  margin: 0 auto;
}
.closing-sparkle {
  font-size: 2rem;
  margin-top: 1.5rem;
  animation: sparkleFloat 3s ease-in-out infinite;
}

@keyframes closingFadeIn {
  from { opacity: 0; transform: translateY(30px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes sparkleFloat {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.1); }
}

.closing-hearts {
  position: absolute;
  inset: -50px;
  pointer-events: none;
  overflow: hidden;
}

/* ============================================================
   MUSIC PLAYER (floating widget)
   ============================================================ */
.music-player {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 9990;
  display: flex; align-items: center; gap: 10px;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--doodle-radius);
  box-shadow: var(--doodle-shadow);
  padding: 10px 16px;
  opacity: 0;
  transform: translateY(20px);
  animation: playerSlideIn 0.6s var(--ease-bounce) 2s forwards;
}
@keyframes playerSlideIn {
  to { opacity: 1; transform: translateY(0); }
}

.vinyl {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: conic-gradient(#333 0% 25%, #555 25% 50%, #333 50% 75%, #444 75% 100%);
  border: 2px solid var(--ink);
  position: relative;
  transition: transform 0.3s;
}
.vinyl.spinning {
  animation: vinylSpin 2s linear infinite;
}
.vinyl-label {
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--blue-400);
  top: 50%; left: 50%; transform: translate(-50%, -50%);
  border: 1px solid var(--ink);
}
.vinyl-hole {
  position: absolute;
  width: 4px; height: 4px;
  border-radius: 50%;
  background: var(--cream);
  top: 50%; left: 50%; transform: translate(-50%, -50%);
}

@keyframes vinylSpin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.music-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue-300);
  border: 2px solid var(--ink);
  border-radius: 50%;
  color: #fff;
  transition: background 0.2s, transform 0.2s var(--ease-bounce);
}
.music-btn:hover { background: var(--blue-500); transform: scale(1.1); }
.music-icon { width: 18px; height: 18px; }

.music-notes {
  position: absolute;
  bottom: 100%; right: 0;
  pointer-events: none;
}
.music-note {
  position: absolute;
  font-size: 1.2rem;
  animation: noteFloat 2s ease-out forwards;
  opacity: 0;
}
@keyframes noteFloat {
  0% { opacity: 1; transform: translateY(0) rotate(0deg) scale(1); }
  100% { opacity: 0; transform: translateY(-60px) rotate(20deg) scale(0.6) translateX(var(--nx, 10px)); }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

/* ---------- TABLET ---------- */
@media (max-width: 768px) {
  .section { padding: 3.5rem 1.2rem; }
  #hero { min-height: 100svh; }

  .hero-title { font-size: clamp(2.2rem, 10vw, 3.8rem); }

  /* cake smaller */
  .cake-tier--top { width: 80px; height: 40px; }
  .cake-tier--mid { width: 110px; height: 45px; }
  .cake-tier--bot { width: 145px; height: 48px; }
  .cake-plate { width: 160px; }
  .candle-body { height: 34px; }

  /* polaroids: 2-column grid on tablet */
  .polaroid-board {
    height: auto;
    min-height: auto;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.2rem;
    padding: 0 0.5rem 2rem;
  }
  .polaroid {
    position: relative !important;
    left: auto !important; top: auto !important;
    width: 180px;
    transform: rotate(var(--rot, 0deg)) !important;
  }



  /* envelope */
  .envelope { width: 240px; height: 160px; }
  .envelope-body::before { border-left-width: 120px; border-right-width: 120px; border-top-width: 70px; }
  .envelope-flap { border-left-width: 120px; border-right-width: 120px; border-top-width: 80px; }

  /* letter */
  .letter-paper { padding: 1.5rem 1.2rem; width: 95%; }
  .letter-paper::before { left: 25px; }

  /* music player */
  .music-player { bottom: 12px; right: 12px; padding: 8px 12px; }


}

/* ---------- MOBILE ---------- */
@media (max-width: 480px) {
  .section { padding: 2.5rem 0.8rem; }

  .hero-title { font-size: clamp(2rem, 13vw, 3rem); }
  .hero-line--3 { font-size: clamp(1.8rem, 10vw, 2.8rem); }

  .section-title { font-size: clamp(1.4rem, 6vw, 2rem); }
  .section-sub { font-size: 1rem; }

  /* cake even smaller */
  .cake-tier--top { width: 65px; height: 34px; }
  .cake-tier--mid { width: 90px; height: 38px; }
  .cake-tier--bot { width: 120px; height: 42px; }
  .cake-plate { width: 135px; height: 12px; }
  .candle-body { width: 10px; height: 28px; }
  .flame-outer { width: 14px; height: 20px; }
  .flame-inner { width: 8px; height: 12px; }

  /* polaroids: stack on small phone */
  .polaroid {
    width: 140px;
  }
  .polaroid-caption { font-size: 0.85rem; }
  .polaroid-front { padding: 8px 8px 30px; }



  /* envelope */
  .envelope { width: 200px; height: 130px; }
  .envelope-body::before { border-left-width: 100px; border-right-width: 100px; border-top-width: 56px; }
  .envelope-flap { border-left-width: 100px; border-right-width: 100px; border-top-width: 65px; }
  .wax-seal { width: 40px; height: 40px; bottom: 14px; }
  .wax-seal span { font-size: 1.1rem; }

  /* letter */
  .letter-paper { padding: 1.2rem 0.8rem; }
  .letter-paper::before { left: 18px; }
  .letter-content { padding-left: 14px; }
  .letter-greeting { font-size: 1.3rem; }
  .letter-body { font-size: 1.05rem; line-height: 1.9; }
  .letter-sign { font-size: 1.1rem; }

  /* wish mailer */
  .wish-mailer-wrapper { max-width: 300px; min-height: 340px; }
  .wish-mailer { height: 340px; }
  .wish-envelope-back { height: 120px; }
  .wish-envelope-front { height: 90px; clip-path: polygon(0 0, 50% 15px, 100% 0, 100% 100%, 0 100%); }
  .wish-flap { bottom: 118px; height: 75px; }
  .wish-paper { bottom: 75px; width: 88%; padding: 1rem 0.8rem 0.8rem; }
  .wish-paper-textarea { min-height: 65px; font-size: 0.95rem; }
  .wish-paper-btn { font-size: 0.9rem; padding: 10px 14px; }

  /* photo scatter */
  .scatter-photo { width: 70px; padding: 4px 4px 14px; }

  /* closing */
  .closing-title { font-size: clamp(1.5rem, 6vw, 2.2rem); }
  .closing-message { font-size: clamp(1rem, 3.5vw, 1.3rem); }

  /* music */
  .music-player {
    bottom: 8px; right: 8px;
    padding: 6px 10px;
  }
  .vinyl { width: 28px; height: 28px; }
  .vinyl-label { width: 12px; height: 12px; }
  .music-btn { width: 30px; height: 30px; }
  .music-icon { width: 14px; height: 14px; }



  /* scroll indicator */
  .scroll-indicator { font-size: 0.85rem; }
  .scroll-arrow svg { width: 20px; height: 20px; }
}

/* ---------- VERY SMALL (iPhone SE, etc.) ---------- */
@media (max-width: 360px) {
  .hero-title { font-size: clamp(1.6rem, 14vw, 2.4rem); }
  .polaroid { width: 120px; }

}

/* ============================================================
   UTILITIES
   ============================================================ */
.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}
