* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --pastel-pink: #ffb6c1;
  --pastel-pink-soft: #ffc0cb;
  --pastel-pink-light: #ffd6e0;
  --pastel-rose: #f8b4c4;
  --pastel-rose-deep: #e895a8;
  --pastel-cream: #fff5f8;
  --pastel-bg: #fadce4;
  --pastel-bg-mid: #f5c6d1;
  --pastel-bg-deep: #e8a8b8;
  --pastel-text: #5c4a52;
  --pastel-text-strong: #7d5a65;
  --pastel-seal: #f4a5b5;
  --pastel-seal-shadow: #e88a9e;
  --envelope-paper: #fef6f0;
  --envelope-paper-shadow: #e8c4b8;
}

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(165deg, var(--pastel-bg-deep) 0%, var(--pastel-bg-mid) 35%, var(--pastel-bg) 60%, var(--pastel-bg-mid) 100%);
  color: var(--pastel-text);
  padding: 1rem;
  overflow-x: hidden;
  position: relative;
}

/* ----- Background: hearts and stars only ----- */
.bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.decor {
  position: absolute;
  color: var(--pastel-rose-deep);
  opacity: 0.45;
  animation: float-decor 6s ease-in-out infinite;
}

.decor-heart {
  font-size: clamp(1.5rem, 4vw, 2.5rem);
}
.decor-heart:nth-of-type(1) { top: 8%; left: 5%; --rot: -15deg; animation-delay: 0s; animation-duration: 5s; }
.decor-heart:nth-of-type(2) { top: 15%; right: 8%; --rot: 10deg; opacity: 0.4; animation-delay: 1s; animation-duration: 6.5s; }
.decor-heart:nth-of-type(3) { bottom: 25%; left: 10%; --rot: 5deg; opacity: 0.42; animation-delay: 2s; animation-duration: 7s; }
.decor-heart:nth-of-type(4) { bottom: 15%; right: 12%; --rot: -20deg; animation-delay: 0.5s; animation-duration: 5.5s; }
.decor-heart:nth-of-type(5) { top: 45%; left: 3%; --rot: 12deg; font-size: clamp(1.2rem, 3vw, 1.8rem); opacity: 0.38; animation-delay: 1.5s; animation-duration: 6s; }

.decor-star {
  font-size: clamp(1.2rem, 3.5vw, 2rem);
  color: var(--pastel-rose);
}
.decor-star:nth-of-type(6) { top: 22%; right: 6%; --rot: -8deg; opacity: 0.4; animation-delay: 0.3s; animation-duration: 6.2s; }
.decor-star:nth-of-type(7) { bottom: 35%; right: 5%; --rot: 15deg; opacity: 0.42; animation-delay: 1.8s; animation-duration: 5.8s; }
.decor-star:nth-of-type(8) { bottom: 8%; left: 15%; --rot: -12deg; opacity: 0.38; animation-delay: 2.5s; animation-duration: 7.2s; }
.decor-star:nth-of-type(9) { top: 8%; left: 22%; --rot: 8deg; opacity: 0.4; animation-delay: 0.7s; animation-duration: 6.5s; }
.decor-star:nth-of-type(10) { top: 35%; right: 18%; --rot: -5deg; opacity: 0.35; animation-delay: 1.2s; animation-duration: 5.5s; }
.decor-star:nth-of-type(11) { bottom: 42%; left: 6%; --rot: 18deg; opacity: 0.4; animation-delay: 2.2s; animation-duration: 6.8s; }

.decor-svg {
  width: clamp(28px, 6vw, 44px);
  height: clamp(28px, 6vw, 44px);
  color: var(--pastel-rose-deep);
  opacity: 0.4;
  animation: float-decor-svg 8s ease-in-out infinite;
}
.decor-svg-heart:nth-of-type(1) { top: 6%; right: 22%; --rot: 20deg; animation-delay: 0s; animation-duration: 7s; }
.decor-svg-heart:nth-of-type(2) { bottom: 30%; right: 25%; --rot: -15deg; opacity: 0.38; animation-delay: 1.5s; animation-duration: 8.5s; }
.decor-svg-heart:nth-of-type(3) { bottom: 12%; right: 8%; --rot: 10deg; animation-delay: 3s; animation-duration: 7.5s; }
.decor-svg-star:nth-of-type(4) { top: 28%; left: 8%; --rot: -10deg; color: var(--pastel-rose); opacity: 0.42; animation-delay: 0.8s; animation-duration: 8s; }
.decor-svg-star:nth-of-type(5) { top: 50%; right: 6%; --rot: 5deg; color: var(--pastel-pink-light); opacity: 0.38; animation-delay: 2.3s; animation-duration: 7.2s; }
.decor-svg-star:nth-of-type(6) { bottom: 22%; left: 25%; --rot: -8deg; opacity: 0.4; animation-delay: 1.7s; animation-duration: 8.2s; }

/* ----- Scenes ----- */
.scene {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem 1rem 2rem;
  z-index: 1;
  overflow-y: auto;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.scene-letter {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.scene-letter.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.scene-envelope.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.scene-ending {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}

.scene-ending.is-visible {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.scene-letter.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* ----- Ending: See you on Valentines ----- */
.ending-card {
  width: min(480px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #fffefe 0%, var(--pastel-cream) 8%, #fff5f8 100%);
  border: 1px solid rgba(200, 140, 130, 0.4);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(120, 70, 80, 0.25);
  padding: 2rem 1.75rem;
  text-align: center;
  animation: letter-appear 0.6s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

.ending-title {
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--pastel-text-strong);
  margin-bottom: 1.5rem;
  letter-spacing: 0.02em;
}

.ending-slideshow {
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(248, 180, 196, 0.45);
  box-shadow: 0 4px 16px rgba(180, 100, 120, 0.2);
  background: #fef0f4;
}

.ending-slideshow-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.6s ease;
}

.ending-slideshow-img.fade-out {
  opacity: 0;
}

@media (min-width: 480px) {
  .ending-slideshow {
    max-width: 360px;
  }
}

/* ----- Envelope: body + inside triangle + flap + seal ----- */
.envelope {
  position: relative;
  width: 280px;
  max-width: 85vw;
  height: 190px;
  max-height: 50vw;
  flex-shrink: 0;
  perspective: 700px;
  animation: envelope-float 3.5s ease-in-out infinite;
}

/* Body: simple rectangle - darker pink */
.envelope-body {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, #e8b4c0 0%, #e0a0b0 40%, #d88a9e 100%);
  border: 1px solid rgba(180, 100, 120, 0.5);
  border-radius: 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    0 6px 20px rgba(120, 60, 80, 0.25);
  z-index: 0;
}

/* Inside: triangle at top, under the flap – slightly lighter than body (interior) */
.envelope-inside {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(175deg, #f0c4d0 0%, #eab8c8 50%, #e4acbe 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  z-index: 1;
}

/* Flap: top triangle – lightest pink, on top of inside */
.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50%;
  background: linear-gradient(175deg, #fff5f8 0%, #ffdce8 35%, #ffd0e0 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transform-style: preserve-3d;
  transition: transform 0.75s cubic-bezier(0.34, 1.2, 0.64, 1);
  z-index: 2;
  box-shadow:
    0 1px 0 rgba(255, 200, 210, 0.8),
    0 3px 8px rgba(140, 80, 100, 0.2);
}

.envelope.is-open .envelope-flap {
  transform: rotateX(-150deg);
}

/* Seal: centered on the flap, where the flap point meets the body */
.seal-heart {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translate(-50%, -50%);
  width: 48px;
  height: 48px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: radial-gradient(circle at 35% 35%, var(--pastel-pink-soft), var(--pastel-seal) 50%, var(--pastel-seal-shadow));
  box-shadow:
    inset 0 -2px 6px rgba(180, 90, 110, 0.35),
    inset 0 2px 5px rgba(255, 255, 255, 0.65),
    0 3px 12px rgba(160, 80, 100, 0.35);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  animation: seal-glow 2.5s ease-in-out infinite;
  z-index: 3;
}

.seal-heart:hover {
  transform: translate(-50%, -50%) scale(1.08);
  box-shadow:
    inset 0 -2px 6px rgba(200, 100, 120, 0.35),
    inset 0 2px 8px rgba(255, 255, 255, 0.7),
    0 0 24px rgba(255, 182, 193, 0.5),
    0 6px 18px rgba(180, 80, 100, 0.45);
}

.seal-heart svg {
  width: 24px;
  height: 24px;
  filter: drop-shadow(0 1px 2px rgba(255, 255, 255, 0.5));
}

.seal-heart.is-broken {
  animation: seal-break 0.55s ease forwards;
  pointer-events: none;
}

/* ----- Hint ----- */
.hint {
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--pastel-text-strong);
  letter-spacing: 0.04em;
  animation: hint-pulse 2s ease-in-out infinite;
}

/* ----- Letter scene: paper card ----- */
.letter-paper {
  width: min(480px, 92vw);
  max-height: 85vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #fffefe 0%, var(--pastel-cream) 6%, #fff5f8 100%);
  border: 1px solid rgba(200, 140, 130, 0.4);
  border-radius: 8px;
  box-shadow: 0 6px 28px rgba(120, 70, 80, 0.25);
  padding: 2rem 1.75rem;
  animation: letter-appear 0.6s cubic-bezier(0.34, 1.2, 0.64, 1) forwards;
}

.letter-content p {
  font-size: 1.05rem;
  line-height: 1.7;
  margin-bottom: 1rem;
  color: var(--pastel-text);
}

.letter-intro {
  font-style: italic;
  margin-bottom: 1.25rem;
  color: var(--pastel-text-strong);
}

.letter-slideshow {
  width: 100%;
  max-width: 320px;
  margin: 1.25rem auto;
  aspect-ratio: 1;
  border-radius: 12px;
  overflow: hidden;
  border: 2px solid rgba(248, 180, 196, 0.45);
  box-shadow: 0 4px 16px rgba(180, 100, 120, 0.2);
  background: #fef0f4;
}

.slideshow-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.6s ease;
}

.slideshow-img.fade-out {
  opacity: 0;
}

.letter-ending {
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--pastel-text-strong);
  text-align: center;
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.letter-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-family: inherit;
  border: none;
  border-radius: 2rem;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
  transform: scale(1.05);
}

.btn-yes {
  background: linear-gradient(135deg, var(--pastel-pink-soft), var(--pastel-rose));
  color: #fff;
  box-shadow: 0 4px 14px rgba(200, 100, 120, 0.45);
}

.btn-yes:hover {
  box-shadow: 0 6px 20px rgba(200, 100, 120, 0.55);
}

.btn-maybe {
  background: rgba(92, 74, 82, 0.1);
  color: var(--pastel-text-strong);
  border: 1px solid rgba(248, 180, 196, 0.55);
}

.btn-maybe:hover {
  background: rgba(92, 74, 82, 0.15);
}

/* ----- Keyframes ----- */
@keyframes envelope-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes seal-glow {
  0%, 100% { box-shadow: inset 0 -2px 6px rgba(200,100,120,0.4), inset 0 2px 6px rgba(255,255,255,0.6), 0 4px 14px rgba(180,80,100,0.4); }
  50% { box-shadow: inset 0 -2px 6px rgba(200,100,120,0.35), inset 0 2px 8px rgba(255,255,255,0.7), 0 0 20px rgba(255,182,193,0.45), 0 4px 14px rgba(180,80,100,0.4); }
}

@keyframes seal-break {
  0% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  35% { transform: translate(-50%, -50%) scale(1.12); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(2.2); opacity: 0; }
}

@keyframes hint-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.65; }
}

@keyframes letter-appear {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes float-decor {
  0%, 100% {
    transform: translateY(0) translateX(0) rotate(var(--rot, 0deg));
  }
  25% {
    transform: translateY(-10px) translateX(4px) rotate(calc(var(--rot, 0deg) + 2deg));
  }
  50% {
    transform: translateY(-15px) translateX(0) rotate(var(--rot, 0deg));
  }
  75% {
    transform: translateY(-10px) translateX(-4px) rotate(calc(var(--rot, 0deg) - 2deg));
  }
}

@keyframes float-decor-svg {
  0%, 100% {
    transform: translateY(0) translateX(0) rotate(var(--rot, 0deg));
  }
  33% {
    transform: translateY(-12px) translateX(5px) rotate(calc(var(--rot, 0deg) + 3deg));
  }
  66% {
    transform: translateY(-8px) translateX(-5px) rotate(calc(var(--rot, 0deg) - 2deg));
  }
}

@media (min-width: 480px) {
  .letter-slideshow {
    max-width: 360px;
  }
}
