* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  height: 100%;
  height: 100dvh;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  font-family: 'Segoe UI', 'Trebuchet MS', sans-serif;
  background: linear-gradient(135deg, #ff9a9e 0%, #fecfef 40%, #fbc2eb 70%, #a6c1ee 100%);
  background-size: 400% 400%;
  animation: gradientShift 12s ease infinite;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

/* ---------- Balloons ---------- */
.balloons {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 1;
}

.balloon {
  position: absolute;
  bottom: -160px;
  width: 60px;
  height: 78px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  opacity: 0.9;
  animation: floatUp linear infinite;
  box-shadow: inset -8px -8px 12px rgba(0,0,0,0.15), inset 8px 8px 12px rgba(255,255,255,0.25);
  pointer-events: auto;
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.balloon:hover {
  transform: scale(1.08);
}

.balloon.popped {
  animation: none;
  transform: scale(1.4);
  opacity: 0;
}

.balloon::after {
  content: '';
  position: absolute;
  bottom: -40px;
  left: 50%;
  width: 1px;
  height: 40px;
  background: rgba(0,0,0,0.25);
  transform: translateX(-50%);
}

@keyframes floatUp {
  0% {
    transform: translateY(0) translateX(0) rotate(0deg);
  }
  25% {
    transform: translateY(-30vh) translateX(20px) rotate(5deg);
  }
  50% {
    transform: translateY(-60vh) translateX(-20px) rotate(-5deg);
  }
  75% {
    transform: translateY(-90vh) translateX(15px) rotate(4deg);
  }
  100% {
    transform: translateY(-130vh) translateX(0) rotate(0deg);
  }
}

/* ---------- Card scene ---------- */
.scene {
  perspective: 1600px;
  z-index: 10;
  position: relative;
}

.card {
  width: min(92vw, 420px);
  height: min(85dvh, 560px);
  max-height: 620px;
  position: relative;
  cursor: pointer;
}

.card-front,
.card-inside {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
  backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: clamp(1.2rem, 5vw, 2rem);
  transition: transform 1s cubic-bezier(0.68, -0.4, 0.27, 1.4);
  transform-origin: left center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.card-front {
  background: linear-gradient(160deg, #ffffff 0%, #ffe9f3 100%);
  transform: rotateY(0deg);
  z-index: 2;
}

.card-front h1 {
  font-size: clamp(1.5rem, 7vw, 2.2rem);
  background: linear-gradient(90deg, #ff5f6d, #ffc371);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  margin: 0.5rem 0;
}

.ribbon {
  font-size: clamp(2.2rem, 9vw, 3rem);
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-12px); }
}

.subtitle {
  color: #888;
  margin-top: 1rem;
  font-style: italic;
}

.sparkles {
  position: absolute;
  bottom: 20px;
  font-size: 1.5rem;
  animation: spin 4s linear infinite;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.card-inside {
  background: linear-gradient(160deg, #fff8e7 0%, #ffe0ec 100%);
  transform: rotateY(180deg);
  z-index: 1;
  gap: 1rem;
}

.card.open .card-front {
  transform: rotateY(-160deg);
}

.card.open .card-inside {
  transform: rotateY(0deg);
}

.card-inside h2 {
  color: #d6336c;
  font-size: clamp(1.2rem, 6vw, 1.6rem);
}

.message {
  color: #555;
  line-height: 1.5;
  font-size: clamp(0.85rem, 3.6vw, 1rem);
}

.signature {
  color: #d6336c;
  font-weight: bold;
  font-style: italic;
}

.controls {
  margin-top: 0.5rem;
}

.play-btn,
.pop-btn {
  border: none;
  border-radius: 30px;
  padding: 0.8rem 1.4rem;
  min-height: 44px;
  font-size: clamp(0.85rem, 3.6vw, 0.95rem);
  cursor: pointer;
  background: linear-gradient(90deg, #ff5f6d, #ffc371);
  color: white;
  font-weight: bold;
  box-shadow: 0 6px 14px rgba(255, 95, 109, 0.4);
  transition: transform 0.15s ease;
  pointer-events: auto;
  touch-action: manipulation;
}

.play-btn:hover,
.pop-btn:hover,
.play-btn:active,
.pop-btn:active {
  transform: scale(1.06);
}

.pop-btn {
  background: linear-gradient(90deg, #667eea, #764ba2);
  box-shadow: 0 6px 14px rgba(118, 75, 162, 0.4);
  margin-top: 0.5rem;
}

@media (max-width: 480px) {
  .card { width: 94vw; height: 88dvh; }
  .card-front, .card-inside { padding: 1.2rem; }
  .controls { width: 100%; }
  .play-btn, .pop-btn { width: 100%; }
}

@media (hover: none) {
  .balloon { width: 46px !important; height: 60px !important; }
}

