:root {
  --bg: #0a0b1e;
  --card: rgba(22, 24, 52, 0.65);
  --border: rgba(255, 255, 255, 0.1);
  --text: #f6f4ff;
  --muted: #c3c2dc;
  --gold: #ffcf5c;
  --purple: #9b6bff;
  --radius: 30px;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.3), 0 35px 90px rgba(0, 0, 0, 0.4);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }
body {
  font-family: Inter, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
}
.background {
  position: fixed; inset: 0; overflow: hidden;
  background:
    radial-gradient(circle at 80% 0%, rgba(155, 107, 255, 0.28), transparent 50%),
    radial-gradient(circle at 10% 100%, rgba(255, 207, 92, 0.14), transparent 50%),
    linear-gradient(#0a0b1e, #14123a 70%, #1c1346);
}
.skyline {
  position: absolute; left: 0; right: 0; bottom: 0; height: 30vh; opacity: 0.55;
  background: #05061a;
  clip-path: polygon(0 100%,0 70%,4% 70%,4% 55%,7% 55%,7% 65%,10% 65%,10% 40%,11% 40%,11% 12%,11.6% 0,12.2% 12%,12.2% 40%,13% 40%,13% 60%,17% 60%,17% 48%,21% 48%,21% 68%,25% 68%,25% 52%,28% 52%,28% 72%,33% 72%,33% 58%,37% 58%,37% 44%,40% 44%,40% 66%,45% 66%,45% 56%,49% 56%,49% 70%,54% 70%,54% 50%,58% 50%,58% 62%,62% 62%,62% 38%,64% 38%,64% 20%,65% 20%,65% 38%,67% 38%,67% 60%,72% 60%,72% 46%,76% 46%,76% 68%,80% 68%,80% 54%,85% 54%,85% 64%,89% 64%,89% 45%,93% 45%,93% 66%,97% 66%,97% 58%,100% 58%,100% 100%);
}
#particles { position: absolute; inset: 0; }
.particle {
  position: absolute; width: 6px; height: 6px; border-radius: 50%;
  background: var(--gold); opacity: 0.5; filter: blur(0.5px);
  animation: floatUp linear forwards;
}
@keyframes floatUp {
  from { transform: translateY(30px); opacity: 0; }
  20% { opacity: 0.7; }
  to { transform: translateY(-160px); opacity: 0; }
}
#confetti { position: fixed; inset: 0; pointer-events: none; z-index: 500; }

#experience { width: min(92vw, 520px); height: min(84dvh, 700px); position: relative; }
.stack { width: 100%; height: 100%; position: relative; }
.card {
  position: absolute; inset: 0; border-radius: var(--radius);
  background: var(--card); backdrop-filter: blur(20px);
  border: 1px solid var(--border); box-shadow: var(--shadow);
  overflow: hidden; display: flex; padding: 44px;
  transition: transform 0.8s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.8s;
}
.card::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(130deg, transparent 20%, rgba(255,255,255,0.07) 50%, transparent 75%);
}
.card-content { width: 100%; display: flex; flex-direction: column; justify-content: center; gap: 22px; }
.card-number { color: var(--gold); letter-spacing: 4px; font-size: 0.8rem; font-weight: 600; }
h1 {
  font-family: Syne, sans-serif; font-weight: 800;
  font-size: clamp(2.2rem, 7vw, 3.2rem); line-height: 1.05; letter-spacing: -0.5px;
}
.card h1 { color: #fff; }
p { color: var(--muted); line-height: 1.7; font-size: 1.08rem; }

button {
  font-family: inherit; cursor: pointer; color: #fff;
  border: 1px solid rgba(255,255,255,0.12); background: rgba(255,255,255,0.1);
  backdrop-filter: blur(12px); padding: 14px 26px; border-radius: 999px; font-size: 1rem;
  transition: 0.25s;
}
button:hover { transform: translateY(-2px); background: rgba(255,255,255,0.18); }
#nextBtn {
  position: absolute; right: 24px; bottom: 24px; z-index: 100;
  background: linear-gradient(120deg, var(--purple), #6a4cff); border: none; font-weight: 600;
}
.card.swipe { animation: swipe 0.9s forwards; }
@keyframes swipe {
  0% { transform: translateX(0) rotate(0); }
  20% { transform: translateY(-12px) rotate(-2deg); }
  100% { transform: translateX(-170%) translateY(-20px) rotate(-18deg); opacity: 0; }
}

/* scenes */
#cakeScene, #loadScene, #finalCard {
  display: none; position: fixed; inset: 0; justify-content: center; align-items: center;
  background: rgba(10, 11, 30, 0.35);
}
.cakeWrap { display: flex; flex-direction: column; align-items: center; gap: 36px; }
.cake { position: relative; width: 260px; height: 270px; }
.plate { position: absolute; bottom: 0; left: -20px; right: -20px; height: 14px; border-radius: 50%; background: #d9d7ee; }
.tier { position: absolute; left: 50%; transform: translateX(-50%) scaleY(0); transform-origin: bottom; border-radius: 14px 14px 6px 6px; transition: transform 0.7s cubic-bezier(0.3, 1.5, 0.5, 1); }
.tier::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 22px; border-radius: 14px 14px 40% 40%; background: #fff; }
.t1 { bottom: 10px; width: 260px; height: 80px; background: #ff7aa8; }
.t2 { bottom: 90px; width: 190px; height: 70px; background: #9b6bff; }
.t3 { bottom: 160px; width: 120px; height: 60px; background: #ffcf5c; }
.cake.built .tier { transform: translateX(-50%) scaleY(1); }
.cake.built .t2 { transition-delay: 0.5s; }
.cake.built .t3 { transition-delay: 1s; }
.candles { position: absolute; bottom: 218px; left: 50%; transform: translateX(-50%); display: flex; gap: 22px; opacity: 0; transition: opacity 0.6s 1.7s; z-index: 5; }
.cake.built .candles { opacity: 1; }
.candle { position: relative; width: 34px; height: 54px; border-radius: 8px; background: linear-gradient(#fff, #e9e6ff); display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 0 12px rgba(255,255,255,0.2); }
.candle b { font-family: Syne, sans-serif; font-size: 1.6rem; color: #6a4cff; }
.wick { position: absolute; top: -6px; left: 50%; width: 2px; height: 8px; background: #222; transform: translateX(-50%); }
.flame {
  position: absolute; left: 50%; top: -34px; width: 20px; height: 32px; transform: translateX(-50%);
  background: radial-gradient(circle at 50% 65%, #fff7b0 0%, #ffd54f 35%, #ff9f1c 70%, #ff6b35 100%);
  border-radius: 60% 60% 60% 60% / 75% 75% 35% 35%;
  filter: drop-shadow(0 0 10px rgba(255,190,80,0.9)); animation: flicker 0.18s infinite alternate;
}
.flame.out { animation: none; opacity: 0; transform: translateX(-50%) scale(0); transition: 0.5s; }
@keyframes flicker {
  from { transform: translateX(-50%) rotate(-3deg) scale(1); }
  to { transform: translateX(-50%) rotate(3deg) scale(1.1); }
}
#blowText { opacity: 0; transition: opacity 1s 2s; font-size: 1.05rem; }
.cake.built ~ #blowText { opacity: 1; }

.load-box, .final-content {
  width: min(90vw, 520px); padding: 44px 36px; border-radius: var(--radius); text-align: center;
  background: var(--card); backdrop-filter: blur(18px); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.load-box h2 { font-family: Syne, sans-serif; font-size: 2rem; margin-bottom: 8px; }
.load-sub { font-size: 1rem; margin-bottom: 26px; }
.bar { height: 16px; border-radius: 999px; background: rgba(255,255,255,0.1); overflow: hidden; }
.fill { height: 100%; width: 0; border-radius: 999px; background: linear-gradient(90deg, var(--purple), var(--gold)); transition: width 0.2s linear; }
.fill.fail { background: #ff4d6d; }
.pct { font-family: Syne, sans-serif; font-size: 2.4rem; margin: 18px 0 6px; }
.load-msg { min-height: 3.4em; font-size: 1rem; }
#skipBtn { display: none; margin-top: 18px; }
.final-content h1 { margin-bottom: 22px; font-size: clamp(2.2rem, 8vw, 3.2rem); color: var(--gold); }
.final-content p { margin: 14px 0; }
.signature { display: block; margin: 28px 0 22px; font-size: 2rem; color: var(--gold); font-family: Caveat, cursive; }

@media (max-width: 600px) { .card { padding: 32px; } #nextBtn { left: 24px; right: 24px; } }
@media (max-height: 640px) { .cake { transform: scale(0.8); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.2s !important; }
}
