:root {
  --ink: #111632;
  --ink-soft: rgba(17, 22, 50, .68);
  --paper: #f8f9ff;
  --line: rgba(25, 34, 74, .16);
  --accent-a: #6758e8;
  --accent-b: #a54cba;
  --accent-c: #ef8c72;
  --header-h: 82px;
  --edge: clamp(24px, 4.6vw, 84px);
  color-scheme: light;
  font-family: "Avenir Next", "Helvetica Neue", "Hiragino Sans", "Yu Gothic", Meiryo, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html {
  scroll-behavior: auto;
  background: var(--paper);
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  overflow-x: clip;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 10px;
  left: 10px;
  padding: 10px 16px;
  color: #fff;
  background: #171a3c;
  border-radius: 999px;
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

.site-header {
  position: fixed;
  z-index: 40;
  inset: 0 0 auto;
  height: var(--header-h);
  display: grid;
  grid-template-columns: minmax(210px, 1fr) auto minmax(210px, 1fr);
  align-items: center;
  gap: 28px;
  padding: max(10px, env(safe-area-inset-top)) var(--edge) 10px;
  color: var(--ink);
  pointer-events: none;
}

.site-header::after {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 120%;
  z-index: -1;
  background: linear-gradient(to bottom, rgba(249,250,255,.84), rgba(249,250,255,0));
  pointer-events: none;
}

body[data-tone="dark"] .site-header,
body[data-tone="dark"] .brand,
body[data-tone="dark"] .top-nav button { color: #fff; }
body[data-tone="dark"] .site-header::after { background: linear-gradient(to bottom, rgba(19,24,73,.54), rgba(19,24,73,0)); }

.brand {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  text-decoration: none;
  pointer-events: auto;
}
.brand img { width: 112px; height: auto; }
body[data-tone="dark"] .brand {
  padding: 8px 13px 8px 10px;
  color: var(--ink);
  background: rgba(255,255,255,.88);
  border: 1px solid rgba(255,255,255,.52);
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(11,16,61,.16);
  backdrop-filter: blur(14px);
}
.brand__edition {
  padding-left: 14px;
  border-left: 1px solid currentColor;
  opacity: .62;
  font-size: 9px;
  line-height: 1.35;
  font-weight: 700;
  letter-spacing: .16em;
}

.top-nav { pointer-events: auto; }
.top-nav ol {
  display: flex;
  gap: clamp(15px, 2.15vw, 34px);
  margin: 0;
  padding: 0;
  list-style: none;
}
.top-nav button {
  position: relative;
  appearance: none;
  padding: 10px 0;
  color: var(--ink);
  background: none;
  border: 0;
  cursor: pointer;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .15em;
  opacity: .45;
}
.top-nav button::after {
  content: "";
  position: absolute;
  left: 0;
  right: 100%;
  bottom: 2px;
  height: 1px;
  background: currentColor;
}
.top-nav button[aria-current="step"] { opacity: 1; }
.top-nav button[aria-current="step"]::after { right: 0; }

.official-link {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 0 18px;
  color: #fff;
  background: #171a3c;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 12px 34px rgba(31,35,84,.14);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  pointer-events: auto;
}
body[data-tone="dark"] .official-link { background: rgba(255,255,255,.15); backdrop-filter: blur(14px); }

.scroll-film {
  position: relative;
  height: 900svh;
  min-height: 5600px;
}

.film-stage {
  position: sticky;
  top: 0;
  width: 100%;
  height: 100svh;
  min-height: 580px;
  overflow: hidden;
  isolation: isolate;
  background: #f4f5fd;
}

.film-poster,
#film-canvas,
#character-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.film-poster { object-fit: cover; object-position: 50% 50%; }
#film-canvas { z-index: 0; display: block; opacity: 0; }
#character-canvas {
  z-index: 1;
  display: block;
  opacity: 0;
  pointer-events: none;
}
body.is-ready #film-canvas,
body.is-ready #character-canvas { opacity: 1; }
body.is-ready .film-poster { visibility: hidden; }

.film-vignette {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(248,249,255,.54) 0%, rgba(248,249,255,.18) 28%, rgba(248,249,255,0) 52%),
    linear-gradient(180deg, rgba(12,19,50,.03), transparent 62%, rgba(16,20,55,.09));
}
body[data-tone="dark"] .film-vignette {
  background:
    linear-gradient(90deg, rgba(14,21,64,.4) 0%, rgba(14,21,64,.12) 34%, transparent 58%),
    linear-gradient(180deg, rgba(7,12,43,.08), transparent 62%, rgba(7,12,43,.24));
}

.film-progress {
  position: absolute;
  z-index: 35;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: rgba(61,66,123,.1);
  pointer-events: none;
}
.film-progress i {
  display: block;
  width: 100%;
  height: 100%;
  transform: scaleX(var(--film-progress, 0));
  transform-origin: 0 50%;
  background: linear-gradient(90deg, #635ce8, #ab4db5 58%, #f18a73);
  box-shadow: 0 0 16px rgba(102,91,232,.55);
}

.chapter-stack {
  position: absolute;
  z-index: 5;
  left: var(--edge);
  top: 0;
  width: min(600px, 44vw);
  height: 100%;
  pointer-events: none;
}

.chapter {
  --chapter-opacity: 0;
  --chapter-shift: 24px;
  position: absolute;
  left: 0;
  top: 50%;
  width: 100%;
  opacity: var(--chapter-opacity);
  transform: translate3d(0, calc(-50% + var(--chapter-shift)), 0);
  pointer-events: none;
}
.chapter[aria-hidden="false"] { pointer-events: auto; }
.chapter__eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 24px;
  color: rgba(18,24,58,.68);
  font-size: 10px;
  line-height: 1;
  font-weight: 700;
  letter-spacing: .16em;
}
.chapter__eyebrow i { width: 34px; height: 1px; background: currentColor; opacity: .45; }
.chapter h1,
.chapter h2 {
  max-width: 12em;
  margin: 0;
  color: var(--ink);
  font-size: clamp(42px, 4.55vw, 76px);
  line-height: 1.18;
  letter-spacing: -.055em;
  font-weight: 650;
  text-wrap: balance;
}
.chapter h1 em,
.chapter h2 em {
  color: transparent;
  background: linear-gradient(110deg, #514fd5 4%, #9950bc 55%, #e27578 96%);
  -webkit-background-clip: text;
  background-clip: text;
  font-style: normal;
}
.chapter__lead {
  margin: 28px 0 0;
  color: var(--ink-soft);
  font-size: clamp(13px, 1.08vw, 17px);
  line-height: 2;
  font-weight: 500;
  letter-spacing: .025em;
}
.chapter__cta {
  display: inline-flex;
  align-items: center;
  gap: 28px;
  min-height: 54px;
  margin-top: 28px;
  padding: 0 24px;
  color: #fff;
  background: linear-gradient(110deg, rgba(107,91,232,.94), rgba(169,74,179,.94));
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 999px;
  box-shadow: 0 18px 42px rgba(32,24,95,.26);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .07em;
  pointer-events: auto;
}

body[data-tone="dark"] .chapter,
body[data-tone="dark"] .chapter h1,
body[data-tone="dark"] .chapter h2 { color: #fff; }
body[data-tone="dark"] .chapter__eyebrow,
body[data-tone="dark"] .chapter__lead { color: rgba(255,255,255,.74); }
body[data-tone="dark"] .chapter h1 em,
body[data-tone="dark"] .chapter h2 em {
  background-image: linear-gradient(110deg, #fff 4%, #c8c5ff 50%, #ffbbbd 100%);
}

.chapter-rail {
  position: absolute;
  z-index: 8;
  top: 50%;
  right: var(--edge);
  display: flex;
  align-items: center;
  gap: 20px;
  transform: translateY(-50%);
}
.chapter-rail > p {
  margin: 0;
  color: rgba(22,27,66,.42);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .25em;
  writing-mode: vertical-rl;
}
.chapter-rail ol { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.chapter-rail button {
  display: flex;
  align-items: center;
  gap: 10px;
  appearance: none;
  width: 52px;
  padding: 5px 0;
  color: rgba(22,27,66,.46);
  background: none;
  border: 0;
  cursor: pointer;
}
.chapter-rail button i {
  width: 18px;
  height: 1px;
  background: currentColor;
  transform-origin: 100% 50%;
}
.chapter-rail button span { font-size: 9px; font-weight: 700; letter-spacing: .08em; }
.chapter-rail button[aria-current="step"] { color: #4d48c9; }
.chapter-rail button[aria-current="step"] i { transform: scaleX(1.75); }
body[data-tone="dark"] .chapter-rail > p,
body[data-tone="dark"] .chapter-rail button { color: rgba(255,255,255,.58); }
body[data-tone="dark"] .chapter-rail button[aria-current="step"] { color: #fff; }

.scene-counter {
  position: absolute;
  z-index: 6;
  left: var(--edge);
  bottom: clamp(24px, 5vh, 54px);
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: rgba(26,31,72,.5);
  pointer-events: none;
}
.scene-counter strong { color: currentColor; font-size: 22px; font-weight: 500; letter-spacing: -.04em; }
.scene-counter span { font-size: 9px; font-weight: 700; letter-spacing: .1em; }
body[data-tone="dark"] .scene-counter { color: rgba(255,255,255,.72); }

.scroll-cue {
  position: absolute;
  z-index: 7;
  left: 50%;
  bottom: clamp(21px, 4vh, 42px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  opacity: var(--cue-opacity, 1);
  transform: translateX(-50%);
  color: rgba(20,26,64,.56);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .19em;
  pointer-events: none;
}
.scroll-cue__track {
  position: relative;
  width: 1px;
  height: 40px;
  overflow: hidden;
  background: rgba(21,27,66,.16);
}
.scroll-cue__track i {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 54%;
  background: currentColor;
  transform: translateY(calc(var(--cue-travel, 0) * 86%));
}
body[data-tone="dark"] .scroll-cue { color: rgba(255,255,255,.68); }
body[data-tone="dark"] .scroll-cue__track { background: rgba(255,255,255,.18); }

.mascot-note {
  position: absolute;
  z-index: 8;
  right: var(--edge);
  bottom: 24px;
  margin: 0;
  color: rgba(26,31,72,.42);
  font-size: 8px;
  font-weight: 600;
  letter-spacing: .08em;
}
body[data-tone="dark"] .mascot-note { color: rgba(255,255,255,.48); }

.motion-control {
  position: absolute;
  z-index: 12;
  right: var(--edge);
  bottom: 48px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  appearance: none;
  padding: 8px 10px;
  color: rgba(26,31,72,.55);
  background: rgba(255,255,255,.46);
  border: 1px solid rgba(34,40,86,.12);
  border-radius: 999px;
  backdrop-filter: blur(12px);
  cursor: pointer;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .08em;
}
.motion-control__icon { display: flex; gap: 2px; width: 9px; height: 10px; align-items: center; justify-content: center; }
.motion-control__icon i { width: 2px; height: 8px; background: currentColor; }
.motion-control[aria-pressed="true"] .motion-control__icon i:first-child { width: 0; height: 0; border-top: 4px solid transparent; border-bottom: 4px solid transparent; border-left: 7px solid currentColor; background: transparent; }
.motion-control[aria-pressed="true"] .motion-control__icon i:last-child { display: none; }
body[data-tone="dark"] .motion-control { color: rgba(255,255,255,.72); background: rgba(30,31,80,.28); border-color: rgba(255,255,255,.18); }

.loading-status {
  position: absolute;
  z-index: 30;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 18px;
  color: rgba(25,30,70,.62);
  background: rgba(247,248,254,.38);
  backdrop-filter: blur(10px);
}
.loading-status span {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(72,70,168,.2);
  border-right-color: #6b5de8;
  border-radius: 50%;
}
.loading-status p { margin: 0; font-size: 9px; font-weight: 700; letter-spacing: .18em; }
body.is-ready .loading-status { display: none; }
body.has-load-error .loading-status { color: #6f243b; background: rgba(255,244,247,.9); }

.noscript-note {
  position: fixed;
  z-index: 100;
  inset: auto 16px 16px;
  padding: 14px;
  color: #fff;
  background: #171a3c;
  border-radius: 12px;
  text-align: center;
}
.noscript-note a { color: #fff; }

:focus-visible { outline: 3px solid #ff8d76; outline-offset: 4px; }

@media (max-width: 900px) {
  :root { --header-h: 68px; --edge: clamp(18px, 5vw, 34px); }
  .site-header { grid-template-columns: 1fr auto; gap: 12px; }
  .brand img { width: 94px; }
  .brand__edition, .top-nav { display: none; }
  .official-link { min-height: 38px; padding: 0 14px; font-size: 10px; }
  .scroll-film { height: 720svh; min-height: 4600px; }
  .film-vignette {
    background:
      linear-gradient(0deg, rgba(249,250,255,.92) 0%, rgba(249,250,255,.64) 33%, rgba(249,250,255,0) 61%),
      linear-gradient(180deg, rgba(249,250,255,.25), transparent 30%);
  }
  body[data-tone="dark"] .film-vignette {
    background:
      linear-gradient(0deg, rgba(13,20,61,.88) 0%, rgba(13,20,61,.5) 36%, transparent 66%),
      linear-gradient(180deg, rgba(10,16,53,.18), transparent 30%);
  }
  .chapter-stack {
    left: var(--edge);
    right: var(--edge);
    top: auto;
    bottom: max(74px, calc(56px + env(safe-area-inset-bottom)));
    width: auto;
    height: 44%;
  }
  .chapter { top: auto; bottom: 0; transform: translate3d(0, var(--chapter-shift), 0); }
  .chapter__eyebrow { margin-bottom: 13px; font-size: 8px; gap: 8px; }
  .chapter__eyebrow i { width: 24px; }
  .chapter h1, .chapter h2 { max-width: 11em; font-size: clamp(34px, 10.4vw, 52px); line-height: 1.12; }
  .chapter__lead { margin-top: 14px; font-size: 12px; line-height: 1.75; }
  .chapter__cta { min-height: 44px; margin-top: 16px; padding: 0 18px; gap: 18px; font-size: 10px; }
  .chapter-rail {
    top: auto;
    right: 50%;
    bottom: max(22px, env(safe-area-inset-bottom));
    display: block;
    transform: translateX(50%);
  }
  .chapter-rail > p { display: none; }
  .chapter-rail ol { display: flex; gap: 13px; }
  .chapter-rail button { width: 21px; height: 21px; padding: 5px; }
  .chapter-rail button i { width: 10px; height: 2px; border-radius: 2px; }
  .chapter-rail button span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .chapter-rail button[aria-current="step"] i { transform: scaleX(1.75); }
  .scene-counter { left: var(--edge); bottom: max(20px, env(safe-area-inset-bottom)); }
  .scene-counter strong { font-size: 16px; }
  .scroll-cue { display: none; }
  .motion-control { right: var(--edge); bottom: max(18px, env(safe-area-inset-bottom)); }
  .motion-control__label { display: none; }
  .motion-control { width: 30px; height: 30px; padding: 0; justify-content: center; }
  .mascot-note {
    display: block;
    top: 66px;
    right: var(--edge);
    bottom: auto;
    padding: 4px 7px;
    color: rgba(24,29,70,.58);
    background: rgba(255,255,255,.62);
    border: 1px solid rgba(30,35,78,.09);
    border-radius: 999px;
    backdrop-filter: blur(10px);
    font-size: 7px;
  }
  body[data-tone="dark"] .mascot-note { color: rgba(255,255,255,.7); background: rgba(24,28,78,.36); border-color: rgba(255,255,255,.13); }
}

@media (max-width: 420px) and (max-height: 740px) {
  .chapter-stack { bottom: 60px; height: 46%; }
  .chapter h1, .chapter h2 { font-size: 31px; }
  .chapter__lead { font-size: 11px; line-height: 1.62; }
  .chapter__cta { margin-top: 12px; }
}

@media (orientation: landscape) and (max-height: 560px) {
  :root { --header-h: 58px; }
  .scroll-film { height: 760svh; min-height: 3400px; }
  .film-stage { min-height: 100svh; }
  .chapter-stack { left: var(--edge); top: 0; bottom: 0; width: min(470px, 44vw); height: 100%; }
  .chapter { top: 53%; bottom: auto; transform: translate3d(0, calc(-50% + var(--chapter-shift)), 0); }
  .chapter h1, .chapter h2 { font-size: clamp(29px, 4.8vw, 48px); }
  .chapter__lead { margin-top: 12px; line-height: 1.6; }
  .chapter__cta { min-height: 40px; margin-top: 12px; }
  .chapter-rail { right: var(--edge); bottom: 16px; transform: none; }
  .scene-counter { display: none; }
}

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