/* ===================================================
   怪談コレクション — Main Stylesheet
   Horror Sound Novel Game
   =================================================== */

/* ---------- CSS Custom Properties ---------- */
:root {
  --color-bg:          #07060b;
  --color-panel:       rgba(4, 3, 8, 0.92);
  --color-panel-light: rgba(10, 8, 15, 0.85);
  --color-text:        #cfc8be;
  --color-text-dim:    #7a7068;
  --color-text-title:  #e8ddd0;
  --color-accent:      #7a1515;
  --color-accent-glow: rgba(122, 21, 21, 0.4);
  --color-accent-dim:  #4a0d0d;
  --color-border:      rgba(120, 90, 70, 0.25);
  --color-border-glow: rgba(180, 120, 80, 0.15);
  --color-white:       #e8e0d8;
  --color-danger:      #cc2222;

  --font-serif: 'Shippori Mincho', 'Yu Mincho', 'YuMincho', '游明朝', 'ヒラギノ明朝 Pro', serif;
  --font-sans:  'Noto Sans JP', 'Yu Gothic', 'YuGothic', 'ヒラギノ角ゴ Pro', sans-serif;

  --text-speed: 45ms;
  --transition: 0.35s ease;
}

/* ---------- Reset & Base ---------- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-serif);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  cursor: pointer;
  font-family: inherit;
  border: none;
  background: none;
  outline: none;
}

button:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

/* ---------- Screen Management ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  opacity: 0;
  transition: opacity 0.6s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
}

.screen.fading-in {
  opacity: 0;
  animation: screenFadeIn 0.8s ease forwards;
}

@keyframes screenFadeIn {
  to { opacity: 1; }
}

/* ---------- CRT Scanlines ---------- */
.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 200;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.12) 3px,
    rgba(0, 0, 0, 0.12) 4px
  );
}

/* ===================================================
   TITLE SCREEN
   =================================================== */
#screen-title {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #0d0a18 0%, #060408 60%, #020206 100%);
}

.title-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 50%, rgba(80, 10, 10, 0.07) 0%, transparent 70%),
    radial-gradient(ellipse 30% 30% at 30% 70%, rgba(30, 10, 60, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 30% 30% at 70% 20%, rgba(10, 5, 40, 0.08) 0%, transparent 60%);
  animation: titlePulse 8s ease-in-out infinite;
}

@keyframes titlePulse {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1; }
}

.title-content {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  padding: 2rem;
  text-align: center;
}

.title-logo {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.2rem;
}

.title-kanji {
  font-size: clamp(5rem, 14vw, 9rem);
  font-weight: 700;
  color: var(--color-text-title);
  letter-spacing: 0.1em;
  line-height: 1;
  text-shadow:
    0 0 30px rgba(180, 80, 80, 0.5),
    0 0 60px rgba(140, 40, 40, 0.3),
    0 2px 4px rgba(0, 0, 0, 0.9);
  animation: kanjiFlicker 12s ease-in-out infinite;
}

@keyframes kanjiFlicker {
  0%, 88%, 92%, 96%, 100% { opacity: 1; }
  89%   { opacity: 0.5; }
  90%   { opacity: 1; }
  93%   { opacity: 0.3; }
  94%   { opacity: 0.9; }
  97%   { opacity: 0.6; }
}

.title-subtitle-text {
  font-family: var(--font-serif);
  font-size: clamp(1.2rem, 3.5vw, 1.8rem);
  letter-spacing: 0.5em;
  color: var(--color-text-dim);
  text-transform: none;
}

.title-flavor {
  font-family: var(--font-serif);
  font-size: clamp(0.7rem, 1.8vw, 0.9rem);
  color: var(--color-text-dim);
  letter-spacing: 0.1em;
  opacity: 0.8;
}

.title-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin-top: 0.5rem;
}

.btn-main {
  padding: 0.85rem 3.5rem;
  font-family: var(--font-serif);
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  letter-spacing: 0.5em;
  color: var(--color-text-title);
  background: transparent;
  border: 1px solid rgba(180, 120, 90, 0.4);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.btn-main::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(120, 30, 30, 0.15), transparent);
  transform: translateX(-100%);
  transition: transform 0.4s ease;
}

.btn-main:hover {
  color: var(--color-white);
  border-color: rgba(200, 100, 80, 0.7);
  box-shadow: 0 0 20px rgba(160, 40, 40, 0.3);
  text-shadow: 0 0 10px rgba(255, 150, 100, 0.4);
}

.btn-main:hover::before {
  transform: translateX(100%);
}

.btn-sub {
  padding: 0.6rem 2rem;
  font-family: var(--font-serif);
  font-size: clamp(0.8rem, 2vw, 0.95rem);
  letter-spacing: 0.3em;
  color: var(--color-text-dim);
  background: transparent;
  border: 1px solid var(--color-border);
  transition: all 0.3s ease;
}

.btn-sub:hover {
  color: var(--color-text);
  border-color: rgba(150, 100, 80, 0.5);
}

.title-version {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  color: rgba(100, 90, 85, 0.5);
  letter-spacing: 0.1em;
}

/* ===================================================
   STORY SELECT SCREEN
   =================================================== */
#screen-select {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--color-bg);
}

.select-wrapper {
  position: relative;
  z-index: 10;
  width: min(600px, 90vw);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  padding: 2rem;
  max-height: 90vh;
}

.select-header {
  text-align: center;
}

.select-title {
  font-family: var(--font-serif);
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  font-weight: 400;
  letter-spacing: 0.5em;
  color: var(--color-text-dim);
  margin-bottom: 0.4rem;
}

.select-desc {
  font-family: var(--font-sans);
  font-size: 0.78rem;
  color: rgba(120, 100, 90, 0.6);
  letter-spacing: 0.05em;
}

.story-list {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  overflow-y: auto;
  max-height: 60vh;
  padding: 0.2rem 0.2rem 1.2rem;
  /* show scrollbar on webkit so users know more content exists */
  scrollbar-width: thin;
  scrollbar-color: rgba(180, 80, 60, 0.4) transparent;
}

.story-list::-webkit-scrollbar {
  width: 4px;
}

.story-list::-webkit-scrollbar-track {
  background: transparent;
}

.story-list::-webkit-scrollbar-thumb {
  background: rgba(180, 80, 60, 0.35);
  border-radius: 2px;
}

/* Story item button (generated in JS) */
.story-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 1rem 1.4rem;
  text-align: left;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

.story-item::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-accent);
  transform: scaleY(0);
  transition: transform 0.3s ease;
}

.story-item:hover {
  border-color: rgba(180, 100, 80, 0.5);
  background: rgba(15, 8, 12, 0.95);
}

.story-item:hover::before {
  transform: scaleY(1);
}

.story-item.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.story-item .story-number {
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--color-accent);
}

.story-item .story-title {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 2.5vw, 1.15rem);
  color: var(--color-text-title);
  letter-spacing: 0.1em;
}

.story-item .story-subtitle {
  font-family: var(--font-serif);
  font-size: 0.8rem;
  color: var(--color-text-dim);
  letter-spacing: 0.05em;
}

.select-footer {
  display: flex;
  justify-content: center;
  padding-top: 0.5rem;
}

/* ===================================================
   GAME SCREEN — BACKGROUND LAYERS
   =================================================== */
#screen-game {
  display: none; /* override when active */
  flex-direction: column;
}

#screen-game.active {
  display: flex;
}

.bg-layer {
  background-size:     cover;
  background-position: center;
  position: absolute;
  inset: 0;
  transition: background 1.2s ease;
  z-index: 0;
}

.effect-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  background: transparent;
  transition: opacity 0.3s ease;
}

/* ===================================================
   CSS Scene Backgrounds
   (used when no image file is available)
   =================================================== */

/* Night school exterior — dusk, just past sunset */
.bg-dusk_school {
  background:
    radial-gradient(ellipse 80% 30% at 50% 100%, rgba(40, 15, 5, 0.6) 0%, transparent 70%),
    radial-gradient(ellipse 50% 50% at 30% 60%, rgba(10, 5, 20, 0.4) 0%, transparent 60%),
    linear-gradient(to bottom,
      #020308 0%,
      #040618 25%,
      #060412 55%,
      #0a0508 80%,
      #0d0608 100%
    );
}

/* Dark school entrance / lobby */
.bg-school_entrance {
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 55px,
      rgba(0, 0, 0, 0.25) 55px,
      rgba(0, 0, 0, 0.25) 57px
    ),
    linear-gradient(to bottom,
      #050508 0%,
      #090810 60%,
      #0a0808 100%
    );
}

/* Long corridor — deep vanishing point in center */
.bg-corridor {
  background:
    radial-gradient(ellipse 10% 20% at 50% 42%, rgba(25, 18, 12, 0.6) 0%, transparent 100%),
    radial-gradient(ellipse 30% 60% at 50% 42%, rgba(15, 10, 8, 0.5) 0%, transparent 100%),
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 70px,
      rgba(0, 0, 0, 0.2) 70px,
      rgba(0, 0, 0, 0.2) 72px
    ),
    linear-gradient(to bottom,
      #040406 0%,
      #08080e 40%,
      #0a0808 100%
    );
}

/* Classroom — desk grid suggestion */
.bg-classroom {
  background:
    repeating-linear-gradient(
      0deg,
      transparent 0px,
      transparent 38px,
      rgba(5, 5, 15, 0.45) 38px,
      rgba(5, 5, 15, 0.45) 40px
    ),
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 55px,
      rgba(5, 5, 15, 0.2) 55px,
      rgba(5, 5, 15, 0.2) 57px
    ),
    linear-gradient(to bottom,
      #040510 0%,
      #06060f 50%,
      #090608 100%
    );
}

/* Corridor with window — lighter area simulating moonlit window */
.bg-corridor_window {
  background:
    radial-gradient(ellipse 12% 20% at 72% 32%, rgba(8, 12, 25, 0.9) 0%, rgba(5, 8, 18, 0.5) 50%, transparent 100%),
    radial-gradient(ellipse 8% 30% at 50% 42%, rgba(20, 15, 10, 0.5) 0%, transparent 100%),
    repeating-linear-gradient(
      90deg,
      transparent 0px,
      transparent 70px,
      rgba(0, 0, 0, 0.2) 70px,
      rgba(0, 0, 0, 0.2) 72px
    ),
    linear-gradient(to bottom,
      #040406 0%,
      #08080e 40%,
      #0a0808 100%
    );
}

/* School gate at night — open sky */
.bg-school_gate_night {
  background:
    radial-gradient(ellipse 40% 25% at 50% 0%, rgba(5, 5, 18, 0.7) 0%, transparent 100%),
    radial-gradient(ellipse 80% 40% at 50% 100%, rgba(10, 5, 5, 0.6) 0%, transparent 60%),
    linear-gradient(to bottom,
      #02030c 0%,
      #040810 35%,
      #060508 75%,
      #080508 100%
    );
}

/* ── Chapter 2 backgrounds ─────────────────────────────────────────────── */

/* Daytime/evening living room — warm amber tones */
.bg-living_evening {
  background:
    radial-gradient(ellipse 60% 40% at 80% 30%, rgba(80, 55, 10, 0.4) 0%, transparent 70%),
    linear-gradient(to bottom,
      #1a1610 0%,
      #1e1c14 40%,
      #16140e 100%
    );
}

/* Night living room — deep shadow, single lamp */
.bg-living_night {
  background:
    radial-gradient(ellipse 35% 50% at 85% 55%, rgba(70, 48, 8, 0.5) 0%, transparent 65%),
    linear-gradient(to bottom,
      #0e0c08 0%,
      #121008 50%,
      #0a0806 100%
    );
}

/* Interior hallway — narrow, dark, staircase at end */
.bg-hallway {
  background:
    radial-gradient(ellipse 15% 30% at 50% 60%, rgba(24, 20, 32, 0.6) 0%, transparent 100%),
    linear-gradient(to bottom,
      #0e0e14 0%,
      #121018 50%,
      #0a0a10 100%
    );
}

/* Looking up the staircase — darkness above */
.bg-stairs_up {
  background:
    radial-gradient(ellipse 30% 50% at 50% 10%, rgba(6, 6, 14, 0.9) 0%, transparent 70%),
    linear-gradient(to bottom,
      #040410 0%,
      #0c0c16 50%,
      #161418 100%
    );
}

/* 2nd-floor hallway — extremely dark */
.bg-upstairs {
  background:
    linear-gradient(to bottom,
      #060610 0%,
      #080812 50%,
      #0a0a14 100%
    );
}

/* Child's bedroom — slight moonlight, lavender-grey */
.bg-child_room {
  background:
    radial-gradient(ellipse 40% 60% at 75% 40%, rgba(30, 28, 48, 0.5) 0%, transparent 70%),
    linear-gradient(to bottom,
      #101018 0%,
      #141220 50%,
      #0e0e18 100%
    );
}

/* Japanese entrance (genkan) — dark, closed door */
.bg-entrance_hall {
  background:
    radial-gradient(ellipse 30% 40% at 50% 35%, rgba(20, 16, 12, 0.6) 0%, transparent 70%),
    linear-gradient(to bottom,
      #0e0c0a 0%,
      #121008 60%,
      #0a0806 100%
    );
}

/* TV static / noise — cold blue-grey glow */
.bg-tv_noise {
  background:
    radial-gradient(ellipse 70% 60% at 50% 45%, rgba(40, 40, 70, 0.7) 0%, transparent 80%),
    linear-gradient(to bottom,
      #060610 0%,
      #08080e 50%,
      #060608 100%
    );
}

/* Pure black — silence */
.bg-black {
  background: #000;
}

/* ── Episode 4 background gradients (CSS fallback while SVG loads) ───────── */

/* Abandoned house exterior — moonlit night, dark silhouette */
.bg-ruin_exterior {
  background:
    radial-gradient(ellipse 25% 30% at 72% 18%, rgba(180, 170, 120, 0.35) 0%, transparent 70%),
    linear-gradient(to bottom,
      #060810 0%,
      #0a0c18 30%,
      #080c14 55%,
      #0e1018 70%,
      #0a0c10 100%
    );
}

/* Dark genkan entrance — rotting floor, shoe silhouettes */
.bg-ruin_entrance {
  background:
    radial-gradient(ellipse 20% 25% at 50% 80%, rgba(20, 16, 10, 0.6) 0%, transparent 70%),
    linear-gradient(to bottom,
      #0a0808 0%,
      #0e0c0a 40%,
      #100e0c 70%,
      #0c0a08 100%
    );
}

/* Long dark corridor — peeling wallpaper, moonlight from end */
.bg-ruin_corridor {
  background:
    radial-gradient(ellipse 15% 30% at 50% 55%, rgba(50, 40, 28, 0.5) 0%, transparent 70%),
    linear-gradient(to bottom,
      #080808 0%,
      #0e0c0c 40%,
      #100e0c 70%,
      #0c0a08 100%
    );
}

/* Tatami room — broken furniture, single candle */
.bg-ruin_tatami {
  background:
    radial-gradient(ellipse 20% 20% at 50% 55%, rgba(80, 55, 12, 0.55) 0%, transparent 65%),
    linear-gradient(to bottom,
      #0a0806 0%,
      #100e08 50%,
      #0c0a06 100%
    );
}

/* Child's room — toys, moonlight, wrong atmosphere */
.bg-ruin_child_room {
  background:
    radial-gradient(ellipse 30% 35% at 68% 38%, rgba(28, 24, 40, 0.5) 0%, transparent 70%),
    linear-gradient(to bottom,
      #080810 0%,
      #0c0c18 45%,
      #0a0a14 100%
    );
}

/* Antique mirror — cracked, wrong reflection */
.bg-ruin_mirror {
  background:
    radial-gradient(ellipse 35% 55% at 50% 50%, rgba(20, 18, 28, 0.7) 0%, transparent 80%),
    linear-gradient(to bottom,
      #060608 0%,
      #0a0a10 50%,
      #060608 100%
    );
}

/* Lived-in room — warmth, food laid out, occupied */
.bg-ruin_lived_in {
  background:
    radial-gradient(ellipse 45% 40% at 50% 55%, rgba(70, 50, 12, 0.65) 0%, transparent 75%),
    linear-gradient(to bottom,
      #0c0a06 0%,
      #141008 45%,
      #100e06 100%
    );
}

/* ── Episode 5 background gradients (CSS fallback while SVG loads) ───────── */

/* Security room — monitor banks, cold blue glow */
.bg-security_room {
  background:
    radial-gradient(ellipse 60% 50% at 50% 40%, rgba(16, 40, 64, 0.75) 0%, transparent 70%),
    linear-gradient(to bottom,
      #06070a 0%,
      #080a0e 50%,
      #060708 100%
    );
}

/* Night corridor — dark office hallway, emergency red */
.bg-night_corridor {
  background:
    radial-gradient(ellipse 20% 30% at 50% 35%, rgba(60, 20, 20, 0.55) 0%, transparent 60%),
    radial-gradient(ellipse 30% 20% at 50% 60%, rgba(50, 60, 80, 0.22) 0%, transparent 60%),
    linear-gradient(to bottom,
      #080a10 0%,
      #0a0c12 50%,
      #080a0c 100%
    );
}

/* Elevator hall — stainless steel, cold metallic */
.bg-elevator_hall {
  background:
    radial-gradient(ellipse 25% 20% at 36% 20%, rgba(80, 60, 20, 0.5) 0%, transparent 60%),
    linear-gradient(to bottom,
      #0a0c12 0%,
      #0c0e16 40%,
      #090b0f 100%
    );
}

/* Emergency stairs — concrete, EXIT green above */
.bg-emergency_stairs {
  background:
    radial-gradient(ellipse 30% 25% at 50% 20%, rgba(40, 16, 16, 0.55) 0%, transparent 55%),
    radial-gradient(ellipse 40% 35% at 50% 42%, rgba(50, 58, 70, 0.3) 0%, transparent 65%),
    linear-gradient(to bottom,
      #0e1014 0%,
      #0c0e12 55%,
      #0a0c10 100%
    );
}

/* Empty lobby — night sky through glass facade */
.bg-empty_lobby {
  background:
    radial-gradient(ellipse 60% 40% at 50% 20%, rgba(16, 32, 48, 0.4) 0%, transparent 70%),
    linear-gradient(to bottom,
      #080a12 0%,
      #0a0c14 40%,
      #080a10 100%
    );
}

/* Machine room — server racks, amber warning glow */
.bg-machine_room {
  background:
    radial-gradient(ellipse 40% 50% at 70% 50%, rgba(30, 20, 10, 0.45) 0%, transparent 65%),
    radial-gradient(ellipse 30% 30% at 30% 30%, rgba(10, 24, 36, 0.5) 0%, transparent 60%),
    linear-gradient(to bottom,
      #060708 0%,
      #070809 50%,
      #050607 100%
    );
}

/* Monitor static — extreme darkness, cold screen glow */
.bg-monitor_static {
  background:
    radial-gradient(ellipse 55% 55% at 50% 50%, rgba(24, 36, 54, 0.7) 0%, transparent 65%),
    linear-gradient(to bottom,
      #050608 0%,
      #060709 50%,
      #040507 100%
    );
}

/* ── Episode 3 background gradients (CSS fallback while SVG loads) ───────── */

/* Sunny beach — bright sky, blue ocean, warm sand */
.bg-beach_day {
  background:
    radial-gradient(ellipse 50% 30% at 50% 18%, rgba(255, 230, 120, 0.55) 0%, transparent 70%),
    linear-gradient(to bottom,
      #4a7ec0 0%,
      #7aaad8 30%,
      #1e5090 42%,
      #2464a8 55%,
      #c8a850 62%,
      #b89040 100%
    );
}

/* Wave break / shallows — transparent water, wet sand */
.bg-beach_shore {
  background:
    radial-gradient(ellipse 40% 20% at 50% 42%, rgba(100, 180, 220, 0.35) 0%, transparent 70%),
    linear-gradient(to bottom,
      #5888c8 0%,
      #7aaad8 22%,
      #2060a0 32%,
      #4080b8 48%,
      #9a8048 58%,
      #c8a850 100%
    );
}

/* Beach house — warm wooden interior, bright opening to outside */
.bg-beach_house {
  background:
    radial-gradient(ellipse 30% 40% at 50% 45%, rgba(70, 136, 192, 0.4) 0%, transparent 65%),
    linear-gradient(to bottom,
      #3a2818 0%,
      #4a3220 25%,
      #3a2a18 60%,
      #2a1e10 100%
    );
}

/* Looking out to sea — large sky, horizon, deep ocean */
.bg-ocean_view {
  background:
    radial-gradient(ellipse 60% 30% at 65% 35%, rgba(255, 220, 100, 0.25) 0%, transparent 70%),
    linear-gradient(to bottom,
      #3a6ab8 0%,
      #7aaad8 38%,
      #90b8d8 52%,
      #1e3878 58%,
      #162860 100%
    );
}

/* Underwater horror — near-black, deep cold, shadowed figure */
.bg-ocean_shadow {
  background:
    radial-gradient(ellipse 40% 25% at 50% 5%, rgba(26, 40, 64, 0.7) 0%, transparent 80%),
    radial-gradient(ellipse 20% 40% at 50% 60%, rgba(8, 12, 20, 0.9) 0%, transparent 80%),
    linear-gradient(to bottom,
      #081428 0%,
      #060e1e 35%,
      #040810 70%,
      #020408 100%
    );
}

/* Sunset beach — orange/red sky, dark ocean */
.bg-beach_evening {
  background:
    radial-gradient(ellipse 40% 25% at 52% 52%, rgba(248, 140, 40, 0.5) 0%, transparent 75%),
    linear-gradient(to bottom,
      #280818 0%,
      #801828 20%,
      #d04018 35%,
      #f09030 48%,
      #f8c040 55%,
      #200828 62%,
      #181840 100%
    );
}

/* Empty deserted beach — same shore, abandoned, eerie */
.bg-beach_empty {
  background:
    radial-gradient(ellipse 50% 20% at 50% 38%, rgba(80, 100, 140, 0.3) 0%, transparent 70%),
    linear-gradient(to bottom,
      #3a607a 0%,
      #5878a8 28%,
      #182860 42%,
      #203060 55%,
      #b09040 62%,
      #988030 100%
    );
}

/* ── Episode 6 background gradients ─────────────────────────────────────── */

/* Streaming room with red LED wash — equipment and camera in darkness */
.bg-stream_room_red {
  background:
    radial-gradient(ellipse 35% 40% at 18% 62%, rgba(80, 8, 8, 0.50) 0%, transparent 65%),
    radial-gradient(ellipse 30% 28% at 62% 42%, rgba(20, 18, 32, 0.55) 0%, transparent 60%),
    linear-gradient(to bottom,
      #0a0408 0%,
      #080306 50%,
      #060204 100%
    );
}

/* Stream monitor close-up — cold screen glow fills frame */
.bg-stream_monitor {
  background:
    radial-gradient(ellipse 55% 50% at 50% 42%, rgba(18, 16, 30, 0.72) 0%, transparent 68%),
    radial-gradient(ellipse 20% 15% at 50% 60%, rgba(30, 8, 8, 0.20) 0%, transparent 55%),
    linear-gradient(to bottom,
      #060408 0%,
      #07050a 50%,
      #050306 100%
    );
}

/* Stream offline — black with faint red standby glow */
.bg-stream_offline {
  background:
    radial-gradient(ellipse 25% 20% at 50% 50%, rgba(50, 4, 4, 0.30) 0%, transparent 60%),
    linear-gradient(to bottom,
      #040204 0%,
      #050304 50%,
      #040204 100%
    );
}

/* Hospital ward — cool blue-green fluorescent wash, clinical */
.bg-hospital_ward {
  background:
    radial-gradient(ellipse 70% 40% at 50% 30%, rgba(20, 48, 56, 0.60) 0%, transparent 70%),
    radial-gradient(ellipse 30% 20% at 50% 80%, rgba(10, 30, 40, 0.35) 0%, transparent 60%),
    linear-gradient(to bottom,
      #07090e 0%,
      #080b10 45%,
      #070a0d 100%
    );
}

/* Hospital corridor — cold green-tinted fluorescent hallway */
.bg-hospital_corridor {
  background:
    radial-gradient(ellipse 18% 35% at 50% 30%, rgba(30, 60, 50, 0.50) 0%, transparent 60%),
    radial-gradient(ellipse 25% 18% at 50% 65%, rgba(15, 40, 35, 0.25) 0%, transparent 55%),
    linear-gradient(to bottom,
      #080b0a 0%,
      #090c0b 50%,
      #070a09 100%
    );
}

/* Hospital room — single patient room, pale diffuse glow */
.bg-hospital_room {
  background:
    radial-gradient(ellipse 55% 45% at 50% 38%, rgba(22, 44, 48, 0.65) 0%, transparent 68%),
    linear-gradient(to bottom,
      #060809 0%,
      #07090b 50%,
      #060708 100%
    );
}

/* Nurse station — monitor glow, slightly warmer than ward */
.bg-nurse_station {
  background:
    radial-gradient(ellipse 50% 35% at 50% 35%, rgba(14, 36, 54, 0.70) 0%, transparent 65%),
    radial-gradient(ellipse 25% 20% at 75% 55%, rgba(10, 28, 44, 0.40) 0%, transparent 55%),
    linear-gradient(to bottom,
      #060809 0%,
      #07090c 45%,
      #060709 100%
    );
}

/* Doctor office — warmer desk lamp glow, but still unsettling */
.bg-doctor_office {
  background:
    radial-gradient(ellipse 40% 40% at 38% 42%, rgba(28, 24, 12, 0.55) 0%, transparent 65%),
    radial-gradient(ellipse 30% 25% at 70% 30%, rgba(10, 20, 30, 0.40) 0%, transparent 55%),
    linear-gradient(to bottom,
      #08080a 0%,
      #09090c 50%,
      #07070a 100%
    );
}

/* ===================================================
   GAME UI
   =================================================== */
.game-ui {
  position: relative;
  z-index: 100;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  padding: 0 1rem 5.5rem;
  pointer-events: none; /* children re-enable as needed */
}

/* Story chapter/title banner */
.story-header {
  position: absolute;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  pointer-events: none;
}

.story-chapter {
  display: block;
  font-family: var(--font-sans);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  color: var(--color-text-dim);
  margin-bottom: 0.2rem;
}

.story-title-display {
  font-family: var(--font-serif);
  font-size: clamp(0.9rem, 2.5vw, 1.1rem);
  letter-spacing: 0.2em;
  color: var(--color-text-dim);
}

/* ===================================================
   TEXT BOX
   =================================================== */
.text-area {
  width: min(820px, 100%);
  pointer-events: all;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.text-box {
  position: relative;
  padding: 1.4rem 1.8rem 1.6rem;
  background: var(--color-panel);
  border: 1px solid var(--color-border);
  border-top: 1px solid var(--color-border-glow);
  box-shadow:
    0 -4px 20px rgba(0, 0, 0, 0.8),
    inset 0 1px 0 rgba(180, 140, 100, 0.05);
  min-height: 8rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.text-content {
  font-family: var(--font-serif);
  font-size: clamp(1rem, 2.4vw, 1.15rem);
  line-height: 2;
  color: var(--color-text);
  letter-spacing: 0.08em;
  white-space: pre-wrap;
  word-break: break-all; /* Japanese line-wrap */
  min-height: 3.5em;
}

/* Blinking next-page indicator */
.next-indicator {
  display: block;
  text-align: right;
  font-size: 0.75rem;
  color: var(--color-text-dim);
  opacity: 0;
  transition: opacity 0.3s ease;
  animation: blink 1.2s ease-in-out infinite;
  padding-right: 0.2rem;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.1; }
}

/* ===================================================
   CHOICE AREA
   =================================================== */
.choice-area {
  position: absolute;
  /* Sit in the image area — centred between top of screen and the text box */
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(640px, 90%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.8rem 1rem;
  pointer-events: all;
}

.choice-buttons {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  width: 100%;
}

.choice-btn {
  padding: 0.85rem 1.5rem;
  font-family: var(--font-serif);
  font-size: clamp(0.95rem, 2.2vw, 1.05rem);
  letter-spacing: 0.1em;
  color: var(--color-text);
  background: rgba(4, 3, 8, 0.92);
  border: 1px solid var(--color-border-glow);
  text-align: center;
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
  animation: choiceAppear 0.3s ease backwards;
  box-shadow: 0 2px 16px rgba(0, 0, 0, 0.7);
}

.choice-btn:nth-child(2) { animation-delay: 0.1s; }
.choice-btn:nth-child(3) { animation-delay: 0.2s; }

@keyframes choiceAppear {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.choice-btn::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(100, 20, 20, 0.12), transparent);
  transform: translateX(-100%);
  transition: transform 0.4s ease;
}

.choice-btn:hover {
  color: var(--color-white);
  border-color: rgba(160, 80, 60, 0.6);
  background: rgba(20, 8, 10, 0.97);
  box-shadow: 0 0 12px rgba(120, 20, 20, 0.2);
}

.choice-btn:hover::before {
  transform: translateX(100%);
}

.choice-btn:active {
  transform: scale(0.98);
}

/* ===================================================
   GAME MENU BAR (top-right)
   =================================================== */
.game-menu {
  position: absolute;
  top: 0.8rem;
  right: 0.8rem;
  z-index: 150;
  display: flex;
  gap: 0.4rem;
}

.menu-btn {
  font-family: var(--font-sans);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: rgba(130, 110, 100, 0.7);
  background: rgba(5, 3, 8, 0.6);
  border: 1px solid rgba(80, 60, 50, 0.3);
  padding: 0.3rem 0.6rem;
  transition: all 0.2s ease;
}

.menu-btn:hover {
  color: var(--color-text);
  border-color: rgba(150, 100, 80, 0.5);
}

.menu-btn.active {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* ===================================================
   MENU OVERLAY (pause menu)
   =================================================== */
.menu-overlay {
  position: absolute;
  inset: 0;
  z-index: 300;
  background: rgba(2, 1, 4, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}

.menu-panel {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  padding: 2rem 2.5rem;
  background: rgba(6, 4, 10, 0.98);
  border: 1px solid var(--color-border);
  min-width: 220px;
  text-align: center;
}

.menu-title {
  font-family: var(--font-serif);
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.4em;
  color: var(--color-text-dim);
  margin-bottom: 0.4rem;
}

.menu-item-btn {
  font-family: var(--font-serif);
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  color: var(--color-text);
  background: transparent;
  border: 1px solid var(--color-border);
  padding: 0.6rem 1rem;
  transition: all 0.2s ease;
}

.menu-item-btn:hover {
  color: var(--color-white);
  border-color: rgba(180, 100, 80, 0.5);
  background: rgba(15, 5, 8, 0.8);
}

.menu-item-btn.secondary {
  color: var(--color-text-dim);
  border-color: transparent;
  font-size: 0.82rem;
}

.menu-divider {
  height: 1px;
  background: var(--color-border);
  margin: 0.3rem 0;
}

/* ===================================================
   ENDING SCREEN
   =================================================== */
.ending-screen {
  position: absolute;
  inset: 0;
  z-index: 400;
  background: rgba(0, 0, 0, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: endingFadeIn 2s ease forwards;
}

@keyframes endingFadeIn {
  from { background: rgba(0, 0, 0, 0); }
  to   { background: rgba(0, 0, 0, 0.96); }
}

.ending-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
  padding: 2rem;
  text-align: center;
  animation: endingContentAppear 1.5s ease 0.8s backwards;
}

@keyframes endingContentAppear {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ending-decoration {
  font-family: var(--font-serif);
  color: rgba(100, 70, 60, 0.5);
  letter-spacing: 0.1em;
  font-size: 0.85rem;
}

.ending-label {
  font-family: var(--font-serif);
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  letter-spacing: 0.3em;
  color: var(--color-text);
  padding: 0.3rem 0;
}

/* Ending type color variants */
.ending-screen[data-ending-type="bad"]       .ending-label { color: #c08060; }
.ending-screen[data-ending-type="worst"]     .ending-label { color: #cc3333; }
.ending-screen[data-ending-type="ambiguous"] .ending-label { color: #9090c0; }

.ending-buttons {
  display: flex;
  gap: 1rem;
  margin-top: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-ending {
  padding: 0.6rem 2rem;
  font-family: var(--font-serif);
  font-size: 0.9rem;
  letter-spacing: 0.2em;
  color: var(--color-text-dim);
  background: transparent;
  border: 1px solid var(--color-border);
  transition: all 0.3s ease;
}

.btn-ending:hover {
  color: var(--color-white);
  border-color: rgba(180, 100, 80, 0.6);
}

/* ===================================================
   SAVE NOTIFICATION TOAST
   =================================================== */
.save-notification {
  position: absolute;
  bottom: 5.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  color: var(--color-text-dim);
  background: rgba(5, 3, 8, 0.95);
  border: 1px solid var(--color-border);
  padding: 0.4rem 1.2rem;
  white-space: nowrap;
  animation: toastShow 0.3s ease;
}

@keyframes toastShow {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ===================================================
   VISUAL EFFECT CLASSES
   =================================================== */

/* Screen shake */
@keyframes shake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  10%  { transform: translate(-4px,  2px) rotate(-0.3deg); }
  20%  { transform: translate( 5px, -2px) rotate( 0.2deg); }
  30%  { transform: translate(-3px,  3px) rotate(-0.2deg); }
  40%  { transform: translate( 4px, -1px) rotate( 0.1deg); }
  50%  { transform: translate(-2px,  2px) rotate(-0.1deg); }
  60%  { transform: translate( 3px, -2px) rotate( 0.2deg); }
  70%  { transform: translate(-2px,  1px) rotate(-0.1deg); }
  80%  { transform: translate( 2px, -1px) rotate( 0.1deg); }
  90%  { transform: translate(-1px,  0px); }
}

.screen-shake {
  animation: shake 0.55s ease-in-out;
}

/* Static/noise overlay */
@keyframes staticAnim {
  0%   { background-position: 0 0; }
  25%  { background-position: 30px 20px; }
  50%  { background-position: -20px 40px; }
  75%  { background-position: 40px -10px; }
  100% { background-position: 0 0; }
}

.effect-static {
  opacity: 0.15 !important;
  background:
    repeating-linear-gradient(
      0deg,
      rgba(255,255,255,0.03) 0px,
      rgba(255,255,255,0.03) 1px,
      transparent 1px,
      transparent 3px
    ),
    repeating-linear-gradient(
      90deg,
      rgba(255,255,255,0.02) 0px,
      rgba(255,255,255,0.02) 1px,
      transparent 1px,
      transparent 4px
    );
  animation: staticAnim 0.08s steps(1) infinite;
  transition: none !important;
}

/* Light flicker */
@keyframes lightFlicker {
  0%, 90%, 100% { opacity: 1; }
  91%  { opacity: 0.3; }
  92%  { opacity: 0.9; }
  94%  { opacity: 0.2; }
  95%  { opacity: 0.8; }
  97%  { opacity: 0.5; }
  98%  { opacity: 0.95; }
}

.bg-flicker {
  animation: lightFlicker 0.6s ease-in-out;
}

/* ===================================================
   UTILITY CLASSES
   =================================================== */
.hidden {
  display: none !important;
}

/* ===================================================
   RESPONSIVE — Mobile
   =================================================== */
@media (max-width: 600px) {
  .text-box {
    padding: 1rem 1.2rem 1.2rem;
  }

  .text-content {
    font-size: 1rem;
    line-height: 1.9;
  }

  .game-menu {
    top: 0.5rem;
    right: 0.5rem;
  }

  .menu-btn {
    font-size: 0.58rem;
    padding: 0.25rem 0.45rem;
  }

  .game-ui {
    padding-bottom: 5rem;
  }

  .choice-btn {
    padding: 0.75rem 1rem;
  }

  .title-kanji {
    font-size: 5rem;
  }

  .btn-main {
    padding: 0.75rem 2.5rem;
    letter-spacing: 0.3em;
  }

  .ending-buttons {
    flex-direction: column;
    gap: 0.6rem;
  }
}

@media (max-width: 380px) {
  .text-content {
    font-size: 0.92rem;
  }

  .title-kanji {
    font-size: 4rem;
  }
}
