/* ═══════════════════════════════════════════════════════════════
   4th Anniversary Website · style.css
   Design system: Editorial Warm
   Fonts: Playfair Display · Nunito · Dancing Script
   ═══════════════════════════════════════════════════════════════ */

/* ─── Design Tokens ────────────────────────────────────────── */
:root {
  /* DESIGN.md color tokens */
  --canvas: #faf9f5;
  --surface: #efe9de;
  --ink: #181715;
  --body: #3d3d3a;
  --muted: #6c6a64;
  --primary: #cc785c;
  --primary-active: #a9583e;
  --hairline: rgba(20, 20, 19, 0.08);
  --success: #2f7d32;
  --warning: #c2710a;
  --error: #b3261e;
  --on-primary: #ffffff;
  --space-xxs: 4px;
  --space-xs: 8px;
  --space-sm: 12px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-xxl: 48px;
  --space-xxxl: 64px;

  /* Existing component aliases mapped to the design tokens */
  --pink: var(--primary);
  --pink-deep: var(--primary-active);
  --pink-light: var(--surface);
  --lavender: var(--surface);
  --lavender-deep: var(--primary-active);
  --peach: var(--surface);
  --sky: var(--surface);
  --mint: var(--surface);
  --cream: var(--canvas);
  --white: var(--canvas);
  --text-main: var(--ink);
  --text-soft: var(--body);
  --text-muted: var(--muted);
  --shadow-soft: 0 8px 32px rgba(24, 23, 21, 0.08);
  --shadow-card: 0 4px 20px rgba(24, 23, 21, 0.06);
  --radius-xs: 4px;
  --radius-lg: 12px;
  --radius-md: 8px;
  --radius-sm: 6px;

  /* Solid fills keep the page within the warm, editorial palette. */
  --hero-surface: var(--canvas);
  --card-surface: var(--surface);

  /* Typography tokens */
  --font-main: 'Nunito', 'Segoe UI', sans-serif;
  --font-deco: 'Playfair Display', Georgia, serif;
  --font-hand: 'Dancing Script', 'Segoe Script', cursive;
  --font-mono: 'JetBrains Mono', monospace;
}

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-main);
  background-color: var(--cream);
  background-image: radial-gradient(rgba(204, 120, 92, 0.12) 0.65px, transparent 0.65px);
  background-size: 18px 18px;
  color: var(--text-main);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* ─── Utility ──────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--pink-light); }
::-webkit-scrollbar-thumb { background: var(--pink-deep); border-radius: 4px; }

/* ─── Particles Background ──────────────────────────────────── */
#particles-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.particle {
  position: absolute;
  animation: particleDrift linear infinite;
  width: var(--particle-size, 8px);
  height: var(--particle-size, 8px);
  border: 1px solid rgba(204, 120, 92, 0.45);
  background: var(--surface);
  border-radius: 50%;
  opacity: 0.42;
  user-select: none;
}

@keyframes particleDrift {
  0%   { transform: translateY(100vh) rotate(0deg); opacity: 0; }
  10%  { opacity: 0.5; }
  90%  { opacity: 0.4; }
  100% { transform: translateY(-10vh) rotate(720deg); opacity: 0; }
}

/* ─── Confetti Canvas ───────────────────────────────────────── */
#confetti-canvas {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
}

/* ─── Floating Music Controller ─────────────────────────────── */
.music-controller {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1100;
}

.music-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 1.4rem;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(24,23,21,.08);
  display: flex; align-items: center; justify-content: center;
  transition: transform 180ms ease-out, box-shadow 180ms ease-out;
}
.music-btn:hover { transform: scale(1.1); box-shadow: 0 6px 28px rgba(24,23,21,.10); }
.music-btn.paused { background: var(--muted); opacity: 0.9; }
.music-btn .music-icon { pointer-events: none; }
.music-icon svg, .gate-lock-icon svg, .storyline-end-badge svg,
.quiz-complete-icon svg, .game-victory-icon svg, .hearts-basket svg {
  display: block;
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.gate-lock-icon svg { width: 48px; height: 48px; }
.storyline-end-badge svg, .quiz-complete-icon svg, .game-victory-icon svg { width: 42px; height: 42px; }
.storyline-end-badge svg path { fill: currentColor; stroke: none; }
.hearts-basket svg { width: 52px; height: 52px; }

/* ─── Global Buttons ────────────────────────────────────────── */
.cta-btn {
  display: inline-block;
  min-height: 40px;
  padding: 12px 20px;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
  transition: transform 180ms ease-out, box-shadow 180ms ease-out, background-color 180ms ease-out;
  letter-spacing: 0.1px;
}
.cta-btn:hover { background: var(--primary-active); transform: translateY(-1px); box-shadow: var(--shadow-soft); }
.cta-btn:active { transform: scale(.97); }

.outline-btn {
  display: inline-block;
  min-height: 40px;
  padding: 12px 20px;
  background: transparent;
  color: var(--primary-active);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all .2s;
}
.outline-btn:hover { background: var(--surface); transform: translateY(-1px); }

/* ─── Section Common Styles ─────────────────────────────────── */
section {
  position: relative;
  z-index: 1;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
}

.section-header {
  text-align: center;
  margin-bottom: 48px;
}

.section-pill {
  display: inline-block;
  padding: 6px 20px;
  background: var(--pink-light);
  color: var(--pink-deep);
  border-radius: 50px;
  font-family: var(--font-deco);
  font-weight: 600;
  font-size: .9rem;
  margin-bottom: 12px;
  letter-spacing: .03em;
}

.section-title {
  font-family: var(--font-deco);
  font-size: clamp(2rem, 5vw, 2.25rem);
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 12px;
  line-height: 1.2;
}

.section-desc {
  font-size: 1.05rem;
  color: var(--text-soft);
  max-width: 480px;
  margin: 0 auto;
  line-height: 1.6;
}

/* ════════════════════════════════════════════════════════════════
   SECTION 1 · PASSCODE GATE
════════════════════════════════════════════════════════════════ */
.gate-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: grid;
  place-items: center;
  grid-template-columns: minmax(0, 1fr);
  min-height: 100svh;
  min-height: 100dvh;
  background: var(--hero-surface);
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  overflow-y: auto;
  transition: opacity .6s, transform .6s;
}

.gate-overlay.unlocking {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}

.gate-card {
  background: var(--canvas);
  border-radius: var(--radius-lg);
  padding: clamp(20px, 4vw, 36px);
  width: min(100%, 400px);
  max-width: 400px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 20px 60px rgba(24,23,21,.06);
  border: 1px solid var(--hairline);
  position: relative;
  overflow: hidden;
  justify-self: center;
  margin: 0 auto;
}

.gate-card::before {
  content: '';
  position: absolute;
  top: -40px; right: -40px;
  width: 120px; height: 120px;
  background: var(--pink-light);
  border-radius: 50%;
}

.gate-lock-icon {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
  animation: lockBounce 2s ease-in-out infinite;
}

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

.gate-title {
  font-family: var(--font-deco);
  font-size: 1.75rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 6px;
}

.gate-subtitle {
  color: var(--text-soft);
  font-size: .95rem;
  margin-bottom: 24px;
}

/* PIN dots */
.pin-display {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 12px;
}

.pin-dot {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--pink-light);
  border: 2.5px solid var(--pink);
  transition: background .15s, transform .15s;
}

.pin-dot.filled {
  background: var(--pink-deep);
  border-color: var(--pink-deep);
  transform: scale(1.15);
}

/* Gate message */
.gate-message {
  min-height: 2.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  line-height: 1.4;
  color: var(--pink-deep);
  margin-bottom: 16px;
  font-weight: 600;
  transition: opacity .2s;
  padding: 0 8px;
}

/* Keypad */
.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.key-btn {
  min-height: clamp(44px, 8vh, 76px);
  width: 100%;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  background: var(--cream);
  font-family: var(--font-deco);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
  cursor: pointer;
  transition: all .15s;
  display: flex; align-items: center; justify-content: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.key-btn:hover { background: var(--pink-light); border-color: var(--pink); transform: scale(1.05); }
.key-btn:active { transform: scale(.93); background: var(--pink); color: var(--on-primary); }

.key-hint { background: var(--lavender); border-color: var(--lavender-deep); color: var(--lavender-deep); }
.key-delete { background: var(--peach); border-color: var(--primary); color: var(--text-main); }

/* Shake animation for wrong PIN */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-10px); }
  40%       { transform: translateX(10px); }
  60%       { transform: translateX(-8px); }
  80%       { transform: translateX(8px); }
}

.pin-display.shake { animation: shake .4s ease; }

/* ════════════════════════════════════════════════════════════════
   SECTION 2 · HERO & LIVE COUNTER
════════════════════════════════════════════════════════════════ */
.section-hero {
  background: var(--hero-surface);
  min-height: 100svh;
  overflow: hidden;
}

.hero-sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.hero-sparkles span {
  position: absolute;
  font-size: clamp(1rem, 3vw, 2rem);
  animation: sparkleFloat 6s ease-in-out infinite;
  opacity: 0.6;
}

.hero-sparkles span:nth-child(1)  { left: 5%;  top: 10%; animation-delay: 0s; }
.hero-sparkles span:nth-child(2)  { left: 18%; top: 30%; animation-delay: .8s; }
.hero-sparkles span:nth-child(3)  { left: 75%; top: 8%;  animation-delay: 1.5s; }
.hero-sparkles span:nth-child(4)  { left: 88%; top: 22%; animation-delay: 0.3s; }
.hero-sparkles span:nth-child(5)  { left: 60%; top: 75%; animation-delay: 2.1s; }
.hero-sparkles span:nth-child(6)  { left: 30%; top: 80%; animation-delay: 1.1s; }
.hero-sparkles span:nth-child(7)  { left: 90%; top: 60%; animation-delay: 0.6s; }
.hero-sparkles span:nth-child(8)  { left: 45%; top: 88%; animation-delay: 1.9s; }
.hero-sparkles span:nth-child(9)  { left: 10%; top: 65%; animation-delay: 2.5s; }
.hero-sparkles span:nth-child(10) { left: 70%; top: 40%; animation-delay: 0.4s; }

@keyframes sparkleFloat {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50%       { transform: translateY(-20px) rotate(5deg); }
}

.hero-inner {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 680px;
  animation: heroFadeIn .8s ease forwards;
}

@keyframes heroFadeIn {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}

.hero-badge {
  display: inline-block;
  padding: 8px 24px;
  background: var(--canvas);
  border-radius: 50px;
  font-family: var(--font-deco);
  font-size: 1rem;
  font-weight: 600;
  color: var(--pink-deep);
  box-shadow: var(--shadow-soft);
  margin-bottom: 20px;
  animation: badgePop .6s .2s cubic-bezier(.34,1.56,.64,1) both;
}

.hero-still-life {
  display: block;
  width: min(100%, 240px);
  height: auto;
  margin: 0 auto 24px;
  border-radius: var(--radius-lg);
}

@keyframes badgePop {
  from { opacity: 0; transform: scale(.5); }
  to   { opacity: 1; transform: scale(1); }
}

.hero-title {
  font-family: var(--font-deco);
  font-size: clamp(2.5rem, 7vw, 4rem);
  font-weight: 600;
  color: var(--text-main);
  line-height: 1.2;
  margin-bottom: 16px;
}

.hero-name-highlight {
  color: var(--primary-active);
}

.hero-subtitle {
  color: var(--text-soft);
  font-size: 1.1rem;
  margin-bottom: 36px;
  line-height: 1.6;
}

/* Counter Box */
.counter-box {
  background: var(--canvas);
  border-radius: var(--radius-lg);
  padding: 28px 32px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--hairline);
  margin-bottom: 36px;
  animation: cardSlideUp .6s .4s cubic-bezier(.34,1.56,.64,1) both;
}

@keyframes cardSlideUp {
  from { opacity: 0; transform: translateY(40px); }
  to   { opacity: 1; transform: translateY(0); }
}

.counter-label {
  font-size: .95rem;
  color: var(--text-soft);
  margin-bottom: 16px;
  font-weight: 600;
}

.counter-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.counter-unit {
  text-align: center;
  min-width: 70px;
}

.counter-value {
  font-family: var(--font-deco);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  color: var(--primary-active);
  line-height: 1;
  display: block;
}

.counter-unit-label {
  font-size: .75rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.counter-sep {
  font-family: var(--font-deco);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--pink);
  margin-bottom: 16px;
  align-self: flex-start;
  padding-top: 4px;
}

.counter-note {
  font-size: .9rem;
  color: var(--text-soft);
  margin-top: 16px;
}

.hero-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 16px 32px;
  background: var(--primary);
  color: var(--on-primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  font-family: var(--font-deco);
  font-size: 1.15rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  text-decoration: none;
  animation: cardSlideUp .6s .6s cubic-bezier(.34,1.56,.64,1) both;
  transition: background-color 180ms ease-out, transform 180ms ease-out, box-shadow 180ms ease-out;
}
.hero-cta:hover { background: var(--primary-active); transform: translateY(-2px); }
.hero-cta:focus-visible, .cta-btn:focus-visible, .outline-btn:focus-visible, .key-btn:focus-visible { outline: 3px solid var(--primary-active); outline-offset: 3px; }

/* ════════════════════════════════════════════════════════════════
   SECTION 3 · VERTICAL STORYLINE ROAD
════════════════════════════════════════════════════════════════ */
.section-storyline {
  background: var(--canvas);
}

/* The vertical track */
.storyline-road {
  position: relative;
  max-width: 760px;
  width: 100%;
  padding: 0 16px 40px;
}

/* Static background track (faded) */
.storyline-road::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0; bottom: 0;
  width: 4px;
  background: var(--hairline);
  border-radius: var(--radius-xs, 4px);
  transform: translateX(-50%);
  z-index: 1;
}

/* Animated progress line overlay */
.storyline-road::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 4px;
  height: 0;
  background: var(--primary);
  border-radius: var(--radius-xs, 4px);
  transform: translateX(-50%);
  transition: height 0.15s ease-out;
  z-index: 1;
}

/* Chapter card */
.chapter-card {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  margin-bottom: 56px;
  opacity: 0;
  transform: translateY(40px);
  transition: opacity .6s, transform .6s;
  position: relative;
  z-index: 2;
}

.chapter-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.chapter-card:nth-child(even) { flex-direction: row-reverse; }

/* Center dot */
.chapter-dot {
  position: absolute;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
  width: 44px; height: 44px;
  background: var(--canvas);
  border: 3px solid var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-deco);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary-active);
  z-index: 3;
  box-shadow: 0 0 0 6px var(--canvas), 0 4px 14px rgba(24,23,21,.12);
  flex-shrink: 0;
}

/* Chapter content bubble */
.chapter-content {
  background: var(--canvas);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: calc(50% - 40px);
  box-shadow: var(--shadow-card);
  border: 1px solid var(--hairline);
  flex-shrink: 0;
}

.chapter-year-badge {
  display: inline-block;
  padding: 4px 14px;
  background: var(--primary);
  color: var(--on-primary);
  border-radius: 50px;
  font-family: var(--font-deco);
  font-size: .8rem;
  font-weight: 700;
  margin-bottom: 10px;
}

.chapter-title {
  font-family: var(--font-deco);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.chapter-date {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 12px;
}

.chapter-story {
  font-size: .95rem;
  color: var(--text-soft);
  line-height: 1.65;
  margin-bottom: 14px;
}

/* Polaroid photo frame */
.chapter-photo {
  width: 100%;
  aspect-ratio: 4/3;
  background: var(--card-surface);
  border-radius: var(--radius-sm);
  overflow: hidden;
  margin-bottom: 12px;
  border: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: center;
  font-size: 3rem;
  position: relative;
}

.chapter-photo img {
  width: 100%; height: 100%;
  object-fit: cover;
}

.chapter-photo .photo-placeholder {
  color: var(--text-muted);
  font-size: .8rem;
  text-align: center;
  padding: 16px;
  font-family: var(--font-hand);
}

.chapter-memories {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chapter-memories li {
  font-size: .88rem;
  color: var(--text-soft);
  padding: 5px 10px;
  background: var(--pink-light);
  border-radius: var(--radius-md);
  display: inline-block;
}

/* Storyline end */
.storyline-end {
  text-align: center;
  padding: 32px 16px;
}

.storyline-end-badge {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
  animation: lockBounce 2s ease-in-out infinite;
}

.storyline-end p {
  color: var(--text-soft);
  font-size: 1.1rem;
  font-family: var(--font-hand);
  margin-bottom: 24px;
}

/* ════════════════════════════════════════════════════════════════
   SECTION 4 · MEMORY QUIZ
════════════════════════════════════════════════════════════════ */
.section-quiz {
  background: var(--canvas);
}

.quiz-card {
  background: var(--canvas);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 5vw, 40px);
  max-width: 540px;
  width: 100%;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--hairline);
}

/* Progress */
.quiz-progress { margin-bottom: 20px; }

.quiz-progress-bar {
  height: 8px;
  background: var(--pink-light);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 6px;
}

.quiz-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 8px;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 360ms cubic-bezier(0.16, 1, 0.3, 1);
}

.quiz-progress-text {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Question */
.quiz-question {
  font-family: var(--font-deco);
  font-size: clamp(1.05rem, 3vw, 1.3rem);
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 20px;
  line-height: 1.4;
}

/* Options */
.quiz-options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.quiz-option {
  padding: 14px 20px;
  background: var(--cream);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-main);
  text-align: left;
  transition: all .15s;
  width: 100%;
}

.quiz-option:hover:not(:disabled) { background: var(--pink-light); border-color: var(--pink); transform: translateX(4px); }
.quiz-option.correct  { background: var(--surface); border-color: var(--success); color: var(--success); }
.quiz-option.wrong    { background: var(--surface); border-color: var(--error); color: var(--error); }
.quiz-option:disabled { cursor: not-allowed; opacity: 0.5; pointer-events: none; }

/* Feedback */
.quiz-feedback {
  padding: 12px 16px;
  background: var(--pink-light);
  border-radius: var(--radius-sm);
  font-size: .95rem;
  color: var(--text-main);
  line-height: 1.5;
  margin-bottom: 12px;
  font-family: var(--font-deco);
  font-size: 1.1rem;
}

.quiz-next-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: 50px;
  font-family: var(--font-deco);
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .2s;
}
.quiz-next-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-soft); }

/* Complete screen */
.quiz-complete {
  text-align: center;
  margin-top: 32px;
  animation: heroFadeIn .6s ease forwards;
}
.quiz-complete-icon { font-size: 4rem; margin-bottom: 12px; }
.quiz-complete-title {
  font-family: var(--font-deco);
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 8px;
}
.quiz-score-text {
  color: var(--text-soft);
  font-size: 1.05rem;
  margin-bottom: 24px;
}

/* ════════════════════════════════════════════════════════════════
   SECTION 5 · CATCH THE LOVE HEARTS GAME
════════════════════════════════════════════════════════════════ */
.section-game {
  background: var(--canvas);
}

.game-container {
  max-width: 520px;
  width: 100%;
  position: relative;
}

.game-hud {
  background: var(--canvas);
  border-radius: var(--radius-md);
  padding: 12px 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
  border: 1px solid var(--hairline);
}

.game-score-display {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
}

.game-score-label { font-size: .9rem; color: var(--text-soft); font-weight: 600; }
.game-score-value { font-family: var(--font-deco); font-size: 1.3rem; font-weight: 700; color: var(--pink-deep); }

.game-progress-bar-wrap {
  height: 10px;
  background: var(--pink-light);
  border-radius: 10px;
  overflow: hidden;
}

.game-progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 10px;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 220ms ease-out;
}

/* Hearts Arena */
.hearts-arena {
  width: 100%;
  height: 400px;
  background: var(--canvas);
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  overflow: hidden;
  position: relative;
  box-shadow: var(--shadow-card);
  touch-action: none;
}

.falling-item {
  position: absolute;
  width: 22px;
  height: 22px;
  top: -40px;
  user-select: none;
  pointer-events: none;
  animation: itemFall linear forwards;
}
.falling-item::before {
  content: '♥';
  color: var(--primary);
  font-size: 28px;
  line-height: 1;
}

@keyframes itemFall {
  from { transform: translateY(0) rotate(0deg); }
  to   { transform: translateY(460px) rotate(180deg); }
}

.hearts-basket {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 72px;
  height: auto;
  cursor: grab;
  user-select: none;
  transition: none;
  filter: drop-shadow(0 4px 8px rgba(24,23,21,.08));
  z-index: 2;
}
.hearts-basket img {
  width: 100%;
  height: auto;
  display: block;
  pointer-events: none;
}
.hearts-basket:active { cursor: grabbing; }

.game-controls {
  text-align: center;
  margin-top: 16px;
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.game-victory {
  text-align: center;
  padding: 32px 20px;
  background: var(--canvas);
  border-radius: var(--radius-lg);
  border: 2px solid var(--mint);
  margin-top: 16px;
  animation: heroFadeIn .5s ease forwards;
}

.game-victory-icon { font-size: 3.5rem; margin-bottom: 12px; }
.game-victory h3 {
  font-family: var(--font-deco);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}
.game-victory p { color: var(--text-soft); font-size: 1rem; margin-bottom: 20px; }

/* ════════════════════════════════════════════════════════════════
   SECTION 6 · LOVE PHOTO PUZZLE
════════════════════════════════════════════════════════════════ */
.section-puzzle {
  background: var(--canvas);
}

.puzzle-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
  max-width: 660px;
}

.puzzle-preview-wrap {
  text-align: center;
  min-width: 130px;
}

.puzzle-preview-label {
  font-size: .85rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 8px;
}

.puzzle-preview {
  width: 120px; height: 120px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-card);
  background: var(--card-surface);
  display: flex; align-items: center; justify-content: center;
  font-size: 2rem;
}
.puzzle-preview img { width: 100%; height: 100%; object-fit: cover; }
.puzzle-fallback-preview {
  display: grid;
  gap: 4px;
  padding: 12px;
  text-align: center;
  color: var(--text-soft);
  font-family: var(--font-main);
  font-size: 13px;
  line-height: 1.3;
}
.puzzle-fallback-preview strong { color: var(--primary-active); font-family: var(--font-deco); font-size: 1.35rem; }

.puzzle-board-wrap { flex: 1; min-width: 260px; }

.puzzle-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  width: 280px; height: 280px;
  margin: 0 auto 16px;
  background: var(--pink-light);
  border-radius: var(--radius-md);
  padding: 4px;
  box-shadow: var(--shadow-card);
}

.puzzle-tile {
  appearance: none;
  padding: 0;
  font: inherit;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  background: var(--cream);
  border: 1px solid var(--hairline);
  transition: transform .15s, box-shadow .15s;
  background-size: 300% 300%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  position: relative;
}
.puzzle-tile:disabled { cursor: default; }
.puzzle-tile:not(.empty-tile):disabled { opacity: .72; }

.puzzle-tile:hover:not(.empty-tile) { transform: scale(1.04); box-shadow: 0 4px 16px rgba(24,23,21,.08); }
.puzzle-tile:active:not(.empty-tile) { transform: scale(.96); }

.puzzle-tile.empty-tile {
  background: var(--pink-light);
  cursor: default;
  border-style: dashed;
  border-color: var(--pink);
}

.puzzle-tile.solved { animation: tileSolve .4s ease; }
@keyframes tileSolve {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.1); }
  100% { transform: scale(1); }
}

.puzzle-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ════════════════════════════════════════════════════════════════
   SECTION 7 · GRAND FINALE · LOVE LETTER
════════════════════════════════════════════════════════════════ */
.section-finale {
  background: var(--canvas);
  min-height: 100svh;
}

.finale-inner {
  width: 100%;
  max-width: 600px;
  position: relative;
}

/* Envelope */
.envelope {
  width: 280px;
  margin: 0 auto 32px;
  cursor: pointer;
  position: relative;
  transition: transform .3s;
}

.envelope:hover { transform: scale(1.03); }
.envelope:focus { outline: 3px solid var(--pink-deep); outline-offset: 4px; border-radius: 4px; }

.envelope-flap {
  width: 0; height: 0;
  border-left: 140px solid transparent;
  border-right: 140px solid transparent;
  border-top: 100px solid var(--pink);
  border-radius: 8px 8px 0 0;
  position: relative;
  transition: transform .5s ease;
  transform-origin: top center;
  z-index: 2;
}

.envelope.open .envelope-flap {
  transform: rotateX(-180deg);
  border-top-color: var(--pink-light);
}

.envelope-body {
  background: var(--canvas);
  width: 280px;
  min-height: 180px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  border: 1px solid var(--hairline);
  border-top: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  margin-top: -3px;
  box-shadow: var(--shadow-soft);
  position: relative;
  z-index: 1;
}

.envelope-wax-seal {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(169, 88, 62, 0.4);
  margin-bottom: 12px;
  animation: sealPulse 2.5s ease-in-out infinite;
  transition: transform .3s;
}

.envelope:hover .envelope-wax-seal { transform: scale(1.1) rotate(5deg); }

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

.envelope-hint {
  font-size: .85rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Love Letter Paper */
.love-letter {
  width: 100%;
  animation: letterUnfold .7s ease forwards;
}

@keyframes letterUnfold {
  from { opacity: 0; transform: translateY(-20px) scaleY(.8); transform-origin: top; }
  to   { opacity: 1; transform: translateY(0) scaleY(1); }
}

.letter-paper {
  background: var(--canvas);
  border-radius: var(--radius-lg);
  padding: clamp(28px, 6vw, 48px);
  box-shadow: var(--shadow-soft);
  border: 1px solid var(--hairline);
  margin-bottom: 32px;
  position: relative;
  overflow: hidden;
}

.letter-paper::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 6px;
  background: var(--primary);
}

.letter-deco {
  text-align: center;
  font-size: 1.3rem;
  margin-bottom: 20px;
  letter-spacing: .3em;
}

.letter-body {
  font-family: var(--font-main);
  font-size: clamp(1.05rem, 2.2vw, 1.2rem);
  color: var(--text-main);
  line-height: 1.85;
  letter-spacing: 0.01em;
}

.letter-body p {
  margin-bottom: 18px;
}

.letter-body p:first-child {
  font-family: var(--font-deco);
  font-size: clamp(1.25rem, 2.5vw, 1.45rem);
  font-weight: 700;
  color: var(--primary-active);
  margin-bottom: 20px;
}

.letter-signature {
  font-family: var(--font-main);
  font-size: 1.05rem;
  color: var(--text-soft);
  text-align: right;
  border-top: 2px dashed var(--hairline);
  padding-top: 18px;
  margin-top: 20px;
  line-height: 1.7;
}

/* Proposal */
.proposal-section {
  text-align: center;
  padding: 32px 20px;
  background: var(--canvas);
  border-radius: var(--radius-lg);
  border: 1px solid var(--hairline);
  box-shadow: var(--shadow-card);
}

.proposal-question {
  font-family: var(--font-deco);
  font-size: clamp(1.2rem, 3.5vw, 1.6rem);
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 28px;
  line-height: 1.4;
}

.proposal-buttons {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
  position: relative;
  min-height: 140px;
  padding: 12px;
}

.btn-yes {
  padding: 16px 40px;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(24,23,21,.08);
  transition: transform .2s, box-shadow .2s;
  animation: yesPulse 2s ease-in-out infinite;
  position: relative;
  z-index: 10;
}

.btn-yes:hover { transform: scale(1.08); box-shadow: 0 12px 32px rgba(24,23,21,.10); }

@keyframes yesPulse {
  0%, 100% { box-shadow: 0 8px 24px rgba(24,23,21,.08); }
  50%       { box-shadow: 0 12px 36px rgba(24,23,21,.12); }
}

.btn-no {
  padding: 12px 28px;
  background: var(--cream);
  color: var(--text-muted);
  border: 1px solid var(--hairline);
  border-radius: 50px;
  font-family: var(--font-main);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: left 0.18s cubic-bezier(0.2, 0, 0.2, 1), top 0.18s cubic-bezier(0.2, 0, 0.2, 1);
  position: relative;
  z-index: 12;
  white-space: nowrap;
}

/* YES Celebration (Viewport-centered modal) */
.yes-celebration {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(24, 23, 21, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 20px;
  animation: heroFadeIn .3s ease;
  cursor: pointer;
}

.celebration-card {
  background: var(--canvas);
  border-radius: var(--radius-lg);
  padding: clamp(32px, 6vw, 48px);
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 24px 80px rgba(24,23,21,.25);
  border: 1px solid var(--hairline);
  animation: celebrationPop .5s cubic-bezier(.34,1.56,.64,1);
  cursor: default;
  margin: auto;
  position: relative;
  z-index: 100000;
}

@keyframes celebrationPop {
  from { opacity: 0; transform: scale(.7); }
  to   { opacity: 1; transform: scale(1); }
}

.celebration-emoji { font-size: 3.5rem; margin-bottom: 12px; animation: lockBounce 1.5s ease-in-out infinite; }

.celebration-title {
  font-family: var(--font-deco);
  font-size: clamp(1.6rem, 4vw, 2.1rem);
  font-weight: 700;
  color: var(--primary-active);
  margin-bottom: 14px;
}

.celebration-message {
  font-family: var(--font-main);
  font-size: clamp(1.05rem, 2.5vw, 1.2rem);
  font-weight: 500;
  color: var(--text-soft);
  line-height: 1.7;
  margin-bottom: 16px;
}

.celebration-heart {
  font-size: 2rem;
  letter-spacing: .3em;
  animation: lockBounce 1.5s .3s ease-in-out infinite;
  margin-bottom: 12px;
}

.celebration-hint {
  display: block;
  font-family: var(--font-main);
  font-size: 0.85rem;
  color: var(--muted);
  opacity: 0.85;
}

/* Scroll-to-top control */
.scroll-top {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(90px, calc(env(safe-area-inset-bottom) + 74px));
  z-index: 1050;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 14px;
  color: var(--on-primary);
  background: var(--primary);
  border: 1px solid var(--primary);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 180ms ease-out, transform 180ms ease-out, background-color 180ms ease-out;
}
.scroll-top.is-visible { opacity: 1; pointer-events: auto; transform: translateY(0); }
.scroll-top:hover { background: var(--primary-active); }
.scroll-top svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 2; }

@media (max-height: 700px) {
  .gate-card { padding: 16px 20px; }
  .gate-lock-icon { margin-bottom: 4px; }
  .gate-title { font-size: 1.5rem; }
  .gate-subtitle { margin-bottom: 12px; }
  .pin-display { margin-bottom: 8px; }
  .gate-message { margin-bottom: 8px; }
  .key-btn { min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
}

/* ════════════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {
  .storyline-road::before { left: 24px; transform: translateX(-50%); }
  .storyline-road::after  { left: 24px; transform: translateX(-50%); }

  .chapter-card {
    flex-direction: column !important;
    padding-left: 56px;
    padding-right: 0;
  }
  .chapter-card:nth-child(even) { flex-direction: column !important; }

  .chapter-dot {
    left: 24px;
    top: 0;
    transform: translateX(-50%);
    box-shadow: 0 0 0 6px var(--canvas), 0 4px 14px rgba(24,23,21,.12);
  }

  .chapter-content { width: 100%; }

  .puzzle-layout { flex-direction: column; align-items: center; }

  .envelope { width: 240px; }
  .envelope-flap { border-left-width: 120px; border-right-width: 120px; border-top-width: 80px; }
  .envelope-body { width: 240px; }

  .counter-grid { gap: 4px; }
  .counter-value { font-size: 1.4rem; }
  .counter-unit { min-width: 54px; }

  .scroll-top {
    bottom: max(90px, calc(env(safe-area-inset-bottom) + 74px));
  }
}

@media (max-width: 380px) {
  .keypad { gap: 7px; }
  .key-btn { font-size: 1.2rem; }
}

/* ════════════════════════════════════════════════════════════════
   GAME SECTION SCROLL-REVEAL ANIMATIONS
════════════════════════════════════════════════════════════════ */
.section-game .section-header,
.section-game .game-container,
.section-quiz .section-header,
.section-quiz .quiz-card,
.section-quiz .quiz-complete,
.section-finale .section-header,
.section-finale .finale-inner {
  opacity: 0;
  transform: translateY(50px) scale(0.96);
  transition: opacity 0.7s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

.section-game .section-header.game-revealed,
.section-game .game-container.game-revealed,
.section-quiz .section-header.game-revealed,
.section-quiz .quiz-card.game-revealed,
.section-quiz .quiz-complete.game-revealed,
.section-finale .section-header.game-revealed,
.section-finale .finale-inner.game-revealed {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Stagger reveal delays */
.section-game .game-container,
.section-quiz .quiz-card,
.section-quiz .quiz-complete,
.section-finale .finale-inner {
  transition-delay: 0.15s;
}

/* Stop button for hearts game */
.stop-btn {
  display: inline-block;
  min-height: 40px;
  padding: 12px 20px;
  background: var(--error);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  box-shadow: var(--shadow-soft);
  transition: transform 180ms ease-out, box-shadow 180ms ease-out, background-color 180ms ease-out;
}
.stop-btn:hover { background: #8b1a14; transform: translateY(-1px); }
.stop-btn:active { transform: scale(.97); }

/* Anniversary photo album */
.quiz-complete .album-unlock-btn { margin: 0 8px 12px; }
.section-album { background: var(--canvas); }
.album-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-lg);
  width: min(100%, 1040px);
}
.album-photo {
  position: relative;
  display: block;
  overflow: hidden;
  aspect-ratio: 4 / 5;
  padding: 8px;
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  cursor: zoom-in;
  transition: transform 400ms ease, box-shadow 400ms ease;
}
.album-photo:hover, .album-photo:focus-visible {
  transform: translateY(-5px) rotate(-1deg);
  box-shadow: var(--shadow-soft);
}
.album-photo:focus-visible { outline: 3px solid var(--primary-active); outline-offset: 3px; }
.album-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-sm);
}
.album-photo span {
  position: absolute;
  right: 14px;
  bottom: 14px;
  padding: 3px 8px;
  color: var(--ink);
  background: var(--canvas);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 12px;
}
.album-lightbox {
  position: fixed;
  z-index: 1000;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-md);
  padding: var(--space-xl);
  background: rgba(24, 23, 21, 0.92);
  cursor: zoom-out;
}
.album-lightbox img {
  display: block;
  max-width: min(92vw, 1100px);
  max-height: 78vh;
  object-fit: contain;
  border: 8px solid var(--canvas);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-soft);
}
.album-lightbox p { color: var(--canvas); font-size: 14px; }
@media (max-width: 760px) {
  .album-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-md); }
  .album-lightbox { padding: var(--space-md); }
}
@media (prefers-reduced-motion: reduce) {
  .album-photo { transition: none; }
  .album-photo:hover, .album-photo:focus-visible { transform: none; }
}
