    *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
    *:focus,
    *:focus-visible { outline: none !important; }

    :root {
      --text-reveal-delay: 114ms;
      --screen-exit-duration: 0.34s;
      --intro-section-title-size: clamp(1.35rem, 2.1vw, 4rem);
      --intro-section-subtitle-size: clamp(0.7rem, 1vw, 1.5rem);
      --menu-chapter-title-size: clamp(1.55rem, 2.3vw, 3.8rem);
      --menu-start-title-size: clamp(1rem, 1.45vw, 2.2rem);
      --menu-text-high: rgba(232, 232, 232, 0.96);
      --menu-text-mid: rgba(232, 232, 232, 0.86);
      --menu-text-soft: rgba(232, 232, 232, 0.72);
      --menu-accent-soft: rgba(126, 184, 212, 0.86);
      --menu-accent-mid: rgba(126, 184, 212, 0.94);
      --menu-accent-strong: rgba(126, 184, 212, 1);
      --safe-bottom: env(safe-area-inset-bottom, 0px);
      --safe-top:    env(safe-area-inset-top,    0px);
      --safe-left:   env(safe-area-inset-left,   0px);
      --safe-right:  env(safe-area-inset-right,  0px);
    }

    html, body {
      width: 100%; height: 100svh;
      background: #000;
      overflow: hidden;
      cursor: default;
      user-select: none;
      -webkit-user-select: none;
    }
    body.manual-reading,
    body.song-pause-skippable { cursor: pointer; }
    button:not(:disabled),
    [role="button"]:not([aria-disabled="true"]),
    label.toggle:not(:has(input:disabled)) { cursor: pointer; }
    button:disabled,
    [aria-disabled="true"],
    label.toggle:has(input:disabled) { cursor: default !important; }

    /* ── Scene ─────────────────────────────────────────────── */
    #scene {
      position: relative;
      width: 100%;
      height: 100svh;
      background: #000;
      overflow: hidden;
      isolation: isolate;
    }

    /* ── Image layers ───────────────────────────────────────── */
    .image-layer {
      position: absolute;
      left: 0; right: 0;
      background-size: contain;
      background-position: center;
      background-repeat: no-repeat;
      background-color: #000;
      pointer-events: none;
    }
    #layer-a { opacity: 1; z-index: 1; }
    #layer-b { opacity: 0; z-index: 2; }

    /* Landscape: image fills full scene height */
    @media (orientation: landscape) {
      .image-layer { top: 0; bottom: 0; }
    }

    /* Portrait: image sits at top, height = 16:9 of width */
    @media (orientation: portrait) {
      .image-layer {
        top: 0;
        height: calc(100vw * 9 / 16);
        bottom: auto;
        background-position: top center;
      }
    }

    .placeholder-bg {
      background: radial-gradient(ellipse at center, #0a0f1e 0%, #000 100%) !important;
    }

    /* ── Intro panel (centered text for intro beats) ──────── */
    #intro-panel {
      position: absolute;
      inset: 0;
      z-index: 8;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 0.6rem;
      opacity: 0;
      transition: opacity 0.8s ease;
      pointer-events: none;
    }
    #intro-panel.show { opacity: 1; }
    /* Section-title fade is slower — it overlaps into the section's first slide
       (see clearIntroOverlay's overlap-hold in app.js) and 0.8s reads as abrupt there. */
    #intro-panel.type-section-title { transition: opacity 2s ease; }

    .intro-location {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.65rem, 0.9vw, 1.8rem);
      font-weight: 300;
      letter-spacing: 0.28em;
      text-transform: uppercase;
      color: rgba(126, 184, 212, 0.75);
      text-align: center;
      line-height: 2;
      text-wrap: balance;
      max-width: min(82vw, 960px);
    }

    .intro-chapter {
      text-align: center;
    }
    .intro-chapter .ep-label {
      display: block;
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.65rem, 0.9vw, 1.8rem);
      font-weight: 300;
      letter-spacing: 0.3em;
      text-transform: uppercase;
      color: rgba(126, 184, 212, 0.55);
      margin-bottom: 0.6rem;
    }
    .intro-chapter h2 {
      font-family: 'Rajdhani', 'Exo 2', sans-serif;
      font-size: clamp(1.6rem, 2.5vw, 5rem);
      font-weight: 600;
      color: #E8E8E8;
      letter-spacing: 0.08em;
      text-wrap: balance;
      max-width: min(84vw, 980px);
      margin-inline: auto;
    }
    .intro-section {
      position: relative;
      z-index: 0;
      isolation: isolate;
      mix-blend-mode: normal;
      text-align: center;
      max-width: min(82vw, 980px);
      padding: 0 2rem;
    }
    /* Soft dark shadow/glow behind chapter-title / section-title / stardate
       words so they stay legible over an illustration (see clearIntroOverlay's
       overlap-hold in app.js for section-title specifically). Scoped to
       .intro-chapter, .intro-section and .intro-location (the stardate title,
       shown in the prologue and every chapter intro) — not .intro-disclaimer,
       which was never reported as a legibility problem.
       Two earlier attempts both failed: a flat rgba-filled ::before pseudo-
       element behind each word read as a hard-edged rectangle, and swapping
       to a shadow-only stacked box-shadow (no fill) still read as a soft but
       clearly box/blob-shaped smudge — box-shadow's blur only softens the
       edge of a shape's own silhouette (a rounded rect), not the letters
       themselves.
       This version drops the pseudo-element entirely and shadows the text
       glyphs directly via filter: drop-shadow(), which — unlike box-shadow —
       blurs around the actual rendered alpha (the letterforms), not a box, so
       it can't read as a rectangle or a blob. Three stacked drop-shadows
       (tight+darkest to wide+faintest) build a soft falloff. No pseudo-
       element or z-index trick is needed for reveal timing either: opacity 0
       on .word (the existing per-word reveal mechanism, driven by
       revealWordsInto() in app.js toggling .visible) already suppresses the
       drop-shadow along with the glyph, since filter effects composite
       through the element's own opacity. */
    .intro-section .word,
    .intro-chapter .word,
    .intro-location .word {
      filter:
        drop-shadow(0 0 3px rgba(0, 0, 0, 0.55))
        drop-shadow(0 0 8px rgba(0, 0, 0, 0.35))
        drop-shadow(0 0 16px rgba(0, 0, 0, 0.2));
    }
    .intro-section h2 {
      font-family: 'Rajdhani', 'Exo 2', sans-serif;
      font-size: var(--intro-section-title-size);
      font-weight: 600;
      color: #E8E8E8;
      letter-spacing: 0.08em;
      line-height: 1.15;
      position: relative;
      mix-blend-mode: normal;
    }
    .intro-section p {
      position: relative;
      mix-blend-mode: normal;
      margin-top: 0.65rem;
      font-family: 'Exo 2', sans-serif;
      font-size: var(--intro-section-subtitle-size);
      font-weight: 300;
      letter-spacing: 0.24em;
      text-transform: uppercase;
      color: rgba(126, 184, 212, 0.68);
      line-height: 1.5;
      text-wrap: balance;
      max-width: min(74vw, 880px);
      margin-inline: auto;
    }
    .intro-logo {
      width: min(72vw, 780px);
      max-width: calc(100vw - 3rem);
      display: flex;
      align-items: center;
      justify-content: center;
      overflow: visible;
      will-change: transform, opacity;
    }
    .intro-logo img {
      width: 100%;
      height: auto;
      display: block;
      object-fit: contain;
      filter: none;
    }

    .intro-disclaimer {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.55rem, 0.7vw, 1.5rem);
      font-weight: 300;
      color: rgba(232, 232, 232, 0.45);
      text-align: center;
      line-height: 1.7;
      max-width: 52ch;
      padding: 0 2rem;
      text-wrap: balance;
    }

    /* ── Story text panel ───────────────────────────────────── */
    #text-panel {
      position: absolute;
      left: 0; right: 0;
      z-index: 10;
      display: flex;
      flex-direction: column;
      gap: 0.4em;
      opacity: 0;
      transition: opacity 0.3s ease;
    }

    /* Landscape: overlay at bottom of image, respect safe areas */
    @media (orientation: landscape) {
      #text-panel {
        bottom: 0;
        padding: 0 calc(6vw + var(--safe-left)) calc(2vh + var(--safe-bottom)) calc(6vw + var(--safe-left));
        background: linear-gradient(to top, rgba(0,0,0,0.46) 0%, rgba(0,0,0,0.325) 65%, transparent 100%);
        min-height: 26svh;
        max-height: 50svh;
        justify-content: flex-end;
        overflow: hidden;
      }
      /* Single-line narration: reposition ONLY the text line itself to center
         vertically on the bottom control-button row's center (#back-btn/
         #play-btn/#section-next-btn, 44px tall, bottom: 1.8vh+safe → center is
         1.8vh+safe+22px from the viewport bottom). #text-panel itself (size,
         background gradient, min/max-height) is deliberately left untouched —
         two earlier attempts resized/repositioned the whole panel and both
         accidentally shrank the legibility gradient behind the text. Taking
         #text-content out of flow with position:absolute and centering it via
         bottom+translateY(50%) (which centers a box around a fixed point
         regardless of the box's own height) sidesteps that entirely. Toggled
         from showStoryText() in app.js once the rendered line count is known. */
      #text-panel.narration-oneline #text-content {
        position: absolute;
        left: 0;
        right: 0;
        bottom: calc(1.8vh + var(--safe-bottom) + 22px);
        transform: translateY(50%);
      }
    }

    /* Portrait: sits below the image in black space */
    @media (orientation: portrait) {
      #text-panel {
        top: calc(100vw * 9 / 16 + 32px);
        bottom: calc(var(--safe-bottom) + 8px);
        padding: 0 5vw 0;
        background: none;
        justify-content: flex-start;
        overflow-y: auto;
      }
    }

    #attribution {
      font-family: 'Exo 2', system-ui, sans-serif;
      font-size: clamp(0.7rem, 0.8vw, 1.8rem);
      font-weight: 600;
      letter-spacing: 0.18em;
      text-transform: uppercase;
      text-align: center;
      opacity: 0.75;
      min-height: 1.2em;
    }

    #text-content {
      font-family: 'Rajdhani', 'Exo 2', sans-serif;
      font-size: clamp(1rem, 1.3vw, 2.8rem);
      font-weight: 500;
      line-height: 1.5;
      color: #E8E8E8;
      text-align: center;
      /* Column width is what forces the wrap — text-wrap:balance only evens out
         lines that already wrapped, it doesn't decide where they break. Width is
         tunable from the app-config sheet (subtitle_max_width_ch) via the
         --subtitle-max-width custom property set in applyAppSettings(). */
      text-wrap: balance;
      max-width: min(86vw, var(--subtitle-max-width, 70ch));
      margin-inline: auto;
    }
    #text-content.large {
      font-size: clamp(1.25rem, 1.6vw, 3.4rem);
    }
    #text-content.dialogue  { font-style: normal; }
    #text-content.narration { font-style: normal; }

    #text-content .word,
    #intro-panel .word { display: inline; opacity: 0; transition: opacity 0.06s ease; }
    #text-content .word.visible,
    #intro-panel .word.visible { opacity: 1; }

    /* ── Loading overlay (shown while rebuilding from sheet) ──────────────── */
    #loading-overlay {
      position: absolute;
      inset: 0;
      z-index: 22;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #000;
      pointer-events: none;
      transition: opacity 0.8s ease;
    }
    #loading-msg {
      font-family: 'Exo 2', monospace, sans-serif;
      font-size: 0.78rem;
      letter-spacing: 0.28em;
      text-transform: uppercase;
      color: rgba(126, 184, 212, 0.6);
    }
    #start-gate {
      position: absolute;
      inset: 0;
      z-index: 23;
      display: none;
      align-items: center;
      justify-content: center;
      background: #000;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.55s ease;
    }
    #start-gate.visible {
      display: flex;
      opacity: 1;
      pointer-events: auto;
    }
    #start-app-btn {
      width: 100%;
      height: 100%;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: clamp(1.5rem, 4vh, 2.5rem);
      padding: max(2rem, var(--safe-top)) max(1.5rem, var(--safe-right)) max(2rem, var(--safe-bottom)) max(1.5rem, var(--safe-left));
      border: 0;
      background: transparent;
      color: inherit;
      cursor: pointer;
      -webkit-tap-highlight-color: transparent;
    }
    #start-app-btn:focus-visible {
      outline: 1px solid rgba(126, 184, 212, 0.64);
      outline-offset: -10px;
    }
    #start-app-btn .start-gate-disclaimer {
      display: block;
      max-width: 68ch;
      padding: 0;
      font-size: clamp(0.72rem, 1vw, 1.02rem);
      color: rgba(232, 232, 232, 0.62);
    }
    #start-app-prompt {
      display: block;
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.7rem, 0.9vw, 0.94rem);
      font-weight: 500;
      letter-spacing: 0.28em;
      text-transform: uppercase;
      color: rgba(126, 184, 212, 0.9);
      animation: start-prompt-pulse 2.2s ease-in-out infinite;
    }
    @keyframes start-prompt-pulse {
      0%, 100% { opacity: 0.48; }
      50% { opacity: 1; }
    }

    /* ── Chapter title (tap-to-begin screen) ──────────────── */
    #chapter-title {
      position: absolute;
      inset: 0;
      z-index: 20;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      padding: clamp(1.25rem, 4vh, 3rem) clamp(1rem, 4vw, 3rem);
      background: transparent;
      gap: 1.1rem;
      opacity: 0;
      pointer-events: none;
      transition: opacity 0.9s ease;
    }
    #chapter-title.menu-syncing {
      pointer-events: none;
    }
    #chapter-title.menu-syncing .menu-nav-row,
    #chapter-title.menu-syncing .title-mode-btns,
    #chapter-title.menu-syncing #chapters-toggle,
    #chapter-title.menu-syncing #chapters-accordion,
    #chapter-title.menu-syncing #menu-disclaimer {
      opacity: 0.55;
      transition: opacity 0.22s ease;
    }
    #scene.menu-exiting #chapter-title,
    #scene.menu-exiting #end-card {
      opacity: 0 !important;
      transform: translateY(26px);
      pointer-events: none;
      transition: opacity var(--screen-exit-duration) ease, transform var(--screen-exit-duration) cubic-bezier(0.25, 0.8, 0.25, 1);
    }
    #scene.story-exiting .image-layer,
    #scene.story-exiting #text-panel,
    #scene.story-exiting #intro-panel,
    #scene.story-exiting #text-mode-screen {
      opacity: 0 !important;
      transform: translateY(26px);
      transition: opacity var(--screen-exit-duration) ease, transform var(--screen-exit-duration) cubic-bezier(0.25, 0.8, 0.25, 1);
    }
    body.story-exiting .chrome-btn {
      opacity: 0 !important;
      pointer-events: none;
    }
    #scene.menu-exiting #vfx-layer,
    #scene.story-exiting #vfx-layer {
      opacity: 0 !important;
      transition: opacity var(--screen-exit-duration) ease;
    }
    #brand-block {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.16rem;
      margin-bottom: 1.7rem;
      text-align: center;
    }
    #chapter-title #brand-block h1 {
      font-family: 'Rajdhani', 'Exo 2', sans-serif;
      font-size: clamp(4.1rem, 7vw, 10rem);
      font-weight: 600;
      line-height: 0.9;
      letter-spacing: 0.14em;
      color: #7EB8D4;
      text-shadow: 0 0 28px rgba(126, 184, 212, 0.18);
    }
    #brand-block h2 {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.72rem, 0.95vw, 1.5rem);
      font-weight: 300;
      letter-spacing: 0.34em;
      text-transform: uppercase;
      color: var(--menu-text-mid);
    }
    #chapter-title #brand-block h4 {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.72rem, 0.95vw, 1.5rem);
      font-weight: 300;
      letter-spacing: 0.34em;
      text-transform: uppercase;
      color: var(--menu-text-mid);
    }
    #chapter-title #brand-block h5 {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.62rem, 0.76vw, 1.18rem);
      font-weight: 300;
      letter-spacing: 0.2em;
      text-transform: uppercase;
      color: var(--menu-accent-soft);
      margin-top: 0.38rem;
    }
    #chapter-title .label {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.64rem, 0.82vw, 1.3rem);
      letter-spacing: 0.34em;
      text-transform: uppercase;
      color: var(--menu-accent-mid);
    }
    #chapter-title h1,
    #chapter-title h2,
    #chapter-title h3,
    #chapter-title h4,
    #chapter-title h5,
    #chapter-title h6 {
      font-family: 'Rajdhani', 'Exo 2', sans-serif;
      font-weight: 600;
      color: var(--menu-text-high);
      line-height: 1.05;
      text-align: center;
    }
    #chapter-title #menu-chapter-title {
      font-size: var(--menu-chapter-title-size);
      letter-spacing: 0.09em;
      text-wrap: balance;
    }
    #chapter-title #menu-chapter-label {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.64rem, 0.82vw, 1.3rem);
      font-weight: 300;
      letter-spacing: 0.34em;
      text-transform: uppercase;
      color: var(--menu-accent-mid);
    }
    #chapter-title #start-point-title {
      font-family: 'Rajdhani', 'Exo 2', sans-serif;
      font-size: var(--menu-start-title-size);
      font-weight: 600;
      letter-spacing: 0.12em;
      color: var(--menu-text-high);
      text-wrap: balance;
    }
    #chapter-title #start-point-heading {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.55rem, 0.68vw, 1.08rem);
      font-weight: 300;
      letter-spacing: 0.26em;
      text-transform: uppercase;
      color: var(--menu-accent-soft);
    }
    #chapter-title #start-point-hint {
      display: none;
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.5rem, 0.62vw, 0.95rem);
      font-weight: 300;
      letter-spacing: 0.16em;
      text-transform: uppercase;
      color: rgba(232, 232, 232, 0.42);
    }
    .menu-nav-row {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: clamp(0.45rem, 1.2vw, 0.9rem);
      width: min(92vw, 760px);
      max-width: min(92vw, 760px);
      opacity: 1;
      transform: translateY(0);
      transition: opacity 0.28s ease, transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
      overflow: visible;
    }
    .menu-nav-row.refreshing {
      animation: menu-row-refresh 0.38s cubic-bezier(0.22, 1, 0.36, 1);
    }
    .menu-nav-copy {
      min-width: 0;
      flex: 1 1 auto;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.5rem;
      transition: opacity 0.24s ease, transform 0.32s cubic-bezier(0.22, 1, 0.36, 1), filter 0.32s ease;
    }
    .menu-nav-copy .label {
      margin: 0;
    }
    .menu-nav-copy p {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.55rem, 0.7vw, 1.2rem);
      font-weight: 300;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: var(--menu-text-soft);
      text-align: center;
    }
    #settings-btn.on-menu {
      width: 44px;
      height: 44px;
      border: 1px solid rgba(126,184,212,0.32);
      border-radius: 999px;
      background: rgba(4, 8, 14, 0.28);
      color: rgba(232,232,232,0.82);
      font-size: 1rem;
      opacity: 0.9;
    }
    #settings-btn.on-menu:hover,
    #settings-btn.on-menu:focus-visible {
      opacity: 1;
      color: #E8E8E8;
      border-color: rgba(126,184,212,0.68);
      background: rgba(126,184,212,0.12);
      transform: translateY(-1px);
      outline: none;
    }
    .menu-nav-btn {
      min-width: 34px;
      width: 34px;
      height: 34px;
      padding: 0;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 0.78rem;
    }
    #start-point-row {
      margin-top: 0.15rem;
      max-width: min(92vw, 680px);
      max-height: 0;
      opacity: 0;
      overflow: hidden;
      pointer-events: none;
      visibility: hidden;
      transform: translateY(-18px) scale(0.985);
      filter: blur(3px);
      transition: max-height 0.44s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.34s ease, transform 0.44s cubic-bezier(0.22, 1, 0.36, 1), margin-top 0.44s cubic-bezier(0.22, 1, 0.36, 1), filter 0.34s ease, visibility 0s linear 0.44s;
      will-change: max-height, opacity, transform, filter;
    }
    #start-point-row.visible {
      max-height: 140px;
      margin-top: 0.78rem;
      opacity: 1;
      overflow: visible;
      pointer-events: auto;
      visibility: visible;
      transform: translateY(0);
      filter: blur(0);
      transition-delay: 0s;
    }
    #menu-disclaimer {
      margin-top: 1.2rem;
      max-width: 72ch;
      color: rgba(232, 232, 232, 0.62);
      opacity: 1;
      transform: translateY(0);
      transition: opacity 0.32s ease, transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
    }
    #chapters-accordion.open ~ #menu-disclaimer {
      opacity: 0;
      transform: translateY(calc(100% + 1rem));
    }
    #menu-sync-indicator {
      position: absolute;
      right: 0.95rem;
      bottom: calc(1.7rem + var(--safe-bottom));
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.54rem, 0.66vw, 1rem);
      font-weight: 300;
      letter-spacing: 0.22em;
      text-transform: uppercase;
      color: var(--menu-accent-mid);
      text-align: right;
      white-space: nowrap;
      max-width: 26ch;
      opacity: 0;
      transform: translateY(4px);
      transition: opacity 0.22s ease, transform 0.22s ease;
      pointer-events: none;
    }
    #menu-sync-indicator.visible {
      opacity: 1;
      transform: translateY(0);
    }
    .tap-hint {
      margin-top: 2rem;
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.6rem, 0.75vw, 1.5rem);
      letter-spacing: 0.2em;
      text-transform: uppercase;
      color: rgba(255,255,255,0.3);
      animation: pulse 2s ease-in-out infinite;
    }
    .title-mode-btns {
      margin-top: 0.5rem;
      display: flex;
      gap: 1rem;
      align-items: center;
    }
    .menu-actions {
      margin-top: 0.3rem;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.48rem;
      width: 100%;
    }
    .mode-btn {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.55rem, 0.7vw, 1.4rem);
      letter-spacing: 0.18em;
      text-transform: uppercase;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 0.45rem;
      line-height: 1;
      color: var(--menu-accent-mid);
      background: rgba(7, 13, 22, 0.28);
      border: 1px solid rgba(126,184,212,0.46);
      padding: 8px 16px;
      border-radius: 4px;
      cursor: pointer;
      transition: color 0.2s ease, border-color 0.2s ease, background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    }
    .mode-btn .btn-icon {
      font-size: 0.9em;
      pointer-events: none;
      margin-right: 0;
    }
    .mode-btn:hover,
    .mode-btn:focus-visible {
      color: #E8F5FB;
      border-color: rgba(184,224,243,0.8);
      background: rgba(18, 31, 46, 0.52);
      box-shadow: 0 0 0 1px rgba(126,184,212,0.14);
      transform: translateY(-1px);
      outline: none;
    }
    .mode-btn.primary { color: var(--menu-accent-strong); border-color: rgba(126,184,212,0.62); }
    .mode-btn.primary:hover,
    .mode-btn.primary:focus-visible { color: #fff; border-color: rgba(255,255,255,0.68); }
    #btn-autoplay {
      background: linear-gradient(180deg, rgba(126,184,212,0.98) 0%, rgba(106,163,192,0.98) 100%);
      color: #07111d;
      border-color: rgba(184,224,243,0.92);
      box-shadow: 0 10px 24px rgba(4, 10, 18, 0.28), 0 0 0 1px rgba(126,184,212,0.12);
    }
    #btn-autoplay:hover,
    #btn-autoplay:focus-visible {
      color: #07111d;
      background: linear-gradient(180deg, rgba(232,245,251,0.98) 0%, rgba(191,228,244,0.98) 100%);
      border-color: rgba(255,255,255,0.96);
      box-shadow: 0 12px 28px rgba(4, 10, 18, 0.32), 0 0 0 1px rgba(255,255,255,0.16);
    }
    .mode-btn:disabled {
      color: rgba(126,184,212,0.38);
      border-color: rgba(126,184,212,0.18);
      background: rgba(7, 13, 22, 0.14);
      cursor: default;
      pointer-events: none;
      box-shadow: none;
      transform: none;
    }
    #chapters-toggle {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      gap: 0.55rem;
    }
    #chapters-toggle i {
      transition: transform 0.25s ease;
    }
    #chapters-toggle.open i {
      transform: rotate(180deg);
    }
    #chapters-accordion {
      width: min(92vw, 820px);
      max-height: 0;
      opacity: 0;
      overflow: hidden;
      transform: translateY(-10px);
      transition: max-height 0.36s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.28s ease, transform 0.36s cubic-bezier(0.22, 1, 0.36, 1);
    }
    #chapters-accordion.open {
      max-height: 260px;
      opacity: 1;
      overflow: visible;
      transform: translateY(0);
    }
    #chapter-carousel {
      overflow-x: auto;
      overflow-y: visible;
      padding: 0.65rem 0.2rem 0.9rem;
      cursor: grab;
      scrollbar-width: thin;
      scrollbar-color: rgba(126,184,212,0.38) transparent;
      scroll-behavior: smooth;
      -webkit-overflow-scrolling: touch;
      overscroll-behavior-x: contain;
      touch-action: pan-x pinch-zoom;
    }
    #chapter-carousel.dragging {
      cursor: grabbing;
    }
    #chapter-carousel::-webkit-scrollbar {
      height: 4px;
    }
    #chapter-carousel::-webkit-scrollbar-track {
      background: transparent;
    }
    #chapter-carousel::-webkit-scrollbar-thumb {
      background: rgba(126,184,212,0.35);
      border-radius: 999px;
    }
    #chapter-carousel-track {
      display: flex;
      align-items: flex-start;
      gap: 0.95rem;
      width: max-content;
      min-width: 100%;
      padding: 0 0.15rem;
    }
    .chapter-thumb {
      width: 132px;
      flex: 0 0 auto;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.45rem;
      padding: 0;
      background: none;
      border: none;
      color: rgba(232,232,232,0.74);
      cursor: pointer;
      opacity: 0;
      transform: translateY(16px) scale(0.985);
      transition: opacity 0.28s ease, transform 0.42s cubic-bezier(0.22, 1, 0.36, 1);
      transition-delay: var(--thumb-delay, 0ms);
      will-change: opacity, transform;
    }
    .chapter-thumb.revealed {
      opacity: 1;
      transform: translateY(0) scale(1);
    }
    .chapter-thumb-frame {
      width: 132px;
      aspect-ratio: 16 / 9;
      border: 1px solid rgba(126,184,212,0.25);
      background: radial-gradient(ellipse at center, #0a0f1e 0%, #000 100%);
      overflow: hidden;
      opacity: 0.72;
      transition: opacity 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    }
    .chapter-thumb img {
      width: 100%;
      height: 100%;
      display: block;
      object-fit: cover;
    }
    .chapter-thumb:hover .chapter-thumb-frame,
    .chapter-thumb.selected .chapter-thumb-frame {
      opacity: 1;
      border-color: rgba(126,184,212,0.72);
      transform: translateY(-1px);
    }
    .chapter-thumb.selected .chapter-thumb-frame {
      border-color: rgba(245, 184, 75, 0.9);
      box-shadow: 0 0 0 1px rgba(245, 184, 75, 0.3), 0 0 18px rgba(245, 184, 75, 0.14);
    }
    .chapter-thumb strong {
      font-family: 'Exo 2', sans-serif;
      font-size: 0.66rem;
      font-weight: 600;
      letter-spacing: 0.18em;
      text-transform: uppercase;
      color: var(--menu-accent-mid);
    }
    .chapter-thumb h6 {
      max-width: 132px;
      font-family: 'Exo 2', sans-serif;
      font-size: 0.58rem;
      font-weight: 300;
      line-height: 1.25;
      letter-spacing: 0.08em;
      color: rgba(232,232,232,0.64);
      text-transform: uppercase;
      text-wrap: balance;
    }
    .chapter-section-dots {
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 0.38rem;
      min-height: 13px;
      margin-top: -0.12rem;
    }
    .chapter-section-dot {
      width: 8px;
      height: 8px;
      border-radius: 999px;
      border: 1px solid rgba(126,184,212,0.34);
      background: rgba(126,184,212,0.14);
      cursor: pointer;
      padding: 0;
      font-size: 0;
      color: transparent;
      line-height: 1;
      transition: transform 0.18s ease, background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
    }
    .chapter-section-dot:hover,
    .chapter-section-dot:focus-visible {
      transform: scale(1.28);
      border-color: rgba(126,184,212,0.8);
      background: rgba(126,184,212,0.5);
      box-shadow: 0 0 10px rgba(126,184,212,0.2);
      outline: none;
    }
    .chapter-section-dot.active-reading {
      width: 10px;
      height: 10px;
      border-color: rgba(255, 193, 79, 0.95);
      background: #F5B84B;
      box-shadow: 0 0 12px rgba(245,184,75,0.5);
    }
    @keyframes menu-row-refresh {
      0% {
        opacity: 0.06;
        transform: translateY(14px);
        filter: blur(5px);
      }
      100% {
        opacity: 1;
        transform: translateY(0);
        filter: blur(0);
      }
    }
    @keyframes pulse { 0%,100%{opacity:0.3} 50%{opacity:0.7} }

    @media (max-width: 900px) and (orientation: landscape), (max-height: 500px) and (orientation: landscape) {
      :root {
        --menu-chapter-title-size: clamp(0.98rem, 2vw, 1.42rem);
        --menu-start-title-size: clamp(0.78rem, 1.45vw, 1.02rem);
      }
      #chapter-title {
        justify-content: flex-start;
        gap: 0.78rem;
        padding: calc(0.95rem + var(--safe-top)) 0.8rem calc(3.15rem + var(--safe-bottom)) 0.8rem;
        overflow-y: auto;
        overflow-x: hidden;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
        scrollbar-width: none;
      }
      #chapter-title::-webkit-scrollbar {
        display: none;
      }
      #brand-block {
        gap: 0.08rem;
        margin-bottom: 0.7rem;
      }
      #chapter-title #brand-block h1 {
        font-size: clamp(1.92rem, 4.1vw, 2.7rem);
        letter-spacing: 0.1em;
      }
      #chapter-title #brand-block h4 {
        font-size: clamp(0.62rem, 1.08vw, 0.8rem);
        letter-spacing: 0.22em;
      }
      #chapter-title #brand-block h5,
      #chapter-title #menu-chapter-label,
      #chapter-title #start-point-heading {
        font-size: clamp(0.58rem, 0.98vw, 0.72rem);
        letter-spacing: 0.2em;
      }
      #chapter-title #brand-block h5 {
        margin-top: 0.24rem;
      }
      .menu-nav-row {
        gap: 0.34rem;
        max-width: min(96vw, 648px);
        width: min(96vw, 648px);
      }
      .menu-nav-copy {
        gap: 0.32rem;
      }
      #settings-btn.on-menu {
        width: 38px;
        height: 38px;
        font-size: 0.9rem;
      }
      #chapter-title #menu-chapter-title {
        font-size: clamp(1rem, 1.9vw, 1.34rem);
        line-height: 1.06;
      }
      #chapter-title #start-point-title {
        font-size: clamp(0.8rem, 1.35vw, 1rem);
        line-height: 1.08;
      }
      #start-point-row {
        margin-top: 0.12rem;
        max-width: min(96vw, 648px);
      }
      #start-point-row.visible {
        max-height: 118px;
        margin-top: 0.64rem;
      }
      .title-mode-btns {
        margin-top: 0.24rem;
        gap: 0.62rem;
        width: auto;
        justify-content: center;
      }
      .menu-actions {
        margin-top: 0.18rem;
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: nowrap;
      }
      .mode-btn {
        font-size: clamp(0.62rem, 1.02vw, 0.74rem);
        padding: 9px 14px;
      }
      #btn-autoplay,
      #btn-manual,
      #btn-text-mode,
      #chapters-toggle {
        min-height: 38px;
        padding: 8px 14px;
      }
      #menu-sync-indicator {
        right: 0.7rem;
        bottom: calc(1.42rem + var(--safe-bottom));
        font-size: clamp(0.42rem, 0.72vw, 0.54rem);
        max-width: 42vw;
      }
      #chapters-toggle {
        gap: 0.32rem;
        flex: 0 0 auto;
      }
      #chapters-accordion {
        width: min(96vw, 648px);
      }
      #chapters-accordion.open {
        max-height: 280px;
      }
      #chapter-carousel {
        padding: 0.32rem 0.08rem 1rem;
        -webkit-overflow-scrolling: touch;
      }
      #chapter-carousel-track {
        gap: 0.58rem;
      }
      .chapter-thumb {
        width: 90px;
        gap: 0.24rem;
      }
      .chapter-thumb-frame {
        width: 90px;
      }
      .chapter-thumb strong {
        font-size: 0.54rem;
      }
      .chapter-thumb h6 {
        max-width: 90px;
        font-size: 0.5rem;
        line-height: 1.22;
        color: rgba(232,232,232,0.74);
      }
      .chapter-section-dots {
        gap: 0.28rem;
        min-height: 10px;
        margin-top: -0.08rem;
      }
      .chapter-section-dot {
        width: 7px;
        height: 7px;
      }
      .chapter-section-dot.active-reading {
        width: 8px;
        height: 8px;
      }
      #menu-disclaimer {
        position: absolute;
        left: 50%;
        bottom: calc(0.28rem + var(--safe-bottom));
        transform: translateX(-50%);
        width: min(calc(100vw - 0.8rem), 92ch);
        max-width: none;
        margin-top: 0;
        padding: 0 0.25rem;
        font-size: clamp(0.44rem, 0.82vw, 0.48rem);
        line-height: 1.34;
        color: rgba(232, 232, 232, 0.62);
        pointer-events: none;
      }
      #chapters-accordion.open ~ #menu-disclaimer {
        transform: translateX(-50%) translateY(calc(100% + 1rem));
      }
      #build-version {
        bottom: calc(10px + var(--safe-bottom));
        right: 10px;
        font-size: 0.5rem;
      }
    }

    @media (pointer: coarse), (max-width: 900px) {
      .chapter-section-dots {
        gap: 0.22rem;
        min-height: 24px;
        margin-top: 0.02rem;
      }
      .chapter-section-dot {
        min-width: 24px;
        width: auto;
        height: 24px;
        padding: 0 5px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 999px;
        font-family: 'Exo 2', sans-serif;
        font-size: 0.56rem;
        font-weight: 600;
        letter-spacing: 0.04em;
        color: rgba(232,232,232,0.82);
        background: rgba(126,184,212,0.18);
      }
      .chapter-section-dot:hover,
      .chapter-section-dot:focus-visible {
        transform: scale(1.04);
      }
      .chapter-section-dot.active-reading {
        min-width: 26px;
        height: 24px;
        color: #10151f;
        box-shadow: 0 0 0 1px rgba(245,184,75,0.24), 0 0 14px rgba(245,184,75,0.26);
      }
    }

    /* The outer clip follows the rendered slide bounds; the inner layer can
       still pan/scale with Ken Burns without painting into letterbox bars. */
    #vfx-clip {
      position: absolute;
      inset: 0;
      z-index: 9;
      overflow: hidden;
      pointer-events: none;
    }
    #vfx-layer {
      position: absolute;
      inset: 0;
      z-index: 1;
      pointer-events: none;
      opacity: 0;
      transform: translateZ(0);
    }
    #vfx-layer canvas { position:absolute!important; inset:0; width:100%!important; height:100%!important; }

    /* ── Chrome buttons (play, back, settings) ─────────────── */
    .chrome-btn {
      position: absolute;
      z-index: 30;
      min-width: 44px; min-height: 44px;
      display: none;
      align-items: center; justify-content: center;
      cursor: pointer;
      opacity: 0.2;
      transition: opacity 0.3s ease, color 0.3s ease;
      background: none;
      border: none;
      color: #fff;
      font-size: 1.1rem;
      padding: 0;
      -webkit-tap-highlight-color: transparent;
    }
    .chrome-btn:hover  { opacity: 0.9; color: #7EB8D4; }
    .chrome-btn:active { opacity: 0.9; }
    .chrome-btn:disabled {
      opacity: 0.16;
      cursor: default;
      pointer-events: none;
    }

    #play-btn {
      bottom: calc(1.8vh + var(--safe-bottom));
      left:   calc(1.8vw  + var(--safe-left) + 104px);
    }

    /* Back button — desktop: bottom-left, leftmost */
    #back-btn {
      bottom: calc(1.8vh + var(--safe-bottom));
      left:   calc(1.8vw  + var(--safe-left));
    }
    #section-prev-btn {
      bottom: calc(1.8vh + var(--safe-bottom));
      left:   calc(1.8vw  + var(--safe-left) + 52px);
    }
    /* Next-section button — bottom-right, aligned with the settings icon above it */
    #section-next-btn {
      bottom: calc(1.8vh + var(--safe-bottom));
      right:  calc(1.8vw + var(--safe-right));
    }

    /* Aspect ratio toggle — desktop only, top-right left of fullscreen */
    #aspect-btn {
      top:   calc(1.8vh + var(--safe-top));
      right: calc(1.8vw + var(--safe-right) + 104px);
      display: none; /* shown via JS on non-touch devices */
    }
    #aspect-btn.active { opacity: 0.9; }

    /* Fullscreen toggle — desktop only, top-right left of settings */
    #fullscreen-btn {
      top:   calc(1.8vh + var(--safe-top));
      right: calc(1.8vw + var(--safe-right) + 52px);
      display: none; /* shown via JS on non-touch devices */
    }
    #fullscreen-btn.active { opacity: 0.9; }

    /* Letterbox mode: constrain scene to 16:9 centered in viewport */
    body.letterbox {
      display: flex;
      align-items: center;
      justify-content: center;
    }
    body.letterbox #scene {
      width:  min(100vw, calc(100svh * 16 / 9));
      height: min(100svh, calc(100vw * 9 / 16));
      flex-shrink: 0;
    }

    /* Settings — always top-right */
    #settings-btn {
      top:   calc(1.8vh + var(--safe-top));
      right: calc(1.8vw + var(--safe-right));
    }
    #settings-btn.open { opacity: 0.9; }

    /* Mobile: move back-btn next to settings (top-right area) */
    @media (max-width: 768px) {
      #back-btn {
        bottom: auto;
        left:   auto;
        top:   calc(1.8vh + var(--safe-top));
        right: calc(1.8vw + var(--safe-right) + 52px);
      }
    }

    /* ── Mobile landscape: subtitle fonts ──────────────────────────────────── */
    @media (max-width: 1300px) and (orientation: landscape) {
      #text-content         { font-size: 0.88rem; }
      #text-content.large   { font-size: 1.3rem; }
      #attribution          { font-size: 0.8rem; }
    }

    /* ── LCARS scan line (sweeps on image crossfade) ──────────────────────── */
    #scan-line {
      position: absolute;
      inset: 0;
      background: linear-gradient(to bottom,
        transparent 0%,
        rgba(126,184,212,0.22) 40%,
        rgba(126,184,212,0.22) 60%,
        transparent 100%);
      z-index: 6;
      pointer-events: none;
      opacity: 0;
    }

    /* ── Version badge (visible on loading screen + menu, hidden during story) */
    #build-version {
      position: absolute;
      bottom: 14px;
      right: 16px;
      z-index: 25;
      font-family: 'Exo 2', monospace, sans-serif;
      font-size: 0.65rem;
      letter-spacing: 0.15em;
      color: rgba(126, 184, 212, 0.65);
      pointer-events: none;
      user-select: none;
    }

    #install-app-btn {
      position: absolute;
      left: calc(16px + var(--safe-left));
      bottom: calc(14px + var(--safe-bottom));
      z-index: 25;
      min-height: 36px;
      font-size: 0.58rem;
      padding: 8px 12px;
      background: rgba(4, 10, 18, 0.68);
      backdrop-filter: blur(10px);
    }
    #install-app-btn[hidden],
    #install-help[hidden] {
      display: none !important;
    }
    body.story-ready #install-app-btn,
    body.text-mode-active #install-app-btn {
      display: none !important;
    }
    #install-help {
      position: absolute;
      inset: 0;
      z-index: 70;
      display: flex;
      align-items: center;
      justify-content: center;
      padding: max(20px, var(--safe-top)) max(20px, var(--safe-right)) max(20px, var(--safe-bottom)) max(20px, var(--safe-left));
      background: rgba(0, 0, 0, 0.78);
      backdrop-filter: blur(12px);
    }
    #install-help-card {
      position: relative;
      width: min(88vw, 430px);
      padding: 30px 28px 26px;
      border: 1px solid rgba(126, 184, 212, 0.42);
      border-radius: 8px;
      background: rgba(7, 13, 22, 0.97);
      box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
      color: #e8e8e8;
      font-family: 'Exo 2', sans-serif;
      text-align: center;
    }
    #install-help-card h2 {
      margin: 0 0 14px;
      color: #7eb8d4;
      font-family: 'Rajdhani', 'Exo 2', sans-serif;
      font-size: 1.55rem;
      letter-spacing: 0.12em;
      text-transform: uppercase;
    }
    #install-help-card p {
      margin: 0;
      color: rgba(232, 232, 232, 0.8);
      font-size: 0.9rem;
      line-height: 1.6;
    }
    #install-help-close {
      position: absolute;
      top: 8px;
      right: 8px;
      width: 36px;
      height: 36px;
      border: 0;
      background: transparent;
      color: rgba(232, 232, 232, 0.64);
      cursor: pointer;
      font-size: 1rem;
    }

    /* ── Spreadsheet sync status panel (visible during loading + start gate) ── */
    #sync-status-panel {
      position: absolute;
      left: 50%;
      bottom: 6vh;
      transform: translateX(-50%);
      z-index: 24;
      width: min(90vw, 480px);
      max-height: 24vh;
      display: none;
      opacity: 0;
      transition: opacity 0.4s ease;
      pointer-events: none;
    }
    #sync-status-panel.visible {
      display: block;
      opacity: 1;
    }
    #sync-status-title {
      margin-bottom: 5px;
      font-family: 'Rajdhani', sans-serif;
      font-size: 0.68rem;
      font-weight: 600;
      letter-spacing: 0.14em;
      text-transform: uppercase;
      color: rgba(126, 184, 212, 0.8);
    }
    #sync-status-list {
      max-height: 24vh;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 2px;
      padding: 8px 12px;
      background: rgba(0, 0, 0, 0.35);
      border-radius: 6px;
      font-family: 'Rajdhani', sans-serif;
      font-size: 0.8rem;
      letter-spacing: 0.02em;
      color: rgba(255, 255, 255, 0.65);
    }
    .sync-status-row::before {
      display: inline-block;
      width: 1.1em;
      margin-right: 0.25em;
      content: '\2014';
      color: rgba(255, 255, 255, 0.35);
    }
    .sync-status-row.new::before,
    .sync-status-row.updated::before {
      content: '\2713';
      color: #78d6ae;
    }
    .sync-status-row.error {
      color: #ff9b91;
    }
    .sync-status-row.error::before {
      content: '!';
      color: #ff786e;
    }
    #sync-status-list::-webkit-scrollbar { width: 3px; }
    #sync-status-list::-webkit-scrollbar-track { background: transparent; }
    #sync-status-list::-webkit-scrollbar-thumb { background: rgba(126, 184, 212, 0.35); border-radius: 2px; }

    /* ── Continuous text reading mode ──────────────────────────────────────── */
    #text-mode-screen[hidden] { display: none !important; }
    #text-mode-screen {
      --text-mode-body-min: 1rem;
      --text-mode-body-fluid: 1.25vw;
      --text-mode-body-max: 1.18rem;
      --text-mode-line-height: 1.6;
      position: absolute;
      inset: 0;
      z-index: 20;
      display: grid;
      grid-template-columns: minmax(0, 2fr) minmax(320px, 1fr);
      background: #000;
      color: #e8e8e8;
      font-family: 'Exo 2', sans-serif;
      overflow: hidden;
    }
    body.text-mode-font-comfortable #text-mode-screen {
      --text-mode-body-min: 1.12rem;
      --text-mode-body-fluid: 1.4vw;
      --text-mode-body-max: 1.32rem;
      --text-mode-line-height: 1.7;
    }
    body.text-mode-font-large #text-mode-screen {
      --text-mode-body-min: 1.3rem;
      --text-mode-body-fluid: 1.62vw;
      --text-mode-body-max: 1.53rem;
      --text-mode-line-height: 1.8;
    }
    #text-mode-image-panel {
      position: relative;
      grid-column: 1;
      grid-row: 1;
      min-width: 0;
      min-height: 0;
      background: #000;
      overflow: hidden;
    }
    .text-mode-image-layer {
      position: absolute;
      inset: 0;
      background: #000 center / contain no-repeat;
      opacity: 0;
      will-change: opacity;
    }
    #text-mode-image-a { opacity: 1; }
    #text-mode-scroll {
      position: relative;
      z-index: 25;
      grid-column: 2;
      grid-row: 1;
      min-width: 0;
      min-height: 0;
      overflow-y: auto;
      overscroll-behavior: contain;
      scroll-behavior: smooth;
      background: #050607;
      user-select: text;
      -webkit-user-select: text;
      scrollbar-color: rgba(126,184,212,0.34) transparent;
    }
    #text-mode-flow {
      width: min(100%, 46rem);
      margin: 0 auto;
      padding: 12svh clamp(24px, 4vw, 64px) 42svh;
    }
    .text-mode-chapter {
      margin: 0 0 1.1rem;
      color: #7eb8d4;
      font-family: 'Rajdhani', sans-serif;
      font-size: clamp(2rem, 3.2vw, 3.8rem);
      font-weight: 500;
      line-height: 1.02;
      letter-spacing: 0.04em;
      text-wrap: balance;
    }
    #text-mode-flow > .text-mode-chapter:not(:first-child) {
      margin-top: clamp(7rem, 16svh, 11rem);
    }
    .text-mode-chapter span {
      display: block;
      margin-bottom: 0.45rem;
      color: rgba(232,232,232,0.58);
      font-size: 0.42em;
      letter-spacing: 0.2em;
      text-transform: uppercase;
    }
    .text-mode-stardate {
      margin: 0 0 3.5rem;
      color: rgba(126,184,212,0.72);
      font-family: 'Rajdhani', sans-serif;
      font-size: 0.85rem;
      letter-spacing: 0.2em;
      text-transform: uppercase;
    }
    .text-mode-section {
      margin: 4.5rem 0 2.4rem;
      padding-top: 1.2rem;
      border-top: 1px solid rgba(126,184,212,0.18);
      color: rgba(232,232,232,0.88);
      font-family: 'Rajdhani', sans-serif;
      font-size: clamp(1.55rem, 2.25vw, 2.2rem);
      font-weight: 500;
      letter-spacing: 0.035em;
      line-height: 1.18;
      text-wrap: balance;
    }
    .text-mode-paragraph {
      margin: 0 0 1.05em;
      padding: 0.2rem 0;
      color: rgba(232,232,232,0.74);
      font-size: clamp(
        var(--text-mode-body-min),
        var(--text-mode-body-fluid),
        var(--text-mode-body-max)
      );
      font-weight: 300;
      line-height: var(--text-mode-line-height);
      text-align: justify;
      text-align-last: left;
      text-justify: inter-word;
      hyphens: auto;
    }
    .text-mode-row {
      border-radius: 4px;
      transition:
        color 0.22s ease,
        filter 0.22s ease;
      -webkit-box-decoration-break: clone;
      box-decoration-break: clone;
    }
    .text-mode-row.dialogue { color: rgba(232,232,232,0.82); }
    body.text-mode-character-colors .text-mode-row.dialogue {
      color: var(--text-mode-character-color, rgba(232,232,232,0.82));
    }
    .text-mode-row.current {
      color: #fff;
      filter: brightness(1.16);
    }
    body.text-mode-character-colors .text-mode-row.dialogue.current {
      color: #f7fafc;
      color: color-mix(
        in srgb,
        var(--text-mode-character-color, #fff) 18%,
        #fff
      );
    }
    body.text-mode-light-theme #text-mode-screen {
      background: #e5e0d6;
      color: #211e1a;
    }
    body.text-mode-light-theme #text-mode-scroll {
      background: #f3eee3;
      scrollbar-color: rgba(49, 83, 99, 0.42) transparent;
    }
    body.text-mode-light-theme .text-mode-chapter { color: #315f75; }
    body.text-mode-light-theme .text-mode-chapter span { color: rgba(33,30,26,0.62); }
    body.text-mode-light-theme .text-mode-stardate { color: #416d80; }
    body.text-mode-light-theme .text-mode-section {
      border-top-color: rgba(49,95,117,0.28);
      color: #28231e;
    }
    body.text-mode-light-theme .text-mode-paragraph { color: #71685e; }
    body.text-mode-light-theme .text-mode-row.dialogue { color: #6d655b; }
    body.text-mode-light-theme.text-mode-character-colors .text-mode-row.dialogue {
      color: var(--text-mode-light-character-color, #354f5b);
    }
    body.text-mode-light-theme .text-mode-row.current {
      color: #1e1a17;
      filter: none;
    }
    body.text-mode-light-theme.text-mode-character-colors .text-mode-row.dialogue.current {
      color: #1e1a17;
      color: color-mix(
        in srgb,
        var(--text-mode-light-character-color, #4e5558) 10%,
        #1e1a17
      );
    }
    .text-mode-dialogue { color: inherit; }
    .text-mode-aside { color: inherit; font-style: normal; }
    #text-mode-menu {
      position: absolute;
      right: calc(33.333% + 18px);
      bottom: calc(1.8vh + var(--safe-bottom));
      z-index: 47;
      display: flex;
      align-items: center;
      gap: 4px;
      padding: 4px;
      border: 1px solid rgba(126,184,212,0.16);
      border-radius: 999px;
      background: rgba(0,0,0,0.62);
      backdrop-filter: blur(10px);
    }
    .text-mode-control {
      width: 42px;
      height: 42px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      border: 0;
      border-radius: 50%;
      background: transparent;
      color: rgba(232,232,232,0.66);
      font-size: 0.95rem;
      transition: color 0.2s ease, background-color 0.2s ease;
    }
    .text-mode-control:hover,
    .text-mode-control:focus-visible {
      color: #7eb8d4;
      background: rgba(126,184,212,0.1);
      outline: none;
    }
    .text-mode-control:disabled { opacity: 0.24; pointer-events: none; }
    #text-mode-index,
    #text-mode-settings {
      position: absolute;
      inset: 0;
      z-index: 60;
      display: grid;
      place-items: center;
      padding: 24px;
      background: rgba(0,0,0,0.72);
      backdrop-filter: blur(8px);
    }
    #text-mode-index[hidden],
    #text-mode-settings[hidden] { display: none; }
    .text-mode-index-card,
    .text-mode-settings-card {
      width: min(92vw, 540px);
      max-height: min(82svh, 760px);
      overflow: hidden;
      border: 1px solid rgba(126,184,212,0.28);
      border-radius: 12px;
      background: #080b10;
      box-shadow: 0 24px 80px rgba(0,0,0,0.56);
    }
    .text-mode-settings-card { width: min(92vw, 620px); }
    .text-mode-index-head {
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 18px 18px 12px 24px;
      border-bottom: 1px solid rgba(126,184,212,0.14);
    }
    .text-mode-index-head h2 {
      font-family: 'Rajdhani', sans-serif;
      font-size: 1.2rem;
      font-weight: 500;
      letter-spacing: 0.16em;
      text-transform: uppercase;
    }
    #text-mode-index-list {
      max-height: calc(min(82svh, 760px) - 72px);
      overflow-y: auto;
      padding: 14px 12px 22px;
    }
    .text-mode-index-entry {
      width: 100%;
      display: block;
      padding: 9px 12px;
      border: 0;
      border-radius: 7px;
      background: transparent;
      color: rgba(232,232,232,0.82);
      font-family: 'Exo 2', sans-serif;
      font-size: 0.9rem;
      line-height: 1.35;
      text-align: left;
    }
    .text-mode-index-entry.chapter {
      margin-top: 6px;
      color: #7eb8d4;
      font-family: 'Rajdhani', sans-serif;
      font-size: 1.05rem;
      font-weight: 500;
    }
    .text-mode-index-entry.section { padding-left: 32px; color: rgba(232,232,232,0.68); }
    .text-mode-index-entry:hover,
    .text-mode-index-entry:focus-visible { background: rgba(126,184,212,0.09); outline: none; }
    .text-mode-settings-kicker {
      margin: 0 0 0.2rem;
      color: rgba(126,184,212,0.7);
      font-family: 'Rajdhani', sans-serif;
      font-size: 0.7rem;
      letter-spacing: 0.2em;
      text-transform: uppercase;
    }
    .text-mode-settings-options {
      display: flex;
      flex-direction: column;
      max-height: calc(min(82svh, 760px) - 72px);
      overflow-y: auto;
      overscroll-behavior: contain;
      padding: 10px 18px 22px;
    }
    .text-mode-font-setting {
      margin: 0;
      padding: 18px 6px 20px;
      border: 0;
      border-bottom: 1px solid rgba(126,184,212,0.12);
    }
    .text-mode-font-setting legend {
      width: 100%;
      display: flex;
      flex-direction: column;
      gap: 5px;
      padding: 0;
    }
    .text-mode-font-setting legend strong,
    .text-mode-font-presets strong {
      color: rgba(232,232,232,0.9);
      font-family: 'Rajdhani', sans-serif;
      font-weight: 500;
      letter-spacing: 0.04em;
    }
    .text-mode-font-setting legend strong { font-size: 1.05rem; }
    .text-mode-font-setting legend small,
    .text-mode-font-setting > p,
    .text-mode-font-presets small {
      color: rgba(232,232,232,0.52);
      font-size: 0.74rem;
      line-height: 1.4;
    }
    .text-mode-font-presets {
      display: grid;
      grid-template-columns: repeat(3, minmax(0, 1fr));
      gap: 8px;
      margin-top: 14px;
    }
    .text-mode-font-presets label {
      position: relative;
      cursor: pointer;
    }
    .text-mode-font-presets input {
      position: absolute;
      opacity: 0;
      pointer-events: none;
    }
    .text-mode-font-presets label > span {
      min-height: 58px;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 3px;
      padding: 8px;
      border: 1px solid rgba(126,184,212,0.18);
      border-radius: 8px;
      background: rgba(126,184,212,0.04);
      text-align: center;
      transition: border-color 0.2s ease, background-color 0.2s ease;
    }
    .text-mode-font-presets input:checked + span {
      border-color: rgba(126,184,212,0.72);
      background: rgba(126,184,212,0.14);
    }
    .text-mode-font-presets input:focus-visible + span {
      outline: 2px solid #7eb8d4;
      outline-offset: 2px;
    }
    .text-mode-font-setting > p { margin: 10px 0 0; }
    .text-mode-setting-row {
      display: grid;
      grid-template-columns: minmax(0, 1fr) auto;
      align-items: center;
      gap: 24px;
      padding: 20px 6px;
      border-bottom: 1px solid rgba(126,184,212,0.12);
      cursor: pointer;
    }
    .text-mode-setting-row > span:first-child {
      display: flex;
      flex-direction: column;
      gap: 5px;
    }
    .text-mode-setting-row strong {
      color: rgba(232,232,232,0.9);
      font-family: 'Rajdhani', sans-serif;
      font-size: 1.05rem;
      font-weight: 500;
      letter-spacing: 0.04em;
    }
    .text-mode-setting-row small {
      max-width: 30rem;
      color: rgba(232,232,232,0.52);
      font-size: 0.78rem;
      line-height: 1.45;
    }
    .text-mode-settings-note {
      margin: 18px 6px 0;
      color: rgba(232,232,232,0.36);
      font-size: 0.72rem;
      line-height: 1.5;
    }
    body.text-mode-light-theme .text-mode-index-card,
    body.text-mode-light-theme .text-mode-settings-card {
      border-color: rgba(49,95,117,0.34);
      background: #faf7f0;
      box-shadow: 0 24px 80px rgba(38,32,24,0.3);
      color: #211e1a;
    }
    body.text-mode-light-theme .text-mode-index-head {
      border-bottom-color: rgba(49,95,117,0.18);
    }
    body.text-mode-light-theme #text-mode-index-close,
    body.text-mode-light-theme #text-mode-settings-close {
      color: #315f75;
      background: rgba(49,95,117,0.08);
    }
    body.text-mode-light-theme #text-mode-index-close:hover,
    body.text-mode-light-theme #text-mode-index-close:focus-visible,
    body.text-mode-light-theme #text-mode-settings-close:hover,
    body.text-mode-light-theme #text-mode-settings-close:focus-visible {
      color: #17313d;
      background: rgba(49,95,117,0.16);
    }
    body.text-mode-light-theme .text-mode-settings-kicker,
    body.text-mode-light-theme .text-mode-index-entry.chapter { color: #315f75; }
    body.text-mode-light-theme .text-mode-index-entry { color: #29251f; }
    body.text-mode-light-theme .text-mode-index-entry.section { color: #544c42; }
    body.text-mode-light-theme .text-mode-index-entry:hover,
    body.text-mode-light-theme .text-mode-index-entry:focus-visible {
      background: rgba(49,95,117,0.09);
    }
    body.text-mode-light-theme .text-mode-font-setting,
    body.text-mode-light-theme .text-mode-setting-row {
      border-bottom-color: rgba(49,95,117,0.16);
    }
    body.text-mode-light-theme .text-mode-font-setting legend strong,
    body.text-mode-light-theme .text-mode-font-presets strong,
    body.text-mode-light-theme .text-mode-setting-row strong { color: #29251f; }
    body.text-mode-light-theme .text-mode-font-setting legend small,
    body.text-mode-light-theme .text-mode-font-setting > p,
    body.text-mode-light-theme .text-mode-font-presets small,
    body.text-mode-light-theme .text-mode-setting-row small { color: #665d52; }
    body.text-mode-light-theme .text-mode-font-presets label > span {
      border-color: rgba(49,95,117,0.2);
      background: rgba(49,95,117,0.03);
    }
    body.text-mode-light-theme .text-mode-font-presets input:checked + span {
      border-color: rgba(49,95,117,0.68);
      background: rgba(49,95,117,0.12);
    }
    body.text-mode-light-theme #text-mode-settings .toggle-track {
      background: rgba(33,30,26,0.2);
    }
    body.text-mode-light-theme .text-mode-settings-note { color: #756b5f; }
    #text-mode-rotate-overlay {
      display: none;
      position: absolute;
      inset: 0;
      z-index: 80;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 1.5rem;
      padding: 2rem;
      background: #000;
      color: #fff;
      text-align: center;
    }
    #text-mode-rotate-overlay i { font-size: 3rem; color: #7eb8d4; }
    #text-mode-rotate-overlay p {
      max-width: 34rem;
      font-size: 1rem;
      line-height: 1.5;
      letter-spacing: 0.08em;
    }
    body.text-mode-active #vfx-clip {
      z-index: 44 !important;
    }
    body.text-mode-images-hidden #text-mode-screen { grid-template-columns: 0 1fr; }
    body.text-mode-images-hidden #text-mode-image-panel,
    body.text-mode-images-hidden #vfx-clip { display: none !important; }
    body.text-mode-images-hidden #text-mode-menu {
      right: calc(1.8vw + var(--safe-right));
    }
    body.text-mode-portrait-blocked #text-mode-rotate-overlay { display: flex; }
    body.text-mode-portrait-blocked #vfx-clip { display: none !important; }

    @media (max-width: 900px) and (orientation: portrait) {
      #text-mode-screen {
        --text-mode-body-min: 1.0625rem;
        --text-mode-body-fluid: 4.3vw;
        --text-mode-body-max: 1.2rem;
        grid-template-columns: 1fr;
        grid-template-rows: auto auto minmax(0, 1fr);
      }
      body.text-mode-font-comfortable #text-mode-screen {
        --text-mode-body-min: 1.18rem;
        --text-mode-body-fluid: 4.8vw;
        --text-mode-body-max: 1.35rem;
      }
      body.text-mode-font-large #text-mode-screen {
        --text-mode-body-min: 1.36rem;
        --text-mode-body-fluid: 5.6vw;
        --text-mode-body-max: 1.56rem;
      }
      #text-mode-menu {
        position: relative;
        right: auto;
        bottom: auto;
        grid-column: 1;
        grid-row: 1;
        justify-content: center;
        min-height: calc(54px + var(--safe-top));
        padding: var(--safe-top) 8px 0;
        border: 0;
        border-radius: 0;
        background: #030405;
        backdrop-filter: none;
      }
      #text-mode-image-panel {
        grid-column: 1;
        grid-row: 2;
        width: 100%;
        aspect-ratio: 16 / 9;
      }
      #text-mode-scroll {
        grid-column: 1;
        grid-row: 3;
      }
      #text-mode-flow {
        padding: 9svh clamp(20px, 7vw, 34px) 38svh;
      }
      .text-mode-section {
        font-size: clamp(1.5rem, 6.4vw, 1.9rem);
      }
      body.text-mode-images-hidden #text-mode-screen {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(0, 1fr);
      }
      body.text-mode-images-hidden #text-mode-scroll { grid-row: 2; }
      body.text-mode-images-hidden #text-mode-menu { right: auto; }
    }

    /* ── Portrait rotate overlay ───────────────────────────────────────────── */
    #rotate-overlay {
      display: none;
      position: fixed;
      inset: 0;
      z-index: 9999;
      background: #000;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 1.5rem;
      color: #fff;
    }
    #rotate-overlay i {
      font-size: 3rem;
      animation: rotate-hint 2s ease-in-out infinite;
    }
    @keyframes rotate-hint {
      0%   { transform: rotate(0deg);   opacity: 1; }
      40%  { transform: rotate(90deg);  opacity: 1; }
      60%  { transform: rotate(90deg);  opacity: 0.5; }
      100% { transform: rotate(90deg);  opacity: 1; }
    }
    #rotate-overlay p {
      font-family: 'Exo 2', sans-serif;
      font-size: 1rem;
      letter-spacing: 0.12em;
      opacity: 0.8;
      text-align: center;
      padding: 0 2rem;
    }

    #settings-panel {
      position: absolute;
      top: calc(1.8vh + var(--safe-top) + 48px);
      right: calc(1.8vw + var(--safe-right));
      z-index: 30;
      font-family: 'Exo 2', sans-serif;
      background: rgba(10, 12, 20, 0.95);
      border: 1px solid rgba(126, 184, 212, 0.3);
      border-radius: 6px;
      padding: 14px 18px;
      display: none;
      flex-direction: column;
      gap: 12px;
      min-width: 180px;
    }
    #settings-panel.open { display: flex; }

    .setting-row {
      display: grid;
      grid-template-columns: 18px 1fr auto;
      align-items: center;
      gap: 12px;
      font-family: inherit;
      font-size: 0.75rem;
      color: rgba(255,255,255,0.7);
      letter-spacing: 0.1em;
      text-transform: uppercase;
      text-align: left;
    }
    .setting-row.disabled {
      opacity: 0.42;
    }
    .setting-row.disabled .toggle {
      cursor: default;
      pointer-events: none;
    }
    .setting-warning {
      display: block;
      margin-top: 0.18rem;
      max-width: 145px;
      font-size: 0.54rem;
      line-height: 1.25;
      letter-spacing: 0.02em;
      text-transform: none;
      color: rgba(255,255,255,0.38);
    }
    .setting-row-icon {
      font-size: 0.82rem;
      color: rgba(126,184,212,0.75);
      text-align: center;
    }
    .setting-row-more {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 36px;
      height: 20px;
      font-size: 1.05rem;
      line-height: 1;
      color: rgba(255,255,255,0.5);
    }

    .toggle { position: relative; width: 36px; height: 20px; cursor: pointer; }
    .toggle input { opacity: 0; width: 0; height: 0; }
    .toggle-track {
      position: absolute; inset: 0;
      background: rgba(255,255,255,0.15);
      border-radius: 20px; transition: background 0.2s;
    }
    .toggle input:checked + .toggle-track { background: #7EB8D4; }
    .toggle-thumb {
      position: absolute; top: 3px; left: 3px;
      width: 14px; height: 14px;
      background: #fff; border-radius: 50%; transition: transform 0.2s;
    }
    .toggle input:checked ~ .toggle-thumb { transform: translateX(16px); }

    #volumes-btn {
      cursor: pointer; background: none; border: none; padding: 0;
      font-family: inherit; width: 100%;
    }

    #volumes-modal {
      position: absolute; inset: 0; z-index: 35;
      display: none; align-items: center; justify-content: center;
      background: rgba(0,0,0,0.75);
    }
    #volumes-modal.open { display: flex; }
    #volumes-card {
      font-family: 'Exo 2', sans-serif;
      background: rgba(10,12,20,0.97);
      border: 1px solid rgba(126,184,212,0.3);
      border-radius: 8px;
      padding: 24px;
      width: min(90vw, 360px);
      display: flex;
      flex-direction: column;
      gap: 16px;
    }
    #volumes-card h3 {
      font-family: inherit;
      font-size: 0.85rem;
      font-weight: 400;
      color: rgba(255,255,255,0.85);
      letter-spacing: 0.15em;
      text-transform: uppercase;
      margin: 0 0 4px;
    }
    .vol-row {
      display: flex; flex-wrap: wrap;
      align-items: center; justify-content: flex-start;
      gap: 6px 12px;
      font-family: inherit;
      font-size: 0.75rem;
      color: rgba(255,255,255,0.7);
      letter-spacing: 0.1em;
      text-transform: uppercase;
    }
    .vol-row-icon {
      flex: 0 0 auto;
      width: 18px;
      font-size: 0.82rem;
      color: rgba(126,184,212,0.75);
      text-align: center;
    }
    .vol-row > span {
      flex: 1 1 auto;
    }
    .vol-row input[type=range] {
      flex: 1 1 100%;
      width: 100%;
      height: 32px;
      margin: 0;
      accent-color: #7EB8D4;
      touch-action: pan-y;
    }
    .vol-row-hint {
      font-size: 0.6rem;
      letter-spacing: normal;
      text-transform: none;
      color: rgba(255,255,255,0.4);
    }
    .vol-row input[type=range]::-webkit-slider-thumb { width: 22px; height: 22px; }
    .vol-row input[type=range]::-moz-range-thumb { width: 22px; height: 22px; }
    #volumes-close {
      margin-top: 4px;
      font-family: inherit;
      font-size: 0.72rem;
      letter-spacing: 0.2em;
      text-transform: uppercase;
      color: rgba(126,184,212,0.5);
      cursor: pointer;
      background: none;
      border: 1px solid rgba(126,184,212,0.25);
      padding: 7px 18px;
      border-radius: 4px;
      transition: all 0.2s;
    }
    #volumes-close:hover { color: #7EB8D4; border-color: #7EB8D4; }

    /* Story-linked song credit: hugs its own content width (icon + text), collapses
       to a small square button — same shape/palette as .menu-nav-btn — after a few
       seconds idle, and re-expands on tap. See showSongCredit()/setSongCreditCollapsed()
       in app.js for the collapse timer and tap-to-expand handler. */
    #song-credit {
      position: absolute;
      top: calc(1.8vh + var(--safe-top) + 58px);
      right: calc(1.8vw + var(--safe-right));
      z-index: 22;
      max-width: min(70vw, 300px);
      display: flex;
      align-items: center;
      gap: 10px;
      padding: 9px 12px;
      color: rgba(232,245,251,0.88);
      background: linear-gradient(90deg, rgba(7,13,22,0.56), rgba(7,13,22,0.78));
      border: 1px solid rgba(126,184,212,0.24);
      border-radius: 6px;
      backdrop-filter: blur(8px);
      -webkit-backdrop-filter: blur(8px);
      cursor: pointer;
      pointer-events: none;
      opacity: 0;
      transform: translateX(calc(100% + 3vw));
      transition: opacity 0.45s ease, transform 0.62s cubic-bezier(0.22, 1, 0.36, 1),
                  width 0.32s cubic-bezier(0.22, 1, 0.36, 1), padding 0.32s cubic-bezier(0.22, 1, 0.36, 1),
                  border-radius 0.32s ease, background 0.32s ease;
    }
    #song-credit.visible { opacity: 1; transform: translateX(0); pointer-events: auto; }
    .song-credit-icon { flex: 0 0 auto; font-size: 0.8rem; color: rgba(126,184,212,0.72); }
    .song-credit-copy { min-width: 0; flex: 1; font-family: 'Exo 2', sans-serif; }
    .song-credit-line { overflow: hidden; white-space: nowrap; font-size: 0.72rem; letter-spacing: 0.055em; }
    .song-credit-line.artist { margin-top: 2px; color: rgba(232,232,232,0.48); font-size: 0.62rem; }
    .song-credit-line.overflowing > span { display: inline-block; padding-right: 34px; animation: song-credit-scroll 9s linear 1.2s infinite alternate; }
    @keyframes song-credit-scroll { to { transform: translateX(-38%); } }
    /* Collapsed: same 34x34 square-chevron shape as .menu-nav-btn (chapter switcher). */
    #song-credit.collapsed {
      width: 34px;
      min-width: 34px;
      max-width: 34px;
      height: 34px;
      padding: 0;
      gap: 0;
      justify-content: center;
      border-radius: 4px;
      background: rgba(7, 13, 22, 0.28);
    }
    #song-credit.collapsed .song-credit-copy { display: none; }
    #song-credit.collapsed .song-credit-icon { font-size: 0.78rem; color: var(--menu-accent-mid); }
    @media (max-width: 768px) {
      #song-credit { top: calc(1.8vh + var(--safe-top) + 50px); max-width: min(60vw, 260px); }
    }
    @media (prefers-reduced-motion: reduce) {
      #song-credit { transition: opacity 0.2s ease; transform: none; }
      .song-credit-line.overflowing > span { animation: none; text-overflow: ellipsis; max-width: 100%; overflow: hidden; }
    }

    /* ── End card ───────────────────────────────────────────── */
    #end-card {
      position: absolute;
      inset: 0; z-index: 25;
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      background: rgba(0,0,0,0.87);
      gap: 0rem;
      opacity: 0;
      transition: opacity 1.5s ease;
    }
    #end-card.show { display: flex; }
    #end-card.visible { opacity: 1; }
    #end-card p {
      font-family: 'Exo 2', sans-serif;
      font-size: clamp(0.65rem, 1.2vw, 0.85rem);
      color: rgba(232,232,232,0.5);
      letter-spacing: 0.18em;
      text-transform: uppercase;
    }
    #restart-btn {
      margin-top: 2rem;
      font-family: 'Exo 2', sans-serif;
      font-size: 0.72rem;
      letter-spacing: 0.2em;
      text-transform: uppercase;
      color: rgba(126,184,212,0.5);
      cursor: pointer;
      border: 1px solid rgba(126,184,212,0.25);
      padding: 7px 18px;
      border-radius: 4px;
      transition: all 0.2s;
    }
    #restart-btn:hover { color: #7EB8D4; border-color: #7EB8D4; }

    #next-chapter-btn {
      margin-top: 0.9rem;
      font-family: 'Exo 2', sans-serif;
      text-transform: uppercase;
      background: #7EB8D4;
      color: #000;
      cursor: pointer;
      border: none;
      padding: 14px 40px;
      border-radius: 4px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 0.2rem;
    }
    #next-chapter-btn strong {
      font-size: 0.8rem;
      font-weight: 700;
      letter-spacing: 0.22em;
      display: block;
    }
    #next-chapter-btn span {
      font-size: 0.7rem;
      font-weight: 400;
      letter-spacing: 0.1em;
      opacity: 0.7;
      display: block;
    }
    #next-chapter-btn[disabled] {
      background: rgba(126,184,212,0.2);
      color: rgba(232,232,232,0.55);
      cursor: default;
    }

    /* ── Dev Console ──────────────────────────────────────────── */
    #dev-console {
      display: none;
      position: fixed;
      left: 0; top: 50%;
      transform: translateY(-50%);
      width: 320px;
      max-height: 55vh;
      z-index: 9999;
      flex-direction: column;
      background: rgba(0, 0, 0, 0.55);
      backdrop-filter: blur(10px);
      -webkit-backdrop-filter: blur(10px);
      border-right:   1px solid rgba(0, 255, 80, 0.25);
      border-top:     1px solid rgba(0, 255, 80, 0.15);
      border-bottom:  1px solid rgba(0, 255, 80, 0.15);
      border-radius: 0 6px 6px 0;
      font-family: 'Courier New', monospace;
      font-size: 11px;
      color: #7FFF00;
      pointer-events: auto;
    }
    #dev-console.visible { display: flex; }
    #dev-console-header {
      padding: 7px 10px 6px;
      font-size: 10px;
      letter-spacing: 0.08em;
      color: #00FF50;
      border-bottom: 1px solid rgba(0, 255, 80, 0.2);
      flex-shrink: 0;
      user-select: none;
    }
    #dev-console-log {
      overflow-y: auto;
      padding: 5px 10px 6px;
      flex: 1;
      min-height: 0;
      line-height: 1.65;
    }
    #dev-console-log div { word-break: break-all; }
    #dev-console-log::-webkit-scrollbar { width: 3px; }
    #dev-console-log::-webkit-scrollbar-track { background: transparent; }
    #dev-console-log::-webkit-scrollbar-thumb { background: rgba(0, 255, 80, 0.3); border-radius: 2px; }
