:root {
  --bg: #1b1022;
  --bg-2: #2c1636;
  --ink: #fbeee6;
  --muted: #cdb4c4;
  --accent: #f2a7b8;
  --accent-ink: #2a1020;
  --gold: #e9c27d;
  --card: rgba(255, 255, 255, 0.06);
  --line: rgba(255, 255, 255, 0.14);
  --serif: 'Playfair Display', Georgia, serif;
  --hand: 'Caveat', 'Comic Sans MS', cursive;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 var(--sans);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(900px 600px at 50% -10%, #43204f 0%, transparent 70%),
    radial-gradient(700px 500px at 100% 110%, #3a1730 0%, transparent 70%),
    var(--bg);
}
.hidden { display: none !important; }

/* ---------- type ---------- */
h1, h2 { font-family: var(--serif); font-weight: 500; line-height: 1.15; text-wrap: balance; }
h1 { font-size: clamp(1.9rem, 6vw, 3rem); }
h1.big, h2.big { font-size: clamp(2.6rem, 11vw, 5rem); font-style: italic; color: var(--accent); }
h2 { font-size: clamp(1.4rem, 4.5vw, 2rem); }
.eyebrow { font-size: 0.78rem; letter-spacing: 0.22em; text-transform: uppercase; color: var(--gold); }
.lead { font-size: 1.1rem; color: var(--muted); max-width: 34ch; }
.muted { color: var(--muted); }
.tiny { font-size: 0.85rem; color: var(--muted); opacity: 0.8; }
.hint { color: var(--gold); font-size: 0.95rem; }
.feedback { min-height: 1.6em; color: var(--accent); font-weight: 500; }

/* ---------- screens ---------- */
#app > * { animation: enter 0.6s ease both; }
#app > .leaving { animation: leave 0.4s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(16px); } }
@keyframes leave { to { opacity: 0; transform: translateY(-12px); } }

.screen {
  min-height: 100svh;
  padding: 48px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
}

/* ---------- buttons & inputs ---------- */
.btn {
  font: 600 1rem var(--sans);
  color: var(--accent-ink);
  background: linear-gradient(135deg, var(--accent), var(--gold));
  border: 0;
  border-radius: 999px;
  padding: 14px 28px;
  cursor: pointer;
  box-shadow: 0 10px 30px -10px rgba(242, 167, 184, 0.6);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 14px 34px -10px rgba(242, 167, 184, 0.8); }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); box-shadow: none; }
.btn.ghost:disabled { opacity: 0.7; cursor: default; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }

.answer-form { display: flex; gap: 10px; width: 100%; max-width: 420px; flex-wrap: wrap; justify-content: center; }
.answer-form input {
  flex: 1 1 200px;
  min-width: 0;
  font: 500 1.05rem var(--sans);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 16px;
}
.answer-form input::placeholder { color: var(--muted); opacity: 0.7; }

.shake { animation: shake 0.45s ease; }
@keyframes shake {
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* ---------- welcome ---------- */
.envelope { font-size: 4rem; animation: float 3s ease-in-out infinite; }
@keyframes float { 50% { transform: translateY(-10px) rotate(-4deg); } }

/* ---------- countdown ---------- */
.clock { display: flex; gap: 10px; }
.clock div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px 10px; min-width: 68px; }
.clock b { display: block; font: 700 1.8rem var(--serif); color: var(--accent); }
.clock span { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.1em; }

/* ---------- quiz ---------- */
.keys { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.key { font-size: 1.6rem; filter: grayscale(1); opacity: 0.45; transition: 0.3s; }
.key.got { filter: none; opacity: 1; animation: pop 0.5s ease; }
@keyframes pop { 50% { transform: scale(1.5) rotate(-15deg); } }

.card {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 28px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  backdrop-filter: blur(6px);
}
.card.unlocked { border-color: rgba(233, 194, 125, 0.5); box-shadow: 0 0 60px -20px rgba(233, 194, 125, 0.5); animation: enter 0.5s ease both; }
.options { display: grid; gap: 10px; width: 100%; }
.option {
  font: 500 1rem var(--sans);
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, border-color 0.2s;
}
.option:hover:not(:disabled) { background: rgba(242, 167, 184, 0.12); border-color: var(--accent); }
.option:disabled { opacity: 0.35; text-decoration: line-through; cursor: default; }
.option.right { background: rgba(233, 194, 125, 0.2); border-color: var(--gold); }
.unlock-icon { font-size: 3rem; animation: pop 0.6s ease; }
.reveal { font: 500 1.15rem/1.5 var(--serif); font-style: italic; max-width: 36ch; }
.reveal-photo { max-width: 240px; }
.card .photos { flex-wrap: nowrap; }
.card .photos.n2 .polaroid, .card .photos.n3 .polaroid { width: min(160px, 40vw); margin: 0 -6px; }
.card .photos .polaroid figcaption { font-size: 1.1rem; line-height: 1.15; }

/* ---------- door ---------- */
.door {
  position: relative;
  width: min(220px, 60vw);
  aspect-ratio: 2 / 3;
  border: 0;
  background: #120a16;
  border-radius: 110px 110px 6px 6px;
  cursor: pointer;
  perspective: 900px;
  overflow: hidden;
  box-shadow: 0 0 0 10px #3a2340, 0 30px 60px -20px #000;
}
.door .light {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 60%, #fff6dc 0%, var(--gold) 35%, var(--accent) 70%, transparent 100%);
  opacity: 0;
  transition: opacity 1.2s ease 0.3s;
}
.door .leaf {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 50%;
  background:
    linear-gradient(transparent 12%, rgba(0, 0, 0, 0.18) 12% 13%, transparent 13% 55%, rgba(0, 0, 0, 0.18) 55% 56%, transparent 56%),
    linear-gradient(160deg, #8c4a62, #5c2c42);
  transition: transform 1.4s cubic-bezier(0.6, 0, 0.2, 1);
}
.door .left { left: 0; transform-origin: left; border-right: 1px solid rgba(0, 0, 0, 0.35); }
.door .right { right: 0; transform-origin: right; }
.door .knob { position: absolute; top: 55%; width: 10px; height: 10px; border-radius: 50%; background: var(--gold); }
.door .left .knob { right: 10px; }
.door .right .knob { left: 10px; }
.door:not(.open):hover .leaf { filter: brightness(1.15); }
.door.open .left { transform: rotateY(-105deg); }
.door.open .right { transform: rotateY(105deg); }
.door.open .light { opacity: 1; }

/* ---------- memory lane ---------- */
.lane-hero {
  min-height: 100svh;
  padding: 48px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}
.scroll-cue { margin-top: 24px; color: var(--muted); font-size: 0.8rem; letter-spacing: 0.2em; text-transform: uppercase; display: flex; flex-direction: column; align-items: center; }
.scroll-cue span { font-size: 1.4rem; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(8px); } }

.timeline { position: relative; max-width: 1040px; margin: 0 auto; padding: 0 16px 0 44px; }
.timeline::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 20px;
  width: 2px;
  background: linear-gradient(transparent, var(--accent) 8%, var(--gold) 92%, transparent);
  opacity: 0.5;
}
.chapter {
  position: relative;
  display: grid;
  gap: 28px;
  padding: 56px 0;
  min-height: 80svh;
  align-content: center;
  opacity: 0;
  transform: translateY(40px);
  transition: opacity 0.9s ease, transform 0.9s ease;
}
.chapter.in { opacity: 1; transform: none; }
.chapter .dot {
  position: absolute;
  left: -31px;
  top: calc(56px + 0.4em);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--bg);
  border: 2px solid var(--accent);
  transition: 0.4s;
}
.chapter.now .dot { background: var(--accent); box-shadow: 0 0 0 6px rgba(242, 167, 184, 0.2), 0 0 20px var(--accent); }
.chapter-text { display: flex; flex-direction: column; gap: 10px; }
.chapter-text p:not(.chapter-date) { color: var(--muted); font-size: 1.08rem; max-width: 42ch; }
.chapter-date { font: 700 1.6rem var(--hand); color: var(--gold); }
.listen {
  align-self: flex-start;
  margin-top: 6px;
  font: 500 0.9rem var(--sans);
  color: var(--accent);
  background: rgba(242, 167, 184, 0.1);
  border: 1px solid rgba(242, 167, 184, 0.35);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
}
.listen:hover { background: rgba(242, 167, 184, 0.2); }

.photos { display: flex; justify-content: center; align-items: center; flex-wrap: wrap; padding: 8px 0; }
.polaroid {
  background: #fdf8f3;
  padding: 10px 10px 0;
  border-radius: 3px;
  box-shadow: 0 18px 40px -16px rgba(0, 0, 0, 0.7);
  width: min(260px, 72vw);
  transform: rotate(-3deg);
  transition: transform 0.3s ease;
}
.polaroid:nth-child(2) { transform: rotate(4deg); }
.polaroid:nth-child(3) { transform: rotate(-1deg); }
.polaroid:hover { transform: rotate(0) scale(1.04); z-index: 2; }
.photos.n2 .polaroid, .photos.n3 .polaroid { width: min(200px, 46vw); margin: -10px; }
.photos.n3 .polaroid { width: min(180px, 42vw); }
.frame { aspect-ratio: 4 / 5; overflow: hidden; background: #e9dfe4; }
.frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.frame.missing {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: linear-gradient(135deg, #f7d6df, #f3e2c2);
}
.frame.missing::after {
  content: '📷 add\A' attr(data-file);
  white-space: pre-wrap;
  word-break: break-all;
  text-align: center;
  font: 500 0.72rem var(--sans);
  color: #7a4a5c;
}
.polaroid figcaption { font: 600 1.35rem var(--hand); color: #4a2a3a; text-align: center; padding: 6px 4px 10px; }
.polaroid:not(:has(figcaption)) { padding-bottom: 28px; }

.lane-end { padding: 80px 16px 120px; display: flex; flex-direction: column; align-items: center; gap: 20px; text-align: center; }

@media (min-width: 820px) {
  .timeline { padding: 0 24px; }
  .timeline::before { left: 50%; }
  .chapter { grid-template-columns: 1fr 1fr; gap: 72px; align-items: center; }
  .chapter .dot { left: calc(50% - 7px); top: 50%; }
  .chapter-text { text-align: right; align-items: flex-end; }
  .chapter-text p:not(.chapter-date) { margin-left: auto; }
  .listen { align-self: flex-end; }
  .chapter.alt .chapter-text { order: 2; text-align: left; align-items: flex-start; }
  .chapter.alt .chapter-text p:not(.chapter-date) { margin-left: 0; }
  .chapter.alt .listen { align-self: flex-start; }
}

/* ---------- cake ---------- */
.cake { position: relative; width: min(300px, 84vw); margin: 30px 0 10px; display: flex; flex-direction: column; align-items: center; }
.candles { display: flex; flex-wrap: wrap-reverse; justify-content: center; gap: 2px 4px; width: 72%; margin-bottom: -8px; position: relative; z-index: 1; }
.candle { position: relative; width: 26px; height: 74px; background: none; border: 0; cursor: pointer; }
.candle::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 50%;
  width: 10px;
  height: 46px;
  transform: translateX(-50%);
  border-radius: 3px 3px 0 0;
  background: repeating-linear-gradient(-45deg, #fff 0 6px, var(--accent) 6px 12px);
}
.flame {
  position: absolute;
  left: 50%;
  bottom: 46px;
  width: 13px;
  height: 22px;
  margin-left: -6.5px;
  border-radius: 50% 50% 45% 45% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 72%, #fff 0 18%, #ffe08a 34%, #ff9a3d 68%, transparent 72%);
  box-shadow: 0 0 22px 8px rgba(255, 190, 90, 0.4);
  transform-origin: 50% 100%;
  animation: flicker 0.12s ease-in-out infinite alternate;
  transition: opacity 0.3s, transform 0.3s, rotate 0.08s linear;
  rotate: calc(var(--blow, 0) * -35deg);
}
@keyframes flicker { to { transform: scale(0.92, 1.06) rotate(2deg); } }
.candle.out { cursor: default; }
.cake.waiting .candle { cursor: default; }
.cake.waiting .flame { opacity: 0.55; }
.candle.out .flame { opacity: 0; transform: scale(0.2); animation: none; }
.candle.out::after {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 48px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(220, 220, 230, 0.5);
  animation: smoke 1.6s ease-out forwards;
}
@keyframes smoke { to { transform: translate(-50%, -50px) scale(5); opacity: 0; } }

.tier { position: relative; border-radius: 12px 12px 6px 6px; }
.tier::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 22px;
  border-radius: 12px 12px 0 0;
  background:
    radial-gradient(circle at 10% 100%, #fff6f0 9px, transparent 10px) 0 6px / 26px 26px repeat-x,
    #fff6f0;
}
.tier.top { width: 72%; height: 66px; background: linear-gradient(#f2a7b8, #d97f97); }
.tier.bottom { width: 100%; height: 86px; background: linear-gradient(#8c4a62, #6a3049); }
.tier.bottom::after {
  content: '';
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: 22px;
  height: 8px;
  background: radial-gradient(circle, var(--gold) 3px, transparent 4px) 0 0 / 18px 8px repeat-x;
}
.plate { width: 116%; height: 14px; border-radius: 50%; background: linear-gradient(#e8dce6, #b7a6b5); margin-top: -4px; }
.meter { position: relative; width: 180px; height: 8px; border-radius: 999px; background: rgba(255, 255, 255, 0.1); overflow: hidden; }
.meter i { position: absolute; inset: 0; transform-origin: left; transform: scaleX(var(--level, 0)); background: linear-gradient(90deg, var(--accent), var(--gold)); transition: transform 0.08s linear; }
.meter b { position: absolute; top: 0; bottom: 0; left: 66.6%; width: 2px; background: var(--ink); opacity: 0.6; }
.candle-line { min-height: 3.2em; font: 500 1.15rem/1.5 var(--serif); font-style: italic; max-width: 34ch; }
.final { display: flex; flex-direction: column; align-items: center; gap: 14px; animation: enter 1s ease both; }
.sign { font: 700 1.8rem var(--hand); color: var(--gold); }

/* ---------- chrome ---------- */
#sound-toggle {
  position: fixed;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 20;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: rgba(27, 16, 34, 0.75);
  backdrop-filter: blur(8px);
  font-size: 1.2rem;
  cursor: pointer;
}
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 30; }
#sparkles { position: fixed; inset: 0; z-index: -1; pointer-events: none; }
#sparkles i {
  position: absolute;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #fff;
  opacity: 0;
  animation: twinkle 6s ease-in-out infinite;
}
@keyframes twinkle { 50% { opacity: 0.7; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
  .chapter { opacity: 1; transform: none; }
}
