:root {
  --bg-deep: #0b1026;
  --panel: rgba(12, 18, 42, 0.68);
  --panel-strong: rgba(10, 15, 36, 0.9);
  --cream: #fff7e8;
  --ink: #241c2e;
  --gold: #ffd166;
  --coral: #ff7a72;
  --pink: #ff9eb5;
  --teal: #57d6c4;
  --lavender: #b9a8ff;
  --muted: rgba(255, 247, 232, 0.76);
}

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

html,
body {
  height: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  background: var(--bg-deep);
}

button {
  font: inherit;
  color: inherit;
}

[hidden] {
  display: none !important;
}

.stage {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--cream);
  isolation: isolate;
}

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 72% 18%, rgba(255, 209, 102, 0.12), transparent 34%),
    radial-gradient(ellipse at 18% 78%, rgba(87, 214, 196, 0.1), transparent 38%),
    linear-gradient(180deg, #0b1026 0%, #14103a 52%, #0b1026 100%);
}

.moon {
  position: absolute;
  top: 8vh;
  right: 7vw;
  width: clamp(64px, 8vw, 104px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #fffdf2 0 52%, #ffe9a8 72%, #f7c96b 100%);
  box-shadow: 0 0 46px rgba(255, 222, 145, 0.5), 0 0 120px rgba(255, 209, 102, 0.2);
  opacity: 0.9;
}

.star {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #fff6d8;
  box-shadow: 0 0 8px rgba(255, 246, 216, 0.9);
  animation: twinkle 2.8s ease-in-out infinite;
}

.balloon {
  position: absolute;
  bottom: -18vh;
  width: clamp(40px, 5vw, 64px);
  aspect-ratio: 0.78;
  border-radius: 50% 50% 48% 52%;
  opacity: 0.82;
  animation: floatUp linear infinite;
}

.balloon::before {
  content: "";
  position: absolute;
  left: 22%;
  top: 14%;
  width: 26%;
  height: 20%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transform: rotate(-24deg);
}

.balloon::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 96%;
  width: 1.5px;
  height: 26vh;
  background: rgba(255, 247, 232, 0.45);
  transform: translateX(-50%);
}

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

#particles canvas {
  display: block;
  width: 100%;
  height: 100%;
}

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

.film-grain {
  position: fixed;
  inset: 0;
  z-index: 8;
  opacity: 0.07;
  pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='180' height='180'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix type='saturate' values='0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)' opacity='0.6'/></svg>");
  animation: grainShift 1.1s steps(2) infinite;
}

.letterbox {
  position: absolute;
  left: 0;
  right: 0;
  height: 7vh;
  z-index: 7;
  background: rgba(0, 0, 0, 0.72);
  pointer-events: none;
}

.letterbox-top {
  top: 0;
}

.letterbox-bottom {
  bottom: 0;
}

.player {
  position: relative;
  z-index: 2;
  height: 100vh;
  height: 100dvh;
  transition: opacity 0.65s ease;
}

.player.is-leaving {
  opacity: 0;
}

.scene {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: var(--bg-deep);
}

.scene-bg {
  position: absolute;
  inset: -3%;
  opacity: 0;
  background: var(--bg-deep) center 30% / cover no-repeat;
  transition: opacity 0.45s ease;
  will-change: transform, opacity;
}

.scene-bg.is-on {
  opacity: 1;
  animation: kenburns 11s ease-out forwards;
}

.scene-bg.is-leaving {
  opacity: 0;
}

.scene-veil {
  position: absolute;
  inset: 0;
  z-index: 2;
  background:
    linear-gradient(180deg, rgba(5, 9, 26, 0.34) 0%, rgba(5, 9, 26, 0.08) 42%, rgba(5, 9, 26, 0.82) 100%),
    linear-gradient(90deg, rgba(5, 9, 26, 0.5), transparent 56%);
}

.scene-copy {
  position: absolute;
  z-index: 3;
  left: 0;
  right: 0;
  bottom: clamp(88px, 14vh, 132px);
  margin: 0 auto;
  width: min(720px, 86vw);
  text-align: center;
  opacity: 0;
  transform: translateY(22px);
  transition: opacity 0.42s ease, transform 0.5s cubic-bezier(0.2, 0.8, 0.2, 1);
}

.scene-copy.is-in {
  opacity: 1;
  transform: translateY(0);
}

.scene-kicker {
  display: inline-block;
  padding: 7px 13px;
  margin-bottom: 16px;
  border: 1px solid rgba(255, 209, 102, 0.55);
  border-radius: 999px;
  background: rgba(10, 15, 36, 0.42);
  color: var(--gold);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0;
  backdrop-filter: blur(6px);
}

.scene-title {
  margin-bottom: 14px;
  font-size: clamp(2.5rem, 6.4vw, 5rem);
  line-height: 1.12;
  font-weight: 800;
  color: var(--cream);
  text-shadow: 0 4px 26px rgba(0, 0, 0, 0.45);
}

.scene-text {
  max-width: 560px;
  margin: 0 auto;
  font-size: clamp(1.05rem, 2.3vw, 1.45rem);
  line-height: 1.7;
  color: var(--muted);
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.45);
}

.hud {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 5;
  pointer-events: none;
}

.progress {
  height: 4px;
  background: rgba(255, 247, 232, 0.16);
}

.progress i {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--coral));
  box-shadow: 0 0 14px rgba(255, 209, 102, 0.85);
}

.hud-meta {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 22px;
}

.date-badge,
.counter {
  padding: 7px 13px;
  border: 1px solid rgba(255, 247, 232, 0.2);
  border-radius: 999px;
  background: rgba(10, 15, 36, 0.5);
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 600;
  backdrop-filter: blur(6px);
}

.hud-meta {
  justify-content: space-between;
}

.hud-btns {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.ending {
  position: relative;
  z-index: 4;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 96px 16px 124px;
  text-align: center;
  background:
    radial-gradient(ellipse at 50% 88%, rgba(255, 209, 102, 0.18), transparent 40%),
    radial-gradient(ellipse at 50% 30%, rgba(185, 168, 255, 0.12), transparent 42%),
    linear-gradient(180deg, rgba(11, 16, 38, 0.94), rgba(20, 16, 58, 0.92));
  animation: fadeUp 0.7s ease both;
}

.ending-kicker {
  color: var(--gold);
  font-weight: 600;
}

.ending-title {
  margin: 4px 0 8px;
  font-size: clamp(2rem, 5.4vw, 3.6rem);
  line-height: 1.15;
  font-weight: 800;
}

.ending-hint {
  color: var(--muted);
  font-size: 1rem;
}

.cake-scene {
  display: flex;
  justify-content: center;
  margin-top: 6px;
}

.cake {
  position: relative;
  width: min(320px, 74vw);
  height: 290px;
}

.layer {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 14px;
  background:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0 9px, transparent 9px 18px),
    var(--layer-color);
  box-shadow: inset 0 -14px 20px rgba(0, 0, 0, 0.24), 0 18px 34px rgba(0, 0, 0, 0.3);
}

.layer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 16px;
  border-radius: 14px 14px 6px 6px;
  background: var(--cream);
  box-shadow: 0 3px 0 rgba(255, 255, 255, 0.3);
}

.layer-top {
  bottom: 136px;
  width: 56%;
  height: 70px;
  --layer-color: #ef9fb1;
  z-index: 3;
}

.layer-mid {
  bottom: 72px;
  width: 74%;
  height: 76px;
  --layer-color: #b6a5f7;
  z-index: 2;
}

.layer-bottom {
  bottom: 14px;
  width: 94%;
  height: 78px;
  --layer-color: #67cfc2;
  z-index: 1;
}

.plate {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 112%;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(ellipse at 50% 32%, #fff9ed, #cfd7e8 62%, #8d9abb);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.3);
}

.candles {
  position: absolute;
  z-index: 5;
  bottom: 206px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: clamp(10px, 2vw, 16px);
  align-items: flex-end;
}

.candle {
  position: relative;
  width: 12px;
  height: 44px;
  border-radius: 6px;
  background: repeating-linear-gradient(45deg, var(--gold) 0 4px, #fff3cf 4px 8px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.28);
  cursor: pointer;
}

.candle::before {
  content: "";
  position: absolute;
  top: -3px;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 7px;
  border-radius: 3px;
  background: #33416e;
}

.flame {
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 17px;
  border-radius: 50% 50% 50% 50% / 62% 62% 38% 38%;
  background: radial-gradient(circle at 50% 28%, #fff8c0 0 34%, var(--gold) 56%, var(--coral) 100%);
  filter: drop-shadow(0 0 7px rgba(255, 209, 102, 0.95));
  transform-origin: 50% 100%;
  animation: flicker 0.8s ease-in-out infinite alternate;
}

.candle.blown .flame {
  opacity: 0;
  transform: translateX(-50%) translateY(-6px) scale(0.15);
  transition: opacity 0.35s ease, transform 0.45s ease;
}

.blow-btn {
  margin-top: 10px;
  padding: 13px 26px;
  border: 1px solid rgba(255, 209, 102, 0.7);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 209, 102, 0.22), rgba(255, 122, 114, 0.16));
  color: var(--gold);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.3);
  transition: transform 0.18s ease, background 0.18s ease;
}

.blow-btn:hover {
  transform: translateY(-2px) scale(1.03);
  background: linear-gradient(180deg, rgba(255, 209, 102, 0.32), rgba(255, 122, 114, 0.24));
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(5, 9, 26, 0.72);
  backdrop-filter: blur(10px);
  animation: fadeIn 0.45s ease both;
}

.modal-panel {
  width: min(760px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: clamp(22px, 4vw, 34px);
  border: 1px solid rgba(255, 209, 102, 0.45);
  border-radius: 8px;
  background: linear-gradient(180deg, #fffaf0, #ffe9d2);
  color: var(--ink);
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.modal-kicker {
  color: #c46a3f;
  font-weight: 700;
}

.modal-title {
  margin: 8px 0 12px;
  font-size: clamp(2.2rem, 5.4vw, 3.4rem);
  line-height: 1.15;
  font-weight: 800;
}

.modal-wish {
  min-height: 3.2rem;
  margin-bottom: 20px;
  font-size: clamp(1.15rem, 2.6vw, 1.5rem);
  line-height: 1.6;
  font-weight: 700;
  color: #4c3540;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.modal-wish.swap {
  opacity: 0;
  transform: translateY(8px);
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 14px;
  margin: 8px 0 22px;
}

.gallery.swiper {
  display: block;
  overflow: hidden;
  margin: 8px 0 26px;
}

.gallery.swiper .swiper-wrapper {
  align-items: stretch;
}

.gallery.swiper .swiper-slide {
  height: auto;
}

.gallery.swiper .photo-card {
  height: 100%;
}

.gallery.swiper .swiper-pagination {
  position: static;
  margin-top: 14px;
}

.gallery.swiper .swiper-pagination-bullet {
  background: #8a5a48;
  opacity: 0.35;
}

.gallery.swiper .swiper-pagination-bullet-active {
  background: #c46a3f;
  opacity: 1;
}

.photo-card {
  background: #fff;
  border-radius: 8px;
  padding: 8px 8px 12px;
  box-shadow: 0 10px 24px rgba(72, 45, 30, 0.16);
  transition: transform 0.2s ease;
}

.photo-card:hover {
  transform: translateY(-3px) rotate(-0.5deg);
}

.photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border-radius: 4px;
  object-fit: cover;
  background: #f2d9c6;
}

.photo-card figcaption {
  margin-top: 9px;
  color: #6b4a3f;
  font-size: 0.88rem;
  font-weight: 600;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.action-btn {
  padding: 12px 22px;
  border: none;
  border-radius: 999px;
  background: #2c2438;
  color: var(--gold);
  font-size: 0.98rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, background 0.18s ease;
}

.action-btn:hover {
  transform: translateY(-2px);
  background: #413451;
}

.controls {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  display: flex;
  gap: 10px;
}

.icon-btn {
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 247, 232, 0.2);
  border-radius: 50%;
  background: var(--panel-strong);
  color: var(--cream);
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.icon-btn.sm {
  width: 38px;
  height: 38px;
  font-size: 0.95rem;
}

.icon-btn:hover {
  transform: translateY(-2px);
  background: rgba(255, 209, 102, 0.18);
  color: var(--gold);
}

.icon-btn:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.icon-btn.on {
  color: var(--gold);
  border-color: rgba(255, 209, 102, 0.7);
}

.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  z-index: 60;
  padding: 10px 18px;
  border-radius: 8px;
  background: var(--panel-strong);
  border: 1px solid rgba(255, 209, 102, 0.45);
  color: var(--cream);
  font-size: 0.95rem;
  opacity: 0;
  transform: translate(-50%, -14px);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes kenburns {
  0% {
    transform: scale(1.04) translate3d(0, 0, 0);
  }
  100% {
    transform: scale(1.16) translate3d(-1.6%, -1.2%, 0);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

@keyframes floatUp {
  0% {
    transform: translate3d(0, 0, 0) rotate(-3deg);
  }
  100% {
    transform: translate3d(6vw, -130vh, 0) rotate(5deg);
  }
}

@keyframes flicker {
  0% {
    transform: translateX(-50%) scale(1) rotate(-2deg);
  }
  100% {
    transform: translateX(-50%) scale(1.14) rotate(3deg);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes grainShift {
  0% {
    background-position: 0 0;
  }
  50% {
    background-position: -36px 22px;
  }
  100% {
    background-position: 24px -32px;
  }
}

@media (max-width: 760px) {
  .scene-copy {
    left: 20px;
    right: 20px;
    width: auto;
    bottom: 104px;
  }

  .scene-kicker {
    margin-bottom: 12px;
  }

  .scene-title {
    margin-bottom: 10px;
  }

  .hud-meta {
    padding: 14px 14px;
  }

  .date-badge,
  .counter {
    font-size: 0.8rem;
    padding: 6px 10px;
  }

  .cake {
    width: min(270px, 72vw);
    height: 260px;
  }

  .candles {
    bottom: 192px;
  }

  .ending {
    padding: 92px 14px 128px;
  }

  .gallery {
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 10px;
  }

  .controls {
    left: 50%;
    right: auto;
    bottom: max(16px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    width: max-content;
  }

  .letterbox {
    height: 5vh;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001s !important;
  }
}
