:root {
  --bg-1: #080814;
  --bg-2: #15102d;
  --bg-3: #21123f;
  --lavender: #d9c7ff;
  --pink: #ff77bd;
  --pink-soft: #ffc1df;
  --white: #fff8ff;
  --muted: rgba(255, 248, 255, 0.72);
  --glass: rgba(255, 255, 255, 0.09);
  --glass-strong: rgba(255, 255, 255, 0.14);
  --border: rgba(255, 255, 255, 0.22);
  --shadow: 0 26px 80px rgba(255, 90, 184, 0.2);
  --serif: "Cormorant Garamond", "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Inter", "Poppins", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg-1);
  scroll-behavior: smooth;
}

body {
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--white);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 18% 18%, rgba(255, 119, 189, 0.2), transparent 26rem),
    radial-gradient(circle at 82% 12%, rgba(157, 134, 255, 0.22), transparent 28rem),
    radial-gradient(circle at 50% 90%, rgba(76, 43, 145, 0.35), transparent 34rem),
    linear-gradient(145deg, var(--bg-1), var(--bg-2) 48%, #050711);
}

button,
video {
  font: inherit;
}

button {
  border: 0;
}

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

.experience {
  position: relative;
  z-index: 1;
  height: 100vh;
  min-height: 100svh;
  overflow: hidden;
}

.scene {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 4.75rem 1rem;
  opacity: 0;
  visibility: hidden;
  transform: translateY(1.5rem) scale(0.98);
  filter: blur(18px);
  transition: opacity 820ms ease, transform 820ms ease, filter 820ms ease, visibility 820ms;
}

.scene.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  filter: blur(0);
}

.scene-inner {
  width: min(calc(100vw - 2rem), 58rem);
  max-height: calc(100svh - 6.5rem);
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  text-align: center;
}

.scene-inner.narrow {
  width: min(calc(100vw - 2rem), 43rem);
}

.scene-inner.wide {
  width: min(calc(100vw - 2rem), 68rem);
}

.eyebrow {
  margin: 0;
  color: var(--pink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  width: 100%;
  margin-bottom: 0;
  font-family: var(--serif);
  font-size: clamp(2.65rem, 10vw, 6.9rem);
  line-height: 0.9;
  font-weight: 700;
  letter-spacing: 0;
  overflow-wrap: break-word;
  text-shadow: 0 0 1.5rem rgba(255, 119, 189, 0.36);
}

h1 span {
  display: block;
}

h2 {
  width: 100%;
  margin-bottom: 0;
  color: var(--lavender);
  font-family: var(--serif);
  font-size: clamp(2.6rem, 9vw, 5.8rem);
  line-height: 0.92;
  font-weight: 600;
  overflow-wrap: break-word;
  text-shadow: 0 0 1.25rem rgba(217, 199, 255, 0.34);
}

.subtitle {
  width: 100%;
  max-width: 36rem;
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: clamp(0.98rem, 2vw, 1.18rem);
  line-height: 1.7;
}

.glass-card {
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.13), rgba(255, 255, 255, 0.055));
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.glow-button,
.ghost-button {
  min-height: 3.15rem;
  max-width: 100%;
  padding: 0 1.45rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--white);
  font-weight: 800;
  letter-spacing: 0;
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease, background 220ms ease;
}

.glow-button {
  background: linear-gradient(135deg, #6e4dff, #d84fba 54%, #ff83bd);
  box-shadow: 0 0 1.5rem rgba(255, 119, 189, 0.42), 0 1rem 2rem rgba(0, 0, 0, 0.22);
  animation: buttonGlow 2.7s ease-in-out infinite;
}

.ghost-button {
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.18);
}

.glow-button:hover,
.ghost-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 2.1rem rgba(255, 119, 189, 0.52), 0 1.2rem 2.2rem rgba(0, 0, 0, 0.26);
}

.countdown-card {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.65rem;
  width: min(calc(100vw - 2rem), 38rem);
  padding: 0.85rem;
  border-radius: 1.35rem;
  animation: riseIn 980ms ease both;
}

.scene-countdown h1 {
  font-size: clamp(2.45rem, 12vw, 5.8rem);
  line-height: 0.96;
}

.countdown-item {
  min-width: 0;
  padding: 1rem 0.45rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.08);
}

.countdown-item strong {
  display: block;
  font-family: var(--serif);
  font-size: clamp(2.1rem, 9vw, 4.1rem);
  line-height: 0.9;
  color: var(--white);
  text-shadow: 0 0 1rem rgba(255, 119, 189, 0.36);
  animation: softPulse 1.8s ease-in-out infinite;
}

.countdown-item span {
  display: block;
  margin-top: 0.55rem;
  color: var(--muted);
  font-size: clamp(0.68rem, 2vw, 0.82rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.09em;
}

.intro-lines {
  display: grid;
  gap: 1.1rem;
}

.intro-lines p {
  margin-bottom: 0;
  color: var(--white);
  font-family: var(--serif);
  font-size: clamp(2.1rem, 8vw, 4.6rem);
  line-height: 1.05;
  opacity: 0;
  filter: blur(14px);
  transform: translateY(1rem);
}

.scene.active .intro-lines p {
  animation: introLine 950ms ease both;
}

.scene.active .intro-lines p:nth-child(2) {
  animation-delay: 900ms;
}

.scene.active .intro-lines p:nth-child(3) {
  animation-delay: 1800ms;
}

.intro-button {
  opacity: 0;
  pointer-events: none;
}

.scene.active .intro-button {
  animation: revealButton 700ms ease 2800ms both;
  pointer-events: auto;
}

.birthday-title {
  animation: titleGlow 3s ease-in-out infinite;
}

.scene-main h2 {
  opacity: 0;
  transform: translateY(1.1rem);
}

.scene-main.active h2 {
  animation: riseIn 820ms ease 260ms both;
}

.floating-hearts {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.floating-hearts span {
  position: absolute;
  bottom: -5rem;
  width: 1rem;
  height: 1rem;
  transform: rotate(45deg);
  background: rgba(255, 119, 189, 0.42);
  filter: drop-shadow(0 0 0.9rem rgba(255, 119, 189, 0.55));
  animation: floatHeart 9s linear infinite;
}

.floating-hearts span::before,
.floating-hearts span::after {
  content: "";
  position: absolute;
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: inherit;
}

.floating-hearts span::before {
  left: -0.5rem;
}

.floating-hearts span::after {
  top: -0.5rem;
}

.floating-hearts span:nth-child(1) { left: 13%; animation-delay: 0s; }
.floating-hearts span:nth-child(2) { left: 32%; animation-delay: 2s; transform: rotate(45deg) scale(0.75); }
.floating-hearts span:nth-child(3) { left: 56%; animation-delay: 1s; transform: rotate(45deg) scale(1.2); }
.floating-hearts span:nth-child(4) { left: 74%; animation-delay: 3.4s; transform: rotate(45deg) scale(0.85); }
.floating-hearts span:nth-child(5) { left: 88%; animation-delay: 5s; }

.letter-card {
  width: min(100%, 47rem);
  max-height: calc(100svh - 6.5rem);
  overflow-y: auto;
  padding: clamp(1.3rem, 5vw, 2.5rem);
  border-radius: 1.35rem;
  text-align: left;
}

.letter-card h1 {
  font-size: clamp(2.55rem, 9vw, 4.9rem);
}

.letter-body {
  display: grid;
  gap: 1rem;
  margin: 1rem 0 1.45rem;
}

.letter-body p {
  margin-bottom: 0;
  color: rgba(255, 248, 255, 0.82);
  font-size: clamp(0.98rem, 2vw, 1.06rem);
  line-height: 1.85;
  opacity: 0;
  transform: translateY(0.9rem);
  filter: blur(10px);
}

.scene.active .letter-body p {
  animation: paragraphIn 760ms ease both;
}

.scene-gallery .scene-inner,
.scene-wishes .scene-inner {
  justify-content: flex-start;
}

.memory-stack,
.wish-grid {
  width: 100%;
  gap: 0.85rem;
}

.memory-stack {
  position: relative;
  width: min(21.5rem, calc(100vw - 2rem));
  aspect-ratio: 4 / 5.05;
  margin: 0.15rem auto 0;
  cursor: pointer;
  perspective: 70rem;
  outline: none;
  touch-action: manipulation;
}

.memory-stack:focus-visible {
  filter: drop-shadow(0 0 1.2rem rgba(255, 119, 189, 0.7));
}

.memory-card {
  position: absolute;
  inset: 0;
  padding: 0.45rem 0.45rem 2.1rem;
  border-radius: 0.45rem;
  background: rgba(255, 248, 255, 0.92);
  box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.3);
  opacity: var(--opacity, 0);
  z-index: var(--z, 1);
  transform: translate3d(var(--x, 0), var(--y, 0), 0) rotate(var(--rotation, 0deg)) scale(var(--scale, 1));
  transition: opacity 420ms ease, transform 520ms cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 240ms ease;
  will-change: transform, opacity;
}

.memory-card.is-top:hover {
  transform: translate3d(0, -0.35rem, 0) rotate(var(--rotation, 0deg)) scale(1.02);
  box-shadow: 0 1.4rem 2.7rem rgba(0, 0, 0, 0.34), 0 0 1.2rem rgba(255, 119, 189, 0.28);
}

.scene.active .memory-card {
  animation: memoryIn 740ms ease both;
}

.memory-card img,
.memory-placeholder {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 0.25rem;
  object-fit: cover;
}

.memory-placeholder {
  display: grid;
  place-items: center;
  color: rgba(255, 248, 255, 0.86);
  font-family: var(--serif);
  font-size: clamp(1.2rem, 4vw, 1.7rem);
  line-height: 1;
  text-shadow: 0 0 1rem rgba(255, 119, 189, 0.38);
  background:
    linear-gradient(135deg, rgba(255, 119, 189, 0.66), rgba(118, 93, 255, 0.54)),
    radial-gradient(circle at top, rgba(255, 255, 255, 0.38), transparent 48%);
}

.memory-card.has-image .memory-placeholder {
  display: none;
}

.memory-caption {
  position: absolute;
  left: 0.55rem;
  right: 0.55rem;
  bottom: 0.55rem;
  overflow: hidden;
  color: rgba(24, 16, 38, 0.84);
  font-size: 0.72rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.memory-hint {
  margin: 0;
  color: rgba(255, 248, 255, 0.68);
  font-size: 0.82rem;
  font-weight: 700;
}

.video-shell {
  position: relative;
  width: min(100%, 50rem);
  aspect-ratio: 16 / 9;
  border-radius: 1.2rem;
  padding: 0.7rem;
  overflow: hidden;
}

.video-shell::before {
  content: "";
  position: absolute;
  inset: -18%;
  z-index: -1;
  background: radial-gradient(circle, rgba(255, 119, 189, 0.28), transparent 62%);
  filter: blur(8px);
}

.video-shell video,
.video-fallback {
  width: 100%;
  height: 100%;
  border-radius: 0.85rem;
  object-fit: cover;
  background: rgba(0, 0, 0, 0.3);
}

.video-fallback {
  position: absolute;
  inset: 0.7rem;
  width: auto;
  height: auto;
  display: grid;
  place-items: center;
  padding: 1rem;
  color: rgba(255, 248, 255, 0.78);
  text-align: center;
  background:
    linear-gradient(135deg, rgba(255, 119, 189, 0.24), rgba(91, 72, 196, 0.24)),
    rgba(255, 255, 255, 0.07);
}

.video-shell.has-video .video-fallback {
  opacity: 0;
  pointer-events: none;
}

.video-control {
  position: absolute;
  left: 50%;
  bottom: 1.4rem;
  transform: translateX(-50%);
  min-width: 6.5rem;
  min-height: 2.55rem;
  padding: 0 1rem;
  border-radius: 999px;
  cursor: pointer;
  color: var(--white);
  font-weight: 800;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid var(--border);
  backdrop-filter: blur(14px);
}

.scene.active .video-shell {
  animation: zoomIn 850ms ease both;
}

.wish-grid {
  display: grid;
  grid-template-columns: 1fr;
}

.wish-card {
  min-height: 5.2rem;
  display: flex;
  align-items: center;
  padding: 1rem;
  border-radius: 0.9rem;
  color: rgba(255, 248, 255, 0.86);
  font-size: clamp(0.98rem, 2vw, 1.08rem);
  line-height: 1.55;
  text-align: left;
  opacity: 0;
  transform: translateY(1rem);
}

.scene.active .wish-card {
  animation: paragraphIn 760ms ease both;
}

.final-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.progress-dots {
  position: fixed;
  left: 50%;
  bottom: max(0.9rem, env(safe-area-inset-bottom));
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transform: translateX(-50%);
  padding: 0.55rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  background: rgba(7, 7, 18, 0.42);
  backdrop-filter: blur(16px);
}

.progress-dots button {
  width: 0.58rem;
  height: 0.58rem;
  border-radius: 50%;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.34);
  transition: width 220ms ease, background 220ms ease, box-shadow 220ms ease;
}

.progress-dots button.active {
  width: 1.6rem;
  border-radius: 999px;
  background: var(--pink);
  box-shadow: 0 0 0.9rem rgba(255, 119, 189, 0.65);
}

.floating-music {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 6;
  width: 3.15rem;
  height: 3.15rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  cursor: pointer;
  color: var(--white);
  background: linear-gradient(135deg, #6e4dff, #ff77bd);
  box-shadow: 0 0 1.4rem rgba(255, 119, 189, 0.44);
}

.music-icon {
  font-size: 1.15rem;
  font-weight: 900;
}

.floating-music.is-playing .music-icon {
  animation: softPulse 1.2s ease-in-out infinite;
}

@keyframes buttonGlow {
  0%, 100% { box-shadow: 0 0 1.4rem rgba(255, 119, 189, 0.34), 0 1rem 2rem rgba(0, 0, 0, 0.22); }
  50% { box-shadow: 0 0 2.25rem rgba(255, 119, 189, 0.6), 0 1.1rem 2rem rgba(0, 0, 0, 0.24); }
}

@keyframes softPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.035); }
}

@keyframes titleGlow {
  0%, 100% { text-shadow: 0 0 1.2rem rgba(255, 119, 189, 0.34); }
  50% { text-shadow: 0 0 2.4rem rgba(255, 119, 189, 0.64), 0 0 3.4rem rgba(217, 199, 255, 0.24); }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(1.2rem); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes introLine {
  from { opacity: 0; transform: translateY(1rem); filter: blur(14px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

@keyframes revealButton {
  from { opacity: 0; transform: translateY(0.7rem); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes paragraphIn {
  from { opacity: 0; transform: translateY(0.9rem); filter: blur(10px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}

@keyframes memoryIn {
  from { opacity: 0; transform: translate3d(0, 1rem, 0) rotate(var(--rotation, 0deg)) scale(0.96); }
  to { opacity: var(--opacity, 1); transform: translate3d(var(--x, 0), var(--y, 0), 0) rotate(var(--rotation, 0deg)) scale(var(--scale, 1)); }
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.92); filter: blur(12px); }
  to { opacity: 1; transform: scale(1); filter: blur(0); }
}

@keyframes floatHeart {
  0% { opacity: 0; transform: translateY(0) rotate(45deg) scale(0.82); }
  15% { opacity: 0.8; }
  100% { opacity: 0; transform: translateY(-115vh) rotate(45deg) scale(1.25); }
}

@media (min-width: 43rem) {
  .scene {
    padding-inline: 2rem;
  }

  .memory-stack {
    width: min(24rem, calc(100vw - 4rem));
  }

  .wish-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 34rem) {
  .scene {
    padding-top: 3.8rem;
    padding-bottom: 5.1rem;
  }

  .countdown-card {
    width: min(18.5rem, calc(100vw - 2rem));
    gap: 0.35rem;
    padding: 0.45rem;
    border-radius: 1rem;
  }

  .scene-countdown .subtitle {
    max-width: 18.5rem;
  }

  .scene-countdown h1 {
    max-width: 19rem;
    font-size: clamp(1.76rem, 8.2vw, 2rem);
    line-height: 1.08;
  }

  .countdown-item {
    padding: 0.68rem 0.18rem;
    border-radius: 0.8rem;
  }

  .countdown-item strong {
    font-size: clamp(1.48rem, 7vw, 1.8rem);
  }

  .countdown-item span {
    font-size: 0.52rem;
    letter-spacing: 0.04em;
  }

  .letter-card {
    padding: 1.1rem;
  }

  .progress-dots {
    max-width: calc(100vw - 5.7rem);
    overflow-x: auto;
  }

  .floating-music {
    width: 2.85rem;
    height: 2.85rem;
  }
}

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