/* ==========================================================================
   متاهة الظلال — Modern Dark Cinema & Interactive AI Mystery Design System
   Generated & Refined via ui-ux-pro-max (MASTER.md)
   ========================================================================== */

:root,
html[data-theme="cinema-dark"] {
  /* Semantic Color Tokens — Modern Dark Cinema (Indigo / Violet / Rose / Amber Gold) */
  --bg-abyss: #070712;
  --bg-primary: #0f0f23;
  --bg-surface: rgba(18, 19, 39, 0.84);
  --bg-elevated: rgba(27, 29, 58, 0.92);
  --bg-glass: rgba(15, 15, 35, 0.78);
  --bg-input: rgba(10, 11, 24, 0.92);

  --border-subtle: rgba(167, 139, 250, 0.16);
  --border-specular: rgba(255, 255, 255, 0.12);
  --border-accent: rgba(226, 176, 73, 0.48);
  --border-primary: rgba(124, 58, 237, 0.52);
  --border-danger: rgba(244, 63, 94, 0.52);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;

  --accent-primary: #7c3aed;
  --accent-secondary: #a78bfa;
  --accent-primary-soft: rgba(124, 58, 237, 0.18);

  --accent-gold: #e2b049;
  --accent-gold-bright: #fbbf24;
  --accent-gold-soft: rgba(226, 176, 73, 0.16);

  --accent-crimson: #f43f5e;
  --accent-crimson-soft: rgba(244, 63, 94, 0.18);

  --accent-arcane: #38bdf8;
  --accent-arcane-soft: rgba(56, 189, 248, 0.16);

  --accent-emerald: #10b981;

  --blob-1: rgba(124, 58, 237, 0.22);
  --blob-2: rgba(244, 63, 94, 0.14);
  --blob-3: rgba(226, 176, 73, 0.13);

  /* Typography */
  --font-ui: 'Cairo', 'Tajawal', system-ui, -apple-system, sans-serif;
  --font-story: 'Amiri', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Orbitron', monospace;

  /* Spacing & Radius (8dp Rhythm + 16px Bento Cards) */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  --shadow-card: 0 20px 44px -12px rgba(3, 4, 12, 0.72), inset 0 1px 0 0 rgba(255, 255, 255, 0.08);
  --shadow-glow-gold: 0 0 26px rgba(226, 176, 73, 0.26);
  --shadow-glow-violet: 0 0 28px rgba(124, 58, 237, 0.32);
  --shadow-glow-crimson: 0 0 34px rgba(244, 63, 94, 0.38);

  /* Smooth Expo.out Easing */
  --transition-fast: 180ms cubic-bezier(0.16, 1, 0.3, 1);
  --transition-med: 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

/* Theme 2: Classic Noir Gold */
html[data-theme="noir-gold"] {
  --bg-abyss: #06080d;
  --bg-primary: #0c1018;
  --bg-surface: rgba(18, 24, 36, 0.88);
  --bg-elevated: rgba(26, 34, 50, 0.94);
  --bg-glass: rgba(12, 17, 27, 0.82);
  --bg-input: rgba(8, 12, 20, 0.94);

  --border-subtle: rgba(148, 163, 184, 0.15);
  --border-accent: rgba(226, 176, 73, 0.52);
  --border-primary: rgba(226, 176, 73, 0.45);

  --accent-primary: #d97706;
  --accent-secondary: #fbbf24;
  --accent-primary-soft: rgba(217, 119, 6, 0.16);

  --blob-1: rgba(226, 176, 73, 0.16);
  --blob-2: rgba(56, 189, 248, 0.10);
  --blob-3: rgba(225, 29, 72, 0.10);
}

/* Theme 3: Detective Parchment Light Mode (WCAG AAA 7:1+ Contrast) */
html[data-theme="detective-light"] {
  --bg-abyss: #f1ede4;
  --bg-primary: #f8f5ee;
  --bg-surface: rgba(255, 253, 248, 0.94);
  --bg-elevated: #ffffff;
  --bg-glass: rgba(248, 245, 238, 0.9);
  --bg-input: #ffffff;

  --border-subtle: rgba(30, 41, 59, 0.16);
  --border-specular: rgba(255, 255, 255, 0.7);
  --border-accent: rgba(146, 64, 14, 0.42);
  --border-primary: rgba(91, 33, 182, 0.38);
  --border-danger: rgba(190, 18, 60, 0.45);

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #475569;

  --accent-primary: #5b21b6;
  --accent-secondary: #6d28d9;
  --accent-primary-soft: rgba(91, 33, 182, 0.1);

  --accent-gold: #92400e;
  --accent-gold-bright: #78350f;
  --accent-gold-soft: rgba(180, 83, 9, 0.12);

  --accent-crimson: #be123c;
  --accent-crimson-soft: rgba(190, 18, 60, 0.1);

  --accent-arcane: #0369a1;
  --accent-arcane-soft: rgba(3, 105, 161, 0.1);

  --accent-emerald: #047857;

  --blob-1: rgba(124, 58, 237, 0.07);
  --blob-2: rgba(217, 119, 6, 0.08);
  --blob-3: rgba(14, 165, 233, 0.06);

  --shadow-card: 0 12px 30px -8px rgba(15, 23, 42, 0.12), inset 0 1px 0 0 rgba(255, 255, 255, 0.8);
  --shadow-glow-gold: 0 4px 18px rgba(180, 83, 9, 0.18);
  --shadow-glow-violet: 0 4px 18px rgba(91, 33, 182, 0.18);
  --shadow-glow-crimson: 0 6px 24px rgba(190, 18, 60, 0.22);
}

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

html,
body {
  min-height: 100vh;
  background-color: var(--bg-abyss);
  color: var(--text-primary);
  font-family: var(--font-ui);
  line-height: 1.65;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color var(--transition-med), color var(--transition-med);
}

/* Custom Sleek Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: rgba(10, 12, 24, 0.4);
}

::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.28);
  border-radius: 999px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-gold);
}

/* Skip Link for Keyboard Accessibility */
.skip-link {
  position: fixed;
  top: -100px;
  right: 24px;
  z-index: 200;
  background: var(--accent-gold-bright);
  color: #090914;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-weight: 800;
  text-decoration: none;
  box-shadow: var(--shadow-card);
  transition: top var(--transition-fast);
}

.skip-link:focus-visible {
  top: 16px;
  outline: 3px solid var(--accent-primary);
}

/* ==========================================================================
   Professional Initial App Preloader (Noir Case Dossier & Audio Calibration)
   ========================================================================== */
.app-preloader {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: radial-gradient(circle at 50% 35%, #161634 0%, #070712 80%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  transition: opacity 450ms cubic-bezier(0.16, 1, 0.3, 1), visibility 450ms cubic-bezier(0.16, 1, 0.3, 1);
}

.app-preloader.fade-out {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.preloader-card {
  width: 100%;
  max-width: 480px;
  background: rgba(18, 19, 39, 0.88);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  padding: 32px 28px;
  text-align: center;
  box-shadow: 0 28px 64px rgba(0, 0, 0, 0.85), var(--shadow-glow-gold);
  backdrop-filter: blur(20px);
}

.preloader-emblem {
  position: relative;
  width: 84px;
  height: 84px;
  margin: 0 auto 18px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.preloader-ring {
  position: absolute;
  border-radius: 50%;
}

.preloader-ring.outer {
  inset: 0;
  border: 2px dashed rgba(226, 176, 73, 0.55);
  animation: spinOrb 6s linear infinite;
}

.preloader-ring.inner {
  inset: 10px;
  border: 2px solid transparent;
  border-top-color: var(--accent-gold-bright);
  border-bottom-color: var(--accent-primary);
  animation: spinOrb 1.6s cubic-bezier(0.5, 0.1, 0.5, 0.9) infinite;
}

.preloader-center-svg {
  width: 34px;
  height: 34px;
  color: var(--accent-gold-bright);
}

.preloader-badge {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-primary-soft);
  border: 1px solid var(--border-primary);
  color: var(--accent-secondary);
  margin-bottom: 10px;
}

.preloader-title {
  font-size: 1.7rem;
  font-weight: 800;
  color: #f8fafc;
  margin-bottom: 6px;
}

.preloader-subtitle {
  font-size: 0.86rem;
  color: #cbd5e1;
  margin-bottom: 20px;
}

.preloader-progress-wrap {
  margin-bottom: 18px;
}

.preloader-progress-track {
  height: 8px;
  background: rgba(8, 9, 20, 0.95);
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  overflow: hidden;
  margin-bottom: 8px;
}

.preloader-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-gold-bright), var(--accent-emerald));
  transition: width 280ms cubic-bezier(0.16, 1, 0.3, 1);
}

.preloader-progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.76rem;
  color: #94a3b8;
}

.preloader-checklist {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: right;
  background: rgba(10, 11, 24, 0.78);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 18px;
}

.boot-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.8rem;
  font-weight: 600;
  color: #64748b;
  transition: color var(--transition-fast);
}

.boot-item.active,
.boot-item.done {
  color: #f8fafc;
}

.boot-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #475569;
  flex-shrink: 0;
}

.boot-item.active .boot-dot {
  background: var(--accent-gold-bright);
  box-shadow: 0 0 8px var(--accent-gold-bright);
}

.boot-item.done .boot-dot {
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.preloader-skip-btn {
  font-size: 0.8rem;
  font-weight: 700;
  color: #cbd5e1;
  padding: 6px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.05);
}

.preloader-skip-btn:hover {
  color: #ffffff;
  border-color: var(--border-accent);
}

/* ==========================================================================
   Atmospheric Background Layers (Modern Dark Cinema Blobs + Fog + Film Grain)
   ========================================================================== */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 18% 15%, var(--blob-1) 0%, transparent 45%),
    radial-gradient(circle at 82% 78%, var(--blob-2) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, var(--bg-primary) 0%, var(--bg-abyss) 100%);
  overflow: hidden;
}

.ambient-blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.65;
  will-change: transform;
}

.blob-violet {
  width: 480px;
  height: 480px;
  top: -120px;
  right: -80px;
  background: var(--blob-1);
  animation: blobFloat1 22s ease-in-out infinite alternate;
}

.blob-rose {
  width: 420px;
  height: 420px;
  bottom: -100px;
  left: -80px;
  background: var(--blob-2);
  animation: blobFloat2 28s ease-in-out infinite alternate;
}

.blob-gold {
  width: 360px;
  height: 360px;
  top: 38%;
  left: 42%;
  background: var(--blob-3);
  animation: blobFloat1 32s ease-in-out infinite alternate-reverse;
}

@keyframes blobFloat1 {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(-40px, 35px, 0) scale(1.1); }
}

@keyframes blobFloat2 {
  0% { transform: translate3d(0, 0, 0) scale(1); }
  100% { transform: translate3d(45px, -30px, 0) scale(1.08); }
}

.fog-layer {
  position: absolute;
  inset: -20%;
  background: radial-gradient(ellipse at center, rgba(167, 139, 250, 0.04) 0%, transparent 70%);
  filter: blur(44px);
  animation: fogDrift 26s ease-in-out infinite alternate;
}

.fog-2 {
  animation-duration: 34s;
  animation-direction: alternate-reverse;
  background: radial-gradient(ellipse at 70% 30%, rgba(226, 176, 73, 0.04) 0%, transparent 65%);
}

.noise-overlay {
  position: absolute;
  inset: 0;
  opacity: 0.025;
  background-image: radial-gradient(rgba(255, 255, 255, 0.6) 1px, transparent 0);
  background-size: 24px 24px;
}

.vignette-overlay {
  position: absolute;
  inset: 0;
  box-shadow: inset 0 0 130px rgba(0, 0, 0, 0.72);
  z-index: 3;
}

.weather-particles-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  opacity: 0.92;
}

html[data-theme="detective-light"] .vignette-overlay {
  box-shadow: inset 0 0 90px rgba(146, 64, 14, 0.08);
}

.preloader-logo-img {
  width: 66px;
  height: 66px;
  object-fit: contain;
  filter: drop-shadow(0 0 14px rgba(226, 176, 73, 0.45));
  z-index: 2;
}

.brand-logo-img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  filter: drop-shadow(0 0 8px rgba(226, 176, 73, 0.4));
}

@keyframes fogDrift {
  0% { transform: translate3d(-3%, -2%, 0) scale(1); }
  100% { transform: translate3d(3%, 2%, 0) scale(1.06); }
}

/* ==========================================================================
   Header Bar (Floating Cinema Glass Nav)
   ========================================================================== */
.top-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 28px;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.brand-area {
  display: flex;
  align-items: center;
  gap: 14px;
}

.logo-mark {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--accent-primary-soft), var(--accent-gold-soft));
  border: 1px solid var(--border-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-gold-bright);
  box-shadow: var(--shadow-glow-gold);
  flex-shrink: 0;
}

.logo-mark svg {
  width: 24px;
  height: 24px;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.brand-text h1 {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.2;
}

.version-chip {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-primary-soft);
  border: 1px solid var(--border-primary);
  color: var(--accent-secondary);
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  display: block;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* Interactive Buttons & Tactile Feedback */
button {
  font-family: var(--font-ui);
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
  transition:
    background-color var(--transition-fast),
    border-color var(--transition-fast),
    color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast),
    opacity var(--transition-fast);
}

button:active:not(:disabled) {
  transform: scale(0.98);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.scenario-card:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent-gold-bright);
  outline-offset: 2px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  min-height: 42px;
  border-radius: 999px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.status-pill:hover {
  border-color: var(--border-accent);
  color: var(--text-primary);
  box-shadow: var(--shadow-glow-gold);
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

.status-dot.connected {
  background: var(--accent-emerald);
  box-shadow: 0 0 10px var(--accent-emerald);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
}

.icon-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-accent);
}

.icon-btn.active {
  color: var(--accent-gold-bright);
  background: var(--accent-gold-soft);
  border-color: var(--border-accent);
}

.secondary-btn,
.primary-outline-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  min-height: 42px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 700;
}

.secondary-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

.secondary-btn:hover {
  border-color: var(--border-primary);
  color: var(--text-primary);
}

.primary-outline-btn {
  background: var(--accent-gold-soft);
  border: 1px solid var(--border-accent);
  color: var(--accent-gold-bright);
}

.primary-outline-btn:hover {
  background: rgba(226, 176, 73, 0.26);
  box-shadow: var(--shadow-glow-gold);
}

.secondary-btn svg,
.primary-outline-btn svg {
  width: 18px;
  height: 18px;
}

/* ==========================================================================
   Main Two-Column Game Layout (Bento Asymmetric Split)
   ========================================================================== */
.game-layout {
  position: relative;
  z-index: 1;
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 28px 48px;
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}

/* ==========================================================================
   Scenario Picker Screen
   ========================================================================== */
.scenario-screen {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 32px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.scenario-hero {
  text-align: center;
  max-width: 720px;
  margin: 0 auto 28px;
}

.hero-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent-primary-soft), var(--accent-gold-soft));
  border: 1px solid var(--border-accent);
  color: var(--accent-gold-bright);
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 12px;
}

.hero-badge svg {
  width: 16px;
  height: 16px;
}

.scenario-hero h2 {
  font-size: clamp(1.45rem, 2.5vw, 1.85rem);
  font-weight: 800;
  color: var(--text-primary);
  margin-bottom: 10px;
}

.scenario-hero p {
  font-size: 0.96rem;
  color: var(--text-secondary);
}

.scenario-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.scenario-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition:
    border-color var(--transition-fast),
    background-color var(--transition-fast),
    box-shadow var(--transition-fast),
    transform var(--transition-fast);
}

.scenario-card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-glow-violet);
  transform: translateY(-2px);
}

.scenario-card.selected {
  border-color: var(--accent-gold);
  background: linear-gradient(145deg, var(--accent-gold-soft), var(--bg-elevated));
  box-shadow: var(--shadow-glow-gold);
}

.scenario-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.scenario-tag {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--accent-gold-bright);
  background: var(--accent-gold-soft);
  border: 1px solid var(--border-accent);
  padding: 4px 10px;
  border-radius: 999px;
}

.scenario-icon {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--accent-primary-soft);
  border: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-gold-bright);
}

.scenario-icon svg {
  width: 20px;
  height: 20px;
}

.scenario-card h3 {
  font-size: 1.14rem;
  font-weight: 800;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.scenario-card p {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.68;
}

.scenario-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.meta-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.08);
  font-weight: 600;
}

.custom-scenario-box {
  margin-bottom: 24px;
  background: var(--bg-input);
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-accent);
}

.custom-scenario-box label {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-gold-bright);
  margin-bottom: 8px;
}

.custom-scenario-box textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.94rem;
  padding: 12px;
  resize: vertical;
}

.scenario-start-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-top: 20px;
  border-top: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.player-name-field {
  display: flex;
  align-items: center;
  gap: 12px;
}

.player-name-field label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.player-name-field input {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  min-height: 44px;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  width: 220px;
}

.start-adventure-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 28px;
  min-height: 48px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #e2b049 0%, #d97706 50%, #7c3aed 100%);
  background-size: 160% 160%;
  color: #ffffff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  font-size: 0.98rem;
  font-weight: 800;
  box-shadow: var(--shadow-glow-gold);
}

.start-adventure-btn:hover {
  box-shadow: 0 0 32px rgba(226, 176, 73, 0.45);
  transform: translateY(-1px);
}

.start-adventure-btn svg {
  width: 20px;
  height: 20px;
}

/* ==========================================================================
   Active Game Stage & Vocal Reaction Bar (Google TTS)
   ========================================================================== */
.game-stage {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.scene-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px 22px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(14px);
}

.scene-location {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.chapter-badge {
  font-family: var(--font-ui);
  background: var(--accent-primary-soft);
  border: 1px solid var(--border-primary);
  color: var(--accent-secondary);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 999px;
}

.scene-location h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: var(--text-primary);
}

.scene-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.preload-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--accent-primary-soft);
  border: 1px solid var(--border-primary);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--accent-secondary);
}

.preload-pulse-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 8px var(--accent-emerald);
}

.preload-pulse-dot.fetching {
  background: var(--accent-gold-bright);
  box-shadow: 0 0 10px var(--accent-gold-bright);
  animation: pulseRec 0.8s ease-in-out infinite;
}

.scene-atmosphere-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-elevated);
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
}

.mood-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-arcane);
  box-shadow: 0 0 8px var(--accent-arcane);
}

/* Vocal Reaction & TTS Bar */
.vocal-reaction-card {
  display: flex;
  align-items: center;
  gap: 16px;
  background: linear-gradient(135deg, var(--bg-elevated), var(--bg-surface));
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-card);
}

.vocal-avatar-wrap {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.vocal-pulse-ring {
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--accent-gold-bright);
  opacity: 0;
  transform: scale(0.9);
  transition: opacity 200ms ease;
}

.vocal-pulse-ring.speaking {
  opacity: 1;
  animation: pulseVoice 1.2s ease-in-out infinite;
}

@keyframes pulseVoice {
  0% { transform: scale(0.95); opacity: 0.85; }
  50% { transform: scale(1.18); opacity: 0.25; }
  100% { transform: scale(0.95); opacity: 0.85; }
}

.vocal-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent-gold-soft);
  border: 1px solid var(--border-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-gold-bright);
}

.vocal-avatar svg {
  width: 22px;
  height: 22px;
}

.vocal-content {
  flex: 1;
  min-width: 0;
}

.vocal-top-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  flex-wrap: wrap;
}

.vocal-speaker-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-gold-bright);
}

.vocal-emotion-badge {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-crimson-soft);
  color: var(--accent-crimson);
  border: 1px solid var(--border-danger);
}

html[data-theme="cinema-dark"] .vocal-emotion-badge,
html[data-theme="noir-gold"] .vocal-emotion-badge {
  color: #fda4af;
}

.tts-provider-tag {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.1);
  padding: 2px 8px;
  border-radius: 6px;
}

.vocal-reaction-text {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-primary);
  font-style: italic;
}

/* Thematic Mystery Tape Recorder & Frequency Decoder Bar */
.tts-decoding-bar {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-primary);
  display: flex;
  align-items: center;
  gap: 12px;
  animation: sceneParaFade 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

.tape-reels-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--accent-gold-bright);
  flex-shrink: 0;
}

.tape-reels-icon svg {
  width: 20px;
  height: 20px;
}

.reel-spin {
  animation: spinOrb 1.8s linear infinite;
}

.reel-spin.reverse {
  animation-direction: reverse;
  animation-duration: 2.2s;
  color: var(--accent-secondary);
}

.tts-decoding-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.tts-decoding-title {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-gold-bright);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tts-freq-track {
  height: 4px;
  width: 100%;
  background: rgba(148, 163, 184, 0.14);
  border-radius: 999px;
  overflow: hidden;
}

.tts-freq-fill {
  display: block;
  height: 100%;
  width: 45%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-gold-bright), var(--accent-crimson));
  animation: freqSweep 1.1s ease-in-out infinite alternate;
}

@keyframes freqSweep {
  0% { transform: translateX(0%); width: 35%; }
  100% { transform: translateX(-120%); width: 55%; }
}

.tts-freq-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--accent-crimson-soft);
  border: 1px solid var(--border-danger);
  color: #fda4af;
  flex-shrink: 0;
  animation: pulseRec 1.1s ease-in-out infinite;
}

@keyframes pulseRec {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.vocal-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

#ttsWaveformCanvas {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.tts-control-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  min-height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.tts-control-btn:hover {
  border-color: var(--accent-gold);
  color: var(--text-primary);
}

.tts-control-btn.primary {
  background: var(--accent-gold-soft);
  border-color: var(--border-accent);
  color: var(--accent-gold-bright);
}

.tts-control-btn.stop {
  background: var(--accent-crimson-soft);
  border-color: var(--border-danger);
  color: #fecdd3;
}

html[data-theme="detective-light"] .tts-control-btn.stop {
  color: var(--accent-crimson);
}

.tts-control-btn svg {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   Main Story Narrative Card (Editorial Serif + Cinema Glass)
   ========================================================================== */
.narrative-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 30px 34px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
  position: relative;
  transition: border-color var(--transition-med), box-shadow var(--transition-med);
}

.narrative-card.twist-active {
  border-color: var(--accent-crimson);
  box-shadow: var(--shadow-glow-crimson);
}

/* Narrative Reading UX Toolbar */
.narrative-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.narrative-reading-meta {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
}

.reading-indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-gold-bright);
  box-shadow: 0 0 8px var(--accent-gold-bright);
}

.narrative-ux-controls {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.ux-tool-btn {
  padding: 4px 10px;
  min-height: 30px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.ux-tool-btn:hover {
  border-color: var(--border-accent);
  color: var(--text-primary);
}

.ux-tool-btn.active {
  background: var(--accent-gold-soft);
  border-color: var(--border-accent);
  color: var(--accent-gold-bright);
}

.narrative-body p.speaking-paragraph {
  padding-right: 12px;
  border-right: 3px solid var(--accent-gold-bright);
  background: linear-gradient(90deg, transparent, rgba(226, 176, 73, 0.08));
  border-radius: 4px;
  transition: background-color var(--transition-fast), border-color var(--transition-fast);
}

.narrative-twist-ribbon {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 20px;
  border-radius: var(--radius-md);
  background: linear-gradient(90deg, var(--accent-crimson-soft), var(--accent-gold-soft));
  border: 1px solid var(--border-danger);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.92rem;
}

.narrative-twist-ribbon svg {
  width: 22px;
  height: 22px;
  color: var(--accent-crimson);
  flex-shrink: 0;
}

.narrative-body {
  font-family: var(--font-story);
  font-size: 1.34rem;
  line-height: 1.98;
  color: var(--text-primary);
  max-width: 72ch;
}

.narrative-body p {
  margin-bottom: 16px;
  animation: sceneParaFade 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.narrative-body p:nth-child(2) {
  animation-delay: 60ms;
}

.narrative-body p:nth-child(3) {
  animation-delay: 120ms;
}

.narrative-body p:last-child {
  margin-bottom: 0;
}

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

/* Inspectable Suspicious Hotspot */
.suspicious-hotspot {
  margin-top: 24px;
  padding: 16px 18px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px dashed var(--accent-arcane);
}

.hotspot-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
  color: var(--accent-arcane);
  font-size: 0.86rem;
  font-weight: 700;
}

.hotspot-header svg {
  width: 18px;
  height: 18px;
}

.hotspot-trigger-btn {
  margin-right: auto;
  padding: 5px 14px;
  min-height: 34px;
  border-radius: 999px;
  background: var(--accent-arcane-soft);
  border: 1px solid var(--accent-arcane);
  color: var(--accent-arcane);
  font-size: 0.78rem;
  font-weight: 700;
}

.hotspot-trigger-btn:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.28);
}

.hotspot-preview {
  font-size: 0.92rem;
  color: var(--text-secondary);
}

.hotspot-reveal {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  color: var(--accent-gold-bright);
  font-size: 0.94rem;
  font-weight: 600;
}

/* ==========================================================================
   Choices & Custom Action (With Keyboard Shortcut Badges)
   ========================================================================== */
.choices-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
}

.choices-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.choices-header h3 {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--accent-gold-bright);
}

.choices-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.choices-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.choice-btn {
  text-align: right;
  padding: 16px 18px;
  min-height: 74px;
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.choice-btn:hover:not(:disabled) {
  border-color: var(--accent-gold);
  box-shadow: var(--shadow-glow-gold);
  transform: translateY(-2px);
}

.choice-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.choice-top-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
}

.choice-num-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.choice-number {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent-gold-soft);
  border: 1px solid var(--border-accent);
  color: var(--accent-gold-bright);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.kbd-hint {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-muted);
  background: rgba(148, 163, 184, 0.1);
  border: 1px solid var(--border-subtle);
  padding: 1px 6px;
  border-radius: 4px;
}

.choice-tag {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-primary-soft);
  color: var(--accent-secondary);
}

.choice-preload-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.14);
  border: 1px solid rgba(16, 185, 129, 0.4);
  color: #34d399;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.choice-preload-badge.loading {
  background: var(--accent-gold-soft);
  border-color: var(--border-accent);
  color: var(--accent-gold-bright);
}

.choice-text {
  font-size: 0.96rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.55;
}

/* Custom Action Input Form */
.custom-action-form {
  display: flex;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.custom-action-input-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 0 14px;
}

.custom-action-input-wrap:focus-within {
  border-color: var(--accent-gold);
  box-shadow: var(--shadow-glow-gold);
}

.custom-action-input-wrap svg {
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.custom-action-input-wrap input {
  width: 100%;
  min-height: 46px;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.92rem;
}

.custom-action-input-wrap input:focus-visible {
  outline: none;
}

.custom-action-submit {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 20px;
  min-height: 46px;
  border-radius: var(--radius-md);
  background: var(--accent-gold-soft);
  border: 1px solid var(--border-accent);
  color: var(--accent-gold-bright);
  font-weight: 700;
  font-size: 0.9rem;
}

.custom-action-submit:hover {
  background: rgba(226, 176, 73, 0.28);
  box-shadow: var(--shadow-glow-gold);
}

.custom-action-submit svg {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   Loading Indicator + Noir Detective Investigation Theatre
   ========================================================================== */
.ai-loading-box {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 26px;
  border-radius: var(--radius-xl);
  background: linear-gradient(145deg, var(--bg-elevated), var(--bg-surface));
  border: 1px solid var(--border-accent);
  box-shadow: var(--shadow-card), var(--shadow-glow-violet);
}

.loading-top-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.detective-radar-orb {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner-orb {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid var(--accent-gold-soft);
  border-top-color: var(--accent-gold-bright);
  border-right-color: var(--accent-primary);
  animation: spinOrb 0.85s linear infinite;
}

.radar-center-icon {
  width: 20px;
  height: 20px;
  color: var(--accent-gold-bright);
}

@keyframes spinOrb {
  to { transform: rotate(360deg); }
}

.loading-texts {
  flex: 1;
}

.loading-badge-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.loading-case-tag {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-primary-soft);
  border: 1px solid var(--border-primary);
  color: var(--accent-secondary);
}

.loading-step-pill {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--accent-gold-bright);
}

.loading-texts h4 {
  font-size: 1.02rem;
  font-weight: 800;
  color: var(--accent-gold-bright);
}

.loading-texts p {
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.investigation-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
}

.inv-step {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.inv-step.active {
  color: var(--accent-gold-bright);
}

.inv-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(148, 163, 184, 0.35);
  flex-shrink: 0;
}

.inv-step.active .inv-dot {
  background: var(--accent-gold-bright);
  box-shadow: 0 0 8px var(--accent-gold-bright);
}

/* Live Remaining Preload Progress Bar */
.preload-live-bar-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preload-live-bar-track {
  height: 8px;
  border-radius: 999px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  overflow: hidden;
}

.preload-live-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-primary), var(--accent-gold-bright), var(--accent-emerald));
  box-shadow: 0 0 12px rgba(226, 176, 73, 0.45);
  transition: width 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

.preload-live-bar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.preload-live-bar-meta .mono-stat {
  color: var(--accent-gold-bright);
}

/* Interactive Scene-Matched Mini-Puzzle During Preload */
.mini-puzzle-card {
  background: var(--bg-input);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: inset 0 0 24px rgba(124, 58, 237, 0.08);
}

.mini-puzzle-card.solved {
  border-color: rgba(16, 185, 129, 0.55);
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), var(--bg-input));
}

.mini-puzzle-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.mini-puzzle-badge {
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--accent-gold-bright);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.mini-puzzle-status {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--accent-primary-soft);
  border: 1px solid var(--border-primary);
  color: var(--accent-secondary);
}

.mini-puzzle-card.solved .mini-puzzle-status {
  background: rgba(16, 185, 129, 0.18);
  border-color: rgba(16, 185, 129, 0.5);
  color: #34d399;
}

.mini-puzzle-desc {
  font-size: 0.84rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.mini-puzzle-target-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.mini-puzzle-code {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent-gold-bright);
}

.mini-puzzle-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.puzzle-node-btn {
  min-width: 58px;
  min-height: 48px;
  padding: 8px 14px;
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  border: 1px solid var(--border-accent);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow: var(--shadow-glow-gold);
}

.puzzle-node-btn:hover:not(:disabled) {
  background: var(--accent-gold-soft);
  border-color: var(--accent-gold-bright);
  transform: translateY(-2px);
}

.puzzle-node-btn.matched {
  background: rgba(16, 185, 129, 0.18);
  border-color: #34d399;
  color: #34d399;
  box-shadow: 0 0 12px rgba(16, 185, 129, 0.35);
}

.puzzle-node-sub {
  font-family: var(--font-ui);
  font-size: 0.66rem;
  font-weight: 600;
  color: var(--text-muted);
}

.loading-mystery-quote {
  font-family: var(--font-story);
  font-size: 1.04rem;
  font-style: italic;
  color: var(--text-primary);
  padding: 8px 14px;
  border-right: 3px solid var(--accent-gold);
  background: rgba(124, 58, 237, 0.07);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.skeleton-lines {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.skeleton-line {
  display: block;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(167, 139, 250, 0.12) 25%,
    rgba(226, 176, 73, 0.32) 50%,
    rgba(167, 139, 250, 0.12) 75%
  );
  background-size: 200% 100%;
  animation: skeletonShimmer 1.5s infinite linear;
}

.skeleton-line.w-85 {
  width: 85%;
}

.skeleton-line.w-65 {
  width: 65%;
}

@keyframes skeletonShimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================================
   Sidebar: Mystery Meters & Detective Notebook
   ========================================================================== */
.mystery-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 84px;
}

.sidebar-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: 20px;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(16px);
}

.sidebar-card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 16px;
}

.sidebar-card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent-gold-bright);
  margin-bottom: 16px;
}

.sidebar-card-title-row .sidebar-card-title {
  margin-bottom: 0;
}

.sidebar-card-title svg {
  width: 20px;
  height: 20px;
}

.small-ghost-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  min-height: 32px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-secondary);
}

.small-ghost-btn:hover {
  border-color: var(--border-accent);
  color: var(--accent-gold-bright);
}

.small-ghost-btn svg {
  width: 14px;
  height: 14px;
}

.meter-group {
  margin-bottom: 16px;
}

.meter-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.mono-stat {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

.meter-track {
  height: 9px;
  background: var(--bg-input);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border-subtle);
}

.meter-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 500ms cubic-bezier(0.16, 1, 0.3, 1);
}

.twist-fill {
  background: linear-gradient(90deg, #38bdf8, #7c3aed, #e2b049, #f43f5e);
}

.danger-fill {
  background: linear-gradient(90deg, #f59e0b, #f43f5e);
}

.meter-caption {
  display: block;
  margin-top: 4px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.quick-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px;
  text-align: center;
}

.stat-num {
  display: block;
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--accent-gold-bright);
}

.stat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* Notebook Tabs with Live Badges */
.notebook-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.notebook-tab {
  padding: 8px 4px;
  min-height: 38px;
  border-radius: var(--radius-sm);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.notebook-tab.active {
  background: var(--accent-gold-soft);
  color: var(--accent-gold-bright);
  border: 1px solid var(--border-accent);
}

.tab-count {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  padding: 1px 5px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.14);
  color: var(--text-secondary);
}

.notebook-tab.active .tab-count {
  background: rgba(226, 176, 73, 0.25);
  color: var(--accent-gold-bright);
}

.notebook-panel {
  max-height: 340px;
  overflow-y: auto;
  padding-left: 4px;
}

.clue-list,
.secret-list,
.suspect-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.clue-item,
.secret-item,
.suspect-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 0.85rem;
}

.secret-item {
  border-color: var(--border-danger);
  background: linear-gradient(135deg, var(--accent-crimson-soft), var(--bg-elevated));
}

.clue-item strong,
.secret-item strong,
.suspect-item strong {
  display: block;
  color: var(--accent-gold-bright);
  margin-bottom: 4px;
}

.secret-item strong {
  color: var(--accent-crimson);
}

html[data-theme="cinema-dark"] .secret-item strong,
html[data-theme="noir-gold"] .secret-item strong {
  color: #fda4af;
}

.suspect-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.suspect-status {
  font-size: 0.72rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-primary-soft);
  color: var(--accent-secondary);
}

.history-entry {
  border-right: 2px solid var(--border-accent);
  padding: 6px 12px 12px 0;
  margin-bottom: 10px;
  font-size: 0.82rem;
}

.history-entry .hist-turn {
  color: var(--accent-gold-bright);
  font-weight: 700;
  font-size: 0.75rem;
}

.empty-note {
  color: var(--text-muted);
  font-size: 0.84rem;
  text-align: center;
  padding: 24px 8px;
}

/* ==========================================================================
   Plot Twist Fullscreen Flash Overlay (with Skip Action)
   ========================================================================== */
.twist-overlay {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: radial-gradient(circle, rgba(136, 19, 55, 0.92) 0%, rgba(7, 7, 18, 0.98) 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  animation: fadeTwistIn 350ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes fadeTwistIn {
  from { opacity: 0; transform: scale(1.04); }
  to { opacity: 1; transform: scale(1); }
}

.twist-banner {
  max-width: 600px;
}

.twist-icon-ring {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: rgba(244, 63, 94, 0.25);
  border: 2px solid #fb7185;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fda4af;
  box-shadow: 0 0 40px rgba(244, 63, 94, 0.6);
}

.twist-icon-ring svg {
  width: 36px;
  height: 36px;
}

.twist-label {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fda4af;
  background: rgba(0, 0, 0, 0.45);
  padding: 4px 14px;
  border-radius: 999px;
  margin-bottom: 12px;
}

.twist-banner h2 {
  font-size: 2rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 8px;
}

.twist-banner p {
  font-size: 1.1rem;
  color: #fecdd3;
  margin-bottom: 20px;
}

.skip-twist-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  min-height: 40px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 700;
}

.skip-twist-btn:hover {
  background: rgba(255, 255, 255, 0.22);
}

/* ==========================================================================
   Settings Modal (Google AI Studio API + Google TTS)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(5, 6, 15, 0.78);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-card {
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-primary);
  border: 1px solid var(--border-accent);
  border-radius: var(--radius-xl);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.85);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--accent-gold-bright);
}

.modal-title-group svg {
  width: 22px;
  height: 22px;
}

.modal-title-group h2 {
  font-size: 1.12rem;
  font-weight: 800;
  color: var(--text-primary);
}

.modal-close-btn {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}

.modal-close-btn:hover {
  background: rgba(148, 163, 184, 0.12);
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.settings-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 18px;
}

.section-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.section-badge-row h3 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--accent-gold-bright);
}

.ext-link {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--accent-arcane);
  text-decoration: none;
}

.ext-link:hover {
  text-decoration: underline;
}

.settings-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.form-row {
  margin-bottom: 14px;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-row label {
  display: block;
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-row.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.input-with-action {
  display: flex;
  gap: 8px;
}

.form-row input[type="password"],
.form-row input[type="text"],
.form-row select {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.9rem;
}

.form-row input[type="range"] {
  width: 100%;
  accent-color: var(--accent-gold);
  margin-top: 8px;
}

.small-btn {
  padding: 0 14px;
  min-height: 42px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  white-space: nowrap;
}

.small-btn.accent {
  background: var(--accent-gold-soft);
  border-color: var(--border-accent);
  color: var(--accent-gold-bright);
}

.api-test-feedback {
  margin-top: 6px;
  font-size: 0.82rem;
  font-weight: 600;
}

.api-test-feedback.success {
  color: var(--accent-emerald);
}

.api-test-feedback.error {
  color: var(--accent-crimson);
}

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem !important;
  cursor: pointer;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent-gold);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-top: 1px solid var(--border-subtle);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background: var(--bg-elevated);
  border: 1px solid var(--border-accent);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  font-size: 0.88rem;
  font-weight: 600;
  animation: toastSlideIn 220ms cubic-bezier(0.16, 1, 0.3, 1);
}

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

.hidden {
  display: none !important;
}

/* ==========================================================================
   Responsive Design (1440px, 1024px, 768px, 375px)
   ========================================================================== */
@media (max-width: 1080px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
  .mystery-sidebar {
    position: static;
  }
}

@media (max-width: 768px) {
  .top-header {
    padding: 12px 16px;
  }
  .game-layout {
    padding: 16px;
  }
  .scenario-screen {
    padding: 20px;
  }
  .scenario-grid,
  .choices-grid,
  .form-row.two-col {
    grid-template-columns: 1fr;
  }
  .vocal-reaction-card {
    flex-direction: column;
    align-items: flex-start;
  }
  .vocal-controls {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .narrative-card {
    padding: 20px;
  }
  .narrative-body {
    font-size: 1.18rem;
  }
}

@media (max-width: 420px) {
  .brand-subtitle,
  .version-chip {
    display: none;
  }
  .player-name-field,
  .player-name-field input,
  .start-adventure-btn {
    width: 100%;
    justify-content: center;
  }
  .custom-action-form {
    flex-direction: column;
  }
}

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