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

body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #fce4ec 0%, #f8bbd0 30%, #f48fb1 70%, #ec407a 100%);
  font-family: 'Bubblegum Sans', 'Patrick Hand', cursive, sans-serif;
  overflow: hidden;
  position: relative;
}

/* ============================================
   Floating Hearts Background
   ============================================ */
.hearts-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-heart {
  position: absolute;
  bottom: -80px;
  font-size: 24px;
  opacity: 0.6;
  animation: floatUp linear infinite;
  pointer-events: none;
  user-select: none;
}

@keyframes floatUp {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 0.7;
  }
  50% {
    opacity: 0.9;
  }
  100% {
    transform: translateY(-110vh) rotate(720deg) scale(0.3);
    opacity: 0;
  }
}

/* ============================================
   Container
   ============================================ */
.container {
  position: relative;
  z-index: 10;
  text-align: center;
  padding: 40px 30px;
  max-width: 500px;
  width: 90%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  border-radius: 30px;
  box-shadow:
    0 20px 60px rgba(233, 30, 99, 0.3),
    0 0 0 4px rgba(255, 255, 255, 0.5);
  animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.hidden {
  display: none !important;
}

@keyframes popIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ============================================
   Bear Character
   ============================================ */
.bear {
  position: relative;
  display: inline-block;
  margin-bottom: 10px;
  animation: bounce 2s ease-in-out infinite;
}

.bear-emoji {
  font-size: 80px;
  line-height: 1;
}

.heart-hold {
  font-size: 36px;
  position: absolute;
  bottom: -5px;
  right: -10px;
  animation: pulse 1.5s ease-in-out infinite;
}

.bear-happy {
  animation: happyDance 0.5s ease-in-out infinite alternate;
}

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

@keyframes happyDance {
  0% { transform: translateY(0) rotate(-5deg); }
  100% { transform: translateY(-10px) rotate(5deg); }
}

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

/* ============================================
   Typography
   ============================================ */
.title {
  font-family: 'Bubblegum Sans', cursive;
  font-size: 2rem;
  color: #c2185b;
  margin-bottom: 5px;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.1);
}

.title #recipientName {
  color: #e91e63;
  font-size: 2.3rem;
  display: inline-block;
  animation: wiggle 3s ease-in-out infinite;
}

.question {
  font-family: 'Patrick Hand', cursive;
  font-size: 1.7rem;
  color: #ad1457;
  margin-bottom: 5px;
  animation: fadeInUp 0.8s 0.3s both;
  position: relative;
}

/* Glitch — brief render artifact, not a flashy animation */
.question.glitching {
  animation: renderGlitch 0.06s steps(1) infinite;
}

.question.glitch-settle {
  animation: none;
  color: #c2185b;
  font-weight: bold;
}

@keyframes renderGlitch {
  0%   { opacity: 1; transform: none; }
  25%  { opacity: 0; transform: translate(1px, 0); }
  50%  { opacity: 1; transform: translate(-1px, 0); }
  75%  { opacity: 0; transform: none; }
  100% { opacity: 1; transform: none; }
}

/* Fade back to sweet/innocent state */
.question.fade-back {
  animation: none;
  color: #ad1457;
  font-weight: normal;
}

/* Subtext slides in after the glitch */
.subtext {
  font-family: 'Patrick Hand', cursive;
  font-size: 1rem;
  color: #e91e63;
  margin-bottom: 25px;
  opacity: 0;
  font-style: italic;
  transition: opacity 0.3s ease;
}

.subtext.reveal {
  animation: subtextReveal 0.6s ease-out both;
}

.subtext.fade-out {
  animation: subtextFadeOut 0.3s ease-in both;
}

@keyframes subtextReveal {
  0%   { opacity: 0; transform: translateY(-10px); }
  100% { opacity: 0.8; transform: translateY(0); }
}

@keyframes subtextFadeOut {
  0%   { opacity: 0.8; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(5px); }
}

.attempt-counter {
  font-family: 'Patrick Hand', cursive;
  font-size: 0.95rem;
  color: #e91e63;
  margin-top: 15px;
  opacity: 0.7;
  animation: fadeInUp 0.4s both;
}

.attempts-note {
  font-family: 'Patrick Hand', cursive;
  font-size: 1.1rem;
  color: #ad1457;
  opacity: 0.7;
  margin-bottom: 15px;
  font-style: italic;
}

.yay-title {
  font-size: 3rem;
  color: #e91e63;
  animation: wiggle 0.5s ease-in-out infinite;
  margin-bottom: 15px;
}

.yes-message {
  font-family: 'Patrick Hand', cursive;
  font-size: 1.4rem;
  color: #880e4f;
  line-height: 1.6;
  margin-bottom: 20px;
  padding: 0 10px;
}

.signed {
  font-family: 'Patrick Hand', cursive;
  font-size: 1.2rem;
  color: #ad1457;
  font-style: italic;
  opacity: 0.8;
}

@keyframes wiggle {
  0%, 100% { transform: rotate(-2deg); }
  25% { transform: rotate(2deg); }
  50% { transform: rotate(-2deg); }
  75% { transform: rotate(2deg); }
}

@keyframes fadeInUp {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   Buttons
   ============================================ */
.buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex-wrap: wrap;
  animation: fadeInUp 0.8s 0.6s both;
}

.btn {
  border: none;
  border-radius: 50px;
  cursor: pointer;
  font-family: 'Bubblegum Sans', cursive;
  font-size: 1.3rem;
  padding: 15px 40px;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-yes {
  background: linear-gradient(135deg, #e91e63, #f06292);
  color: white;
  box-shadow: 0 6px 20px rgba(233, 30, 99, 0.4);
  font-size: 1.3rem;
  padding: 15px 40px;
}

.btn-yes:hover {
  background: linear-gradient(135deg, #c2185b, #e91e63);
  box-shadow: 0 8px 30px rgba(233, 30, 99, 0.6);
  transform: scale(1.05);
}

.btn-no {
  background: #f5f5f5;
  color: #999;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  font-size: 1rem;
  padding: 10px 25px;
  position: relative;
  /* Will be set to position: fixed by JS when dodging */
}

.btn-no:hover {
  background: #eee;
}

/* Yes button grow animation */
.btn-yes.grow {
  animation: growPulse 0.3s ease;
}

@keyframes growPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.15); }
  100% { transform: scale(1.1); }
}

/* ============================================
   Confetti Canvas
   ============================================ */
#confettiCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 100;
  pointer-events: none;
}

/* ============================================
   Celebration hearts burst
   ============================================ */
.celebration {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.burst-heart {
  position: absolute;
  font-size: 30px;
  animation: burstOut 2s ease-out forwards;
  pointer-events: none;
}

@keyframes burstOut {
  0% {
    transform: translate(0, 0) scale(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translate(var(--tx), var(--ty)) scale(1.5) rotate(720deg);
    opacity: 0;
  }
}

/* ============================================
   Mobile Responsiveness
   ============================================ */
@media (max-width: 480px) {
  .container {
    padding: 30px 20px;
    border-radius: 20px;
  }

  .bear-emoji {
    font-size: 60px;
  }

  .heart-hold {
    font-size: 28px;
  }

  .title {
    font-size: 1.5rem;
  }

  .title #recipientName {
    font-size: 1.8rem;
  }

  .question {
    font-size: 1.3rem;
    margin-bottom: 20px;
  }

  .btn-yes {
    font-size: 1.1rem;
    padding: 12px 30px;
  }

  .btn-no {
    font-size: 0.9rem;
    padding: 8px 20px;
  }

  .yes-message {
    font-size: 1.2rem;
  }
}
