:root {
  --bg-black: #02040a;
  --bg-blue: #050c18;
  --panel: rgba(5, 12, 24, 0.88);

  --cyan: #00f6ff;
  --pink: #ff2a6d;
  --red: #ff003c;
  --yellow: #fcee09;
  --violet: #9b5cff;

  --text: #d9fbff;
  --muted: #7f9ca8;

  --border-cyan: rgba(0, 246, 255, 0.45);
  --border-pink: rgba(255, 42, 109, 0.45);
  --shadow-cyan: 0 0 28px rgba(0, 246, 255, 0.22);
  --shadow-pink: 0 0 28px rgba(255, 42, 109, 0.18);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

/* Custom Text Selection to match aesthetic */
::selection {
  background: var(--pink);
  color: var(--bg-black);
  text-shadow: none;
}

/* Theme-matching Scrollbars */
::-webkit-scrollbar {
  width: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-black);
}
::-webkit-scrollbar-thumb {
  background: var(--border-cyan);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--cyan);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 42, 109, 0.18), transparent 30rem),
    radial-gradient(circle at bottom right, rgba(0, 246, 255, 0.16), transparent 34rem),
    linear-gradient(135deg, #02040a 0%, #050c18 48%, #170314 100%);
  font-family: "Courier New", Courier, monospace;
  letter-spacing: 0.02em;
  overflow-x: hidden;
}

/* surveillance haze */
.surveillance-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 50%, rgba(0, 0, 0, 0.08) 50%),
    linear-gradient(90deg, rgba(255, 0, 60, 0.035), rgba(0, 246, 255, 0.035));
  background-size: 100% 4px, 6px 100%;
  mix-blend-mode: screen;
  opacity: 0.32;
}

/* Upgraded Scanline - GPU optimized to reduce stuttering */
.scanline-overlay {
  position: fixed;
  inset: 0;
  z-index: 21;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(0, 246, 255, 0.12) 10%,
    transparent 20%,
    transparent 100%
  );
  background-size: 100% 500%;
  animation: scanline 8s linear infinite;
  opacity: 0.35;
}

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

.terminal {
  width: min(1020px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 3rem 0;
}

.chapter-page {
  position: relative;
  overflow: hidden;
  padding: clamp(1.25rem, 4vw, 3rem);
  border: 1px solid var(--border-cyan);
  background:
    linear-gradient(rgba(5, 12, 24, 0.86), rgba(2, 4, 10, 0.92)),
    repeating-linear-gradient(
      90deg,
      rgba(255, 255, 255, 0.015) 0,
      rgba(255, 255, 255, 0.015) 1px,
      transparent 1px,
      transparent 80px
    );
  box-shadow:
    var(--shadow-cyan),
    var(--shadow-pink),
    inset 0 0 70px rgba(255, 42, 109, 0.08);
}

.chapter-page::before {
  content: "STATE SURVEILLANCE ACTIVE";
  position: absolute;
  top: 1.1rem;
  right: -4.25rem;
  transform: rotate(35deg);
  padding: 0.4rem 4.5rem;
  color: white;
  background: var(--red);
  font-size: 0.65rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  box-shadow: 0 0 18px rgba(255, 0, 60, 0.75);
  z-index: 10;
}

.chapter-page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border: 1px solid rgba(255, 42, 109, 0.25);
  transform: translate(8px, 8px);
}

.chapter-header {
  position: relative;
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid rgba(0, 246, 255, 0.28);
}

.system-label,
.chapter-subtitle,
.monitoring-text {
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.system-label {
  margin: 0 0 0.8rem;
  color: var(--cyan);
  font-size: 0.78rem;
  text-shadow: 0 0 12px rgba(0, 246, 255, 0.9);
}

.chapter-title {
  position: relative;
  margin: 0.35rem 0;
  color: var(--text);
  font-size: clamp(2.5rem, 8vw, 6.5rem); /* Improved fluid scaling */
  line-height: 0.9;
  text-transform: uppercase;
  text-shadow:
    3px 0 var(--pink),
    -3px 0 var(--cyan),
    0 0 30px rgba(0, 246, 255, 0.36);
}

.chapter-title::before,
.chapter-title::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  opacity: 0.55;
  pointer-events: none;
}

.chapter-title::before {
  color: var(--pink);
  transform: translate(3px, 0);
  clip-path: inset(0 0 55% 0);
}

.chapter-title::after {
  color: var(--cyan);
  transform: translate(-3px, 0);
  clip-path: inset(55% 0 0 0);
}

.chapter-subtitle {
  margin: 0.6rem 0 0;
  color: var(--muted);
  font-size: 0.84rem;
}

.monitoring-text {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.55rem 0.8rem;
  color: var(--yellow);
  border: 1px solid rgba(252, 238, 9, 0.48);
  background: rgba(252, 238, 9, 0.08);
  font-size: 0.72rem;
  box-shadow: 0 0 18px rgba(252, 238, 9, 0.12);
}

.panel {
  border: 1px solid var(--border-pink);
  background: var(--panel);
  box-shadow:
    inset 0 0 22px rgba(255, 42, 109, 0.08),
    0 0 18px rgba(0, 246, 255, 0.08);
}

.chapter-meta {
  margin-bottom: 1.25rem;
  padding: 1rem;
}

/* Upgraded for perfect responsiveness across all mobile sizes */
.chapter-meta dl {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.8rem;
  margin: 0;
}

.chapter-meta div {
  padding: 0.8rem;
  border-left: 2px solid var(--cyan);
  background:
    linear-gradient(90deg, rgba(0, 246, 255, 0.08), transparent),
    rgba(0, 246, 255, 0.025);
}

.chapter-meta dt {
  margin-bottom: 0.4rem;
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
}

.chapter-meta dd {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  word-break: break-word;
}

.status-unlocked {
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 246, 255, 0.9);
}

.threat-level {
  color: var(--red);
  text-shadow: 0 0 12px rgba(255, 0, 60, 0.85);
}

.warning-panel {
  margin-bottom: 1.5rem;
  padding: 1rem;
  color: #ffd6df;
  border-color: rgba(255, 0, 60, 0.6);
  background:
    linear-gradient(90deg, rgba(255, 0, 60, 0.12), transparent),
    rgba(255, 0, 60, 0.06);
}

.warning-panel strong {
  color: var(--red);
  text-transform: uppercase;
  text-shadow: 0 0 9px rgba(255, 0, 60, 0.85);
}

.chapter-content {
  padding: clamp(1rem, 3vw, 2rem);
}

.playback-header {
  margin-bottom: 1.75rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid rgba(0, 246, 255, 0.32);
}

.access-code {
  margin: 0 0 0.5rem;
  color: var(--pink);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.playback-header h2 {
  margin: 0 0 0.5rem;
  color: var(--cyan);
  text-transform: uppercase;
  text-shadow: 0 0 14px rgba(0, 246, 255, 0.75);
}

.playback-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
}

.story-text {
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.85;
}

.story-text p {
  margin: 0 0 1.25rem;
}

.glow-text {
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 246, 255, 0.85);
}

.dialogue {
  color: var(--pink);
  text-shadow: 0 0 10px rgba(255, 42, 109, 0.75);
}

.detail-line {
  color: #ffe4ee;
  border-left: 3px solid var(--pink);
  padding-left: 1rem;
}

.short-line {
  color: var(--yellow);
  font-size: 1.25rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.aside-line {
  color: var(--muted);
  font-style: italic;
}

.transmission {
  padding: 0.85rem 1rem;
  color: var(--yellow);
  border-left: 3px solid var(--yellow);
  background: rgba(252, 238, 9, 0.08);
  font-size: 0.9rem;
  text-transform: uppercase;
  box-shadow: inset 0 0 18px rgba(252, 238, 9, 0.08);
}

.sound-effect {
  margin: 2.2rem 0;
  color: var(--red);
  font-size: clamp(2rem, 6vw, 4rem);
  font-weight: 900;
  text-align: center;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-shadow:
    3px 3px 0 var(--cyan),
    -3px -2px 0 var(--pink),
    0 0 24px rgba(255, 0, 60, 0.8);
}

.reveal-line {
  margin-top: 2rem;
  color: var(--red);
  font-size: clamp(1.6rem, 5vw, 3.2rem);
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-shadow:
    0 0 16px rgba(255, 0, 60, 0.9),
    2px 0 var(--cyan),
    -2px 0 var(--pink);
}

.scene-break {
  display: flex;
  justify-content: center;
  margin: 2.75rem 0;
}

.scene-break span {
  width: 72%;
  height: 1px;
  background: linear-gradient(
    to right,
    transparent,
    var(--pink),
    var(--cyan),
    var(--pink),
    transparent
  );
  box-shadow:
    0 0 14px rgba(0, 246, 255, 0.75),
    0 0 20px rgba(255, 42, 109, 0.42);
}

.chapter-ending {
  color: var(--muted);
  text-align: right;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  font-size: 0.85rem;
}

/* Completed and Upgraded Navigation Section */
.chapter-navigation {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(0, 246, 255, 0.25);
}

.chapter-nav-btn {
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--cyan);
  padding: 0.6rem 1.2rem;
  border: 1px solid var(--border-cyan);
  background: rgba(0, 246, 255, 0.03);
  transition: all 0.25s ease-in-out;
  position: relative;
}

.chapter-nav-btn:hover {
  color: var(--bg-black);
  background: var(--cyan);
  box-shadow: 0 0 15px var(--cyan);
  text-shadow: none;
}

/* Disabled styling for first/last nodes */
.chapter-nav-btn.disabled {
  color: var(--muted);
  border-color: rgba(127, 156, 168, 0.2);
  background: transparent;
  pointer-events: none;
  opacity: 0.4;
}

/* Print Overrides to prevent wasting physical ink cartridges */
@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }
  .chapter-page {
    border: none;
    box-shadow: none;
    background: none;
  }
  .surveillance-overlay,
  .scanline-overlay,
  .chapter-page::before,
  .chapter-page::after {
    display: none !important;
  }
}
/* Styling for your Orwellian Thoughtcrime protocols */
.thoughtcrime-alert {
  color: var(--red) !important;
  animation: alarmPulse 0.5s ease infinite alternate;
}

@keyframes alarmPulse {
  from { opacity: 0.6; text-shadow: 0 0 5px var(--red); }
  to { opacity: 1; text-shadow: 0 0 15px var(--red), 0 0 25px var(--red); }
}

.scrambled {
  font-family: monospace;
  color: var(--pink);
}
.console-box {
  margin-top: 2rem;
  padding: 1.5rem;
  border-color: var(--border-cyan);
}

.console-output {
  height: 120px;
  overflow-y: auto;
  font-size: 0.85rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(0, 246, 255, 0.15);
}

.console-output p {
  margin: 0 0 0.4rem 0;
  line-height: 1.4;
}

.sys-msg { color: var(--muted); }
.success-msg { color: var(--cyan); text-shadow: 0 0 8px rgba(0, 246, 255, 0.5); }
.error-msg { color: var(--red); text-shadow: 0 0 8px rgba(255, 0, 60, 0.5); }
.secret-msg { color: var(--yellow); font-weight: bold; }

.console-input-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.prompt {
  color: var(--cyan);
  font-weight: bold;
}

#consoleInput {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: inherit;
  font-size: 0.9rem;
}

#consoleInput::placeholder {
  color: rgba(127, 156, 168, 0.4);
}
.lore-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
  cursor: help;
}

.lore-link:hover,
.lore-link:focus {
  color: #ff4fd8;
  text-shadow: 0 0 8px currentColor;
  border-bottom-style: solid;
}

.lore-link::after {
  content: " ⟦ARCHIVE⟧";
  font-size: 0.65em;
  opacity: 0;
  margin-left: 0.25rem;
  transition: opacity 0.2s ease;
}

.lore-link:hover::after,
.lore-link:focus::after {
  opacity: 0.85;
}
/* ================================
CHAPTER CSS POLISH PATCH
Add near the bottom of chapter.css
================================ */

/* Keep chapter styling from accidentally mutating archive/index pages */
.chapter-page .panel {
border: 1px solid var(--border-pink);
background: var(--panel);
box-shadow:
inset 0 0 22px rgba(255, 42, 109, 0.08),
0 0 18px rgba(0, 246, 255, 0.08);
}

/* Stronger keyboard focus for interactive elements */
.chapter-page a:focus-visible,
.chapter-page button:focus-visible,
#consoleInput:focus-visible {
outline: 2px solid var(--yellow);
outline-offset: 4px;
}

/* Make lore links feel clickable/accessibility-friendly */
.lore-link {
color: inherit;
text-decoration: none;
border-bottom: 1px dotted currentColor;
cursor: help;
text-underline-offset: 0.2em;
}

.lore-link:hover,
.lore-link:focus-visible {
color: #ff4fd8;
text-shadow: 0 0 8px currentColor;
border-bottom-style: solid;
}

/* Cleaner disabled navigation state */
.chapter-nav-btn.disabled,
.chapter-nav-btn[aria-disabled="true"] {
color: var(--muted);
border-color: rgba(127, 156, 168, 0.2);
background: transparent;
pointer-events: none;
opacity: 0.4;
box-shadow: none;
text-shadow: none;
}

/* Avoid transition: all; it can make future edits behave strangely */
.chapter-nav-btn {
transition:
color 0.25s ease-in-out,
background-color 0.25s ease-in-out,
box-shadow 0.25s ease-in-out,
border-color 0.25s ease-in-out,
text-shadow 0.25s ease-in-out;
}

/* Mobile comfort improvements */
@media (max-width: 700px) {
.terminal {
width: min(100% - 1rem, 1020px);
padding: 1rem 0 3rem;
}

.chapter-page {
padding: 1rem;
}

.chapter-page::before {
top: 0.75rem;
right: -4.75rem;
font-size: 0.55rem;
letter-spacing: 0.12em;
}

.chapter-header {
padding-top: 2rem;
}

.chapter-navigation {
flex-direction: column;
align-items: stretch;
}

.chapter-nav-btn {
text-align: center;
}

.sound-effect {
letter-spacing: 0.12em;
}
}

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

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

.scanline-overlay {
animation: none;
opacity: 0.18;
}

.thoughtcrime-alert {
animation: none;
}

.chapter-title::before,
.chapter-title::after {
transform: none;
opacity: 0.25;
}
}

/* Better print readability */
@media print {
html,
body {
background: #fff !important;
color: #000 !important;
font-family: Georgia, "Times New Roman", serif;
letter-spacing: normal;
}

.terminal {
width: 100%;
padding: 0;
}

.chapter-page,
.panel,
.chapter-content {
border: none !important;
box-shadow: none !important;
background: none !important;
}

.story-text {
font-size: 12pt;
line-height: 1.6;
}

.chapter-navigation,
.surveillance-overlay,
.scanline-overlay,
.console-box,
.chapter-page::before,
.chapter-page::after {
display: none !important;
}
}
.live-system-log {
  margin-top: 0.75rem;
  color: var(--yellow);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.boot-complete {
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(0, 246, 255, 0.75);
}

.js-glitch-pulse {
  filter: drop-shadow(2px 0 var(--pink)) drop-shadow(-2px 0 var(--cyan));
  transform: translateX(1px);
}