/* ============================================================
   night sky theme
   ============================================================ */
:root {
  --bg: #070a1f;
  --bg-2: #110d30;
  --text: #ece8ff;
  --text-soft: #c3bce6;
  --muted: #8d87b8;
  --gold: #f2d49b;
  --gold-soft: rgba(242, 212, 155, 0.72);
  --gold-glow: rgba(242, 212, 155, 0.35);
  --glass: rgba(22, 19, 54, 0.62);
  --glass-strong: rgba(16, 14, 42, 0.86);
  --line: rgba(255, 255, 255, 0.09);
  --paper: #f6f0e4;
  --paper-2: #ede3d0;
  --ink: #2b2440;
  --ink-soft: #5b5170;
  --wine: #6e2a48;

  --serif: "Cormorant Garamond", Georgia, serif;
  --hand: "Caveat", "Segoe Print", cursive;
  --sans: "Nunito", system-ui, -apple-system, sans-serif;

  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--bg);
  color: var(--text);
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}
body.locked, body.modal-open { overflow: hidden; }

button { font: inherit; color: inherit; cursor: pointer; }
img, video { display: block; max-width: 100%; }
svg { display: block; }

/* ---------- sky ---------- */
.nebula {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 85% 10%, rgba(92, 64, 170, 0.32), transparent 70%),
    radial-gradient(ellipse 70% 45% at 10% 55%, rgba(40, 70, 160, 0.22), transparent 70%),
    radial-gradient(ellipse 90% 50% at 60% 100%, rgba(120, 50, 120, 0.2), transparent 70%),
    linear-gradient(180deg, #060818 0%, #0c0b2a 45%, #140f35 100%);
}
#sky {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  width: 100%; height: 100vh; height: 100lvh;
}

/* ============================================================
   intro / envelope
   ============================================================ */
.intro {
  position: fixed; inset: 0; z-index: 40;
  display: grid; place-items: center;
  transition: opacity 1.2s ease, visibility 1.2s;
}
.intro.gone { opacity: 0; visibility: hidden; pointer-events: none; }

/* ---------- password ---------- */
.intro.asking .intro-stage { display: none; }
.lock {
  width: 100%; max-width: 380px; padding: 24px 20px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  animation: fadeUp 1.6s var(--ease) both 0.3s;
}
.lock.unlocked { animation: lockOut 0.8s var(--ease) both; }
.lock-eyebrow { margin: 0 0 18px; font-size: 0.78rem; letter-spacing: 0.3em; color: var(--muted); }
.lock-q {
  font-family: var(--serif); font-style: italic; font-weight: 500;
  font-size: 2.3rem; line-height: 1.15;
  text-shadow: 0 0 30px rgba(200, 185, 255, 0.3);
}
.lock-note { margin: 6px 0 0; font-family: var(--hand); font-size: 1.5rem; line-height: 1.2; color: var(--gold-soft); }
.lock-field {
  display: flex; align-items: center;
  width: 100%; margin-top: 36px;
  border-bottom: 1px solid rgba(242, 212, 155, 0.35);
  transition: border-color 0.3s, box-shadow 0.3s;
}
.lock-field:focus-within { border-color: var(--gold); box-shadow: 0 10px 22px -16px var(--gold); }
.lock-field input {
  flex: 1; min-width: 0;
  padding: 12px 0 12px 44px; /* balances the arrow button so text sits centered */
  border: 0; border-radius: 0; background: none; outline: none;
  color: var(--text); caret-color: var(--gold);
  font-family: var(--serif); font-size: 1.45rem; text-align: center;
}
.lock-go { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; }
.lock-go svg { width: 22px; height: 22px; fill: none; stroke: var(--gold); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.lock-msg { min-height: 1.5em; margin: 16px 0 0; font-family: var(--serif); font-style: italic; font-size: 1.15rem; color: var(--text-soft); }
.lock.shake .lock-field { animation: shake 0.45s ease; }

.intro-stage {
  display: flex; flex-direction: column; align-items: center; gap: 28px;
  padding: 24px;
  transition: opacity 0.9s ease, transform 1.1s var(--ease);
}
.intro.reading .intro-stage { opacity: 0; transform: scale(0.92) translateY(-20px); pointer-events: none; }

.intro-to {
  margin: 0;
  font-family: var(--hand); font-size: 2.4rem; line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 24px var(--gold-glow);
  animation: fadeUp 1.6s var(--ease) both 0.3s;
}
.intro-hint {
  margin: 0;
  font-size: 0.78rem; letter-spacing: 0.32em; text-transform: lowercase;
  color: var(--muted);
  animation: fadeUp 1.6s var(--ease) both 0.9s, breathe 3s ease-in-out infinite 2.5s;
}
.intro.opening .intro-hint { opacity: 0; transition: opacity 0.4s; animation: none; }

.envelope {
  position: relative;
  width: min(76vw, 320px); aspect-ratio: 1.55;
  padding: 0; border: 0; background: none;
  filter: drop-shadow(0 22px 34px rgba(0, 0, 0, 0.5)) drop-shadow(0 0 46px rgba(190, 170, 255, 0.2));
  animation: fadeUp 1.6s var(--ease) both 0.5s, float 6s ease-in-out infinite 2s;
}
.envelope:focus-visible { outline: 2px solid var(--gold); outline-offset: 10px; border-radius: 8px; }
.env-back, .env-letter, .env-front, .env-flap { position: absolute; display: block; }
.env-back { inset: 0; border-radius: 6px; background: linear-gradient(180deg, #cfc4ea, #d9d0ef); }
.env-letter {
  left: 7%; right: 7%; top: 7%; height: 86%; z-index: 1;
  border-radius: 3px;
  background:
    repeating-linear-gradient(180deg, transparent 0 13px, rgba(43, 36, 64, 0.08) 13px 14px) 14px 26px / calc(100% - 28px) 60% no-repeat,
    var(--paper);
  transition: transform 1.1s var(--ease);
}
.env-front {
  inset: 0; z-index: 2; border-radius: 0 0 6px 6px;
  background: linear-gradient(0deg, #efe9fa, #e3dbf4);
  clip-path: polygon(0 0, 50% 54%, 100% 0, 100% 100%, 0 100%);
}
.env-front::after {
  content: ""; position: absolute; inset: 0;
  background: rgba(70, 50, 120, 0.06);
  clip-path: polygon(0 100%, 50% 48%, 100% 100%);
}
.env-flap {
  left: 0; right: 0; top: 0; height: 58%; z-index: 3;
  background: linear-gradient(180deg, #d6ccee, #c8bce6);
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  transform-origin: 50% 0;
  transition: transform 0.8s cubic-bezier(0.5, 0, 0.3, 1);
}
.env-seal {
  position: absolute; z-index: 4;
  left: 50%; top: 58%;
  width: 50px; height: 50px; margin: -25px 0 0 -25px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #a2456c, #5c1d39 75%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35), inset 0 0 0 3px rgba(255, 255, 255, 0.07), inset 0 -3px 6px rgba(0, 0, 0, 0.3);
  transition: transform 0.5s ease, opacity 0.4s ease;
}
.env-seal svg { width: 24px; height: 24px; fill: #f2d49b; opacity: 0.9; }

.intro.opening .envelope { animation: none; }
.intro.opening .env-seal { transform: scale(0.4) rotate(-30deg); opacity: 0; }
.intro.opening .env-flap { transform: rotateX(180deg); }
.intro.opening-2 .env-flap { z-index: 0; }
.intro.opening-2 .env-letter { transform: translateY(-58%); }

/* ---------- letter (shared paper style) ---------- */
.letter {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 20px 16px calc(20px + var(--safe-b));
  opacity: 0; visibility: hidden;
  transition: opacity 1.2s ease 0.2s, visibility 1.2s;
}
.intro.reading .letter { opacity: 1; visibility: visible; }

.paper {
  position: relative;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 8%, rgba(255, 255, 255, 0.7), transparent 45%),
    radial-gradient(circle at 90% 95%, rgba(190, 160, 110, 0.18), transparent 50%),
    linear-gradient(170deg, var(--paper), var(--paper-2));
  border-radius: 6px;
  box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.75), 0 0 60px -10px rgba(190, 170, 255, 0.18);
  font-family: var(--serif);
}
.letter-paper {
  width: 100%; max-width: 520px;
  max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 38px 28px 32px;
  transform: translateY(30px) scale(0.97);
  transition: transform 1.4s var(--ease) 0.2s;
}
.intro.reading .letter-paper { transform: none; }

.paper-to { margin: 0 0 18px; font-family: var(--hand); font-size: 1.7rem; line-height: 1.1; color: var(--wine); }
.paper-body p {
  margin: 0 0 1.05em;
  font-size: 1.24rem; font-weight: 500; line-height: 1.62;
}
.paper-body p:last-child { margin-bottom: 0; }
.paper-sign { margin: 26px 0 0; font-family: var(--hand); font-size: 1.8rem; line-height: 1; color: var(--wine); text-align: right; }

#letterBody p:last-child { font-style: italic; font-size: 1.42rem; color: var(--wine); }

/* paragraphs fade in one by one */
.letter-paper .paper-to,
.letter-paper .paper-body p,
.letter-paper .paper-sign,
.letter-paper .btn-ink { opacity: 0; }
.intro.reading .letter-paper .paper-to,
.intro.reading .letter-paper .paper-body p,
.intro.reading .letter-paper .paper-sign,
.intro.reading .letter-paper .btn-ink {
  /* --line-gap: time between each line appearing. --line-fade: how long each line takes to fade in */
  --line-gap: 2.4s;
  --line-fade: 2.6s;
  animation: inkIn var(--line-fade) var(--ease) both;
  animation-delay: calc(1.4s + var(--i, 0) * var(--line-gap));
}
.letter-paper.skip * { animation-delay: 0s !important; animation-duration: 0.4s !important; }

.btn-ink {
  display: block; margin: 30px auto 4px;
  padding: 12px 30px;
  border: 1px solid rgba(43, 36, 64, 0.35); border-radius: 999px;
  background: transparent; color: var(--ink);
  font-family: var(--sans); font-size: 0.86rem; letter-spacing: 0.18em;
  transition: background 0.3s, color 0.3s;
}
.btn-ink:hover, .btn-ink:focus-visible { background: var(--ink); color: var(--paper); outline: none; }

/* ============================================================
   main
   ============================================================ */
main {
  position: relative; z-index: 1;
  visibility: hidden;
  padding-bottom: calc(110px + var(--safe-b));
}
body.entered main { visibility: visible; }

/* ---------- hero ---------- */
.hero {
  position: relative;
  min-height: 100vh; min-height: 100svh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 80px 20px 120px;
  text-align: center;
}
.moon {
  width: 74px; height: 74px; border-radius: 50%;
  box-shadow: 16px -8px 0 0 #f6e6bf;
  filter: drop-shadow(0 0 18px rgba(246, 230, 191, 0.55));
  transform: rotate(-12deg);
  margin: 0 0 34px 18px;
}
.moon.small { width: 40px; height: 40px; box-shadow: 9px -4px 0 0 #f6e6bf; margin: 0 auto 18px; }

.hero-title {
  margin: 0;
  font-family: var(--serif); font-style: italic; font-weight: 500;
  font-size: clamp(3.2rem, 15vw, 5rem); line-height: 1;
  text-shadow: 0 0 40px rgba(200, 185, 255, 0.35);
}
.hero-from { margin: 10px 0 0; font-family: var(--hand); font-size: 1.7rem; color: var(--gold-soft); }

.counter { margin-top: 56px; display: flex; flex-direction: column; align-items: center; }
.count-num {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(3.4rem, 17vw, 4.6rem); line-height: 1;
  color: var(--gold);
  text-shadow: 0 0 30px var(--gold-glow);
  font-variant-numeric: tabular-nums;
}
.count-label { margin-top: 10px; font-size: 0.82rem; letter-spacing: 0.24em; color: var(--text-soft); }
.count-date { margin-top: 2px; font-family: var(--serif); font-style: italic; font-size: 1.05rem; color: var(--muted); }
.secret {
  max-width: 300px; margin: 26px auto 0;
  font-family: var(--serif); font-style: italic; font-size: 1.08rem; line-height: 1.5;
  color: var(--muted);
}
.secret::before { content: "✧"; display: block; margin-bottom: 6px; color: var(--gold-soft); font-style: normal; }

.scroll-hint {
  position: absolute; left: 50%; bottom: 40px;
  width: 1px; height: 54px; overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}
.scroll-hint span {
  position: absolute; left: 0; top: -50%; width: 100%; height: 50%;
  background: linear-gradient(transparent, var(--gold));
  animation: drip 2.4s ease-in-out infinite;
}

/* ---------- sections ---------- */
.section { max-width: 560px; margin: 0 auto; padding: 72px 20px; }
.sec-head { text-align: center; margin-bottom: 44px; }
.ornament { display: block; color: var(--gold); font-size: 0.9rem; margin-bottom: 10px; text-shadow: 0 0 12px var(--gold-glow); }
.sec-head h2 {
  margin: 0;
  font-family: var(--serif); font-style: italic; font-weight: 500;
  font-size: 2.4rem; line-height: 1.1;
}
.sec-sub { margin: 10px 0 0; font-size: 0.8rem; letter-spacing: 0.2em; color: var(--muted); }

/* reveal on scroll */
.reveal { opacity: 0; transform: translateY(28px); filter: blur(6px); transition: opacity 1.1s ease, transform 1.2s var(--ease), filter 1.1s ease; }
.reveal.in { opacity: 1; transform: none; filter: none; }

/* ---------- timeline ---------- */
.timeline { list-style: none; margin: 0; padding: 0 0 0 28px; position: relative; }
.timeline::before {
  content: ""; position: absolute; left: 7px; top: 4px; bottom: 0; width: 1px;
  background: linear-gradient(180deg, transparent, rgba(242, 212, 155, 0.4) 6%, rgba(242, 212, 155, 0.25) 90%, transparent);
}
.tl-item { position: relative; margin-bottom: 60px; }
.tl-item::before {
  content: ""; position: absolute; left: -25px; top: 7px;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 0 4px rgba(242, 212, 155, 0.12), 0 0 14px 2px var(--gold-glow);
}
.tl-date { margin: 0 0 12px; font-size: 0.78rem; font-weight: 600; letter-spacing: 0.2em; color: var(--gold-soft); }
.tl-item figure { margin: 0; }
.media {
  position: relative; overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  box-shadow: 0 24px 50px -24px rgba(0, 0, 0, 0.8), 0 0 40px -14px rgba(160, 140, 255, 0.3);
}
.media img, .media video { width: 100%; height: auto; }
.media.photo { cursor: zoom-in; padding: 0; display: block; width: 100%; }
.tl-item figcaption {
  margin-top: 14px;
  font-family: var(--serif); font-style: italic; font-size: 1.22rem; line-height: 1.5;
  color: var(--text-soft);
}
/* several photos in one memory: swipe sideways */
.slides {
  display: flex;
  aspect-ratio: 4 / 5;
  overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.slides::-webkit-scrollbar, .lb-track::-webkit-scrollbar { display: none; }
.slide {
  position: relative; flex: 0 0 100%;
  display: grid; place-items: center;
  padding: 0; border: 0; background: none;
  scroll-snap-align: center; scroll-snap-stop: always;
}
.slide.photo { cursor: zoom-in; }
.slide img, .slide video { width: 100%; height: 100%; object-fit: cover; }

.slide-count {
  position: absolute; top: 10px; right: 10px; z-index: 2;
  padding: 3px 10px; border-radius: 999px;
  background: rgba(8, 8, 26, 0.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  font-size: 0.72rem; font-weight: 600; letter-spacing: 0.08em; color: #fff;
  pointer-events: none;
}
.slide-arrow {
  position: absolute; top: 50%; z-index: 2;
  width: 38px; height: 38px; margin-top: -19px;
  display: none; place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18); border-radius: 50%;
  background: rgba(8, 8, 26, 0.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  transition: opacity 0.2s;
}
.slide-arrow.prev { left: 10px; }
.slide-arrow.next { right: 10px; }
.slide-arrow svg { width: 18px; height: 18px; fill: none; stroke: #fff; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.slide-arrow:disabled { opacity: 0; pointer-events: none; }
@media (hover: hover) and (pointer: fine) { .slide-arrow { display: grid; } }

.dots { display: flex; justify-content: center; gap: 6px; margin-top: 12px; }
.dots span {
  width: 6px; height: 6px; border-radius: 3px;
  background: rgba(255, 255, 255, 0.25);
  transition: width 0.35s var(--ease), background 0.35s;
}
.dots span.on { width: 18px; background: var(--gold); box-shadow: 0 0 8px var(--gold-glow); }

.missing {
  padding: 40px 16px; text-align: center;
  font-size: 0.85rem; color: var(--muted); word-break: break-all;
}

.sound-btn {
  position: absolute; right: 10px; bottom: 10px;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(8, 8, 26, 0.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.sound-btn svg { width: 20px; height: 20px; fill: none; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sound-btn .i-on { display: none; }
.sound-btn.on .i-on { display: block; }
.sound-btn.on .i-off { display: none; }

.tl-note {
  position: relative; margin: -12px 0 60px;
  padding: 18px 20px;
  border: 1px dashed rgba(242, 212, 155, 0.25); border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  font-family: var(--hand); font-size: 1.65rem; line-height: 1.3;
  color: var(--gold);
  --rot: -1.2deg;
}
.tl-note.alt { --rot: 1deg; }
.tl-note.reveal { transform: translateY(28px) rotate(var(--rot)); }
.tl-note.reveal.in { transform: rotate(var(--rot)); }

/* ---------- constellation ---------- */
.constellation { position: relative; width: 100%; max-width: 400px; aspect-ratio: 1; margin: 0 auto; }
.const-lines { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.const-lines line {
  stroke: rgba(242, 212, 155, 0.55); stroke-width: 0.35; stroke-linecap: round;
  transition: stroke-dashoffset 1.2s ease, stroke 1s ease;
}
.constellation.complete .const-lines line { stroke: rgba(242, 212, 155, 0.9); filter: drop-shadow(0 0 1.2px rgba(242, 212, 155, 0.9)); }

.cstar {
  position: absolute; width: 48px; height: 48px;
  margin: -24px 0 0 -24px; padding: 0;
  border: 0; background: none; border-radius: 50%;
}
.cstar::before {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 7px; height: 7px; margin: -3.5px 0 0 -3.5px; border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 10px 3px rgba(210, 205, 255, 0.55);
  animation: pulse 2.8s ease-in-out infinite;
  animation-delay: var(--d, 0s);
  transition: background 0.5s, box-shadow 0.5s;
}
.cstar::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 22px; height: 22px; margin: -11px 0 0 -11px; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.25);
  animation: ring 2.8s ease-out infinite; animation-delay: var(--d, 0s);
}
.cstar.lit::before {
  width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px;
  background: var(--gold);
  box-shadow: 0 0 16px 5px var(--gold-glow), 0 0 4px 1px #fff;
  animation: none;
}
.cstar.lit::after { animation: none; opacity: 0; }
.cstar:focus-visible { outline: 1px solid var(--gold); }
.constellation.complete .cstar.lit::before { animation: glowPulse 3s ease-in-out infinite; animation-delay: var(--d, 0s); }

.star-count { margin: 18px 0 0; text-align: center; font-size: 0.78rem; letter-spacing: 0.22em; color: var(--muted); min-height: 1.4em; }
.star-msg {
  min-height: 5.2em; margin: 8px auto 0; max-width: 380px;
  text-align: center;
  font-family: var(--serif); font-style: italic; font-size: 1.35rem; line-height: 1.45;
  color: var(--text);
  transition: opacity 0.4s ease, transform 0.5s var(--ease);
}
.star-msg.swap { opacity: 0; transform: translateY(6px); }
.star-msg p { margin: 0 0 0.5em; }
.star-msg p:last-child { margin-bottom: 0; }
.star-media { max-width: 320px; margin: 4px auto 18px; }
.star-done {
  max-width: 380px; margin: 0 auto; max-height: 0; overflow: hidden; opacity: 0;
  text-align: center;
  font-family: var(--serif); font-style: italic; font-size: 1.35rem; line-height: 1.45;
  color: var(--gold); text-shadow: 0 0 20px var(--gold-glow);
  transition: opacity 1.2s ease, max-height 1s var(--ease), margin 1s var(--ease);
}
.star-done.in { opacity: 1; max-height: 8em; margin: 6px auto 18px; }

/* ---------- open when ---------- */
.ow-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.ow-card {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  min-height: 150px; padding: 20px 14px;
  border: 1px solid var(--line); border-radius: 18px;
  background: var(--glass);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  text-align: center;
  transition: transform 0.3s var(--ease), border-color 0.3s, background 0.3s;
}
.ow-card:active { transform: scale(0.97); }
.ow-card:hover { border-color: rgba(242, 212, 155, 0.3); }
.ow-card svg { width: 38px; height: 38px; fill: none; stroke: var(--gold); stroke-width: 1.3; stroke-linejoin: round; stroke-linecap: round; filter: drop-shadow(0 0 6px var(--gold-glow)); }
.ow-card .i-open { display: none; }
.ow-card.opened .i-open { display: block; }
.ow-card.opened .i-closed { display: none; }
.ow-card.opened { background: rgba(22, 19, 54, 0.35); }
.ow-title { font-family: var(--hand); font-size: 1.38rem; line-height: 1.15; color: var(--text); }
.ow-state { position: absolute; top: 10px; right: 12px; font-size: 0.66rem; letter-spacing: 0.16em; color: var(--muted); opacity: 0; transition: opacity 0.3s; }
.ow-card.opened .ow-state { opacity: 1; }

/* ---------- final letter ---------- */
.final-paper { padding: 40px 28px 34px; }
.final-title {
  margin: 0 0 22px; text-align: center;
  font-family: var(--serif); font-style: italic; font-weight: 500;
  font-size: 2.1rem; line-height: 1.1; color: var(--wine);
}
.ending { position: relative; z-index: 1; padding: 30px 20px 40px; text-align: center; }
.ending p { margin: 0; font-family: var(--hand); font-size: 1.6rem; color: var(--gold-soft); }

/* ============================================================
   modal
   ============================================================ */
.modal {
  position: fixed; inset: 0; z-index: 60;
  display: grid; place-items: center;
  padding: 20px 16px calc(20px + var(--safe-b));
  background: rgba(4, 5, 18, 0.78);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  animation: fadeIn 0.35s ease both;
}
.modal[hidden] { display: none; }
.modal.closing { animation: fadeOut 0.3s ease both; }
.modal-inner { position: relative; width: 100%; max-width: 480px; animation: popIn 0.5s var(--ease) both; }
.modal-close {
  position: absolute; top: -14px; right: -6px; z-index: 2;
  width: 40px; height: 40px; border-radius: 50%;
  display: grid; place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.2); background: var(--glass-strong);
}
.modal-close svg { width: 18px; height: 18px; stroke: #fff; stroke-width: 1.8; stroke-linecap: round; fill: none; }
.modal .paper {
  max-height: calc(100vh - 80px); max-height: calc(100dvh - 80px);
  overflow-y: auto; overscroll-behavior: contain;
  padding: 36px 26px 30px;
}
.modal .note-title { margin: 0 0 16px; font-family: var(--hand); font-size: 1.9rem; line-height: 1.1; color: var(--wine); }
.lb-frame { position: relative; }
.lb-track {
  display: flex; overflow-x: auto;
  scroll-snap-type: x mandatory; overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.lb-frame .slide-count { right: auto; left: 10px; }
.lb-slide { flex: 0 0 100%; display: grid; place-items: center; scroll-snap-align: center; scroll-snap-stop: always; }
.modal-photo img {
  width: 100%; max-height: calc(100vh - 160px); max-height: calc(100dvh - 160px);
  object-fit: contain; border-radius: 12px;
}
.modal-photo p { margin: 14px 4px 0; font-family: var(--serif); font-style: italic; font-size: 1.2rem; color: var(--text-soft); text-align: center; }

/* ============================================================
   music player
   ============================================================ */
.player {
  position: fixed; z-index: 50;
  left: 50%; bottom: calc(12px + var(--safe-b));
  width: calc(100% - 24px); max-width: 440px;
  transform: translate(-50%, 140%);
  border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 22px;
  background: var(--glass-strong);
  backdrop-filter: blur(18px) saturate(140%); -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.7), 0 0 30px -10px rgba(160, 140, 255, 0.35);
  overflow: hidden;
  transition: transform 0.9s var(--ease);
}
.player[hidden] { display: none; }
.player.shown { transform: translate(-50%, 0); }

.player-bar { position: relative; display: flex; align-items: center; gap: 4px; padding: 8px 8px 8px 10px; }
.bar-progress { position: absolute; left: 18px; right: 18px; top: 0; height: 2px; background: rgba(255, 255, 255, 0.06); border-radius: 2px; overflow: hidden; }
.bar-progress span { display: block; height: 100%; width: 0; background: var(--gold); box-shadow: 0 0 8px var(--gold); }
.player.open .bar-progress { opacity: 0; }

.bar-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; padding: 2px; border: 0; background: none; text-align: left; }
.disc {
  flex: none; position: relative;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--disc, linear-gradient(135deg, #6b4fc9, #d48aa8));
  background-size: cover; background-position: center;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12), 0 4px 12px rgba(0, 0, 0, 0.4);
  animation: spin 9s linear infinite; animation-play-state: paused;
}
.disc::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--bg); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}
.player.playing .disc { animation-play-state: running; }
.bar-text { min-width: 0; display: flex; flex-direction: column; }
.bar-title, .bar-artist { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-title { font-weight: 600; font-size: 0.92rem; line-height: 1.3; }
.bar-artist { font-size: 0.78rem; color: var(--muted); line-height: 1.3; }

.ctl {
  flex: none; width: 44px; height: 44px;
  display: grid; place-items: center;
  border: 0; border-radius: 50%; background: none;
  transition: background 0.2s, transform 0.2s;
}
.ctl:active { transform: scale(0.92); }
.ctl svg { width: 22px; height: 22px; fill: none; stroke: var(--text); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.play-btn .i-play { fill: var(--text); stroke: none; }
.play-btn .i-pause { display: none; stroke-width: 2.6; }
.player.playing .play-btn .i-play { display: none; }
.player.playing .play-btn .i-pause { display: block; }
.chevron svg { transition: transform 0.4s var(--ease); }
.player.open .chevron svg { transform: rotate(180deg); }
.player.open #playSmall { display: none; }

.player-panel { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.55s var(--ease); }
.player.open .player-panel { grid-template-rows: 1fr; }
.panel-inner { min-height: 0; overflow: hidden; }
.player.open .panel-inner { overflow-y: auto; max-height: min(70vh, 560px); }
.panel-inner > * { padding-left: 20px; padding-right: 20px; }

.np { padding-top: 22px; text-align: center; }
.np-title { margin: 0; font-family: var(--serif); font-style: italic; font-weight: 500; font-size: 1.6rem; line-height: 1.2; }
.np-artist { margin: 4px 0 0; font-size: 0.85rem; color: var(--muted); }
.np-note { margin: 12px 0 0; font-family: var(--hand); font-size: 1.35rem; line-height: 1.25; color: var(--gold-soft); }
.np-note:empty { display: none; }

.seek { display: flex; align-items: center; gap: 10px; margin-top: 18px; font-size: 0.72rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.seek span { width: 34px; flex: none; }
.seek span:last-child { text-align: right; }
.seek input { flex: 1; -webkit-appearance: none; appearance: none; height: 28px; background: none; margin: 0; }
.seek input::-webkit-slider-runnable-track { height: 3px; border-radius: 3px; background: linear-gradient(90deg, var(--gold) var(--p, 0%), rgba(255, 255, 255, 0.14) var(--p, 0%)); }
.seek input::-moz-range-track { height: 3px; border-radius: 3px; background: rgba(255, 255, 255, 0.14); }
.seek input::-moz-range-progress { height: 3px; border-radius: 3px; background: var(--gold); }
.seek input::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5.5px; border-radius: 50%; background: #fff; box-shadow: 0 0 10px var(--gold); }
.seek input::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: #fff; }

.controls { display: flex; justify-content: center; align-items: center; gap: 22px; margin-top: 6px; }
.ctl.big { width: 60px; height: 60px; background: var(--text); }
.ctl.big svg { width: 26px; height: 26px; }
.ctl.big .i-play { fill: var(--bg); }
.ctl.big .i-pause { stroke: var(--bg); }

.list-label { margin: 22px 0 6px; font-size: 0.72rem; letter-spacing: 0.22em; color: var(--muted); }
.song-list { list-style: none; margin: 0; padding-bottom: 16px !important; }
.song-list button {
  width: 100%; display: flex; align-items: center; gap: 14px;
  padding: 10px 8px; margin: 0 -8px; width: calc(100% + 16px);
  border: 0; border-radius: 12px; background: none; text-align: left;
  transition: background 0.2s;
}
.song-list button:hover { background: rgba(255, 255, 255, 0.04); }
.song-list .active button { background: rgba(242, 212, 155, 0.08); }
.s-num { width: 18px; flex: none; text-align: center; font-size: 0.8rem; color: var(--muted); }
.s-text { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.s-title { font-weight: 600; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.s-artist { font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.active .s-title { color: var(--gold); }
.eq { display: none; width: 18px; height: 14px; flex: none; align-items: flex-end; justify-content: center; gap: 2px; }
.eq i { width: 3px; background: var(--gold); border-radius: 1px; animation: eq 1s ease-in-out infinite; }
.eq i:nth-child(2) { animation-delay: -0.4s; }
.eq i:nth-child(3) { animation-delay: -0.7s; }
.active .eq { display: flex; }
.active .s-num { display: none; }
.player:not(.playing) .eq i { animation-play-state: paused; }

.player-error { color: #f3a6b8 !important; }

/* ============================================================
   keyframes
   ============================================================ */
@keyframes fadeUp { from { opacity: 0; transform: translateY(18px); } to { opacity: 1; transform: none; } }
@keyframes inkIn { from { opacity: 0; transform: translateY(10px); filter: blur(4px); } to { opacity: 1; transform: none; filter: none; } }
@keyframes float { 0%, 100% { transform: translateY(0) rotate(-1deg); } 50% { transform: translateY(-10px) rotate(1deg); } }
@keyframes breathe { 0%, 100% { opacity: 0.45; } 50% { opacity: 1; } }
@keyframes drip { 0% { top: -50%; } 100% { top: 100%; } }
@keyframes pulse { 0%, 100% { transform: scale(0.85); opacity: 0.7; } 50% { transform: scale(1.25); opacity: 1; } }
@keyframes ring { 0% { transform: scale(0.4); opacity: 0.8; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes glowPulse { 0%, 100% { box-shadow: 0 0 16px 5px var(--gold-glow), 0 0 4px 1px #fff; } 50% { box-shadow: 0 0 26px 9px var(--gold-glow), 0 0 6px 2px #fff; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes eq { 0%, 100% { height: 30%; } 50% { height: 100%; } }
@keyframes lockOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-16px) scale(0.97); filter: blur(4px); } }
@keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-8px); } 40% { transform: translateX(7px); } 60% { transform: translateX(-5px); } 80% { transform: translateX(3px); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }
@keyframes popIn { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: none; } }

@media (min-width: 720px) {
  .section { padding: 100px 20px; }
  .letter-paper, .final-paper { padding: 50px 46px 40px; }
}

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