:root {
  color-scheme: dark;
  --ink: #080a0f;
  --ink-soft: #0d1119;
  --surface: #151a24;
  --silver: #e4e7ec;
  --muted: #9ba3b1;
  --faint: #697383;
  --line: rgba(220, 228, 238, 0.18);
  --blue: #889bae;
  --ease-cinema: cubic-bezier(0.22, 0.74, 0.22, 1);
}

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

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background: var(--ink);
}

html.story-locked,
html.story-locked body {
  overflow: hidden;
}

body {
  color: var(--silver);
  font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible {
  outline: 1px solid rgba(228, 231, 236, 0.8);
  outline-offset: 5px;
}

.story {
  width: 100%;
  height: 100vh;
  height: 100svh;
  overflow-y: auto;
  overflow-x: hidden;
  scroll-snap-type: y mandatory;
  scroll-behavior: smooth;
  overscroll-behavior-y: contain;
  scrollbar-width: none;
  background:
    radial-gradient(circle at 24% 8%, rgba(90, 110, 135, 0.08), transparent 31%),
    var(--ink);
}

.story::-webkit-scrollbar {
  display: none;
}

.story--locked {
  overflow-y: hidden;
  touch-action: none;
}

.scene {
  position: relative;
  isolation: isolate;
  display: flex;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  padding: max(38px, env(safe-area-inset-top)) 24px max(34px, env(safe-area-inset-bottom));
  overflow: hidden;
  scroll-snap-align: start;
  scroll-snap-stop: always;
}

.scene::after {
  position: absolute;
  z-index: 8;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.1;
  background-image:
    repeating-linear-gradient(115deg, rgba(255,255,255,0.055) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(25deg, rgba(255,255,255,0.025) 0 1px, transparent 1px 6px);
  mix-blend-mode: soft-light;
}

.scene-shade {
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
}

.eyebrow {
  margin: 0;
  color: rgba(219, 226, 234, 0.56);
  font-family: Inter, "Helvetica Neue", sans-serif;
  font-size: 9px;
  font-weight: 400;
  letter-spacing: 0.32em;
}

.scene--opening {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.opening-media {
  position: absolute;
  z-index: -3;
  inset: -5%;
  background-color: #111722;
  background-position: center;
  background-size: cover;
  filter: blur(18px) saturate(0.7) brightness(0.72);
  transform: scale(1.16);
  transition:
    filter 2.2s var(--ease-cinema),
    transform 2.6s var(--ease-cinema);
}

.opening-media.is-missing,
.photo-frame.is-missing,
.final-media.is-missing {
  background:
    linear-gradient(135deg, rgba(105, 122, 144, 0.16), rgba(8, 10, 15, 0.18)),
    radial-gradient(circle at 64% 28%, #283345 0, #121722 38%, #090b10 78%);
}

.scene--opening.is-open .opening-media {
  filter: blur(0) saturate(0.82) brightness(0.78);
  transform: scale(1.02);
}

.scene-shade--opening {
  z-index: -2;
  background:
    linear-gradient(to bottom, rgba(5, 7, 11, 0.36), rgba(5, 7, 11, 0.12) 44%, rgba(5, 7, 11, 0.74)),
    radial-gradient(circle at center, transparent 0 18%, rgba(3, 5, 8, 0.36) 86%);
}

.opening-content {
  display: flex;
  align-items: center;
  flex-direction: column;
  width: min(100%, 340px);
  transform: translateY(3vh);
}

.opening-question {
  margin: 26px 0 46px;
  font-size: clamp(26px, 7.2vw, 34px);
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 1.5;
  text-shadow: 0 3px 24px rgba(0, 0, 0, 0.52);
}

.quiet-button,
.light-button {
  border: 0;
  background: transparent;
  cursor: pointer;
}

.quiet-button {
  display: flex;
  align-items: center;
  flex-direction: column;
  gap: 13px;
  padding: 8px 20px;
  color: rgba(236, 239, 243, 0.82);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 12px;
  letter-spacing: 0.18em;
  transition: opacity 500ms ease, transform 500ms ease;
}

.button-line {
  width: 28px;
  height: 1px;
  background: rgba(236, 239, 243, 0.45);
  transition: width 500ms var(--ease-cinema);
}

.quiet-button:hover .button-line {
  width: 48px;
}

.quiet-button:disabled {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.opening-hint {
  position: absolute;
  right: 0;
  bottom: max(22px, env(safe-area-inset-bottom));
  left: 0;
  margin: 0;
  color: rgba(226, 231, 238, 0.42);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 9px;
  letter-spacing: 0.24em;
  transition: opacity 700ms ease;
}

.scene--opening.is-open .opening-hint {
  opacity: 0;
}

.scene--prologue {
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 40%, rgba(94, 113, 137, 0.08), transparent 34%),
    var(--ink);
  text-align: center;
}

.prologue-content {
  width: min(100%, 340px);
}

.prologue-date {
  display: block;
  margin-bottom: 56px;
  color: #cbd2db;
  font-family: Inter, "Helvetica Neue", sans-serif;
  font-size: clamp(27px, 8.5vw, 40px);
  font-weight: 300;
  letter-spacing: 0.15em;
}

.prologue-line {
  margin: 0 auto;
  color: rgba(225, 229, 235, 0.82);
  font-size: clamp(16px, 4.5vw, 20px);
  font-weight: 400;
  letter-spacing: 0.08em;
  line-height: 2;
}

.scene--chapter {
  align-items: center;
  flex-direction: column;
  justify-content: center;
  background: var(--ink-soft);
}

.scene--chapter:nth-child(even) {
  background: #0a0d13;
}

.photo-frame {
  position: relative;
  flex: 0 0 auto;
  margin: 0;
  overflow: hidden;
  border: 1px solid rgba(221, 229, 238, 0.1);
  background-color: #131822;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.24);
}

.photo-frame.is-missing::after,
.final-media.is-missing::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 32px;
  height: 1px;
  content: "";
  background: rgba(226, 231, 238, 0.28);
  transform: translate(-50%, -50%);
}

.photo-frame img,
.final-media img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-frame--single {
  width: min(78vw, 310px);
  height: min(55svh, 470px);
  max-height: 58vh;
}

.chapter-copy {
  width: min(100%, 330px);
  margin: 34px auto 0;
  color: rgba(224, 229, 235, 0.78);
  font-size: clamp(14px, 4.1vw, 18px);
  letter-spacing: 0.08em;
  line-height: 1.95;
  text-align: center;
}

.photo-pair {
  position: relative;
  display: flex;
  align-items: center;
  width: min(100%, 350px);
  min-height: min(50svh, 430px);
}

.photo-frame--pair {
  position: absolute;
  width: 55%;
  height: 72%;
}

.photo-frame--pair:first-child {
  z-index: 2;
  top: 0;
  left: 0;
}

.photo-frame--pair:nth-child(2) {
  right: 0;
  bottom: 0;
  height: 68%;
}

.photo-frame--pair:only-child {
  top: 12%;
  left: 22.5%;
}

.chapter--text {
  background:
    linear-gradient(140deg, rgba(46, 57, 75, 0.12), transparent 38%),
    var(--ink);
}

.text-rule {
  display: block;
  width: 1px;
  height: 56px;
  margin-bottom: 42px;
  background: linear-gradient(to bottom, transparent, rgba(201, 211, 224, 0.55));
}

.memory-text {
  width: min(100%, 326px);
  margin: 0;
  color: rgba(231, 234, 239, 0.87);
  font-size: clamp(19px, 5.4vw, 25px);
  font-weight: 400;
  letter-spacing: 0.09em;
  line-height: 2;
  text-align: left;
}

.chapter--date {
  background:
    radial-gradient(circle at 50% 50%, rgba(112, 132, 158, 0.09), transparent 36%),
    #090c12;
}

.date-card {
  display: flex;
  align-items: center;
  flex-direction: column;
  width: min(100%, 340px);
  text-align: center;
}

.date-card__date {
  color: #d7dce3;
  font-family: Inter, "Helvetica Neue", sans-serif;
  font-size: clamp(31px, 9vw, 44px);
  font-weight: 300;
  letter-spacing: 0.13em;
}

.date-card__line {
  width: 1px;
  height: 62px;
  margin: 32px 0;
  background: var(--line);
}

.date-card__title {
  margin: 0;
  color: rgba(218, 224, 232, 0.75);
  font-size: clamp(15px, 4.5vw, 20px);
  letter-spacing: 0.1em;
  line-height: 1.8;
}

.scene--letter {
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 80% 20%, rgba(91, 108, 132, 0.08), transparent 32%),
    #0a0d13;
}

.letter-content {
  width: min(100%, 352px);
}

.letter-content .eyebrow {
  margin-bottom: 40px;
}

.letter-paragraph {
  margin: 0 0 20px;
  color: rgba(225, 229, 235, 0.82);
  font-size: clamp(14px, 4vw, 17px);
  letter-spacing: 0.07em;
  line-height: 2;
}

.letter-paragraph:last-child {
  margin-bottom: 0;
}

.scene--finale {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.final-media {
  position: absolute;
  z-index: -3;
  inset: 0;
  margin: 0;
  background-color: #111722;
}

.scene-shade--final {
  z-index: -2;
  background:
    linear-gradient(to bottom, rgba(3, 5, 8, 0.36), rgba(3, 5, 8, 0.54) 52%, rgba(3, 5, 8, 0.84)),
    radial-gradient(circle at 50% 45%, transparent 0, rgba(2, 4, 7, 0.38) 82%);
}

.final-content {
  display: flex;
  align-items: center;
  flex-direction: column;
  width: min(100%, 350px);
  transform: translateY(4vh);
}

.final-text {
  margin: 0 0 52px;
  color: rgba(236, 238, 242, 0.92);
  font-size: clamp(18px, 5.2vw, 24px);
  letter-spacing: 0.09em;
  line-height: 1.9;
  text-shadow: 0 3px 28px rgba(0, 0, 0, 0.6);
}

.final-greeting {
  margin: 0 0 40px;
  color: rgba(221, 226, 233, 0.72);
  font-family: "Times New Roman", serif;
  font-size: clamp(17px, 5vw, 22px);
  font-style: italic;
  letter-spacing: 0.08em;
}

.light-button {
  padding: 10px 2px;
  border-bottom: 1px solid rgba(228, 233, 240, 0.28);
  color: rgba(226, 231, 238, 0.68);
  font-family: "Noto Sans SC", "Microsoft YaHei", sans-serif;
  font-size: 11px;
  letter-spacing: 0.16em;
  transition: color 600ms ease, border-color 600ms ease;
}

.light-button.is-lit {
  color: rgba(234, 238, 243, 0.9);
  border-color: rgba(210, 222, 238, 0.55);
}

.afterglow {
  position: absolute;
  z-index: -1;
  inset: 0;
  pointer-events: none;
}

.soft-spark {
  position: absolute;
  top: var(--y);
  left: var(--x);
  width: var(--size);
  height: var(--size);
  border-radius: 50%;
  opacity: 0;
  background: #dce8f5;
  box-shadow: 0 0 10px 2px rgba(178, 204, 232, 0.32);
}

.afterglow.is-lit .soft-spark {
  animation: slow-glimmer var(--duration) ease-in-out var(--spark-delay) infinite;
}

.music-toggle {
  position: fixed;
  z-index: 30;
  top: max(18px, env(safe-area-inset-top));
  right: 17px;
  display: grid;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid rgba(225, 231, 238, 0.18);
  border-radius: 50%;
  background: rgba(7, 10, 15, 0.3);
  backdrop-filter: blur(10px);
  place-items: center;
  cursor: pointer;
}

.music-toggle[hidden] {
  display: none;
}

.music-bars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  height: 11px;
}

.music-bars i {
  display: block;
  width: 1px;
  height: 4px;
  background: rgba(230, 235, 241, 0.74);
}

.music-toggle.is-playing .music-bars i {
  animation: sound-bar 1.2s ease-in-out infinite alternate;
}

.music-toggle.is-playing .music-bars i:nth-child(2) {
  animation-delay: -0.55s;
}

.music-toggle.is-playing .music-bars i:nth-child(3) {
  animation-delay: -0.25s;
}

.reveal-item {
  opacity: 0;
  transform: translateY(17px);
  transition:
    opacity 1s var(--ease-cinema) var(--delay, 0ms),
    transform 1.15s var(--ease-cinema) var(--delay, 0ms);
}

.scene.is-visible .reveal-item {
  opacity: 1;
  transform: translateY(0);
}

@keyframes slow-glimmer {
  0%, 100% { opacity: 0.08; transform: scale(0.7); }
  48% { opacity: 0.75; transform: scale(1.15); }
}

@keyframes sound-bar {
  from { height: 3px; }
  to { height: 10px; }
}

@media (max-height: 700px) {
  .scene {
    padding-top: 28px;
    padding-bottom: 24px;
  }

  .photo-frame--single {
    height: 50svh;
  }

  .photo-pair {
    min-height: 44svh;
  }

  .chapter-copy {
    margin-top: 24px;
  }

  .letter-content .eyebrow {
    margin-bottom: 26px;
  }

  .letter-paragraph {
    margin-bottom: 12px;
    line-height: 1.8;
  }
}

@media (min-width: 700px) {
  .scene {
    padding-right: 8vw;
    padding-left: 8vw;
  }

  .photo-frame--single {
    width: min(42vw, 400px);
  }
}

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

  .opening-media {
    filter: blur(7px) saturate(0.75) brightness(0.72);
    transform: scale(1.05);
  }

  .scene--opening.is-open .opening-media {
    filter: none;
    transform: none;
  }
}
