:root {
  --cream: #fff8f0;
  --paper: #fffdf8;
  --rose: #e8577e;
  --rose-deep: #c23a62;
  --blush: #fbd3dd;
  --gold: #f2b84b;
  --plum: #4a2340;
  --ink: #3b2633;
  --muted: #8a6b7a;
  --shadow: 0 18px 40px -18px rgba(74, 35, 64, .45);
  --display: "Fraunces", Georgia, serif;
  --hand: "Caveat", cursive;
  --body: "DM Sans", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 10% -10%, #ffe3ea 0%, transparent 60%),
    radial-gradient(900px 500px at 110% 20%, #fff0d6 0%, transparent 60%),
    var(--cream);
  background-attachment: fixed;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }

/* ---------- floating petals ---------- */
.petals { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.petal {
  position: absolute; top: -40px; font-size: 18px; opacity: .55;
  animation: fall linear infinite;
}
@keyframes fall {
  to { transform: translate3d(var(--drift, 40px), 110vh, 0) rotate(540deg); }
}

/* ---------- intro ---------- */
.intro {
  position: fixed; inset: 0; z-index: 40;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px; padding: 24px; text-align: center;
  background: radial-gradient(circle at 50% 40%, #ffe9ef, var(--cream) 70%);
  transition: opacity .9s ease, visibility .9s;
}
.intro.gone { opacity: 0; visibility: hidden; }
.intro-kicker, .kicker {
  margin: 0; font-size: 13px; letter-spacing: .18em; text-transform: uppercase; color: var(--rose);
  font-weight: 700;
}
.intro-title {
  margin: 0; font-family: var(--display); font-weight: 600;
  font-size: clamp(28px, 6vw, 52px); line-height: 1.1; color: var(--plum);
}
.hint { margin: 0; color: var(--muted); animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px); } }

.gift {
  position: relative; width: 170px; height: 170px; border: 0; background: none; padding: 0;
  animation: wiggle 2.4s ease-in-out infinite; margin: 20px 0;
}
.gift:hover { animation-duration: .8s; }
@keyframes wiggle {
  0%, 70%, 100% { transform: rotate(0); }
  75% { transform: rotate(-7deg); } 80% { transform: rotate(7deg); }
  85% { transform: rotate(-5deg); } 90% { transform: rotate(4deg); }
}
.gift-box {
  position: absolute; left: 10px; right: 10px; bottom: 0; height: 110px;
  background:
    linear-gradient(90deg, transparent 42%, var(--gold) 42% 58%, transparent 58%),
    var(--rose);
  border-radius: 8px; box-shadow: var(--shadow);
}
.gift-lid {
  position: absolute; left: 0; right: 0; top: 34px; height: 36px; z-index: 2;
  background:
    linear-gradient(90deg, transparent 42%, #f7c766 42% 58%, transparent 58%),
    var(--rose-deep);
  border-radius: 8px;
  transition: transform .8s cubic-bezier(.2, 1.6, .4, 1);
}
.gift-bow {
  position: absolute; left: 50%; top: -30px; width: 0; height: 0;
}
.gift-bow::before, .gift-bow::after {
  content: ""; position: absolute; top: 0; width: 40px; height: 30px;
  border: 8px solid var(--gold); border-radius: 50% 50% 10% 50%;
}
.gift-bow::before { right: 0; transform: rotate(-20deg); }
.gift-bow::after { left: 0; transform: scaleX(-1) rotate(-20deg); }
.gift.open { animation: none; }
.gift.open .gift-lid { transform: translateY(-160px) rotate(-25deg); opacity: 0; transition: transform .8s ease-out, opacity .8s .3s; }

/* ---------- controls ---------- */
.music-btn {
  position: fixed; top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 60;
  width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--paper); box-shadow: var(--shadow); font-size: 20px; color: var(--rose);
}
.music-btn.on { animation: pulse 1.2s ease-in-out infinite; background: var(--rose); color: #fff; }
@keyframes pulse { 50% { transform: scale(1.08); } }

.dots {
  position: fixed; right: 16px; top: 50%; transform: translateY(-50%); z-index: 30;
  display: flex; flex-direction: column; gap: 12px;
}
.dots a {
  width: 11px; height: 11px; border-radius: 50%; background: var(--blush); display: block;
  transition: transform .3s, background .3s;
}
.dots a.active { background: var(--rose); transform: scale(1.4); }
@media (max-width: 640px) { .dots { display: none; } }

/* ---------- scenes ---------- */
main { position: relative; z-index: 1; }
.scene {
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 80px 16px; text-align: center;
}
.scene h2 {
  margin: 0; font-family: var(--display); font-weight: 600; color: var(--plum);
  font-size: clamp(30px, 6vw, 56px); line-height: 1.05;
}
.sub { margin: 0; color: var(--muted); max-width: 440px; }
.reveal { opacity: 0; transform: translateY(30px); transition: opacity .8s ease, transform .8s ease; }
.reveal.in { opacity: 1; transform: none; }

.btn {
  border: 0; border-radius: 999px; padding: 13px 22px; font-weight: 700;
  background: var(--rose); color: #fff; box-shadow: 0 10px 24px -10px var(--rose);
  transition: transform .2s, background .2s;
}
.btn:hover { transform: translateY(-2px); background: var(--rose-deep); }
.btn:active { transform: scale(.96); }
.btn-ghost { background: var(--paper); color: var(--rose-deep); box-shadow: var(--shadow); }
.btn-ghost:hover { background: #fff; }
.btn-small { padding: 9px 16px; font-size: 14px; }

/* ---------- cake ---------- */
.cake { position: relative; width: 280px; height: 300px; margin: 30px 0 10px; }
.candles {
  position: absolute; left: 50px; right: 50px; bottom: 210px; height: 90px;
  display: flex; justify-content: space-around; align-items: flex-end;
}
.candle {
  position: relative; width: 14px; height: 52px; border: 0; padding: 0; border-radius: 4px;
  background: repeating-linear-gradient(-45deg, #fff 0 6px, var(--blush) 6px 12px);
  box-shadow: inset -3px 0 0 rgba(0,0,0,.06);
}
.candle::before { /* wick */
  content: ""; position: absolute; left: 50%; top: -8px; width: 2px; height: 9px;
  background: #4b3a3a; transform: translateX(-50%);
}
.flame {
  position: absolute; left: 50%; bottom: 58px; width: 16px; height: 26px;
  transform: translateX(-50%); transform-origin: 50% 100%;
  background: radial-gradient(ellipse at 50% 80%, #fff7c2 0%, #ffd34d 40%, #ff8a1f 75%, transparent 76%);
  border-radius: 50% 50% 45% 45% / 65% 65% 35% 35%;
  filter: drop-shadow(0 0 10px #ffb84d) drop-shadow(0 0 22px rgba(255,170,60,.6));
  animation: flicker .12s ease-in-out infinite alternate;
  transition: opacity .25s, transform .25s;
}
@keyframes flicker {
  from { transform: translateX(-50%) scale(1, 1) rotate(-2deg); }
  to   { transform: translateX(-50%) scale(.94, 1.06) rotate(2deg); }
}
.candle.out .flame { opacity: 0; transform: translateX(-50%) scale(.2); animation: none; }
.smoke {
  position: absolute; left: 50%; bottom: 60px; width: 8px; height: 8px; border-radius: 50%;
  background: rgba(150,140,150,.5); pointer-events: none;
  animation: smoke 1.4s ease-out forwards;
}
@keyframes smoke {
  to { transform: translate(-50%, -70px) scale(4); opacity: 0; }
}
.cake.blowing .flame { animation-duration: .05s; transform: translateX(-50%) skewX(-18deg); }

.tier { position: absolute; left: 50%; transform: translateX(-50%); border-radius: 14px; }
.tier-top {
  bottom: 140px; width: 190px; height: 70px;
  background: linear-gradient(#ffb6c8, #f58aa6);
}
.tier-bottom {
  bottom: 30px; width: 260px; height: 112px;
  background: linear-gradient(#ffe0b0, #f5c37a);
}
.drip {
  position: absolute; left: 0; right: 0; top: 0; height: 26px; border-radius: 14px 14px 0 0;
  background:
    radial-gradient(circle at 10% 100%, var(--paper) 9px, transparent 10px) 0 6px / 34px 26px repeat-x,
    linear-gradient(var(--paper), var(--paper)) 0 0 / 100% 14px no-repeat;
}
.tier-top .drip {
  background:
    radial-gradient(circle at 10% 100%, #fff 9px, transparent 10px) 0 6px / 30px 26px repeat-x,
    linear-gradient(#fff, #fff) 0 0 / 100% 14px no-repeat;
}
.sprinkles {
  position: absolute; inset: 40px 20px 20px;
  background-image:
    radial-gradient(circle, var(--rose) 2px, transparent 3px),
    radial-gradient(circle, #6fc2b0 2px, transparent 3px),
    radial-gradient(circle, var(--plum) 2px, transparent 3px);
  background-size: 38px 30px, 46px 34px, 52px 28px;
  background-position: 0 0, 14px 10px, 26px 4px;
  opacity: .8;
}
.plate {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  width: 300px; height: 26px; border-radius: 50%;
  background: linear-gradient(#fff, #e9dfe3); box-shadow: var(--shadow);
}
.cake-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.meter { width: 200px; height: 8px; border-radius: 99px; background: var(--blush); overflow: hidden; }
.meter span { display: block; height: 100%; width: 0; background: var(--rose); transition: width .08s; }
.wish {
  min-height: 1.4em; margin: 6px 0 0; font-family: var(--hand); font-size: 34px; color: var(--rose-deep);
}

/* ---------- envelope & letter ---------- */
.envelope {
  position: relative; width: min(380px, 86vw); aspect-ratio: 3 / 2; margin: 50px 0 10px;
  border: 0; padding: 0; background: none; perspective: 900px;
  transition: transform .3s;
}
.envelope:not(.open):hover { transform: translateY(-4px) rotate(-1deg); }
.env-back, .env-front, .env-flap, .env-paper { position: absolute; display: block; }
.env-back { inset: 0; background: #e9a4b5; border-radius: 10px; box-shadow: var(--shadow); }
.env-paper {
  left: 6%; right: 6%; top: 8%; bottom: 8%; background: var(--paper); border-radius: 6px;
  display: grid; place-items: center; font-family: var(--hand); font-size: 30px; color: var(--rose-deep);
  transition: transform .9s .5s cubic-bezier(.3, 1.3, .5, 1); z-index: 1;
}
.env-front {
  inset: 0; z-index: 2; border-radius: 10px;
  background:
    linear-gradient(to top right, #f6bccb 50%, transparent 50%) left / 50.5% 100% no-repeat,
    linear-gradient(to top left, #f3b0c1 50%, transparent 50%) right / 50.5% 100% no-repeat;
}
.env-flap {
  left: 0; right: 0; top: 0; height: 58%; z-index: 3; transform-origin: top;
  background: #f09bb2; clip-path: polygon(0 0, 100% 0, 50% 100%);
  transition: transform .6s ease, z-index 0s .3s;
}
.env-seal {
  position: absolute; left: 50%; top: 58%; z-index: 4; transform: translate(-50%, -50%);
  width: 44px; height: 44px; border-radius: 50%; background: var(--rose-deep); color: #fff;
  display: grid; place-items: center; font-size: 20px; box-shadow: 0 4px 10px rgba(0,0,0,.2);
  transition: transform .4s, opacity .4s;
}
.envelope.open .env-seal { transform: translate(-50%, -50%) scale(0); opacity: 0; }
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .env-paper { transform: translateY(-55%); }

.letter {
  width: min(560px, 100%); text-align: left; margin-top: 10px;
  background: var(--paper); border-radius: 14px; padding: 30px 28px 22px; box-shadow: var(--shadow);
  background-image: repeating-linear-gradient(transparent 0 35px, #f3e3e8 35px 36px);
  background-position: 0 22px;
  animation: rise .7s ease both;
}
@keyframes rise { from { opacity: 0; transform: translateY(30px) scale(.97); } }
.letter-body { font-family: var(--hand); font-size: 26px; line-height: 36px; min-height: 120px; }
.letter-body p { margin: 0 0 36px; }
.letter-body p:last-child { margin: 0; }
.caret { display: inline-block; width: 2px; height: 1em; background: var(--rose); vertical-align: -3px; animation: blink .8s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.letter-sign { font-family: var(--hand); font-size: 28px; color: var(--rose-deep); text-align: right; margin: 22px 0 6px; min-height: 1em; }

/* ---------- memories board ---------- */
.board {
  position: relative; width: min(980px, 100%); height: 600px; margin: 16px 0;
  border-radius: 20px; background: rgba(255,255,255,.35); border: 2px dashed #f0c6d2;
}
@media (max-width: 640px) { .board { height: 620px; } }
.polaroid {
  position: absolute; width: 220px; height: 214px; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  perspective: 900px; cursor: grab;
}
@media (max-width: 640px) { .polaroid { width: 150px; height: 153px; } }
.polaroid.dragging { cursor: grabbing; }
.polaroid-inner {
  position: relative; width: 100%; height: 100%; transform-style: preserve-3d;
  transition: transform .6s cubic-bezier(.3, 1.4, .5, 1), box-shadow .3s;
  transform: rotate(var(--rot, 0deg));
}
.polaroid.dragging .polaroid-inner { transform: rotate(0) scale(1.06); }
.polaroid.flipped .polaroid-inner { transform: rotate(var(--rot, 0deg)) rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: #fff; padding: 10px 10px 0; border-radius: 4px; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.face img, .face .ph {
  width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 2px; pointer-events: none;
}
.ph {
  display: grid; place-items: center; font-size: 46px; color: #fff;
  background: linear-gradient(135deg, var(--c1, #f7a8bd), var(--c2, #f6c78a));
}
.face figcaption { font-family: var(--hand); font-size: 21px; padding: 6px 0; text-align: center; line-height: 1; }
.face.back {
  transform: rotateY(180deg); padding: 16px; justify-content: center; align-items: center;
  background: #fff9e9; font-family: var(--hand); font-size: 22px; text-align: center; line-height: 1.15;
}
.tape {
  position: absolute; top: -10px; left: 50%; width: 64px; height: 20px; transform: translateX(-50%) rotate(-3deg);
  background: rgba(242, 184, 75, .55); z-index: 2;
}

/* ---------- reasons jar ---------- */
.reasons { display: flex; gap: 40px; align-items: center; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.jar { position: relative; width: 170px; height: 220px; border: 0; background: none; padding: 0; transition: transform .2s; }
.jar:hover { transform: rotate(-3deg); }
.jar.shake { animation: jarShake .45s ease; }
@keyframes jarShake {
  25% { transform: rotate(-9deg); } 50% { transform: rotate(8deg); } 75% { transform: rotate(-4deg); }
}
.jar-lid {
  position: absolute; left: 30px; right: 30px; top: 0; height: 26px; border-radius: 6px;
  background: linear-gradient(var(--gold), #d9982b); z-index: 2;
}
.jar-glass {
  position: absolute; left: 10px; right: 10px; top: 20px; bottom: 0; border-radius: 30px 30px 40px 40px;
  background: linear-gradient(110deg, rgba(255,255,255,.7), rgba(255,255,255,.25) 40%, rgba(255,255,255,.55));
  border: 3px solid rgba(255,255,255,.9); box-shadow: var(--shadow); overflow: hidden;
}
.jar-hearts { position: absolute; inset: 0; }
.jar-hearts i {
  position: absolute; font-style: normal; font-size: 26px; transition: transform .4s, opacity .4s;
}
.jar-hearts i.gone { opacity: 0; transform: translateY(-80px) scale(.5); }
.reason-card {
  width: min(340px, 90vw); min-height: 190px; padding: 26px; border-radius: 18px; background: var(--paper);
  box-shadow: var(--shadow); display: flex; flex-direction: column; justify-content: center; gap: 8px;
}
.reason-card p { margin: 0; font-family: var(--hand); font-size: 30px; line-height: 1.15; color: var(--plum); }
.reason-card.pop { animation: pop .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { from { transform: scale(.7) rotate(-4deg); opacity: 0; } }
.reason-num { font-size: 13px; letter-spacing: .14em; text-transform: uppercase; color: var(--rose); font-weight: 700; }
.flyer { position: fixed; z-index: 55; font-size: 28px; pointer-events: none; animation: fly 1s ease-out forwards; }
@keyframes fly { to { transform: translate(var(--dx), var(--dy)) scale(.4) rotate(40deg); opacity: 0; } }

/* ---------- finale ---------- */
.finale { cursor: crosshair; }
.big {
  font-size: clamp(46px, 12vw, 130px) !important; display: flex; flex-wrap: wrap; justify-content: center;
  gap: 0 .3em; user-select: none;
}
.big .word { display: inline-flex; }
.big .ch {
  display: inline-block; transition: transform .3s cubic-bezier(.3, 1.8, .5, 1), color .3s;
  animation: wave 2.6s ease-in-out infinite; animation-delay: calc(var(--i) * 80ms);
}
.big .ch:hover, .big .ch.hit { transform: translateY(-24px) rotate(-8deg) scale(1.15); color: var(--rose); }
@keyframes wave { 0%, 60%, 100% { translate: 0 0; } 30% { translate: 0 -10px; } }
.big-sub { margin: 0; font-family: var(--hand); font-size: clamp(30px, 6vw, 46px); color: var(--rose-deep); }
.finale-photo {
  margin: 0 0 10px; width: min(520px, 92vw); padding: 12px 12px 6px; background: #fff;
  border-radius: 6px; box-shadow: var(--shadow); transform: rotate(-2deg);
}
.finale-photo img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 3px; }
.finale-photo figcaption { font-family: var(--hand); font-size: 24px; padding: 6px 0 2px; color: var(--plum); }
.foot { margin-top: 40px; font-size: 13px; color: var(--muted); }

/* ---------- sparkle cursor trail ---------- */
.spark {
  position: fixed; z-index: 70; pointer-events: none; width: 8px; height: 8px; border-radius: 50%;
  background: var(--gold); box-shadow: 0 0 8px var(--gold);
  animation: sparkFade .7s ease-out forwards;
}
@keyframes sparkFade { to { transform: translate(var(--sx), var(--sy)) scale(0); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
  .petals { display: none; }
}
