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

:root {
  --pink-light:   #ffe4f0;
  --pink-soft:    #ffc2da;
  --pink-mid:     #ff8fbe;
  --pink-deep:    #e8316d;
  --pink-glow:    #ff6faa;
  --red-bright:   #ff2d6e;
  --rose:         #ff69b4;
  --white:        #fff9fc;
  --text-dark:    #5a1a35;
  --text-mid:     #9e4468;
  --glass-bg:     rgba(255, 255, 255, 0.18);
  --glass-border: rgba(255, 255, 255, 0.35);
  --shadow-soft:  0 8px 32px rgba(232, 49, 109, 0.15);
  --shadow-deep:  0 12px 48px rgba(232, 49, 109, 0.25);
  --font-display: 'Pacifico', cursive;
  --font-body:    'Poppins', sans-serif;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--text-dark);
  overflow-x: hidden;
  position: relative;
  cursor: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 20 20"><text y="16" font-size="16">❤️</text></svg>'), auto;
}

/* ===== BACKGROUND VARIATIONS ===== */
.page1-bg {
  background: 
    radial-gradient(circle at 20% 80%, rgba(255, 143, 190, 0.3) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255, 111, 170, 0.25) 0%, transparent 50%),
    linear-gradient(135deg, #ffe4f0 0%, #ffc2da 40%, #ff8fbe 100%);
}

.page2-bg {
  background:
    radial-gradient(circle at 30% 70%, rgba(255, 194, 218, 0.4) 0%, transparent 50%),
    radial-gradient(circle at 70% 30%, rgba(232, 49, 109, 0.2) 0%, transparent 50%),
    linear-gradient(145deg, #ffcfe8 0%, #ff8fbe 50%, #ffc2da 100%);
}

.page3-bg {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 105, 180, 0.25) 0%, transparent 60%),
    linear-gradient(160deg, #ffe4f0 0%, #ff8fbe 40%, #ffcfe8 100%);
}

.bg-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-image: 
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 10px,
      rgba(255, 255, 255, 0.03) 10px,
      rgba(255, 255, 255, 0.03) 20px
    );
  pointer-events: none;
  z-index: 1;
}

/* ===== PAGE TRANSITIONS ===== */
body { 
  opacity: 1; 
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

body.page-enter { 
  animation: pageEnter 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards; 
}

body.page-exit { 
  opacity: 0 !important; 
  transform: scale(0.98);
  transition: opacity 0.5s ease, transform 0.5s ease; 
}

@keyframes pageEnter {
  from { 
    opacity: 0; 
    transform: translateY(20px) scale(0.98);
    filter: blur(4px);
  }
  to { 
    opacity: 1; 
    transform: translateY(0) scale(1); 
    filter: blur(0);
  }
}

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

.float-heart {
  position: absolute;
  bottom: -80px;
  font-size: clamp(1.2rem, 3vw, 2rem);
  opacity: 0;
  animation: floatUp linear infinite;
  user-select: none;
  filter: drop-shadow(0 2px 8px rgba(255, 111, 170, 0.3));
}

.falling-hearts .float-heart {
  top: -80px;
  bottom: auto;
  animation: floatDown linear infinite;
}

@keyframes floatUp {
  0% { 
    transform: translateY(0) translateX(0) rotate(0deg) scale(0.8);
    opacity: 0;
  }
  10% { opacity: 0.9; }
  50% { opacity: 0.7; }
  100% { 
    transform: translateY(-120vh) translateX(var(--drift, 0)) rotate(360deg) scale(1.2);
    opacity: 0;
  }
}

@keyframes floatDown {
  0% { 
    transform: translateY(0) translateX(0) rotate(0deg);
    opacity: 0;
  }
  10% { opacity: 0.85; }
  50% { opacity: 0.6; }
  100% { 
    transform: translateY(120vh) translateX(var(--drift, 0)) rotate(360deg);
    opacity: 0;
  }
}

/* ===== LAYOUT ===== */
.center-wrap {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(16px, 4vw, 40px);
}

/* ===== GLASS CARD ===== */
.card {
  background: var(--glass-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border: 2px solid var(--glass-border);
  border-radius: 32px;
  padding: clamp(32px, 6vw, 56px) clamp(24px, 5vw, 48px);
  max-width: 520px;
  width: 100%;
  text-align: center;
  box-shadow: 
    var(--shadow-deep),
    inset 0 1px 1px rgba(255, 255, 255, 0.6),
    0 0 80px rgba(255, 111, 170, 0.1);
  position: relative;
  overflow: visible;
}

.glass-card::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, rgba(255, 143, 190, 0.25) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  animation: glowMove 8s ease-in-out infinite;
}

@keyframes glowMove {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-20px, 20px) scale(1.1); }
}

.fade-in { 
  animation: fadeIn 0.8s cubic-bezier(0.4, 0, 0.2, 1) both; 
}

@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: translateY(24px) scale(0.96);
  }
  to { 
    opacity: 1; 
    transform: translateY(0) scale(1);
  }
}

/* ===== EMOJIS & HEARTS ===== */
.card-emoji, .pulse-heart {
  font-size: clamp(3rem, 8vw, 4.5rem);
  margin-bottom: 16px;
  animation: pulse 2s ease-in-out infinite;
  display: inline-block;
  filter: drop-shadow(0 4px 12px rgba(255, 111, 170, 0.4));
}

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

/* ===== HEADINGS ===== */
.heading {
  font-family: var(--font-display);
  color: var(--pink-deep);
  font-size: clamp(1.6rem, 5.5vw, 2.4rem);
  line-height: 1.3;
  margin-bottom: 12px;
  text-shadow: 0 2px 16px rgba(232, 49, 109, 0.2);
  letter-spacing: 0.02em;
}

.subtext {
  color: var(--text-mid);
  font-size: clamp(0.9rem, 2.5vw, 1.05rem);
  margin-bottom: 32px;
  font-weight: 300;
  line-height: 1.6;
}

/* ===== INPUT ===== */
.name-input {
  width: 100%;
  padding: 16px 24px;
  border: 2.5px solid var(--pink-mid);
  border-radius: 50px;
  font-family: var(--font-body);
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  color: var(--text-dark);
  background: rgba(255, 255, 255, 0.9);
  outline: none;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  margin-bottom: 24px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(232, 49, 109, 0.1);
}

.name-input:focus {
  border-color: var(--pink-deep);
  box-shadow: 0 0 0 5px rgba(232, 49, 109, 0.15);
  transform: translateY(-2px);
  background: #fff;
}

.name-input::placeholder {
  color: var(--text-mid);
  opacity: 0.7;
}

.name-input.shake {
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97);
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(10px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}

/* ===== BUTTONS ===== */
.btn-glow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 42px;
  background: linear-gradient(135deg, var(--pink-mid), var(--red-bright));
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  border: none;
  border-radius: 50px;
  cursor: pointer;
  box-shadow: 
    0 6px 24px rgba(232, 49, 109, 0.4),
    0 0 0 0 rgba(232, 49, 109, 0),
    inset 0 1px 1px rgba(255, 255, 255, 0.3);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  letter-spacing: 0.03em;
  position: relative;
  overflow: hidden;
}

.btn-glow::before {
  content: '';
  position: absolute;
  top: 0; left: -100%;
  width: 100%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
  transition: left 0.5s;
}

.btn-glow:hover::before {
  left: 100%;
}

.btn-glow:hover {
  transform: translateY(-3px) scale(1.03);
  box-shadow: 
    0 10px 36px rgba(232, 49, 109, 0.5),
    0 0 28px rgba(255, 111, 170, 0.4);
}

.btn-glow:active { 
  transform: translateY(-1px) scale(0.98); 
}

.btn-icon {
  font-size: 1.2em;
}

/* Outline button variant */
.btn-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 32px;
  background: rgba(255, 255, 255, 0.25);
  backdrop-filter: blur(10px);
  color: var(--pink-deep);
  border: 2.5px solid var(--pink-mid);
  border-radius: 50px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
  border-color: var(--pink-deep);
  box-shadow: 0 6px 20px rgba(232, 49, 109, 0.25);
}

.btn-celebrate {
  animation: celebrate 0.6s ease-in-out;
}

@keyframes celebrate {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.2) rotate(-10deg); }
  50% { transform: scale(1.1) rotate(10deg); }
  75% { transform: scale(1.15) rotate(-5deg); }
}

/* ===== ERROR MESSAGE ===== */
.error-msg {
  display: none;
  color: var(--red-bright);
  font-size: clamp(0.85rem, 2vw, 0.95rem);
  margin-top: 12px;
  font-style: italic;
  font-weight: 500;
}

/* ===== PAGE 2 SPECIFIC ===== */
.proposal-heading { 
  font-size: clamp(1.8rem, 6vw, 2.6rem); 
}

.big-heart-anim {
  font-size: clamp(3.5rem, 10vw, 5rem);
  display: block;
  animation: heartBeat 1.4s ease-in-out infinite;
  margin-bottom: 8px;
  filter: drop-shadow(0 6px 16px rgba(255, 111, 170, 0.45));
}

@keyframes heartBeat {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.28); }
  60% { transform: scale(1.12); }
}

.dear-name {
  font-family: var(--font-display);
  color: var(--pink-glow);
  font-size: clamp(1.3rem, 4vw, 1.8rem);
  margin: 8px 0 24px;
  text-shadow: 0 2px 12px rgba(255, 111, 170, 0.4);
}

.romantic-image {
  margin: 16px 0 28px;
}

.image-placeholder {
  padding: 24px;
  background: rgba(255, 240, 248, 0.5);
  border-radius: 24px;
  border: 2px dashed var(--pink-mid);
}

.hearts-couple {
  font-size: clamp(2rem, 6vw, 3rem);
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(8px, 2vw, 16px);
}

.heart-left { 
  animation: swing 2.2s ease-in-out infinite; 
}

.heart-right { 
  animation: swing 2.2s ease-in-out infinite 0.6s; 
}

.heart-center { 
  animation: heartBeat 1.6s ease-in-out infinite; 
  font-size: clamp(2.5rem, 7vw, 3.8rem); 
}

@keyframes swing {
  0%, 100% { transform: rotate(-12deg) scale(1); }
  50% { transform: rotate(12deg) scale(1.08); }
}

.proposal-btns {
  display: flex;
  gap: 16px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

.yes-btn { 
  padding: 16px 48px; 
  font-size: clamp(1.05rem, 2.8vw, 1.25rem);
  min-width: 140px;
}

.btn-no {
  padding: 15px 40px;
  background: rgba(255, 255, 255, 0.35);
  backdrop-filter: blur(10px);
  color: var(--text-mid);
  border: 2.5px solid var(--pink-mid);
  border-radius: 50px;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  min-width: 140px;
}

.btn-no:hover {
  background: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

/* Popup card for NO click */
.popup-card {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 32px 24px;
  background: rgba(255, 240, 248, 0.6);
  backdrop-filter: blur(15px);
  border-radius: 24px;
  border: 2px solid var(--pink-mid);
  margin-top: 24px;
}

.popup-enter {
  animation: popupEnter 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes popupEnter {
  from {
    opacity: 0;
    transform: scale(0.7) translateY(20px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.popup-emoji {
  font-size: clamp(2.5rem, 7vw, 3.5rem);
  animation: wiggle 1s ease-in-out infinite;
}

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

.popup-text {
  color: var(--pink-deep);
  font-size: clamp(1rem, 2.8vw, 1.2rem);
  font-weight: 500;
  text-align: center;
}

.try-again-btn {
  padding: 14px 36px;
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
}

/* ===== PAGE 3 SPECIFIC ===== */
.letter-card {
  max-width: 640px;
  padding: clamp(36px, 6vw, 52px) clamp(28px, 5vw, 44px);
}

.letter-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 28px;
}

.letter-big-heart { 
  font-size: clamp(3.2rem, 8vw, 4rem);
}

.letter-title { 
  margin-top: 12px; 
}

.letter-body {
  background: rgba(255, 240, 248, 0.75);
  backdrop-filter: blur(10px);
  border-left: 5px solid var(--pink-mid);
  border-radius: 16px;
  padding: clamp(20px, 4vw, 28px);
  text-align: left;
  min-height: 200px;
  position: relative;
  box-shadow: inset 0 2px 8px rgba(232, 49, 109, 0.08);
}

.letter-text {
  font-size: clamp(0.95rem, 2.2vw, 1.05rem);
  line-height: 1.9;
  color: var(--text-dark);
  white-space: pre-wrap;
  font-weight: 400;
}

.cursor {
  display: inline-block;
  color: var(--pink-deep);
  font-weight: 700;
  font-size: 1.15em;
  animation: blink 0.8s step-end infinite;
  margin-left: 2px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

.forever-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 32px;
  gap: 12px;
  animation: fadeIn 0.8s ease both;
}

.forever-msg p {
  font-family: var(--font-display);
  font-size: clamp(1.3rem, 3.5vw, 1.7rem);
  color: var(--pink-deep);
  text-shadow: 0 2px 12px rgba(232, 49, 109, 0.3);
}

.big-pulsing-heart {
  font-size: clamp(3.5rem, 9vw, 4.5rem);
  animation: heartBeat 1.2s ease-in-out infinite;
  filter: drop-shadow(0 4px 16px rgba(255, 111, 170, 0.5));
}

.letter-footer { 
  margin-top: 28px;
  animation: fadeIn 0.6s ease both;
  animation-delay: 0.3s;
}

.footer-btns {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.share-btn {
  background: linear-gradient(135deg, var(--rose), var(--red-bright));
  padding: 14px 36px;
  font-size: clamp(0.95rem, 2.5vw, 1.08rem);
}

.replay-btn {
  padding: 13px 32px;
  font-size: clamp(0.92rem, 2.3vw, 1.02rem);
}

/* ===== MUSIC BUTTON ===== */
.music-btn {
  position: fixed;
  top: clamp(12px, 3vw, 20px);
  right: clamp(12px, 3vw, 20px);
  z-index: 100;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  border: 2.5px solid var(--pink-mid);
  color: var(--pink-deep);
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  width: clamp(48px, 10vw, 60px);
  height: clamp(48px, 10vw, 60px);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(232, 49, 109, 0.25);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.music-btn:hover {
  transform: scale(1.15) rotate(5deg);
  box-shadow: 0 6px 24px rgba(232, 49, 109, 0.4);
  background: rgba(255, 255, 255, 0.95);
}

.music-icon {
  position: relative;
  z-index: 2;
}

.music-note {
  position: absolute;
  font-size: 0.7em;
  animation: musicFloat 2s ease-in-out infinite;
  opacity: 0;
}

@keyframes musicFloat {
  0% {
    transform: translateY(0) scale(0.5);
    opacity: 0;
  }
  50% {
    opacity: 0.8;
  }
  100% {
    transform: translateY(-20px) scale(1);
    opacity: 0;
  }
}

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

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 600px) {
  html { font-size: 15px; }
  
  .card { 
    padding: 36px 20px 32px;
    border-radius: 28px;
  }
  
  .letter-card { 
    padding: 32px 18px 28px; 
  }
  
  .proposal-btns,
  .footer-btns {
    flex-direction: column;
    width: 100%;
  }
  
  .yes-btn,
  .btn-no,
  .share-btn,
  .replay-btn {
    width: 100%;
  }
}

@media (max-width: 400px) {
  html { font-size: 14px; }
  
  .card {
    padding: 28px 16px 24px;
  }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== FOCUS STYLES ===== */
button:focus-visible,
input:focus-visible {
  outline: 3px solid var(--pink-deep);
  outline-offset: 3px;
}
