/* ============ 主题与基础 ============ */
:root {
  --bg-1: #1a0f2e;
  --bg-2: #2b1a3d;
  --bg-3: #3d2352;
  --pink: #f8c8dc;
  --pink-deep: #f4a7c3;
  --gold: #ffd591;
  --lavender: #cbb8ea;
  --cream: #fff5f7;
  --muted: #8a7aa8;
  --font-hand: 'LXGW WenKai', 'Kaiti SC', 'STKaiti', 'KaiTi', serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-hand);
  background: linear-gradient(180deg, var(--bg-1) 0%, var(--bg-2) 45%, var(--bg-3) 75%, var(--bg-1) 100%);
  color: var(--cream);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

#particles {
  position: fixed;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.hidden { display: none !important; }

/* ============ 场景通用 ============ */
.scene {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
}

.inner {
  width: 100%;
  max-width: 480px;
  text-align: center;
}

.btn-soft {
  font-family: inherit;
  border: none;
  cursor: pointer;
  padding: 12px 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--pink-deep), #e88bb0);
  color: #fff;
  font-size: 15px;
  letter-spacing: 2px;
  box-shadow: 0 4px 24px rgba(244, 167, 195, .45);
  transition: transform .25s ease, box-shadow .25s ease;
}
.btn-soft:active { transform: scale(.95); }

/* ============ 音乐按钮 ============ */
#music-toggle {
  position: fixed;
  top: calc(12px + env(safe-area-inset-top));
  right: 14px;
  z-index: 50;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(248, 200, 220, .35);
  background: rgba(43, 26, 61, .55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--pink);
  font-size: 20px;
  cursor: pointer;
}
#music-toggle.playing { animation: spin 6s linear infinite; color: var(--gold); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ ① 开场礼物盒 ============ */
.gift {
  position: relative;
  width: 150px;
  height: 150px;
  margin: 0 auto 34px;
  animation: float 3.5s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

.gift-glow {
  position: absolute;
  inset: -40px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 213, 145, .35) 0%, rgba(248, 200, 220, .18) 45%, transparent 70%);
  animation: glowPulse 2.6s ease-in-out infinite;
}
@keyframes glowPulse { 0%,100% { transform: scale(1); opacity: .8; } 50% { transform: scale(1.15); opacity: 1; } }

.gift-box {
  position: absolute;
  left: 10px; right: 10px; bottom: 0;
  height: 100px;
  border-radius: 10px;
  background: linear-gradient(160deg, #f4a7c3 0%, #e88bb0 60%, #d977a2 100%);
  box-shadow: inset 0 -14px 24px rgba(90, 30, 70, .25), 0 10px 30px rgba(0,0,0,.35);
  transition: transform .8s ease, opacity .8s ease;
}
.ribbon-v {
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 22px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--gold), #f0b96a);
}

.gift-lid {
  position: absolute;
  left: 0; right: 0; top: 28px;
  height: 34px;
  border-radius: 8px;
  background: linear-gradient(160deg, #f8b8cf, #e88bb0);
  box-shadow: 0 4px 12px rgba(0,0,0,.25);
  transform-origin: center;
  transition: transform .9s cubic-bezier(.34, 1.4, .5, 1), opacity .9s ease;
}
.gift-lid::before {
  content: '';
  position: absolute;
  left: 50%; top: 0; bottom: 0;
  width: 22px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, var(--gold), #f0b96a);
}
.bow {
  position: absolute;
  left: 50%; top: -22px;
  width: 44px; height: 24px;
  transform: translateX(-50%);
}
.bow::before, .bow::after {
  content: '';
  position: absolute;
  top: 0;
  width: 22px; height: 22px;
  border: 6px solid var(--gold);
  border-radius: 50% 50% 0 50%;
}
.bow::before { left: 0; transform: rotate(-40deg); }
.bow::after { right: 0; transform: rotate(130deg) scaleY(-1); }

.gift.opened .gift-lid { transform: translateY(-130px) rotate(-24deg); opacity: 0; }
.gift.opened .gift-box { transform: scale(.92) translateY(30px); opacity: 0; }
.gift.opened .gift-glow { animation: burst 1s ease forwards; }
@keyframes burst {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(3.2); opacity: 0; }
}
.gift.opened { animation: none; }

.gift-hint {
  color: var(--pink);
  font-size: 17px;
  letter-spacing: 2px;
  margin-bottom: 22px;
  text-shadow: 0 0 18px rgba(248, 200, 220, .45);
}

/* ============ ② 祝福主页 ============ */
.eyebrow {
  color: var(--gold);
  font-size: 13px;
  letter-spacing: 6px;
  margin-bottom: 18px;
  opacity: 0;
  transform: translateY(20px);
  transition: all 1s ease .2s;
}
.title {
  font-size: 46px;
  letter-spacing: 10px;
  color: #fff;
  text-shadow: 0 0 34px rgba(248, 200, 220, .6);
  opacity: 0;
  transform: translateY(24px);
  transition: all 1s ease .5s;
}
.name {
  font-size: 22px;
  color: var(--pink);
  letter-spacing: 4px;
  margin-top: 12px;
  opacity: 0;
  transform: translateY(24px);
  transition: all 1s ease .8s;
}
.scene-wish.active .eyebrow,
.scene-wish.active .title,
.scene-wish.active .name { opacity: 1; transform: translateY(0); }

.wish-line {
  margin-top: 30px;
  font-size: 15px;
  line-height: 2.2;
  color: var(--lavender);
  min-height: 66px;
}
.wish-line .ch {
  opacity: 0;
  display: inline-block;
  transform: translateY(10px);
  transition: opacity .5s ease, transform .5s ease;
}
.wish-line .ch.on { opacity: 1; transform: translateY(0); }

.scroll-hint {
  margin-top: 40px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 3px;
  animation: hintPulse 2s ease-in-out infinite;
}
@keyframes hintPulse { 0%,100% { opacity: .4; } 50% { opacity: 1; } }

/* ============ 蛋糕（通用） ============ */
.cake {
  position: relative;
  width: 170px;
  height: 150px;
  margin: 34px auto 0;
}
.cake .candles {
  position: absolute;
  top: 18px; left: 0; right: 0;
  display: flex;
  justify-content: center;
  gap: 26px;
}
.candle {
  position: relative;
  width: 8px;
  height: 34px;
  border-radius: 4px;
  background: repeating-linear-gradient(45deg, #fff 0 4px, var(--pink-deep) 4px 8px);
}
.candle.c2 { height: 42px; }
.flame {
  position: absolute;
  top: -16px; left: 50%;
  width: 12px; height: 16px;
  transform: translateX(-50%);
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(circle at 50% 70%, #fff7d6 0%, var(--gold) 55%, #ff9d5c 100%);
  box-shadow: 0 0 16px 5px rgba(255, 213, 145, .55);
  animation: flicker .35s ease-in-out infinite alternate;
  transform-origin: 50% 100%;
}
@keyframes flicker {
  from { transform: translateX(-50%) scale(1) rotate(-2deg); }
  to   { transform: translateX(-50%) scale(.88) rotate(3deg); }
}
.smoke {
  position: absolute;
  top: -20px; left: 50%;
  width: 4px; height: 18px;
  border-radius: 4px;
  background: linear-gradient(180deg, transparent, rgba(220, 210, 235, .7));
  opacity: 0;
  transform: translateX(-50%);
}
.cake-top {
  position: absolute;
  top: 50px; left: 25px; right: 25px;
  height: 34px;
  border-radius: 12px 12px 8px 8px;
  background: linear-gradient(180deg, #fff0f5 0%, var(--pink) 100%);
}
.cake-top::after {
  content: '';
  position: absolute;
  left: 6px; right: 6px; bottom: -8px;
  height: 12px;
  background: radial-gradient(circle at 8px 0, var(--pink) 6px, transparent 7px);
  background-size: 18px 12px;
  background-repeat: repeat-x;
}
.cake-mid {
  position: absolute;
  top: 84px; left: 12px; right: 12px;
  height: 30px;
  border-radius: 6px;
  background: linear-gradient(180deg, #e88bb0, #d977a2);
}
.cake-base {
  position: absolute;
  top: 114px; left: 0; right: 0;
  height: 26px;
  border-radius: 6px 6px 10px 10px;
  background: linear-gradient(180deg, #c9648f, #b05579);
}
.cake-plate {
  position: absolute;
  top: 140px; left: -12px; right: -12px;
  height: 10px;
  border-radius: 50%;
  background: rgba(203, 184, 234, .45);
}

/* 结尾场景：吹灭状态 */
.cake.blown .flame { animation: none; opacity: 0; transition: opacity .4s ease; }
.cake.blown .smoke {
  animation: smokeRise 2.2s ease forwards;
}
@keyframes smokeRise {
  0% { opacity: 0; transform: translate(-50%, 0) scaleY(.5); }
  25% { opacity: .8; }
  100% { opacity: 0; transform: translate(-50%, -34px) scaleY(1.6); }
}

/* ============ ③ 情书信封 ============ */
.envelope {
  position: relative;
  width: min(340px, 88vw);
  height: 220px;
  margin: 0 auto;
  perspective: 900px;
}
.env-back {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(160deg, #b9a3dd, #9c83c6);
  box-shadow: 0 14px 40px rgba(0, 0, 0, .4);
  z-index: 1;
}
.env-letter {
  position: absolute;
  left: 5%;
  width: 90%;
  bottom: 14px;
  z-index: 2;
  transform: translateY(6%);
  transition: transform 1.4s cubic-bezier(.22, .9, .3, 1) .5s;
}
.letter-paper {
  background: linear-gradient(180deg, #fff9f4, #ffefea);
  border-radius: 8px;
  padding: 22px 18px;
  color: #6b4a5e;
  text-align: left;
  font-size: 14px;
  line-height: 2.1;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .18);
}
.letter-salutation { margin-bottom: 6px; color: #a05a78; }
.letter-p { min-height: 1.4em; margin-bottom: 6px; }
.letter-sign { text-align: right; color: #a05a78; margin-top: 10px; opacity: 0; transition: opacity 1s ease; }
.letter-sign.on { opacity: 1; }

.env-front {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: linear-gradient(200deg, #cbb8ea 0%, #b09ad4 100%);
  clip-path: polygon(0 22%, 50% 62%, 100% 22%, 100% 100%, 0 100%);
  z-index: 3;
}
.env-flap {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 55%;
  background: linear-gradient(180deg, #d5c5ef, #b9a3dd);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 1s ease .1s, z-index 0s .6s;
  z-index: 4;
  border-radius: 12px 12px 0 0;
}
.env-seal {
  position: absolute;
  left: 50%; top: 46%;
  width: 44px; height: 44px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, #f4a7c3, #e0709c);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  z-index: 5;
  box-shadow: 0 3px 12px rgba(224, 112, 156, .5);
  transition: opacity .5s ease, transform .5s ease;
}
.envelope.open .env-flap { transform: rotateX(180deg); z-index: 0; }
.envelope.open .env-seal { opacity: 0; transform: translate(-50%, -50%) scale(1.6); }
.envelope.open .env-letter { transform: translateY(-72%); }

/* ============ ④ 照片回忆 ============ */
.section-title {
  color: var(--gold);
  font-size: 16px;
  letter-spacing: 5px;
  margin-bottom: 36px;
}
.photo-list {
  display: flex;
  flex-direction: column;
  gap: 30px;
}
.polaroid {
  background: #fff;
  padding: 10px 10px 12px;
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  width: min(300px, 82%);
  opacity: 0;
  transition: opacity .9s ease, transform .9s ease;
  cursor: pointer;
}
.polaroid.left {
  margin-right: auto;
  transform: translateX(-30px) rotate(-3deg);
}
.polaroid.right {
  margin-left: auto;
  transform: translateX(30px) rotate(3deg);
}
.scene-photos.active .polaroid { opacity: 1; }
.scene-photos.active .polaroid.left { transform: translateX(0) rotate(-3deg); }
.scene-photos.active .polaroid.right { transform: translateX(0) rotate(3deg); }
.polaroid:nth-child(2) { transition-delay: .15s; }
.polaroid:nth-child(3) { transition-delay: .3s; }
.polaroid:nth-child(4) { transition-delay: .45s; }
.polaroid:nth-child(5) { transition-delay: .6s; }
.polaroid:nth-child(6) { transition-delay: .75s; }
.polaroid img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: 3px;
  display: block;
}
.polaroid figcaption {
  margin-top: 10px;
  text-align: center;
  color: #7a5a6e;
  font-size: 14px;
  letter-spacing: 1px;
}

/* ============ ⑤ 结尾 ============ */
.finale-hint {
  margin-top: 30px;
  color: var(--pink);
  font-size: 17px;
  letter-spacing: 3px;
}
.btn-blow { margin-top: 22px; background: linear-gradient(135deg, var(--gold), var(--pink-deep)); color: #5d3a4a; }
.finale-msg {
  margin-top: 34px;
  font-size: 24px;
  letter-spacing: 4px;
  color: #fff;
  text-shadow: 0 0 30px rgba(255, 213, 145, .7);
  opacity: 0;
  transform: translateY(20px) scale(.94);
  transition: all 1.4s ease;
}
.finale-msg.show { opacity: 1; transform: translateY(0) scale(1); }

/* ============ 灯箱 ============ */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(12, 6, 24, .93);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .35s ease;
  padding: 24px;
}
.lightbox.show { opacity: 1; pointer-events: auto; }
.lightbox img {
  max-width: 88vw;
  max-height: 76vh;
  border-radius: 10px;
  box-shadow: 0 0 60px rgba(248, 200, 220, .25);
}
.lightbox-cap { color: var(--pink); font-size: 15px; letter-spacing: 2px; }

/* ============ 桌面端 ============ */
@media (min-width: 768px) {
  .title { font-size: 56px; }
}
