/* -----------------------------------------
   VALENTINE PINK & WHITE THEME DESIGN SYSTEM
   ----------------------------------------- */

:root {
  --primary-pink: #ff6b8b;
  --soft-pink: #fff0f3;
  --dark-pink: #e03a5c;
  --light-blush: #fff5f6;
  --rose-gold: #e5a9a9;
  --gold: #d4af37;
  --pure-white: #ffffff;
  --cream-white: #faf8f6;
  --text-dark: #4a2830;
  --text-muted: #8c606a;
  --glass-white: rgba(255, 255, 255, 0.78);
  --glass-border: rgba(255, 107, 139, 0.15);
  --shadow-sm: 0 4px 6px -1px rgba(224, 58, 92, 0.05);
  --shadow-md: 0 10px 15px -3px rgba(224, 58, 92, 0.08), 0 4px 6px -2px rgba(224, 58, 92, 0.03);
  --shadow-lg: 0 20px 25px -5px rgba(224, 58, 92, 0.12), 0 10px 10px -5px rgba(224, 58, 92, 0.04);
  --shadow-heart: 0 0 20px rgba(255, 107, 139, 0.4);
}

/* Global Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Montserrat', sans-serif;
  color: var(--text-dark);
  background-color: var(--soft-pink);
  overflow-x: hidden;
  min-height: 100vh;
}

h1, h2, h3, .elegant-title {
  font-family: 'Playfair Display', serif;
  font-weight: 700;
  color: var(--text-dark);
}

/* Background Particle Canvas */
#particles-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
}

/* -----------------------------------------
   AUDIO CONTROL PANEL
   ----------------------------------------- */
#audio-panel {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--glass-white);
  padding: 10px 15px;
  border-radius: 50px;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#audio-panel.hidden {
  opacity: 0;
  transform: translateY(-20px);
  pointer-events: none;
}

#music-toggle {
  background: var(--primary-pink);
  color: var(--pure-white);
  border: none;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(255, 107, 139, 0.3);
}

#music-toggle:hover {
  background: var(--dark-pink);
  transform: scale(1.08);
}

#music-toggle.playing {
  animation: pulse-music 1.5s infinite;
}

.visualizer {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 15px;
  width: 25px;
}

.visualizer .bar {
  width: 3px;
  height: 2px;
  background-color: var(--primary-pink);
  border-radius: 2px;
  transition: height 0.15s ease;
}

#music-toggle.playing + .visualizer .bar:nth-child(1) { animation: bounce-bar 0.6s infinite alternate 0.1s; }
#music-toggle.playing + .visualizer .bar:nth-child(2) { animation: bounce-bar 0.8s infinite alternate 0.2s; }
#music-toggle.playing + .visualizer .bar:nth-child(3) { animation: bounce-bar 0.5s infinite alternate 0.3s; }
#music-toggle.playing + .visualizer .bar:nth-child(4) { animation: bounce-bar 0.7s infinite alternate 0s; }


/* -----------------------------------------
   SCREEN 1: PASSWORD LOCK SCREEN
   ----------------------------------------- */
#lock-screen {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  background: linear-gradient(135deg, var(--soft-pink) 0%, #fff 100%);
  transition: all 1s cubic-bezier(0.77, 0, 0.175, 1);
  opacity: 0;
  pointer-events: none;
}

#lock-screen.active {
  opacity: 1;
  pointer-events: all;
}

#lock-screen.unlocked {
  transform: translateY(-100%);
  opacity: 0;
  pointer-events: none;
}

.lock-container {
  background: var(--glass-white);
  padding: 45px 35px;
  border-radius: 24px;
  border: 1px solid var(--pure-white);
  width: 90%;
  max-width: 440px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(255, 107, 139, 0.12);
  backdrop-filter: blur(15px);
  animation: float-card 6s ease-in-out infinite;
  z-index: 10;
}

/* Pulsing Heart Keylock */
.lock-heart-wrapper {
  position: relative;
  width: 80px;
  height: 80px;
  margin: 0 auto 25px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lock-heart {
  width: 70px;
  height: 70px;
  background: var(--primary-pink);
  color: var(--pure-white);
  font-size: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  box-shadow: var(--shadow-heart);
  animation: beat-heart 1.2s infinite ease-in-out;
}

.pulse-ring {
  position: absolute;
  top: 5px;
  left: 5px;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: 2px solid var(--primary-pink);
  opacity: 0;
  animation: pulse-out 2s infinite linear;
  z-index: 1;
}

.pulse-ring.delay-1 {
  animation-delay: 0.8s;
}

.elegant-title {
  font-size: 2.2rem;
  margin-bottom: 8px;
  letter-spacing: 1px;
}

.lock-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 30px;
  line-height: 1.5;
}

/* Form Styles */
#password-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  left: 18px;
  color: var(--primary-pink);
  font-size: 1.1rem;
}

#password-input {
  width: 100%;
  padding: 16px 50px;
  border-radius: 12px;
  border: 1.5px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.9);
  font-family: inherit;
  font-size: 1.1rem;
  letter-spacing: 3px;
  font-weight: 600;
  color: var(--text-dark);
  text-align: center;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

#password-input:focus {
  outline: none;
  border-color: var(--primary-pink);
  box-shadow: 0 0 0 4px rgba(255, 107, 139, 0.15);
}

#password-input::placeholder {
  letter-spacing: 1px;
  font-weight: 400;
  color: #c7a7ae;
}

#toggle-visible {
  position: absolute;
  right: 18px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  transition: color 0.2s ease;
}

#toggle-visible:hover {
  color: var(--primary-pink);
}

#unlock-btn {
  background: var(--primary-pink);
  color: var(--pure-white);
  border: none;
  padding: 16px 24px;
  font-size: 1.05rem;
  font-weight: 600;
  font-family: inherit;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 6px 20px rgba(255, 107, 139, 0.25);
}

#unlock-btn:hover {
  background: var(--dark-pink);
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(255, 107, 139, 0.35);
}

#unlock-btn:active {
  transform: translateY(1px);
}

.lock-message {
  margin-top: 15px;
  font-size: 0.9rem;
  font-weight: 500;
  min-height: 20px;
  transition: all 0.3s ease;
}

.lock-message.error {
  color: var(--dark-pink);
  animation: shake 0.5s ease-in-out;
}

.lock-message.success {
  color: #2e7d32;
}


/* -----------------------------------------
   SCREEN 2: MAIN SURPRISE SPACE
   ----------------------------------------- */
#main-screen {
  max-width: 1200px;
  margin: 0 auto;
  padding: 60px 20px 80px;
  position: relative;
  z-index: 10;
  opacity: 0;
  transform: translateY(30px);
  transition: all 1.2s cubic-bezier(0.075, 0.82, 0.165, 1);
  pointer-events: none;
}

#main-screen.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

/* Header styling */
.birthday-header {
  text-align: center;
  margin-bottom: 50px;
  animation: fade-down 1s ease-out;
}

.header-heart-icon {
  font-size: 2.5rem;
  color: var(--primary-pink);
  margin-bottom: 12px;
  animation: float 4s ease-in-out infinite;
}

.main-title {
  font-size: 3rem;
  margin-bottom: 10px;
  background: linear-gradient(to right, var(--text-dark), var(--primary-pink), var(--text-dark));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-size: 200% auto;
  animation: gradient-glow 6s linear infinite;
}

.main-subtitle {
  font-size: 1.05rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.5px;
}

.header-divider {
  width: 120px;
  height: 3px;
  background: linear-gradient(to right, transparent, var(--primary-pink), var(--rose-gold), var(--primary-pink), transparent);
  margin: 25px auto 0;
  border-radius: 2px;
}

/* Grid & Cards system */
.grid-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 30px;
}

.card-item {
  background: var(--glass-white);
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  padding: 35px;
  box-shadow: var(--shadow-md);
  backdrop-filter: blur(12px);
  transition: all 0.4s cubic-bezier(0.165, 0.84, 0.44, 1);
  position: relative;
  overflow: hidden;
}

.card-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--primary-pink), var(--rose-gold));
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card-item:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-lg);
  border-color: rgba(255, 107, 139, 0.2);
}

.card-item:hover::before {
  opacity: 1;
}

.span-two {
  grid-column: span 2;
}

/* Letter card: allow opened envelope to extend without clipping greeting */
.letter-card {
  overflow: visible;
}

.card-title {
  font-size: 1.6rem;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-title i {
  color: var(--primary-pink);
  font-size: 1.3rem;
}

.card-description {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 25px;
  line-height: 1.5;
}


/* -----------------------------------------
   MODULE 1: THE BIRTHDAY CAKE & CANDLES
   ----------------------------------------- */
.cake-container {
  height: 220px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  margin: 30px 0;
}

.birthday-cake {
  position: relative;
  width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.cake-stand {
  width: 220px;
  height: 12px;
  background: var(--rose-gold);
  border-radius: 20px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.05);
  position: relative;
  z-index: 1;
}

.cake-stand::after {
  content: '';
  position: absolute;
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 15px;
  background: #d49898;
  clip-path: polygon(15% 0%, 85% 0%, 100% 100%, 0% 100%);
}

.cake-bottom {
  width: 170px;
  height: 55px;
  background: var(--primary-pink);
  border-radius: 12px 12px 0 0;
  box-shadow: inset 0 8px 0 rgba(255, 255, 255, 0.2);
  position: relative;
  z-index: 2;
}

.cake-bottom::after {
  content: '';
  position: absolute;
  top: 15px;
  left: 0;
  width: 100%;
  height: 8px;
  background: var(--pure-white);
  border-radius: 5px;
}

.cake-middle {
  width: 140px;
  height: 48px;
  background: var(--pure-white);
  border-radius: 10px 10px 0 0;
  position: relative;
  z-index: 3;
  box-shadow: inset 0 6px 0 rgba(0,0,0,0.03), 0 2px 4px rgba(0,0,0,0.05);
}

.cake-middle::after {
  content: '';
  position: absolute;
  top: 12px;
  left: 0;
  width: 100%;
  height: 6px;
  background: var(--rose-gold);
  border-radius: 5px;
}

.cake-top {
  width: 110px;
  height: 42px;
  background: #ff8fa3;
  border-radius: 8px 8px 0 0;
  position: relative;
  z-index: 4;
  box-shadow: inset 0 5px 0 rgba(255,255,255,0.2), 0 2px 4px rgba(0,0,0,0.05);
}

/* Cake Candles styling */
.candle {
  position: absolute;
  width: 8px;
  height: 38px;
  cursor: pointer;
  z-index: 10;
  transition: transform 0.2s ease;
}

.candle:hover {
  transform: scale(1.1);
}

#candle-1 { left: 45px; top: -12px; }
#candle-2 { left: 86px; top: -18px; }
#candle-3 { left: 127px; top: -12px; }

.candle-body {
  width: 100%;
  height: 100%;
  border-radius: 4px 4px 0 0;
}

.candle-body.c-pink { background: linear-gradient(to right, #ff4d6d, #ff8fa3); }
.candle-body.c-white { background: linear-gradient(to right, #e8e8e8, #ffffff); }
.candle-body.c-gold { background: linear-gradient(to right, #d4af37, #f3e5ab); }

.wick {
  width: 2px;
  height: 6px;
  background: #444;
  margin: 0 auto;
  position: relative;
  top: -6px;
}

/* Realistic flicking flame in CSS */
.flame {
  width: 12px;
  height: 20px;
  background: radial-gradient(ellipse at bottom, #ff9e00 20%, #ff5400 50%, #ff0054 90%);
  border-radius: 50% 50% 20% 20% / 60% 60% 40% 40%;
  position: absolute;
  top: -24px;
  left: -2px;
  box-shadow: 0 0 10px rgba(255, 158, 0, 0.6), 0 0 20px rgba(255, 84, 0, 0.4);
  transform-origin: center bottom;
  animation: flicker 1s infinite alternate ease-in-out;
  transition: all 0.4s ease;
}

.candle.extinguished .flame {
  opacity: 0 !important;
  visibility: hidden !important;
  transform: scale(0) !important;
  animation: none !important;
  box-shadow: none !important;
  pointer-events: none;
}

/* Make a wish controls */
#blow-btn {
  display: block;
  position: relative;
  z-index: 20;
  margin: 18px auto 12px;
  background: var(--pure-white);
  color: var(--primary-pink);
  border: 1.5px solid var(--primary-pink);
  padding: 12px 25px;
  border-radius: 50px;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: var(--shadow-sm);
}

#blow-btn:hover:not(:disabled) {
  background: var(--primary-pink);
  color: var(--pure-white);
  box-shadow: 0 6px 15px rgba(255, 107, 139, 0.2);
}

#blow-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.cake-card {
  overflow: visible;
}

.wish-prompt-box {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  margin-top: 0;
}

.wish-prompt-box.visible {
  max-height: 150px;
  opacity: 1;
  margin-top: 0;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.wish-text {
  font-size: 0.9rem;
  font-weight: 500;
  text-align: center;
  margin-bottom: 12px;
  color: var(--primary-pink);
}

.wish-input-wrapper {
  display: flex;
  gap: 8px;
}

.wish-input-wrapper input {
  flex: 1;
  padding: 12px 18px;
  border-radius: 12px;
  border: 1.5px solid var(--glass-border);
  font-family: inherit;
  font-size: 0.95rem;
  color: var(--text-dark);
  background: rgba(255,255,255,0.7);
}

.wish-input-wrapper input:focus {
  outline: none;
  border-color: var(--primary-pink);
  background: var(--pure-white);
}

#save-wish-btn {
  background: var(--primary-pink);
  color: var(--pure-white);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

#save-wish-btn:hover {
  background: var(--dark-pink);
}

.wish-success-box {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: all 0.6s ease;
  margin-top: 0;
}

.wish-success-box.visible {
  max-height: 100px;
  opacity: 1;
  margin-top: 25px;
}

.success-message {
  font-size: 0.9rem;
  line-height: 1.5;
  text-align: center;
  color: #2e7d32;
  font-weight: 500;
  background: rgba(232, 245, 233, 0.6);
  padding: 15px;
  border-radius: 12px;
  border: 1px solid rgba(46, 125, 50, 0.15);
}


/* -----------------------------------------
   MODULE 2: THE PRESENT BOX
   ----------------------------------------- */
.gift-box-container {
  height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 30px 0 10px;
}

.gift-box {
  position: relative;
  width: 100px;
  height: 100px;
  background: var(--primary-pink);
  border-radius: 0 0 8px 8px;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(255, 107, 139, 0.15);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.gift-box:hover {
  transform: scale(1.05) rotate(2deg);
}

/* Ribbons */
.body-ribbon-v, .lid-ribbon-v {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 100%;
  background: var(--pure-white);
  z-index: 2;
}

.body-ribbon-h {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 100%;
  height: 16px;
  background: var(--pure-white);
  z-index: 1;
}

/* Lid */
.gift-lid {
  position: absolute;
  top: -15px;
  left: -5px;
  width: 110px;
  height: 22px;
  background: var(--dark-pink);
  border-radius: 4px;
  box-shadow: 0 4px 6px rgba(0,0,0,0.06);
  z-index: 3;
  transition: all 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-origin: left bottom;
}

.lid-ribbon-h {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 100%;
  height: 8px;
  background: var(--pure-white);
}

/* Decorative Bow */
.gift-bow {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  width: 32px;
  height: 18px;
  z-index: 4;
}

.gift-bow::before, .gift-bow::after {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border: 4px solid var(--pure-white);
  border-radius: 50%;
  top: 0;
}

.gift-bow::before {
  left: -6px;
  transform: rotate(-35deg);
}

.gift-bow::after {
  right: -6px;
  transform: rotate(35deg);
}

/* Lid Pop Off State */
.gift-box.opened {
  animation: pop-bounce 0.4s ease-out forwards;
}

.gift-box.opened .gift-lid {
  transform: translateY(-60px) rotate(-35deg) scale(0.9);
  opacity: 0;
  pointer-events: none;
}

.gift-box.opened:hover {
  transform: none;
  cursor: default;
}

/* Vibrate & grow animation on gift box tap */
.gift-box.vibrating {
  animation: vibrate-grow 1.2s ease-in-out forwards;
  cursor: default;
  pointer-events: none;
}

/* Polaroid image container inside unboxed gift card */
.gift-image-container {
  margin-top: 25px;
  opacity: 0;
  transform: translateY(25px) rotate(-3deg);
  transition: all 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  justify-content: center;
}

.gift-image-container.visible {
  opacity: 1;
  transform: translateY(0) rotate(-2deg);
}

.polaroid-frame {
  background: var(--pure-white);
  padding: 16px;
  border-radius: 6px;
  box-shadow: 0 10px 25px rgba(224, 58, 92, 0.12), 0 3px 6px rgba(0, 0, 0, 0.05);
  border: 1px solid rgba(255, 107, 139, 0.1);
  max-width: 285px;
  width: 100%;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  transform-origin: center center;
}

.polaroid-frame:hover {
  transform: scale(1.04) rotate(1deg);
  box-shadow: 0 15px 35px rgba(224, 58, 92, 0.18);
}

.polaroid-img-wrapper {
  width: 100%;
  overflow: hidden;
  border-radius: 4px;
  background: var(--light-blush);
  border: 1px solid rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: center;
  align-items: center;
}

.polaroid-img-wrapper img {
  width: 100%;
  height: auto;
  max-height: 380px;
  object-fit: contain;
  display: block;
  transition: transform 0.5s ease;
}

.polaroid-frame:hover img {
  transform: scale(1.05);
}

@keyframes vibrate-grow {
  0% { transform: scale(1) rotate(0deg); }
  15% { transform: scale(1.05) rotate(-3deg); }
  30% { transform: scale(1.1) rotate(3deg); }
  45% { transform: scale(1.15) rotate(-4deg); }
  60% { transform: scale(1.2) rotate(4deg); }
  75% { transform: scale(1.25) rotate(-3deg); }
  90% { transform: scale(1.3) rotate(3deg); }
  100% { transform: scale(1.32) rotate(0deg); }
}


/* -----------------------------------------
   MODULE 3: THE LETTER & ENVELOPE
   ----------------------------------------- */
.envelope-container {
  height: 380px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
  perspective: 1000px;
  transition: min-height 0.6s ease;
  overflow: visible;
}

.envelope-container:has(.envelope.opened) {
  height: auto;
  min-height: 580px;
  align-items: flex-start;
  padding-top: 40px;
  padding-bottom: 20px;
}

.envelope {
  position: relative;
  width: 300px;
  height: 200px;
  background: #f7ced6;
  border-radius: 0 0 10px 10px;
  cursor: pointer;
  box-shadow: 0 15px 30px rgba(0,0,0,0.06);
  transform-style: preserve-3d;
  transition: all 0.4s ease;
}

.envelope:hover {
  transform: translateY(-5px);
  box-shadow: 0 20px 40px rgba(255, 107, 139, 0.1);
}

/* Envelope Front Overlay */
.envelope-front {
  position: absolute;
  width: 0;
  height: 0;
  border-top: 100px solid transparent;
  border-bottom: 100px solid #f7ced6;
  border-left: 150px solid #f2b4c1;
  border-right: 150px solid #f2b4c1;
  border-radius: 0 0 10px 10px;
  z-index: 3;
}

.envelope-back {
  position: absolute;
  width: 100%;
  height: 100%;
  background: #f1b3bf;
  border-radius: 0 0 10px 10px;
  z-index: 1;
}

/* Flap */
.envelope-top-flap {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-left: 150px solid transparent;
  border-right: 150px solid transparent;
  border-top: 105px solid #e99eaf;
  transform-origin: top center;
  z-index: 4;
  transition: transform 0.6s ease, z-index 0.2s ease;
}

/* Gold Wax Seal */
.envelope-seal {
  position: absolute;
  top: 85px;
  left: 50%;
  transform: translateX(-50%);
  width: 36px;
  height: 36px;
  background: var(--gold);
  border-radius: 50%;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--pure-white);
  font-size: 0.95rem;
  box-shadow: 0 4px 6px rgba(0,0,0,0.15);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.envelope-seal:hover {
  transform: translateX(-50%) scale(1.1);
  background: #b8952b;
}

/* Paper letter inside */
.envelope-paper {
  position: absolute;
  top: 10px;
  left: 15px;
  width: 270px;
  height: 180px;
  background: var(--pure-white);
  border-radius: 6px;
  z-index: 2;
  box-shadow: 0 4px 10px rgba(0,0,0,0.05);
  padding: 20px;
  transition: all 0.8s cubic-bezier(0.19, 1, 0.22, 1);
  overflow: hidden;
  border: 1px dashed var(--rose-gold);
}

.paper-content {
  opacity: 0.8;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 5px;
}

/* Letter Scrollbar style */
.paper-content::-webkit-scrollbar {
  width: 4px;
}
.paper-content::-webkit-scrollbar-thumb {
  background: var(--glass-border);
  border-radius: 10px;
}

.letter-date {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: right;
  font-weight: 500;
  display: block;
}

.paper-content h3 {
  font-size: 1.1rem;
  color: var(--text-dark);
  font-family: 'Playfair Display', serif;
}

.paper-content p {
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--text-dark);
  text-align: justify;
}

.paper-content .letter-greeting {
  font-family: 'Playfair Display', serif;
  font-size: 1.05rem;
  font-weight: 700;
  text-align: left;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.signature {
  font-family: 'Playfair Display', serif;
  font-style: italic;
  font-weight: 600;
  text-align: right !important;
  color: var(--primary-pink) !important;
  font-size: 0.95rem !important;
}

/* Envelope Open State */
.envelope.opened {
  cursor: default;
}

.envelope.opened .envelope-top-flap {
  transform: rotateX(180deg);
  z-index: 1; /* Pushed behind letter */
}

.envelope.opened .envelope-seal {
  opacity: 0;
  pointer-events: none;
}

.envelope.opened .envelope-paper {
  top: -90px;
  height: auto;
  min-height: 440px;
  max-height: none;
  z-index: 4; /* Floats above envelopes */
  box-shadow: 0 15px 30px rgba(224, 58, 92, 0.15);
  border: 1px solid var(--rose-gold);
  cursor: default;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow: visible;
}

.envelope.opened .paper-content {
  opacity: 1;
  flex: 0 0 auto;
  height: auto;
  max-height: none;
  overflow: visible;
  scroll-margin-top: 0;
}

/* Polaroid: hidden until envelope opens */
.letter-polaroid {
  display: none;
  flex-shrink: 0;
  align-self: center;
  margin: 8px auto 12px;
  max-width: 240px;
  width: 100%;
  padding: 14px 14px 32px;
  cursor: pointer;
  user-select: none;
}

.envelope.opened .letter-polaroid {
  display: block;
}

.letter-polaroid-photo {
  position: relative;
  width: 100%;
  min-height: 200px;
  background: linear-gradient(145deg, var(--light-blush), #f7d4dc);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.letter-polaroid-photo .polaroid-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-dark);
  text-align: center;
  letter-spacing: 0.5px;
  pointer-events: none;
  z-index: 2;
  transition: opacity 0.35s ease;
}

.letter-polaroid-photo #letter-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
  object-position: center;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.5s ease, transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.letter-polaroid.revealed .polaroid-text {
  opacity: 0;
  visibility: hidden;
}

.letter-polaroid.revealed .letter-polaroid-photo {
  min-height: 220px;
  height: auto;
}

.letter-polaroid.revealed #letter-img {
  position: relative;
  inset: auto;
  width: 100%;
  height: auto;
  max-height: 320px;
  display: block;
  opacity: 1;
  transform: scale(1);
}

.letter-polaroid.tap-wiggle {
  animation: polaroid-tap-wiggle 0.35s ease;
}

@keyframes polaroid-tap-wiggle {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-4deg) scale(1.03); }
  75% { transform: rotate(4deg) scale(1.03); }
}

.letter-polaroid.revealed {
  cursor: default;
  pointer-events: none;
}


/* -----------------------------------------
   MODULE 4: THE CELEBRATION JAR
   ----------------------------------------- */
.jar-container {
  height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 10px;
}

.jar-wrapper {
  position: relative;
  width: 105px;
  height: 145px;
  cursor: pointer;
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.jar-wrapper:hover {
  transform: scale(1.08) rotate(-3deg);
}

.jar-wrapper:active {
  transform: scale(0.96);
}

.jar-lid-top {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 65px;
  height: 15px;
  background: var(--gold);
  border-radius: 8px 8px 2px 2px;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.jar-lid-top::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 5px;
  width: 55px;
  height: 4px;
  background: #a67c1e;
}

.jar-body {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  width: 90px;
  height: 125px;
  background: rgba(255, 255, 255, 0.3);
  border: 3.5px solid var(--pure-white);
  border-radius: 12px 12px 24px 24px;
  box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.8), 0 8px 16px rgba(0,0,0,0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.jar-tag {
  background: var(--pure-white);
  border: 1px dashed var(--primary-pink);
  color: var(--primary-pink);
  padding: 4px 8px;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 4px;
  transform: rotate(-6deg);
  box-shadow: var(--shadow-sm);
  z-index: 3;
}

/* Jar float elements */
.jar-particle {
  position: absolute;
  font-size: 0.8rem;
  user-select: none;
  animation: jar-float 3s infinite ease-in-out alternate;
}

.jar-particle.p1 { left: 15px; top: 25px; animation-delay: 0.2s; }
.jar-particle.p2 { right: 15px; top: 40px; animation-delay: 0.7s; }
.jar-particle.p3 { left: 25px; bottom: 20px; animation-delay: 1.1s; }
.jar-particle.p4 { right: 20px; bottom: 30px; animation-delay: 0s; }
.jar-particle.p5 { left: 45px; top: 20px; animation-delay: 1.5s; }

/* Jar message drawing output box */
.jar-message-box {
  background: var(--light-blush);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid rgba(255, 107, 139, 0.08);
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
}

.jar-note-placeholder {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-style: italic;
}

.jar-note {
  animation: fold-out 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.jar-note.hidden {
  display: none !important;
}

.note-heart {
  color: var(--primary-pink);
  font-size: 1.1rem;
  animation: beat-heart 1.2s infinite;
}

#jar-note-text {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
  color: var(--text-dark);
}


/* -----------------------------------------
   MODULE 5: THE CELEBRATION DATE PROPOSAL (RUNAWAY NO BUTTON)
   ----------------------------------------- */
.propose-card {
  text-align: center;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.proposal-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  position: relative;
  min-height: 120px;
}

.action-btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 28px;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}

.yes-btn {
  background: var(--primary-pink);
  color: var(--pure-white);
  border: none;
}

.yes-btn:hover {
  background: var(--dark-pink);
  transform: scale(1.06);
  box-shadow: 0 6px 15px rgba(255, 107, 139, 0.3);
}

.yes-btn:active {
  transform: scale(0.98);
}

.no-btn {
  background: var(--pure-white);
  color: var(--text-muted);
  border: 1.5px solid var(--glass-border);
  position: absolute;
  z-index: 100;
  /* Transitions only apply to scaling, background, not positions to avoid visual lag when running away */
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

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

.propose-card.accepted .proposal-actions {
  display: none !important;
}

.propose-card.accepted .card-description {
  display: none !important;
}

.proposal-success {
  animation: scale-up 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
  padding: 10px 0;
  text-align: center;
}

.proposal-success.hidden {
  display: none !important;
}

.success-icon {
  font-size: 3rem;
  color: var(--primary-pink);
  margin-bottom: 15px;
}

.proposal-success h3 {
  font-size: 1.4rem;
  margin-bottom: 8px;
  color: var(--text-dark);
}

.proposal-success p {
  font-size: 0.92rem;
  color: var(--text-muted);
  line-height: 1.6;
}


/* -----------------------------------------
   FOOTER SECTION
   ----------------------------------------- */
.main-footer {
  text-align: center;
  margin-top: 60px;
  padding-top: 30px;
  border-top: 1px solid var(--glass-border);
  animation: fade-up 1.2s ease-out;
}

.main-footer p {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  font-weight: 500;
}


/* -----------------------------------------
   ANIMATIONS & KEYFRAMES
   ----------------------------------------- */
@keyframes beat-heart {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@keyframes pulse-music {
  0% { box-shadow: 0 0 0 0 rgba(255, 107, 139, 0.5); }
  70% { box-shadow: 0 0 0 10px rgba(255, 107, 139, 0); }
  100% { box-shadow: 0 0 0 0 rgba(255, 107, 139, 0); }
}

@keyframes bounce-bar {
  0% { height: 2px; }
  100% { height: 15px; }
}

@keyframes pulse-out {
  0% { transform: scale(0.95); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

@keyframes float-card {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-6px) rotate(3deg); }
}

@keyframes flicker {
  0% { transform: scale(1) rotate(-1deg); opacity: 0.8; }
  20% { transform: scale(0.9) rotate(1deg); opacity: 0.9; }
  40% { transform: scale(1.1) rotate(-2deg); opacity: 0.85; }
  60% { transform: scale(1) rotate(2deg); opacity: 1; }
  80% { transform: scale(0.95) rotate(-1deg); opacity: 0.9; }
  100% { transform: scale(1.05) rotate(0deg); opacity: 0.95; }
}

@keyframes pop-bounce {
  0% { transform: scale(1); }
  50% { transform: scale(0.9); }
  100% { transform: scale(1); }
}

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

@keyframes fade-in {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes fade-down {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes scale-up {
  from { opacity: 0; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1); }
}

@keyframes fold-out {
  from { transform: scaleY(0); opacity: 0; }
  to { transform: scaleY(1); opacity: 1; }
}

@keyframes jar-float {
  0% { transform: translateY(0) scale(1); }
  100% { transform: translateY(-12px) scale(1.1); }
}

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


/* -----------------------------------------
   RESPONSIVE DESIGN (MEDIA QUERIES)
   ----------------------------------------- */
@media (max-width: 900px) {
  .grid-container {
    grid-template-columns: 1fr;
  }
  .span-two {
    grid-column: span 1;
  }
  .main-title {
    font-size: 2.3rem;
  }
  #main-screen {
    padding: 40px 15px 60px;
  }
  .envelope-paper {
    width: 250px;
  }
  .envelope.opened .envelope-paper {
    width: 250px;
  }
}

@media (max-width: 480px) {
  .lock-container {
    padding: 35px 20px;
  }
  .elegant-title {
    font-size: 1.8rem;
  }
  .main-title {
    font-size: 1.9rem;
  }
  .card-item {
    padding: 25px 20px;
  }
  .envelope {
    width: 260px;
  }
  .envelope-front {
    border-left-width: 130px;
    border-right-width: 130px;
  }
  .envelope-top-flap {
    border-left-width: 130px;
    border-right-width: 130px;
  }
  .envelope-paper {
    width: 230px;
    left: 15px;
  }
  .envelope.opened .envelope-paper {
    width: 230px;
  }
}
