:root {
  --paper: #fff8e8;
  --paper-soft: rgba(255, 248, 232, 0.74);
  --ink-shadow: rgba(3, 8, 10, 0.64);
  --warm-line: rgba(245, 201, 122, 0.72);
  --earth: #8e6a40;
  --leaf: #3f684f;
  --night: #0b1320;
  --shade: 0.26;
  --camera-x: 0px;
  --camera-y: 0px;
  --camera-scale: 1.045;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--night);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  overflow-x: hidden;
  color: var(--paper);
  background: var(--night);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", Georgia, serif;
  letter-spacing: 0;
}

body:not(.is-image-ready) {
  overflow: hidden;
}

body::selection {
  color: #1c1711;
  background: #ffe7a6;
}

button {
  font: inherit;
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 32px;
  color: var(--paper);
  background:
    linear-gradient(180deg, rgba(12, 18, 30, 0.98), rgba(12, 24, 28, 0.94)),
    radial-gradient(ellipse at 50% 78%, rgba(211, 156, 84, 0.18), transparent 52%);
  transition: opacity 900ms ease, visibility 900ms ease;
}

.loading-inner {
  width: min(680px, 100%);
  text-align: center;
  text-shadow: 0 18px 42px rgba(0, 0, 0, 0.38);
}

.loading-name,
.chapter-label {
  margin: 0 0 18px;
  color: rgba(255, 233, 187, 0.82);
  font-size: 0.86rem;
  letter-spacing: 0;
  text-transform: uppercase;
}

.loading-inner h1 {
  margin: 0;
  font-size: 2.65rem;
  font-weight: 500;
  line-height: 1.28;
}

.loading-note {
  margin: 22px auto 0;
  color: rgba(255, 248, 232, 0.68);
  font-size: 1rem;
  line-height: 1.9;
}

.birthday-line {
  margin: 22px auto 0;
  color: rgba(255, 248, 232, 0.84);
  font-size: 1.12rem;
  line-height: 1.8;
}

.birthday-days {
  display: inline-block;
  min-width: 4.6ch;
  color: #ffe6aa;
  font-size: 1.26em;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(255, 214, 142, 0.38);
}

.loading-line {
  display: block;
  width: 168px;
  height: 1px;
  margin: 34px auto 0;
  overflow: hidden;
  background: rgba(255, 248, 232, 0.18);
}

.loading-line::after {
  content: "";
  display: block;
  width: 45%;
  height: 100%;
  background: linear-gradient(90deg, transparent, #ffe2a4, transparent);
  animation: loadingLine 1.9s ease-in-out infinite;
}

body.is-image-ready .loading-screen {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.stage {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #101515;
  opacity: 0;
  isolation: isolate;
  transition: opacity 900ms ease;
}

body.is-image-ready .stage {
  opacity: 1;
}

.stage-layer {
  position: absolute;
  inset: -3vmax;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  opacity: 0;
  transform: translate3d(var(--camera-x), var(--camera-y), 0) scale(var(--camera-scale));
  transform-origin: center;
  transition: opacity 760ms linear;
  will-change: opacity, transform;
}

.stage-layer.is-active {
  opacity: 1;
}

.stage-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(5, 8, 8, 0.48), rgba(5, 8, 8, 0.08) 43%, rgba(5, 8, 8, 0.38)),
    linear-gradient(180deg, rgba(4, 8, 12, 0.1), rgba(4, 8, 12, var(--shade))),
    radial-gradient(ellipse at 50% 112%, rgba(0, 0, 0, 0.66), transparent 62%);
}

.stage-grain {
  position: absolute;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  opacity: 0.18;
  mix-blend-mode: soft-light;
  background:
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.055) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.075) 0 1px, transparent 1px 5px);
}

.story {
  position: relative;
  z-index: 5;
  opacity: 0;
  transition: opacity 680ms ease 620ms;
}

body.is-image-ready .story {
  opacity: 1;
}

.story-section {
  min-height: 112svh;
  display: flex;
  align-items: center;
  padding: 18vh 8vw;
}

.story-section-right {
  justify-content: flex-end;
}

.story-section-final {
  min-height: 122svh;
}

.story-copy {
  width: min(620px, 100%);
  padding-left: 28px;
  border-left: 1px solid var(--warm-line);
  opacity: 0.2;
  transform: translate3d(0, 22px, 0);
  text-shadow: 0 2px 18px var(--ink-shadow), 0 18px 46px rgba(0, 0, 0, 0.44);
  transition: opacity 700ms ease, transform 700ms ease;
}

.story-section.is-visible .story-copy {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.story-copy h2 {
  margin: 0;
  max-width: 11em;
  font-size: 3.2rem;
  font-weight: 500;
  line-height: 1.34;
  letter-spacing: 0;
}

.story-copy p:not(.chapter-label) {
  max-width: 34em;
  margin: 24px 0 0;
  color: var(--paper-soft);
  font-size: 1.06rem;
  line-height: 2.05;
  letter-spacing: 0;
}

.scene-rail {
  position: fixed;
  right: 24px;
  top: 50%;
  z-index: 8;
  display: grid;
  gap: 14px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-50%);
  transition: opacity 680ms ease 620ms;
}

body.is-image-ready .scene-rail {
  opacity: 1;
  pointer-events: auto;
}

.scene-dot {
  width: 12px;
  height: 12px;
  padding: 0;
  border: 1px solid rgba(255, 248, 232, 0.58);
  border-radius: 999px;
  background: rgba(255, 248, 232, 0.16);
  cursor: pointer;
  transition: background 220ms ease, transform 220ms ease, border-color 220ms ease;
}

.scene-dot.is-active,
.scene-dot:focus-visible {
  background: #ffe6aa;
  border-color: #ffe6aa;
  transform: scale(1.22);
  outline: none;
}

@keyframes loadingLine {
  0% {
    transform: translateX(-110%);
  }
  100% {
    transform: translateX(250%);
  }
}

@media (max-width: 960px) {
  .story-copy h2 {
    font-size: 2.7rem;
  }
}

@media (max-width: 760px) {
  .loading-screen {
    padding: 24px;
  }

  .loading-inner h1 {
    font-size: 2.12rem;
  }

  .birthday-line {
    font-size: 1rem;
  }

  .stage-layer {
    inset: -7vmax;
  }

  .stage-overlay {
    background:
      linear-gradient(180deg, rgba(4, 7, 9, 0.22), rgba(4, 7, 9, var(--shade))),
      radial-gradient(ellipse at 50% 104%, rgba(0, 0, 0, 0.72), transparent 66%);
  }

  .story-section,
  .story-section-right {
    min-height: 116svh;
    align-items: flex-end;
    justify-content: flex-start;
    padding: 44vh 24px 18vh;
  }

  .story-section-final {
    min-height: 126svh;
  }

  .story-copy {
    padding-left: 18px;
  }

  .story-copy h2 {
    max-width: 10.5em;
    font-size: 2.05rem;
    line-height: 1.38;
  }

  .story-copy p:not(.chapter-label) {
    font-size: 0.98rem;
    line-height: 1.92;
  }

  .scene-rail {
    right: 14px;
    gap: 10px;
  }

  .scene-dot {
    width: 10px;
    height: 10px;
  }
}

@media (max-width: 380px) {
  .loading-inner h1 {
    font-size: 1.9rem;
  }

  .birthday-line,
  .loading-note {
    font-size: 0.94rem;
  }

  .story-section,
  .story-section-right {
    padding-left: 18px;
    padding-right: 18px;
  }

  .story-copy h2 {
    font-size: 1.82rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .stage-layer {
    transform: none;
  }
}
