:root {
  --pink: #ffd6e8;
  --pink-deep: #ffb6c1;
  --lavender: #e5d9f8;
  --cream: #fff8f0;
  --coral: #ff8c7a;
  --text: #5a4a52;
  --shadow: 0 8px 24px rgba(180, 120, 140, 0.18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Quicksand', sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--cream), var(--pink) 60%, var(--lavender));
  overflow-x: hidden;
}

.script {
  font-family: 'Caveat', cursive;
  font-size: 2.6rem;
  margin: 0.2em 0;
  color: var(--coral);
}

.screen {
  display: none;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.screen.active {
  display: flex;
}

.card {
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(6px);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 32px 24px;
  max-width: 420px;
  width: 100%;
  text-align: center;
}

.card.wide { max-width: 640px; }

input[type="password"] {
  width: 100%;
  padding: 14px 16px;
  border-radius: 16px;
  border: 2px solid var(--pink-deep);
  font-family: inherit;
  font-size: 1rem;
  margin: 16px 0;
  text-align: center;
}

input[type="password"]:focus { outline: 2px solid var(--coral); }

button {
  background: var(--coral);
  color: white;
  border: none;
  padding: 14px 28px;
  border-radius: 20px;
  font-family: 'Quicksand', sans-serif;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(255, 140, 122, 0.4);
  transition: transform 0.15s ease;
}

button:hover { transform: translateY(-2px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.msg { min-height: 1.4em; color: var(--coral); font-weight: 600; }

.hero-photo, .timeline-card img {
  width: 100%;
  max-width: 280px;
  aspect-ratio: 3/4;
  object-fit: cover;
  border-radius: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}

.subtle { color: #a08a94; font-size: 0.9rem; margin-top: -8px; }

.timeline-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin: 16px 0;
}

@media (min-width: 560px) {
  .timeline-grid { grid-template-columns: 1fr 1fr; }
}

/* Polaroid flip cards */
.timeline-card {
  perspective: 1200px;
  cursor: pointer;
  min-height: 340px;
}

.flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 340px;
  transition: transform 0.6s ease;
  transform-style: preserve-3d;
}

.timeline-card.open .flip-inner { transform: rotateY(180deg); }

.flip-front, .flip-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  background: white;
  border-radius: 20px;
  padding: 16px;
  box-shadow: var(--shadow);
}

.flip-front { transition: transform 0.2s ease; }
.timeline-card:hover .flip-front { transform: translateY(-3px); }

.flip-back {
  transform: rotateY(180deg);
  display: flex;
  align-items: center;
  text-align: left;
  font-size: 0.92rem;
}

.timeline-card h3 { margin: 8px 0 4px; color: var(--coral); }

/* Dog easter egg peeking out of the anniversary card */
.dog-peek {
  position: absolute;
  bottom: 6px;
  right: 10px;
  font-size: 1.3rem;
  transition: transform 0.3s ease;
}

.timeline-card:hover .dog-peek { transform: translateX(40px) rotate(15deg); }

/* Wave dividers */
.wave-divider {
  width: 100%;
  height: 24px;
  color: var(--pink-deep);
  opacity: 0.6;
  display: block;
}

.wave-divider.on-photo { position: absolute; top: 0; z-index: 2; color: var(--cream); opacity: 0.9; }

/* Washi-taped quiz reveal photo */
.washi-photo {
  position: relative;
  display: inline-block;
  margin-top: 12px;
  transform: rotate(-3deg);
}

.washi-photo img {
  width: 100%;
  max-width: 220px;
  border-radius: 4px;
  box-shadow: var(--shadow);
  display: block;
}

.washi-photo::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(-4deg);
  width: 60px;
  height: 22px;
  background: rgba(255, 214, 232, 0.85);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

/* Heart progress bar */
.heart-progress { letter-spacing: 4px; font-size: 1.1rem; margin-bottom: 8px; }
.heart-progress .filled { filter: none; }
.heart-progress .pending { opacity: 0.35; }

/* Hidden bonus after the letter */
.bonus { margin-top: 20px; text-align: center; transition: opacity 0.4s ease; }
.bonus.hidden { display: none; }
.bonus-note { font-size: 1.3rem; }

/* Countdown page */
.countdown-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 24px 0;
}

.countdown-grid.hidden { display: none; }

.countdown-unit {
  background: white;
  border-radius: 16px;
  padding: 14px 4px;
  box-shadow: var(--shadow);
}

.countdown-unit span {
  display: block;
  font-family: 'Caveat', cursive;
  font-size: 2.2rem;
  color: var(--coral);
  line-height: 1;
}

.countdown-unit small {
  color: #a08a94;
  font-size: 0.75rem;
}

#countdown-done.hidden { display: none; }

#quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 16px 0;
}

.quiz-option {
  background: white;
  border: 2px solid var(--pink-deep);
  border-radius: 16px;
  padding: 12px;
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--text);
}

.quiz-option:hover { background: var(--pink); }
.quiz-option.correct { background: #c9f2d8; border-color: #7fd99f; }
.quiz-option.wrong { background: #ffd9d9; border-color: #ff9f9f; }

#quiz-progress {
  font-size: 0.85rem;
  color: #a08a94;
  margin-bottom: 8px;
}

#quiz-reveal img {
  width: 100%;
  max-width: 220px;
  border-radius: 16px;
  margin-top: 12px;
  box-shadow: var(--shadow);
}

.letter-card { position: relative; overflow: hidden; padding: 0; }

.letter-bg {
  width: 100%;
  height: 260px;
  object-fit: cover;
  display: block;
  filter: brightness(0.85);
  cursor: pointer;
}

.letter-text-wrap {
  padding: 28px 26px 36px;
  background: rgba(255, 248, 240, 0.95);
}

.typewriter {
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
  line-height: 1.6;
  white-space: pre-wrap;
  text-align: left;
  color: var(--text);
}

.hero-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
}

.hero-bg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: brightness(0.6) saturate(1.05);
}

.hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(160deg, rgba(255, 182, 193, 0.35), rgba(229, 217, 248, 0.5));
}

#bg-hearts {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.floating-heart {
  position: absolute;
  bottom: -40px;
  font-size: 1.4rem;
  opacity: 0.7;
  animation: floatUp linear forwards;
}

@keyframes floatUp {
  to { transform: translateY(-110vh) rotate(20deg); opacity: 0; }
}

#confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 999;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 14px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  to { transform: translateY(110vh) rotate(360deg); opacity: 0.9; }
}

.confetti-piece.emoji {
  width: auto;
  height: auto;
  font-size: 1.2rem;
  background: none !important;
}

.screen, .card { position: relative; z-index: 1; }

@media (prefers-reduced-motion: reduce) {
  .floating-heart, .confetti-piece { animation: none !important; display: none; }
  .flip-inner, .flip-front, button, .timeline-card:hover .dog-peek { transition: none !important; }
}
