:root {
  --maroon-deep: #24050c;
  --maroon-dark: #420b18;
  --maroon-primary: #6e1226;
  --maroon-mid: #8f1d36;
  --rose-muted: #c86d7d;
  --blush-soft: #f5dce0;
  --cream-paper: #fdf6f0;
  --gold-accent: #d8b26e;
  --gold-light: #f3dfb3;
  --text-dark: #380914;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: radial-gradient(circle at 50% 25%, var(--maroon-mid) 0%, var(--maroon-dark) 50%, var(--maroon-deep) 100%);
  color: var(--cream-paper);
  user-select: none;
}

.bg-glow {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 20% 20%, rgba(216, 178, 110, 0.12), transparent 40%),
    radial-gradient(circle at 80% 75%, rgba(200, 109, 125, 0.14), transparent 45%);
  z-index: 0;
}

.stage {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transform: scale(0.97) translateY(10px);
  transition: opacity 0.8s ease, transform 0.8s ease, visibility 0.8s ease;
  z-index: 2;
}

.stage.active {
  opacity: 1;
  visibility: visible;
  transform: scale(1) translateY(0);
}

.music-btn {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 50;
  background: rgba(66, 11, 24, 0.72);
  border: 1px solid rgba(216, 178, 110, 0.45);
  color: var(--gold-light);
  padding: 9px 15px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 7px;
  transition: all 0.3s ease;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.music-btn:hover {
  background: rgba(110, 18, 38, 0.9);
  border-color: var(--gold-accent);
  transform: translateY(-1px);
}

/* STAGE 1: ENVELOPE */
.envelope-prompt {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  color: var(--gold-light);
  margin-bottom: 28px;
  text-align: center;
  opacity: 0.9;
  animation: pulseText 2.4s infinite ease-in-out;
}

@keyframes pulseText {
  0%, 100% { opacity: 0.75; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

.envelope-wrapper {
  position: relative;
  width: 310px;
  height: 205px;
  cursor: pointer;
  perspective: 1000px;
  transition: transform 0.4s ease;
}

.envelope-wrapper:hover {
  transform: translateY(-6px) scale(1.02);
}

.envelope-back {
  position: absolute;
  inset: 0;
  background: linear-gradient(145deg, #5c0f20, #3a0712);
  border-radius: 12px;
  border: 1px solid rgba(216, 178, 110, 0.45);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.55);
}

.envelope-letter {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 12px;
  height: 170px;
  background: var(--cream-paper);
  border-radius: 8px;
  padding: 18px 14px;
  text-align: center;
  color: var(--text-dark);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  transition: transform 0.85s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 2;
  border: 1px solid rgba(216, 178, 110, 0.5);
}

.envelope-letter h4 {
  font-family: 'Great Vibes', cursive;
  font-size: 1.7rem;
  color: var(--maroon-primary);
  margin-bottom: 4px;
}

.envelope-letter p {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.98rem;
  font-weight: 600;
  color: #5e1d2b;
}

.envelope-front {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  overflow: hidden;
  border-radius: 12px;
}

.envelope-front::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, #7c162c 0%, #590d1e 100%);
  clip-path: polygon(0 0, 52% 54%, 0 100%);
}

.envelope-front::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(225deg, #871830 0%, #5c0e1f 100%);
  clip-path: polygon(100% 0, 48% 54%, 100% 100%);
}

.envelope-bottom {
  position: absolute;
  inset: 0;
  z-index: 4;
  background: linear-gradient(0deg, #4b0a18 0%, #751429 100%);
  clip-path: polygon(0 100%, 50% 47%, 100% 100%);
  border-radius: 0 0 12px 12px;
  pointer-events: none;
}

.envelope-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 118px;
  background: linear-gradient(180deg, #961d37 0%, #681023 100%);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: top center;
  transition: transform 0.7s ease, z-index 0.2s ease;
  z-index: 5;
  border-top: 1px solid rgba(216, 178, 110, 0.5);
}

.wax-seal {
  position: absolute;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #f3dfb3, #cfa252 65%, #9e7328 100%);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.45), inset 0 2px 5px rgba(255, 255, 255, 0.65);
  border: 3px double #6e1226;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.wax-seal span {
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #420b18;
  line-height: 1.1;
}

.envelope-wrapper.open .envelope-flap {
  transform: rotateX(180deg);
  z-index: 1;
}

.envelope-wrapper.open .wax-seal {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.6);
}

.envelope-wrapper.open .envelope-letter {
  transform: translateY(-88px);
}

/* STAGE 2: CALENDAR */
.calendar-card {
  width: 100%;
  max-width: 390px;
  background: var(--cream-paper);
  color: var(--text-dark);
  border-radius: 22px;
  padding: 26px 24px 24px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.5);
  border: 2px solid var(--gold-accent);
  text-align: center;
  position: relative;
}

.calendar-badge {
  display: inline-block;
  background: var(--maroon-primary);
  color: var(--gold-light);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 999px;
  margin-bottom: 10px;
}

.calendar-header h2 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--maroon-primary);
  line-height: 1.1;
}

.calendar-header p {
  font-size: 0.86rem;
  color: #7c3b49;
  margin-top: 4px;
  margin-bottom: 18px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  margin-bottom: 18px;
}

.cal-day-name {
  font-size: 0.72rem;
  font-weight: 600;
  color: #9e5665;
  padding-bottom: 6px;
  text-transform: uppercase;
}

.cal-date {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  font-weight: 500;
  color: #4f1824;
  border-radius: 50%;
  position: relative;
}

.cal-date.empty {
  visibility: hidden;
}

.cal-date.birthday-highlight {
  background: linear-gradient(135deg, var(--maroon-mid), var(--maroon-dark));
  color: var(--gold-light);
  font-weight: 700;
  border: 2px solid var(--gold-accent);
  box-shadow: 0 0 0 4px rgba(143, 29, 54, 0.22), 0 6px 15px rgba(110, 18, 38, 0.45);
  animation: heartbeat 1.6s infinite ease-in-out;
  cursor: pointer;
}

.cal-date.birthday-highlight::before {
  content: '👑';
  position: absolute;
  top: -15px;
  font-size: 0.85rem;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.13); }
}

.calendar-note {
  background: rgba(110, 18, 38, 0.07);
  border: 1px dashed rgba(110, 18, 38, 0.3);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--maroon-primary);
  margin-bottom: 18px;
}

.btn-primary {
  width: 100%;
  padding: 12px 20px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--maroon-mid), var(--maroon-dark));
  color: var(--gold-light);
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  cursor: pointer;
  border: 1px solid rgba(216, 178, 110, 0.5);
  box-shadow: 0 10px 24px rgba(66, 11, 24, 0.35);
  transition: all 0.3s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 28px rgba(66, 11, 24, 0.45);
}

/* STAGE 3: SPRING TREE & GREETING */
#stage-celebration {
  justify-content: flex-end;
  padding-bottom: 26px;
}

#springCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: auto;
}

.celebration-card {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 500px;
  background: rgba(44, 7, 16, 0.72);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(216, 178, 110, 0.45);
  border-radius: 24px;
  padding: 24px 24px 22px;
  text-align: center;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  max-height: 82vh;
  overflow-y: auto;
}

.age-pill {
  display: inline-block;
  padding: 5px 15px;
  border-radius: 999px;
  background: rgba(216, 178, 110, 0.16);
  border: 1px solid rgba(216, 178, 110, 0.5);
  color: var(--gold-light);
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.celebration-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.35rem;
  font-weight: 600;
  color: var(--blush-soft);
  letter-spacing: 0.04em;
}

.celebration-name {
  font-family: 'Great Vibes', cursive;
  font-size: clamp(2.5rem, 7vw, 3.4rem);
  color: var(--gold-light);
  line-height: 1.15;
  margin: 4px 0 6px;
  text-shadow: 0 4px 18px rgba(216, 178, 110, 0.35);
}

.celebration-date {
  font-size: 0.85rem;
  color: #eab8c2;
  margin-bottom: 14px;
  letter-spacing: 0.05em;
}

.celebration-message {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.14rem;
  line-height: 1.65;
  color: var(--cream-paper);
  margin-bottom: 18px;
}

.candle-box {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 14px;
  cursor: pointer;
}

.flame-wrap {
  height: 28px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.flame {
  width: 14px;
  height: 22px;
  background: radial-gradient(circle at 50% 75%, #fff7d1 10%, #ffbe3b 55%, #e85d1a 100%);
  border-radius: 50% 50% 50% 50% / 65% 65% 35% 35%;
  box-shadow: 0 0 16px #ffbe3b, 0 0 28px rgba(255, 190, 59, 0.6);
  animation: flicker 0.9s infinite alternate ease-in-out;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.flame.blown-out {
  opacity: 0;
  transform: scale(0.2) translateY(-10px);
  animation: none;
}

@keyframes flicker {
  0% { transform: scale(1) rotate(-2deg); }
  100% { transform: scale(1.08, 0.94) rotate(2deg); }
}

.candle-body {
  width: 56px;
  height: 34px;
  background: linear-gradient(135deg, #fdf6f0, #e6cfd3);
  border-radius: 8px;
  border: 1.5px solid var(--gold-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Cormorant Garamond', serif;
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--maroon-primary);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

.candle-hint {
  font-size: 0.76rem;
  color: var(--gold-light);
  margin-top: 6px;
  opacity: 0.9;
}

.action-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-outline {
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(216, 178, 110, 0.5);
  color: var(--cream-paper);
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.25s ease;
}

.btn-outline:hover {
  background: rgba(216, 178, 110, 0.22);
}

@media (max-width: 480px) {
  .envelope-wrapper {
    width: 280px;
    height: 188px;
  }
  .calendar-card {
    padding: 20px 18px;
  }
  .celebration-card {
    padding: 20px 18px;
  }
}
