:root {
  --cream: #fff8eb;
  --pink: #f8d6dc;
  --rose: #f19ca8;
  --latte: #d6b59e;
  --brown: #8f6a56;
  --choco: #6e4f3f;
  --shadow: rgba(73, 45, 33, 0.22);
  --text: #5f3f35;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 98vh;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #fffdfa 0%, var(--cream) 45%, #f5e9dd 100%);
  color: var(--text);
  overflow: hidden;
}

.scene {
  position: relative;
  min-height: 95vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.loading-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: #1f1c22;
  color: #fff6f2;
  letter-spacing: 0.06em;
  font-size: clamp(1rem, 2vw, 1.4rem);
  z-index: 30;
  animation: fadeLoading 1s ease forwards;
  animation-delay: 1.4s;
}

.stage {
  position: relative;
  width: min(90vw, 560px);
  height: min(58vh, 420px);
  display: flex;
  justify-content: center;
  align-items: flex-end;
  opacity: 0;
  transform: translateY(20px);
  animation: revealStage 1.1s ease forwards;
  animation-delay: 2.2s;
}

.table {
  position: absolute;
  bottom: 2.8rem;
  width: min(88vw, 520px);
  height: 34px;
  background: linear-gradient(90deg, #c9a084, #dcb89f, #c79d83);
  border-radius: 999px;
  box-shadow: 0 15px 30px var(--shadow);
}

.cake {
  position: relative;
  width: clamp(180px, 30vw, 260px);
  height: 270px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.cake-base,
.cake-frosting,
.cake-icing {
  position: absolute;
  width: 100%;
  transform: scaleY(0);
  transform-origin: bottom;
  opacity: 0;
}

.cake-base {
  height: 115px;
  bottom: 38px;
  border-radius: 16px;
  background: linear-gradient(#ba8669, #9f6f58);
  box-shadow: inset 0 -8px 0 rgba(85, 49, 33, 0.17);
  animation: buildLayer 0.8s ease forwards;
  animation-delay: 3.1s;
}

.cake-frosting {
  height: 80px;
  bottom: 132px;
  border-radius: 14px;
  background: linear-gradient(#ffe8ec, #ffd5de);
  animation: buildLayer 0.7s ease forwards;
  animation-delay: 3.9s;
}

.cake-icing {
  height: 46px;
  bottom: 193px;
  width: 88%;
  border-radius: 30px;
  background: linear-gradient(#fff8fb, #ffe9f0);
  box-shadow: inset 0 -8px 0 rgba(229, 177, 192, 0.42);
  animation: buildLayer 0.6s ease forwards;
  animation-delay: 4.5s;
}

.cake-icing::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -10px;
  height: 14px;
  border-radius: 999px;
  background: repeating-radial-gradient(circle at 12px 0, #ffd2dc 0 7px, transparent 7px 14px);
}

.candles {
  position: absolute;
  bottom: 224px;
  display: flex;
  gap: clamp(10px, 2vw, 14px);
}

.candle {
  width: 14px;
  height: 42px;
  border-radius: 6px;
  background: repeating-linear-gradient(
    45deg,
    #ffc5d1 0 6px,
    #fff9f2 6px 12px
  );
  position: relative;
  opacity: 0;
  transform: translateY(12px);
  animation: candleUp 0.55s ease forwards;
}

.flame {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%) scale(0);
  width: 12px;
  height: 18px;
  border-radius: 50% 50% 45% 45%;
  background: radial-gradient(circle at 30% 35%, #fff8bf 0 35%, #ffb347 70%);
  filter: drop-shadow(0 0 8px rgba(255, 185, 88, 0.85));
  animation: flameOn 0.45s ease forwards, flicker 1s ease-in-out infinite;
  animation-delay: var(--flame-delay), calc(var(--flame-delay) + 0.45s);
}

.flame.off {
  opacity: 0;
  transform: translateX(-50%) scale(0.2);
  animation: none;
}

.message {
  text-align: center;
  position: absolute;
  bottom: clamp(1.2rem, 3vh, 2rem);
  opacity: 0;
  transform: translateY(14px);
  animation: revealMessage 1s ease forwards;
  animation-delay: 6.2s;
  max-width: min(90vw, 640px);
}

.message h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 3.1rem);
  color: #c66a83;
  text-shadow: 0 4px 18px rgba(255, 194, 212, 0.7);
  animation: pulseTitle 2.4s ease-in-out infinite;
}

.message p {
  margin: 0.8rem 0 0;
  font-size: clamp(0.95rem, 2vw, 1.2rem);
}

button {
  margin-top: 1.0rem;
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.3rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: #fff;
  background: linear-gradient(100deg, #f08fa3, #e47f95);
  box-shadow: 0 8px 18px rgba(224, 130, 153, 0.45);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover,
button:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 11px 20px rgba(224, 130, 153, 0.5);
}

.final-message {
  margin-top: 1rem;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.6s ease;
  font-weight: 600;
  color: #b4536b;
}

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

.hearts,
.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.heart {
  --size: 12px;
  position: absolute;
  width: var(--size);
  height: var(--size);
  transform: rotate(45deg);
  background: rgba(245, 158, 177, 0.38);
  animation: floatHeart linear infinite;
}

.heart::before,
.heart::after {
  content: "";
  position: absolute;
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  background: inherit;
}

.heart::before {
  left: -50%;
}

.heart::after {
  top: -50%;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: confettiFall 1.9s ease-in forwards;
}

.wish-glow {
  position: absolute;
  width: 300px;
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 214, 227, 0.58), transparent 72%);
  opacity: 0;
  pointer-events: none;
}

.wish-glow.active {
  animation: wishGlow 1.2s ease;
}

@keyframes fadeLoading {
  to {
    opacity: 0;
    visibility: hidden;
  }
}

@keyframes revealStage {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes buildLayer {
  to {
    opacity: 1;
    transform: scaleY(1);
  }
}

@keyframes candleUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes flameOn {
  to {
    transform: translateX(-50%) scale(1);
  }
}

@keyframes flicker {
  0%,
  100% {
    transform: translateX(-50%) scale(1) rotate(-2deg);
  }
  45% {
    transform: translateX(-45%) scale(0.93) rotate(5deg);
  }
  60% {
    transform: translateX(-52%) scale(1.05) rotate(-5deg);
  }
}

@keyframes revealMessage {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

@keyframes floatHeart {
  0% {
    transform: translateY(108vh) rotate(45deg) scale(0.7);
    opacity: 0;
  }
  15% {
    opacity: 1;
  }
  100% {
    transform: translateY(-15vh) rotate(45deg) scale(1.15);
    opacity: 0;
  }
}

@keyframes confettiFall {
  0% {
    opacity: 0;
    transform: translateY(-10px) scale(0.7);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateY(50vh) scale(1);
  }
}

@keyframes wishGlow {
  0% {
    opacity: 0;
    transform: scale(0.2);
  }
  30% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: scale(1.35);
  }
}

@media (max-width: 540px) {
  .stage {
    height: min(52vh, 350px);
  }

  .table {
    bottom: 2.3rem;
  }

  .cake {
    height: 240px;
  }

  .message {
    bottom: 1rem;
  }
}
