/* ===== RESET & BASE ===== */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --pink: #ff7eb3; --purple: #a78bfa; --orange: #fb923c;
  --yellow: #fde047; --teal: #4ecdc4; --gold: #fbbf24;
}

body {
  font-family: 'Nunito', sans-serif;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  position: relative; overflow: hidden;
  background-color: #0b0f19;
  color: white;
  user-select: none; /* Prevent selection while interacting */
}

/* ===== DYNAMIC BACKGROUND ===== */
.bg-gradient {
  position: fixed; inset: -50%; z-index: 0;
  background: radial-gradient(circle at 50% 50%, #2a0845 0%, #0b0f19 40%, #050510 100%);
  animation: bgShift 15s ease-in-out infinite alternate;
}
@keyframes bgShift {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.1) translate(-2%, 2%); }
}

/* ===== STARS ===== */
.stars { position: fixed; inset: 0; pointer-events: none; z-index: 1; }
.star {
  position: absolute; background: #fff; border-radius: 50%;
  animation: twinkle var(--dur) ease-in-out infinite alternate;
}
@keyframes twinkle {
  0% { opacity: 0.1; transform: scale(0.5); }
  100% { opacity: var(--op); transform: scale(1.5); box-shadow: 0 0 5px #fff; }
}

/* ===== INTERACTIVE CANVAS ===== */
#interactiveCanvas { position: fixed; inset: 0; z-index: 12; pointer-events: none; }

/* ===== HINTS ===== */
.hints-container {
  position: absolute; top: 20px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 15px; z-index: 50;
  pointer-events: none;
  flex-wrap: wrap; /* Allows stacking naturally on very small screen */
  padding: 0 10px;
}
.hint-badge {
  background: rgba(0,0,0,0.5); border: 2px solid var(--pink);
  backdrop-filter: blur(8px); padding: 8px 16px; border-radius: 20px;
  font-size: 0.9rem; font-weight: 800; color: #fff; text-shadow: 0 2px 5px rgba(0,0,0,0.8);
  box-shadow: 0 5px 15px rgba(255, 126, 179, 0.4);
  animation: gentleFloat 2.5s ease-in-out infinite alternate;
}
.hint-badge:nth-child(2) { border-color: var(--teal); box-shadow: 0 5px 15px rgba(78, 205, 196, 0.4); animation-delay: -1.2s; }
.hint-badge:nth-child(3) { border-color: var(--gold); box-shadow: 0 5px 15px rgba(251, 191, 36, 0.4); animation-delay: -0.6s; }

@keyframes gentleFloat {
  0% { transform: translateY(0); opacity: 0.8; }
  100% { transform: translateY(-8px); opacity: 1; filter: drop-shadow(0 0 8px rgba(255,255,255,0.4)); }
}

/* ===== BALLOONS ===== */
.balloons-container { position: fixed; inset: 0; z-index: 15; pointer-events: none; }
.balloon {
  position: absolute; bottom: -120px; width: 65px;
  animation: riseUp var(--rise) linear forwards;
  pointer-events: auto; /* Allow clicking */
  cursor: crosshair;
  transition: transform 0.1s;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.4));
}
.balloon svg { width: 100%; animation: sway var(--swayDur) ease-in-out infinite alternate; transform-origin: bottom center; }
.balloon:hover { transform: scale(1.1); filter: drop-shadow(0 12px 20px rgba(255,255,255,0.2)); }
.balloon.popped { animation: popAnim 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards !important; pointer-events: none; }

@keyframes sway { 0% { transform: rotate(-10deg); } 100% { transform: rotate(10deg); } }
@keyframes riseUp { 0% { transform: translateY(0); } 100% { transform: translateY(calc(-100vh - 200px)); } }
@keyframes popAnim { 0% { transform: scale(1.1); } 50% { transform: scale(1.4); opacity: 0.8; filter: brightness(1.5); } 100% { transform: scale(0); opacity: 0; } }

/* ===== 3D SCENE & CARD ===== */
.scene {
  position: relative; z-index: 10;
  perspective: 1500px; padding: 20px; height: 100dvh; width: 100%;
  display: flex; flex-direction: column; overflow-y: auto; overflow-x: hidden;
}
.card {
  margin: auto; /* Allows safe centering without top-clipping when height overflows */
  width: min(480px, 92vw);
  border-radius: 32px;
  background: linear-gradient(145deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.02) 100%);
  border: 1px solid rgba(255,255,255,0.2);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 40px 100px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.3);
  transform-style: preserve-3d;
  transition: transform 0.1s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.1s;
  will-change: transform;
}
.card-content { padding: 40px 30px; transform: translateZ(30px); /* Lift content in 3D */ }
.card-glare {
  position: absolute; inset: 0; border-radius: 32px; pointer-events: none;
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,0.2), transparent 60%);
  opacity: 0; transition: opacity 0.3s; mix-blend-mode: overlay;
}

/* ===== HEADER ===== */
.card-header { text-align: center; margin-bottom: 20px; transform: translateZ(40px); }
.subtitle-top { font-size: 0.8rem; letter-spacing: 0.15em; color: var(--gold); font-weight: 800; text-transform: uppercase; margin-bottom: 5px; }
.main-title {
  font-family: 'Dancing Script', cursive; font-size: clamp(3rem, 10vw, 4.5rem); line-height: 1;
  background: linear-gradient(to right, #ffefba, #ffffff); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 8px rgba(0,0,0,0.5));
}
.dad-label { font-size: 1.4rem; font-weight: 900; color: #fff; margin-top: 5px; letter-spacing: 0.1em; text-shadow: 0 2px 10px var(--gold); }

/* ===== CAKE ===== */
.cake-wrapper { display: flex; justify-content: center; transform: translateZ(60px); margin: 15px 0; }
.cake-stage { position: relative; cursor: pointer; transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275); display: flex; flex-direction: column; align-items: center; }
.cake-stage:hover { transform: scale(1.05) translateY(-5px); }
.cake-svg { width: min(280px, 75vw); filter: drop-shadow(0 15px 25px rgba(0,0,0,0.5)); overflow: visible; }

.flame-group {
  transform-origin: center bottom;
  transform-box: fill-box;
  animation: flicker 0.6s ease-in-out infinite alternate;
}
@keyframes flicker {
  0%   { transform: scaleX(0.95) scaleY(1.05) rotate(-2deg); opacity: 0.9; }
  100% { transform: scaleX(1.05) scaleY(0.95) rotate(2deg); opacity: 1; filter: drop-shadow(0 0 12px #fde047); }
}
#flame1 { animation-duration: 0.5s; animation-delay: 0s; }
#flame2 { animation-duration: 0.6s; animation-delay: 0.1s; }
#flame3 { animation-duration: 0.45s; animation-delay: 0.2s; }
#flame4 { animation-duration: 0.55s; animation-delay: 0.15s; }

@keyframes poofOut {
  0%   { transform: scaleX(1) scaleY(1); opacity: 1; filter: drop-shadow(0 0 10px #fde047); }
  20%  { transform: scaleX(1.3) scaleY(1.3); opacity: 0.9; filter: drop-shadow(0 0 25px #fde047); }
  100% { transform: scaleX(0) scaleY(2) translateY(-20px); opacity: 0; filter: drop-shadow(0 0 0 transparent); }
}

.blow-hint {
  text-align: center; font-size: 0.85rem; color: #fff; background: rgba(0,0,0,0.4);
  padding: 8px 16px; border-radius: 20px; width: fit-content; margin: 10px auto 0;
  backdrop-filter: blur(4px); box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.interactive-pulse { animation: iPulse 2s infinite; }
@keyframes iPulse { 0%, 100% { transform: scale(1); box-shadow: 0 0 0 rgba(255,255,255,0); } 50% { transform: scale(1.05); box-shadow: 0 0 15px rgba(255,255,255,0.4); } }

/* ===== MESSAGE & FOOTER ===== */
.card-message {
  text-align: center; position: relative; padding: 25px 20px;
  background: rgba(0,0,0,0.2) border-box; border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px; transform: translateZ(30px); margin-bottom: 20px;
}
.message-text { font-size: clamp(0.9rem, 2.5vw, 1.05rem); color: #e2e8f0; line-height: 1.6; }
.message-text strong { color: var(--gold); font-size: 1.1em; }
.highlight { display: block; margin-top: 10px; color: var(--pink); font-weight: 800; font-size: 1.15em; }

.age-badge {
  position: absolute; top: -20px; right: -10px; width: 60px; height: 60px;
  background: linear-gradient(135deg, #f59e0b, #ec4899); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem; font-weight: 900; box-shadow: 0 5px 20px rgba(236,72,153,0.6);
  border: 3px solid #fff; transform: translateZ(50px);
}
.pulse-anim { animation: thump 2s infinite; }
@keyframes thump { 0%, 100% { transform: scale(1) rotate(5deg); } 50% { transform: scale(1.1) rotate(-5deg); filter: brightness(1.2); } }

.card-footer { text-align: center; transform: translateZ(20px); border-top: 1px solid rgba(255,255,255,0.1); padding-top: 15px; }
.footer-wish { font-size: 0.85rem; color: var(--gold); font-weight: 800; }
.footer-date { font-size: 0.75rem; color: #94a3b8; font-weight: 700; text-transform: uppercase; margin-top: 5px; letter-spacing: 0.1em;}

/* ===== OVERLAY ===== */
.blown-overlay {
  position: fixed; inset: 0; background: rgba(5,5,15,0.9); backdrop-filter: blur(15px);
  display: flex; align-items: center; justify-content: center; z-index: 100;
  opacity: 0; pointer-events: none; transition: opacity 0.5s;
}
.blown-overlay.active { opacity: 1; pointer-events: all; }
.blown-message { text-align: center; transform: scale(0.8); transition: transform 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.blown-overlay.active .blown-message { transform: scale(1); }
.bounce-anim { font-size: 6rem; animation: bounceEm 2s infinite; margin-bottom: 10px; }
@keyframes bounceEm { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-20px); } }

.gradient-text {
  font-family: 'Dancing Script', cursive; font-size: clamp(2.5rem, 8vw, 4rem);
  background: linear-gradient(45deg, #fde047, #f472b6, #38bdf8);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; line-height: 1.2;
}
.blown-message p { color: #cbd5e1; font-size: 1.2rem; font-weight: 600; margin: 15px 0 30px; }

.magic-hover {
  background: linear-gradient(90deg, #8b5cf6, #ec4899, #f59e0b, #8b5cf6);
  background-size: 300% 100%; border: none; padding: 15px 40px; border-radius: 50px;
  color: white; font-weight: 800; font-size: 1.1rem; cursor: pointer;
  box-shadow: 0 10px 30px rgba(236,72,153,0.4); transition: all 0.3s;
  animation: gradientMove 3s linear infinite;
}
.magic-hover:hover { transform: translateY(-5px) scale(1.05); box-shadow: 0 15px 40px rgba(236,72,153,0.6); }
.magic-hover:active { transform: translateY(2px) scale(0.95); }
@keyframes gradientMove { 0% { background-position: 0% 50%; } 100% { background-position: 100% 50%; } }

/* Extra Interactivity Styles */
.smoke-puff {
  position: absolute; 
  background: radial-gradient(circle, rgba(230,230,230,0.9) 0%, rgba(200,200,200,0) 70%); 
  border-radius: 50%;
  animation: floatSmoke 2s cubic-bezier(0.2, 0.8, 0.4, 1) forwards; 
  pointer-events: none;
  z-index: 20;
}
@keyframes floatSmoke {
  0% { transform: translate(0,0) scale(0.5); opacity: 0.9; filter: blur(2px); }
  50% { opacity: 0.6; }
  100% { transform: translate(var(--dx), -140px) scale(5); opacity: 0; filter: blur(12px); }
}

/* Floating emojis */
.floating-emoji {
  position: absolute; pointer-events: none; font-size: 1.5rem;
  animation: floatUp 2s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}
@keyframes floatUp {
  0% { transform: translateY(0) scale(0.5); opacity: 1; }
  100% { transform: translateY(-100px) scale(1.5); opacity: 0; }
}

/* ===== MUSIC BUTTON ===== */
.music-btn {
  position: fixed;
  bottom: 30px;
  right: 25px;
  z-index: 9999;
  background: #ff4785;
  border: 3px solid #fff;
  color: white;
  padding: 12px 24px;
  border-radius: 30px;
  font-weight: 900;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(0,0,0,0.5), 0 0 15px #ff4785;
  transition: all 0.3s;
  animation: pulse-btn 2s infinite;
}
@keyframes pulse-btn {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); box-shadow: 0 15px 25px rgba(0,0,0,0.6), 0 0 20px #ff7eb3; }
  100% { transform: scale(1); }
}
.music-btn:hover {
  background: #ff7eb3;
  transform: scale(1.1);
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 480px), (max-height: 700px) {
  .scene {
    padding: 110px 10px 80px; /* Space for hints (top) and music button (bottom) */
  }
  .hints-container {
    top: 10px;
    gap: 8px;
  }
  .hint-badge {
    padding: 6px 10px;
    font-size: 0.75rem;
  }
  .card-content {
    padding: 20px 15px;
  }
  .card-header {
    margin-bottom: 10px;
  }
  .subtitle-top {
    font-size: 0.7rem;
  }
  .main-title {
    font-size: clamp(2.2rem, 10vw, 3rem);
  }
  .dad-label {
    font-size: 1.1rem;
    margin-top: 0px;
  }
  .cake-wrapper {
    margin: 5px 0;
  }
  .cake-svg {
    width: clamp(180px, 45vw, 240px);
  }
  .card-message {
    padding: 15px 10px;
    margin-bottom: 10px;
  }
  .message-text {
    font-size: 0.85rem;
    line-height: 1.4;
  }
  .age-badge {
    width: 45px;
    height: 45px;
    font-size: 1.1rem;
    top: -15px;
    right: -10px;
  }
  .card-footer {
    padding-top: 10px;
  }
  .footer-wish {
    font-size: 0.75rem;
  }
  .footer-date {
    font-size: 0.65rem;
  }
  .magic-hover {
    padding: 12px 20px;
    font-size: 0.95rem;
  }
  .music-btn {
    bottom: 15px;
    right: 15px;
    padding: 8px 16px;
    font-size: 0.9rem;
  }
  .blown-message {
    transform: scale(0.7);
  }
  .blown-overlay.active .blown-message {
    transform: scale(0.9);
  }
}
