:root {
  color-scheme: dark;
  --black: #030506;
  --panel: #07100f;
  --ink: #d9fff1;
  --muted: #73958b;
  --acid: #69ffc9;
  --cyan: #53dfff;
  --violet: #bd80ff;
  --amber: #ff9a50;
  --danger: #ff315f;
  --terminal: #ff003c;
  --line: rgba(105, 255, 201, 0.22);
  --capability: 22%;
  --safeguards: 18%;
  --risk: 0;
  --route: var(--acid);
  --mouse-x: 50vw;
  --mouse-y: 50vh;
  font-family: "Courier New", Courier, monospace;
}

* { box-sizing: border-box; }

html { background: var(--black); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at var(--mouse-x) var(--mouse-y), rgba(105, 255, 201, 0.07), transparent 24rem),
    linear-gradient(rgba(105, 255, 201, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(105, 255, 201, 0.018) 1px, transparent 1px),
    var(--black);
  background-size: auto, 48px 48px, 48px 48px, auto;
  font-size: 16px;
}

button,
a { font: inherit; }

button { color: inherit; }

button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--acid);
  outline-offset: 3px;
}

[hidden] { display: none !important; }

.noise,
.scanline,
.screen-flash {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

.noise {
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.92' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E");
  animation: noise-shift 0.18s steps(2) infinite;
}

.scanline {
  z-index: 89;
  opacity: 0.16;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 3px, rgba(0, 0, 0, 0.72) 4px);
}

.screen-flash {
  z-index: 88;
  opacity: 0;
  background: var(--route);
}

body.flash .screen-flash { animation: screen-flash 0.32s steps(2); }

.system-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: 60px;
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 2rem;
  padding: 0 2.5rem;
  border-bottom: 1px solid var(--line);
  background: rgba(3, 5, 6, 0.94);
  backdrop-filter: blur(16px);
  letter-spacing: 0.12em;
  font-size: 0.82rem;
}

.system-id,
.system-state,
.system-bar a,
.signature { white-space: nowrap; }

.system-id { color: var(--acid); }
.system-id span:last-child { margin-left: 1.25rem; color: var(--muted); }

.pulse {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 0.7rem;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 14px var(--acid);
  animation: pulse 1.3s steps(2) infinite;
}

.system-state { color: var(--route); }

.system-bar a {
  color: var(--muted);
  text-decoration: none;
}

.system-bar a:hover { color: var(--acid); }
.signature { color: #fff; letter-spacing: 0.35em; }

.simulator {
  min-height: calc(100vh - 60px);
  display: grid;
  grid-template-columns: minmax(210px, 0.78fr) minmax(510px, 2.1fr) minmax(310px, 1fr);
}

.event-log,
.control-rack,
.event-terminal { min-width: 0; }

.event-log,
.control-rack {
  position: relative;
  z-index: 2;
  padding: 1.75rem;
  background: rgba(3, 8, 8, 0.78);
}

.event-log { border-right: 1px solid var(--line); }
.control-rack { border-left: 1px solid var(--line); }

.panel-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.8rem;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.16em;
}

.panel-label span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line);
  color: var(--acid);
}

.event-rail {
  position: relative;
  min-height: calc(100vh - 190px);
  padding-left: 1.15rem;
}

.event-rail::before {
  content: "";
  position: absolute;
  top: 0.7rem;
  bottom: 0.7rem;
  left: 0.28rem;
  width: 1px;
  background: linear-gradient(var(--acid) var(--rail, 0%), var(--line) var(--rail, 0%));
}

.rail-event {
  position: relative;
  width: 100%;
  margin: 0 0 1.35rem;
  padding: 0 0 0.15rem 0.85rem;
  border: 0;
  background: transparent;
  text-align: left;
  opacity: 0.26;
  transition: opacity 180ms ease, transform 180ms ease;
}

.rail-event::before {
  content: "";
  position: absolute;
  top: 0.32rem;
  left: -1.18rem;
  width: 9px;
  height: 9px;
  border: 1px solid var(--muted);
  background: var(--black);
  transform: rotate(45deg);
}

.rail-event.active,
.rail-event.resolved { opacity: 1; }
.rail-event.active { transform: translateX(5px); }
.rail-event.active::before { border-color: var(--route); background: var(--route); box-shadow: 0 0 12px var(--route); }
.rail-event.resolved::before { border-color: var(--acid); background: var(--acid); }

.rail-event span,
.rail-event b,
.rail-event em { display: block; }
.rail-event span { margin-bottom: 0.25rem; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.11em; }
.rail-event b { color: var(--ink); font-size: 0.83rem; line-height: 1.25; }
.rail-event em { margin-top: 0.28rem; color: var(--route); font-size: 0.68rem; font-style: normal; line-height: 1.25; }

.log-footer {
  display: flex;
  justify-content: space-between;
  padding-top: 0.8rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.68rem;
}

.event-terminal {
  position: relative;
  overflow: hidden;
  min-height: calc(100vh - 60px);
  background:
    radial-gradient(circle at 52% 40%, color-mix(in srgb, var(--route) 10%, transparent), transparent 44%),
    rgba(4, 8, 9, 0.72);
}

.terminal-grid {
  position: absolute;
  inset: 0;
  opacity: 0.24;
  background:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 34px 34px;
  mask-image: linear-gradient(to bottom, black, transparent 85%);
}

.boot-screen,
.play-screen {
  position: relative;
  z-index: 2;
  min-height: calc(100vh - 60px);
  padding: clamp(2rem, 5vw, 5rem);
}

.boot-screen {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

.boot-screen > p,
.event-heading p {
  margin: 0 0 1.2rem;
  color: var(--acid);
  font-size: 0.82rem;
  letter-spacing: 0.18em;
}

.boot-screen h1,
.result-inner > h1 {
  position: relative;
  margin: 0;
  color: #fff;
  font-size: clamp(3.1rem, 8vw, 8.8rem);
  line-height: 0.82;
  letter-spacing: -0.09em;
  text-shadow: 0 0 42px color-mix(in srgb, var(--route) 35%, transparent);
}

.boot-screen h1::before,
.boot-screen h1::after,
.result-inner > h1::before,
.result-inner > h1::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  overflow: hidden;
  opacity: 0.6;
  pointer-events: none;
}

.boot-screen h1::before,
.result-inner > h1::before { color: var(--cyan); clip-path: inset(18% 0 58% 0); transform: translateX(-4px); }
.boot-screen h1::after,
.result-inner > h1::after { color: var(--danger); clip-path: inset(68% 0 8% 0); transform: translateX(5px); }

.boot-readout {
  width: min(32rem, 100%);
  display: grid;
  gap: 0.45rem;
  margin: 3rem 0 2.2rem;
  color: var(--muted);
  line-height: 1.4;
}

.command-button,
.execute-button,
.reset-button,
.result-actions a,
.result-actions button {
  border: 1px solid var(--acid);
  background: rgba(105, 255, 201, 0.055);
  color: var(--acid);
  cursor: pointer;
  text-decoration: none;
}

.command-button {
  min-width: min(25rem, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  padding: 1.2rem 1.35rem;
  text-align: left;
}

.command-button span { color: var(--muted); font-size: 0.76rem; }
.command-button:hover { background: var(--acid); color: var(--black); box-shadow: 0 0 32px rgba(105, 255, 201, 0.2); }
.command-button:hover span { color: var(--black); }

.play-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.event-heading {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  border-bottom: 1px solid var(--line);
}

.event-heading p { margin: 0 0 0.7rem; }
.event-heading span { margin-bottom: 0.7rem; color: var(--route); font-size: 0.72rem; letter-spacing: 0.13em; }

.event-title {
  max-width: 15ch;
  margin: clamp(1.5rem, 4vh, 3rem) 0 1.25rem;
  color: #fff;
  font-size: clamp(2.4rem, 5.2vw, 6.3rem);
  line-height: 0.88;
  letter-spacing: -0.065em;
  text-transform: uppercase;
  text-wrap: balance;
  filter: drop-shadow(3px 0 0 color-mix(in srgb, var(--route) 52%, transparent));
}

.signal-scope {
  height: 66px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0.6rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  overflow: hidden;
}

.signal-scope i {
  flex: 1;
  min-width: 2px;
  height: var(--scope);
  background: var(--route);
  opacity: 0.42;
  box-shadow: 0 0 8px var(--route);
  transform-origin: center;
  animation: scope 0.75s var(--delay) steps(3) infinite alternate;
}

.diagnostics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 2rem;
  margin: 1.2rem 0;
}

.diagnostic-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.65rem;
  min-height: 2.1rem;
  font-size: 0.78rem;
}

.diagnostic-row span { color: var(--muted); }
.diagnostic-row i { border-top: 1px dotted var(--line); }
.diagnostic-row b { color: var(--route); text-align: right; }

.decision-block { margin-top: auto; }

.decision-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 0.8rem;
  color: var(--ink);
  font-size: 0.78rem;
  letter-spacing: 0.1em;
}

.decision-label b { color: var(--danger); font-weight: normal; }

.choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.choice-card {
  position: relative;
  min-height: 108px;
  padding: 1rem;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.42);
  cursor: pointer;
  text-align: left;
}

.choice-card::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 3px;
  background: var(--choice-colour, var(--acid));
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 170ms ease;
}

.choice-card:hover,
.choice-card.selected {
  border-color: var(--choice-colour, var(--acid));
  background: color-mix(in srgb, var(--choice-colour, var(--acid)) 9%, transparent);
}

.choice-card:hover::after,
.choice-card.selected::after { transform: scaleX(1); }

.choice-card > b {
  display: block;
  margin-bottom: 1rem;
  color: #fff;
  font-size: clamp(0.88rem, 1.15vw, 1.05rem);
  line-height: 1.3;
}

.choice-card small {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 1rem;
  color: var(--muted);
  font-size: 0.7rem;
}

.choice-card small span:last-child { color: var(--choice-colour, var(--acid)); }

.execute-button {
  width: 100%;
  display: flex;
  justify-content: space-between;
  margin-top: 0.75rem;
  padding: 0.85rem 1rem;
  letter-spacing: 0.08em;
}

.execute-button:disabled { cursor: not-allowed; opacity: 0.25; }
.execute-button:not(:disabled):hover { background: var(--acid); color: var(--black); }

.gauge { margin-bottom: 1.6rem; }
.gauge-heading { display: flex; justify-content: space-between; align-items: flex-end; }
.gauge-heading span { color: var(--muted); font-size: 0.77rem; letter-spacing: 0.11em; }
.gauge-heading strong { color: var(--gauge-colour); font-size: 2.2rem; font-weight: normal; line-height: 1; }
.capability-gauge { --gauge-colour: var(--cyan); }
.safeguard-gauge { --gauge-colour: var(--acid); }

.gauge-track {
  position: relative;
  height: 12px;
  margin: 0.65rem 0;
  border: 1px solid color-mix(in srgb, var(--gauge-colour) 38%, transparent);
  background: rgba(0, 0, 0, 0.65);
}

.gauge-track::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 9%, rgba(3, 5, 6, 0.9) 9% 10%);
}

.gauge-track i {
  display: block;
  width: var(--gauge-value);
  height: 100%;
  background: var(--gauge-colour);
  box-shadow: 0 0 16px color-mix(in srgb, var(--gauge-colour) 65%, transparent);
  transition: width 280ms cubic-bezier(.2,.8,.2,1);
}

.capability-gauge .gauge-track { --gauge-value: var(--capability); }
.safeguard-gauge .gauge-track { --gauge-value: var(--safeguards); }

.gauge p {
  min-height: 1em;
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: right;
}

.breach-display {
  margin: 1.8rem -1.75rem;
  padding: 1.4rem 1.75rem;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--route) 5%, transparent);
}

.breach-display > span { color: var(--muted); font-size: 0.72rem; letter-spacing: 0.12em; }
.breach-display > strong { display: block; color: var(--route); font-size: clamp(3.3rem, 5vw, 5.6rem); font-weight: normal; line-height: 0.9; }
.breach-display > div { display: flex; justify-content: space-between; margin-top: 1rem; font-size: 0.77rem; }
.breach-display div span { color: var(--muted); }
.breach-display div b { color: var(--danger); font-weight: normal; }

.bank-heading { display: flex; justify-content: space-between; margin-bottom: 0.7rem; font-size: 0.7rem; letter-spacing: 0.08em; }
.bank-heading span { color: var(--muted); }
.bank-heading b { color: var(--route); font-weight: normal; }

.route-meter {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.35rem 0.75rem;
  margin-bottom: 0.75rem;
  padding: 0.55rem 0.65rem;
  border-left: 2px solid var(--meter-colour);
  background: rgba(255, 255, 255, 0.018);
  opacity: 0.58;
  transition: opacity 180ms ease, background 180ms ease, transform 180ms ease;
}

.route-meter.dominant { opacity: 1; background: color-mix(in srgb, var(--meter-colour) 9%, transparent); transform: translateX(4px); }
.route-meter b { color: var(--ink); font-size: 0.75rem; }
.route-meter > span { color: var(--meter-colour); font-size: 0.72rem; }
.route-meter .route-track { grid-column: 1 / -1; height: 3px; background: rgba(255,255,255,0.07); }
.route-meter .route-track i { display: block; width: var(--load); height: 100%; background: var(--meter-colour); box-shadow: 0 0 10px var(--meter-colour); transition: width 280ms ease; }

.reset-button {
  width: 100%;
  margin-top: 1.15rem;
  padding: 0.8rem;
  border-color: var(--line);
  color: var(--muted);
  background: transparent;
}

.reset-button:hover { border-color: var(--acid); color: var(--acid); }

.result-screen {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  overflow: auto;
  padding: 2rem;
  background: rgba(1, 2, 3, 0.96);
}

.result-screen::before {
  content: "";
  position: fixed;
  inset: 0;
  background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--route) 18%, transparent), transparent 46%);
  animation: alarm 1.25s steps(2) infinite;
}

.result-static {
  position: fixed;
  inset: 0;
  opacity: 0.12;
  background: repeating-linear-gradient(90deg, transparent 0 3px, var(--route) 4px, transparent 5px 18px);
  transform: skewX(-8deg);
  animation: static-slip 0.24s steps(2) infinite;
}

.result-inner {
  position: relative;
  width: min(860px, 100%);
  padding: clamp(1.4rem, 5vw, 4rem);
  border: 1px solid var(--route);
  background: rgba(2, 5, 6, 0.92);
  box-shadow: 0 0 80px color-mix(in srgb, var(--route) 16%, transparent);
  text-align: center;
}

.result-inner > p { margin: 0 0 1.4rem; color: var(--route); letter-spacing: 0.17em; font-size: 0.76rem; }
.result-inner > h1 { font-size: clamp(3.5rem, 10vw, 8rem); }
.result-symbol { margin: 1.4rem 0 0; color: var(--route); font-size: 3.5rem; text-shadow: 0 0 20px var(--route); }
.result-inner > h2 { margin: 0.6rem 0 1.6rem; color: #fff; font-size: clamp(1.5rem, 4vw, 3.4rem); letter-spacing: -0.04em; }

.result-readout {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border: 1px solid var(--line);
}

.result-readout span,
.result-readout b { padding: 0.75rem 0.5rem; }
.result-readout span { color: var(--muted); font-size: 0.66rem; }
.result-readout b { color: var(--route); font-size: 1.35rem; font-weight: normal; }

.result-log {
  max-height: 150px;
  margin: 1.2rem 0;
  overflow: auto;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  text-align: left;
}

.result-log span { display: grid; grid-template-columns: 5.2rem 1fr; gap: 1rem; padding: 0.55rem 0; color: var(--muted); font-size: 0.72rem; }
.result-log b { color: var(--acid); font-weight: normal; }

.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.result-actions a,
.result-actions button { padding: 1rem; }
.result-actions a:hover { background: var(--route); color: var(--black); }
.result-actions button { border-color: var(--line); color: var(--muted); }

body.critical .event-terminal,
body.critical .control-rack { animation: critical-jolt 1.4s steps(2) infinite; }

body.critical .event-title { animation: title-break 1.7s steps(2) infinite; }

@keyframes pulse { 50% { opacity: 0.2; } }
@keyframes noise-shift { 50% { transform: translate3d(1%, -1%, 0); } }
@keyframes screen-flash { 0%, 100% { opacity: 0; } 25% { opacity: 0.13; } 52% { opacity: 0.025; } }
@keyframes scope { to { transform: scaleY(0.24); opacity: 0.9; } }
@keyframes alarm { 50% { opacity: 0.58; } }
@keyframes static-slip { 50% { transform: translateX(18px) skewX(-8deg); } }
@keyframes critical-jolt { 0%, 94%, 100% { transform: none; } 95% { transform: translateX(-2px); } 97% { transform: translateX(3px); } }
@keyframes title-break { 0%, 92%, 100% { text-shadow: none; } 94% { text-shadow: -5px 0 var(--cyan), 6px 0 var(--danger); } }

@media (max-width: 1120px) {
  .simulator { grid-template-columns: 190px minmax(460px, 1fr) 285px; }
  .event-log, .control-rack { padding: 1.25rem; }
  .breach-display { margin-inline: -1.25rem; padding-inline: 1.25rem; }
  .boot-screen, .play-screen { padding: 2.2rem; }
  .diagnostics { grid-template-columns: 1fr; }
}

@media (max-width: 860px) {
  .system-bar { grid-template-columns: 1fr auto auto; gap: 1rem; padding: 0 1rem; }
  .system-state { display: none; }
  .simulator { display: flex; flex-direction: column; }
  .event-terminal { order: 1; min-height: 650px; }
  .control-rack { order: 2; border-top: 1px solid var(--line); border-left: 0; }
  .event-log { order: 3; border-top: 1px solid var(--line); border-right: 0; }
  .event-rail { min-height: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; padding: 0; }
  .event-rail::before { display: none; }
  .rail-event { margin: 0; padding: 0.7rem; border: 1px solid var(--line); }
  .rail-event::before { display: none; }
  .route-bank > div:last-child { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.6rem; }
  .route-meter { margin: 0; }
}

@media (max-width: 560px) {
  .system-bar { min-height: 54px; font-size: 0.69rem; }
  .system-id span:last-child, .system-bar a { display: none; }
  .signature { letter-spacing: 0.2em; }
  .event-terminal { min-height: 680px; }
  .boot-screen, .play-screen { min-height: 680px; padding: 1.35rem; }
  .boot-screen h1 { font-size: clamp(3.4rem, 20vw, 5.5rem); }
  .boot-readout { font-size: 0.8rem; }
  .event-heading { align-items: flex-start; flex-direction: column; gap: 0; }
  .event-title { font-size: clamp(2.5rem, 14vw, 4.5rem); }
  .signal-scope { height: 52px; }
  .diagnostic-row { font-size: 0.7rem; }
  .choice-grid { grid-template-columns: 1fr; }
  .choice-card { min-height: 88px; }
  .event-rail, .route-bank > div:last-child { grid-template-columns: 1fr; }
  .result-screen { padding: 0; }
  .result-inner { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; border: 0; }
  .result-readout { grid-template-columns: repeat(2, 1fr); }
  .result-actions { grid-template-columns: 1fr; }
}

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