:root {
  --space-ink: #040611;
  --space-navy: #0b1430;
  --space-teal: #123d4b;
  --rose: #ff7aa8;
  --rose-soft: #ffc3d7;
  --gold: #ffd77b;
  --cyan: #85e7ff;
  --paper: #fffaf0;
  --text: rgba(255, 255, 255, 0.94);
  --muted: rgba(255, 255, 255, 0.68);
  --glass: rgba(7, 10, 24, 0.54);
  --hairline: rgba(255, 255, 255, 0.16);
}

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

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--space-ink);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 18% 18%, rgba(133, 231, 255, 0.18), transparent 25%),
    radial-gradient(circle at 82% 20%, rgba(255, 122, 168, 0.16), transparent 24%),
    radial-gradient(ellipse at 52% 92%, rgba(255, 215, 123, 0.14), transparent 34%),
    linear-gradient(150deg, #03050d 0%, #081029 48%, #123d4b 100%);
  pointer-events: none;
}

button {
  font: inherit;
}

noscript {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #050712;
  color: rgba(255, 255, 255, 0.86);
  text-align: center;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
}

.deep-space,
.aurora,
.stardust,
.vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.deep-space {
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), transparent 18%),
    radial-gradient(ellipse at center, transparent 0 36%, rgba(0, 0, 0, 0.36) 78%, rgba(0, 0, 0, 0.58) 100%);
}

.aurora {
  z-index: 1;
  opacity: 0.78;
  background:
    linear-gradient(116deg, transparent 0 24%, rgba(133, 231, 255, 0.13) 39%, transparent 57%),
    linear-gradient(64deg, transparent 0 34%, rgba(255, 215, 123, 0.12) 49%, transparent 68%),
    radial-gradient(ellipse at 62% 62%, rgba(255, 122, 168, 0.18), transparent 42%);
  filter: blur(14px) saturate(118%);
  animation: auroraDrift 13s ease-in-out infinite alternate;
}

.stardust {
  z-index: 2;
  opacity: 0.52;
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.72) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(255,215,123,0.54) 0 1px, transparent 1.5px),
    radial-gradient(circle, rgba(133,231,255,0.48) 0 1px, transparent 1.5px);
  background-size: 150px 150px, 230px 230px, 310px 310px;
  background-position: 12px 28px, 74px 92px, 132px 18px;
  animation: dustFloat 18s linear infinite;
}

.vignette {
  z-index: 4;
  background:
    radial-gradient(circle at 50% 42%, transparent 0 44%, rgba(0, 0, 0, 0.42) 100%),
    linear-gradient(to bottom, rgba(0, 0, 0, 0.22), transparent 22%, rgba(0, 0, 0, 0.46));
  mix-blend-mode: multiply;
}

@keyframes auroraDrift {
  from { transform: scale(1) translate3d(-1.5%, 1%, 0); }
  to { transform: scale(1.08) translate3d(1.5%, -1%, 0); }
}

@keyframes dustFloat {
  from { transform: translate3d(0, 0, 0); }
  to { transform: translate3d(-24px, 18px, 0); }
}

#star-canvas,
#firework-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

#star-canvas {
  z-index: 10;
}

#star-canvas.fallback-starfield {
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 1px, transparent 1.6px),
    radial-gradient(circle, rgba(255, 215, 123, 0.72) 0 1px, transparent 1.8px),
    radial-gradient(circle, rgba(133, 231, 255, 0.6) 0 1px, transparent 1.8px);
  background-position: 20px 24px, 84px 130px, 146px 68px;
  background-size: 180px 180px, 260px 260px, 340px 340px;
  animation: fallbackStars 18s linear infinite;
}

#star-canvas.fallback-sparkle {
  filter: brightness(1.3) saturate(1.2);
}

#star-canvas.fallback-meteor {
  background-image:
    linear-gradient(132deg, transparent 0 44%, rgba(255, 246, 214, 0.86) 49%, rgba(255, 122, 168, 0.42) 50%, transparent 58%),
    radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 1px, transparent 1.6px),
    radial-gradient(circle, rgba(255, 215, 123, 0.72) 0 1px, transparent 1.8px);
  background-position: 110vw -20vh, 20px 24px, 84px 130px;
  background-size: 46vw 22vh, 180px 180px, 260px 260px;
  animation: fallbackMeteor 1s ease-out both;
}

@keyframes fallbackStars {
  from { background-position: 20px 24px, 84px 130px, 146px 68px; }
  to { background-position: -40px 68px, 24px 172px, 86px 112px; }
}

@keyframes fallbackMeteor {
  from { background-position: 110vw -20vh, 20px 24px, 84px 130px; }
  to { background-position: -40vw 96vh, 20px 24px, 84px 130px; }
}

#firework-canvas {
  z-index: 5;
  opacity: 0;
  transition: opacity 1s ease;
  pointer-events: none;
}

#firework-canvas.active {
  opacity: 1;
}

#opening {
  position: absolute;
  left: 50%;
  top: 48%;
  z-index: 22;
  display: grid;
  justify-items: center;
  width: min(88vw, 720px);
  text-align: center;
  opacity: 0;
  transform: translate(-50%, -45%) scale(0.96);
  transition:
    opacity 0.8s ease,
    transform 0.8s cubic-bezier(0.19, 1, 0.22, 1),
    filter 0.8s ease;
}

#opening.ready {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

#opening.hidden {
  opacity: 0;
  filter: blur(10px);
  pointer-events: none;
  transform: translate(-50%, -54%) scale(1.04);
}

#wish-stage {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 23;
  display: grid;
  justify-items: center;
  width: min(86vw, 620px);
  padding: 0 12px;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -44%) scale(0.98);
  transition:
    opacity 0.55s ease,
    transform 0.55s cubic-bezier(0.19, 1, 0.22, 1);
}

#wish-stage.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.wish-kicker {
  margin-bottom: 14px;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 760;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(133, 231, 255, 0.42);
}

#wish-line {
  color: #fff7d8;
  font-size: clamp(25px, 5vw, 52px);
  font-weight: 780;
  line-height: 1.22;
  text-wrap: balance;
  text-shadow:
    0 0 18px rgba(255, 215, 123, 0.6),
    0 0 42px rgba(255, 122, 168, 0.28),
    0 16px 46px rgba(0, 0, 0, 0.46);
}

.opening-kicker {
  margin-bottom: 16px;
  color: var(--gold);
  font-size: clamp(12px, 1.5vw, 14px);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  text-shadow: 0 0 18px rgba(255, 215, 123, 0.42);
}

#opening-title {
  max-width: 10em;
  color: #fff7d8;
  font-size: clamp(44px, 9vw, 96px);
  font-weight: 850;
  line-height: 0.96;
  letter-spacing: 0;
  text-shadow:
    0 0 18px rgba(255, 215, 123, 0.72),
    0 0 50px rgba(255, 122, 168, 0.34),
    0 16px 48px rgba(0, 0, 0, 0.5);
}

#opening-subtitle {
  width: min(88vw, 520px);
  margin-top: 18px;
  color: rgba(255, 255, 255, 0.78);
  font-size: clamp(15px, 2vw, 19px);
  line-height: 1.7;
  text-wrap: balance;
}

#anniversary-badge {
  margin-top: 16px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(8, 12, 28, 0.42);
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  line-height: 1.4;
  backdrop-filter: blur(12px);
}

#anniversary-badge:empty,
#anniversary-badge[hidden] {
  display: none;
}

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

#start-button,
#preview-button,
#replay-button {
  min-height: 46px;
  margin-top: 28px;
  padding: 0 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 246, 214, 0.95), rgba(255, 215, 123, 0.88)),
    var(--gold);
  box-shadow:
    0 18px 52px rgba(255, 122, 168, 0.18),
    0 0 36px rgba(255, 215, 123, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.68);
  color: #3b2608;
  cursor: pointer;
  font-weight: 760;
  letter-spacing: 0;
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

#start-button:hover,
#preview-button:hover,
#replay-button:hover {
  transform: translateY(-2px);
  filter: brightness(1.04);
  box-shadow:
    0 22px 60px rgba(255, 122, 168, 0.24),
    0 0 46px rgba(255, 215, 123, 0.44),
    inset 0 1px 0 rgba(255, 255, 255, 0.72);
}

#preview-button {
  background:
    linear-gradient(180deg, rgba(18, 25, 52, 0.82), rgba(8, 12, 28, 0.68));
  color: rgba(255, 255, 255, 0.9);
}

#top-controls {
  position: absolute;
  right: clamp(16px, 4vw, 34px);
  top: clamp(16px, 4vw, 34px);
  z-index: 26;
  display: flex;
  gap: 10px;
}

#sound-toggle {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(8, 12, 28, 0.44);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.24);
  color: var(--gold);
  cursor: pointer;
  backdrop-filter: blur(14px);
}

#sound-toggle.muted {
  color: rgba(255, 255, 255, 0.58);
}

#photo-overlay {
  position: absolute;
  inset: 0;
  z-index: 18;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.photo-card {
  position: absolute;
  top: 50%;
  left: 50%;
  display: grid;
  gap: clamp(14px, 2.4vh, 20px);
  justify-items: center;
  width: min(74vw, 560px);
  opacity: 0;
  transform: translate(-50%, -46%) scale(0.88) rotate(-1.2deg);
  transition:
    transform 0.76s cubic-bezier(0.19, 1, 0.22, 1),
    opacity 0.5s ease;
}

.photo-card::before {
  content: "";
  position: absolute;
  inset: -18px -18px 54px;
  z-index: -1;
  border-radius: 26px;
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 215, 123, 0.2), transparent 42%),
    radial-gradient(circle at 18% 82%, rgba(255, 122, 168, 0.18), transparent 34%);
  filter: blur(18px);
  opacity: 0.9;
}

.photo-card.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1) rotate(-1.2deg);
}

.photo-card img,
.photo-card.memory-card::after,
.photo-card.missing-photo::after {
  width: min(100%, 520px);
  aspect-ratio: 4 / 5;
  max-height: 55vh;
  border-radius: 10px;
  box-shadow:
    0 30px 90px rgba(0, 0, 0, 0.48),
    0 0 0 1px rgba(255, 255, 255, 0.56),
    0 0 58px rgba(255, 215, 123, 0.22);
}

.photo-card img {
  padding: 12px 12px 46px;
  object-fit: cover;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), var(--paper));
}

.photo-card.memory-card::after,
.photo-card.missing-photo::after {
  content: attr(data-label);
  display: grid;
  place-items: center;
  padding: 24px;
  border: 12px solid rgba(255, 250, 240, 0.96);
  background:
    radial-gradient(circle at 50% 38%, rgba(255, 215, 123, 0.32), transparent 28%),
    linear-gradient(145deg, #fffaf0, #f4edf4 58%, #eaf8ff);
  color: rgba(20, 25, 42, 0.62);
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 800;
  line-height: 1.2;
  text-align: center;
}

.photo-card .caption {
  max-width: min(82vw, 640px);
  min-height: 42px;
  padding: 12px 20px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(11, 16, 36, 0.66), rgba(6, 8, 20, 0.48));
  box-shadow:
    0 14px 44px rgba(0, 0, 0, 0.32),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  color: var(--text);
  font-size: clamp(15px, 1.9vw, 18px);
  line-height: 1.65;
  text-align: center;
  text-shadow: 0 0 18px rgba(255, 215, 123, 0.3);
  backdrop-filter: blur(16px);
}

#hint-text {
  position: absolute;
  left: 50%;
  bottom: clamp(30px, 9vh, 92px);
  z-index: 24;
  max-width: min(86vw, 520px);
  padding: 11px 18px;
  border: 1px solid rgba(255, 255, 255, 0.17);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(10, 15, 35, 0.58), rgba(8, 12, 28, 0.38));
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.28);
  color: var(--muted);
  font-size: 15px;
  line-height: 1.5;
  text-align: center;
  transform: translateX(-50%);
  animation: hintPulse 2.5s ease-in-out infinite;
  pointer-events: none;
  backdrop-filter: blur(14px);
}

#hint-text::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 16px var(--gold);
  vertical-align: 1px;
}

#hint-text:empty {
  display: none;
}

@keyframes hintPulse {
  0%, 100% { opacity: 0.52; transform: translateX(-50%) translateY(0); }
  50% { opacity: 0.96; transform: translateX(-50%) translateY(-4px); }
}

#photo-wall {
  position: absolute;
  inset: 0;
  z-index: 18;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(12px, 2.1vh, 20px);
  padding: clamp(18px, 4vw, 56px);
  pointer-events: none;
}

#photo-wall::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: -1;
  width: min(86vw, 820px);
  height: min(74vh, 660px);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 42%, rgba(5, 7, 18, 0.72), rgba(5, 7, 18, 0.36) 48%, transparent 72%),
    radial-gradient(circle at 50% 60%, rgba(255, 215, 123, 0.08), transparent 50%);
  transform: translate(-50%, -50%);
  filter: blur(2px);
}

#photo-wall.show {
  display: flex;
}

#photo-wall .grid {
  display: flex;
  flex-wrap: nowrap;
  gap: clamp(10px, 1.4vw, 16px);
  width: min(88vw, 760px);
  align-items: center;
  justify-content: center;
}

#photo-wall .grid img,
.memory-tile {
  width: clamp(120px, 10vw, 144px);
  flex: 0 0 auto;
  max-width: 144px;
  aspect-ratio: 1;
  border: 7px solid rgba(255, 250, 240, 0.96);
  border-radius: 10px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 215, 123, 0.28), transparent 34%),
    linear-gradient(145deg, #fffaf0, #eef7ff);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.34),
    0 0 0 1px rgba(255, 255, 255, 0.28);
  opacity: 0;
  transform: translateY(18px) scale(0.84);
  transition:
    opacity 0.45s ease,
    transform 0.58s cubic-bezier(0.19, 1, 0.22, 1);
}

#photo-wall .grid img {
  object-fit: cover;
}

.memory-tile {
  position: relative;
  display: grid;
  place-items: center;
  padding: 16px;
  color: rgba(22, 28, 48, 0.74);
  font-size: 13px;
  font-weight: 760;
  line-height: 1.35;
  text-align: center;
}

.memory-tile::before {
  content: attr(data-index);
  position: absolute;
  left: 10px;
  top: 8px;
  color: rgba(201, 154, 60, 0.62);
  font-size: 11px;
}

#photo-wall .grid img:nth-child(2n),
.memory-tile:nth-child(2n) {
  transform: translateY(18px) scale(0.84) rotate(2deg);
}

#photo-wall .grid img:nth-child(2n + 1),
.memory-tile:nth-child(2n + 1) {
  transform: translateY(18px) scale(0.84) rotate(-2deg);
}

#photo-wall .grid img.show,
.memory-tile.show {
  opacity: 1;
  transform: translateY(0) scale(1) rotate(0deg);
}

#photo-wall .birthday-text {
  max-width: min(90vw, 900px);
  color: #fff7d8;
  font-size: clamp(40px, 6.4vw, 70px);
  font-weight: 850;
  line-height: 1.05;
  text-align: center;
  text-wrap: balance;
  text-shadow:
    0 0 18px rgba(255, 215, 123, 0.78),
    0 0 42px rgba(255, 122, 168, 0.42),
    0 14px 38px rgba(0, 0, 0, 0.48);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 1.5s ease, transform 1s ease;
}

#photo-wall .birthday-text.show {
  opacity: 1;
  transform: translateY(0);
}

.final-message {
  width: min(86vw, 760px);
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(15px, 1.75vw, 17px);
  line-height: 1.7;
  text-align: center;
  text-wrap: balance;
  text-shadow: 0 8px 28px rgba(0, 0, 0, 0.76);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 1s ease, transform 1s ease;
}

.final-message.show {
  opacity: 1;
  transform: translateY(0);
}

.final-wishes {
  display: grid;
  gap: 5px;
  width: min(82vw, 680px);
  margin-top: 2px;
}

.final-wish {
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: clamp(13px, 1.6vw, 15px);
  line-height: 1.65;
  text-align: center;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.76);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.65s ease, transform 0.65s ease;
}

.final-wish.show {
  opacity: 1;
  transform: translateY(0);
}

#replay-button {
  position: relative;
  z-index: 25;
  margin-top: 4px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 0.5s ease, transform 0.5s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

#replay-button.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#loading {
  position: fixed;
  inset: 0;
  z-index: 99;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 215, 123, 0.14), transparent 30%),
    radial-gradient(circle at 58% 56%, rgba(255, 122, 168, 0.1), transparent 24%),
    #050712;
  color: var(--muted);
  font-size: 14px;
  transition: opacity 0.6s ease;
}

.loading-mark {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 18px var(--gold), 0 0 34px rgba(255, 122, 168, 0.58);
  animation: loadingTwinkle 1.2s ease-in-out infinite;
}

@keyframes loadingTwinkle {
  0%, 100% { transform: scale(0.72); opacity: 0.5; }
  50% { transform: scale(1.2); opacity: 1; }
}

#loading.hidden {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 640px) {
  #opening {
    top: 46%;
  }

  #opening-title {
    font-size: clamp(42px, 15vw, 64px);
  }

  #opening-subtitle {
    margin-top: 14px;
  }

  #wish-line {
    font-size: clamp(25px, 9vw, 40px);
  }

  .opening-actions,
  .final-actions {
    gap: 10px;
  }

  #start-button,
  #preview-button,
  #replay-button {
    min-height: 44px;
    padding: 0 18px;
  }

  .photo-card {
    width: min(88vw, 420px);
  }

  .photo-card img,
  .photo-card.memory-card::after,
  .photo-card.missing-photo::after {
    max-height: 46vh;
  }

  .photo-card img {
    padding: 9px 9px 36px;
  }

  .photo-card .caption,
  #hint-text {
    border-radius: 18px;
    font-size: 14px;
  }

  #hint-text {
    bottom: clamp(20px, 6vh, 54px);
  }

  #photo-wall {
    justify-content: center;
    padding: 16px;
  }

  #photo-wall .grid {
    width: min(90vw, 420px);
    flex-wrap: wrap;
    gap: 10px;
  }

  #photo-wall .grid img,
  .memory-tile {
    width: clamp(112px, 38vw, 132px);
    max-width: 124px;
    border-width: 6px;
  }

  #photo-wall .birthday-text {
    font-size: clamp(34px, 12vw, 54px);
  }

  .final-message {
    font-size: 14px;
  }

  .final-wishes {
    gap: 6px;
  }

  .final-wish {
    font-size: 13px;
  }
}

@media (max-height: 620px) {
  .photo-card img,
  .photo-card.memory-card::after,
  .photo-card.missing-photo::after {
    max-height: 42vh;
  }

  #photo-wall {
    gap: 10px;
  }

  #photo-wall .grid img,
  .memory-tile {
    max-width: 112px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
