
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bezel: #1a1a1e;
  --bezel-light: #2a2a30;
  --bezel-dark: #0a0a0d;
  --accent: #00cc88;
  --accent-dim: #005533;
  --danger: #ff3344;
  --warn: #ffaa22;
}
body {
  background: #0d0d10;
  overflow: hidden;
  font-family: 'Share Tech Mono', 'Courier New', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
}

/* ======== CRT MONITOR FRAME ======== */
#monitor {
  position: relative;
  width: 96vw;
  height: 94vh;
  background: linear-gradient(145deg, var(--bezel-light), var(--bezel), var(--bezel-dark));
  border-radius: 18px;
  padding: 22px 26px 32px;
  box-shadow:
    0 0 0 2px #333,
    0 0 0 4px #111,
    inset 0 2px 4px rgba(255,255,255,0.05),
    0 8px 40px rgba(0,0,0,0.8),
    0 0 120px rgba(0, 180, 120, 0.04);
}
#monitor-brand {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  color: #555;
  font-size: 10px;
  letter-spacing: 4px;
  text-transform: uppercase;
  user-select: none;
}
#power-led {
  position: absolute;
  bottom: 10px;
  right: 40px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00ff88;
  box-shadow: 0 0 6px #00ff88, 0 0 12px #00ff8844;
  animation: ledBlink 3s ease-in-out infinite;
}
@keyframes ledBlink {
  0%, 90%, 100% { opacity: 1; }
  95% { opacity: 0.3; }
}
#power-label {
  position: absolute;
  bottom: 8px;
  right: 52px;
  color: #444;
  font-size: 8px;
  letter-spacing: 2px;
}

/* ======== SCREEN VIEWPORT ======== */
#screen {
  position: relative;
  width: 100%;
  height: 100%;
  background: #000408;
  border-radius: 8px;
  overflow: hidden;
  box-shadow:
    inset 0 0 80px rgba(0, 180, 120, 0.06),
    inset 0 0 3px rgba(0,0,0,1),
    0 0 1px rgba(0, 180, 120, 0.3);
}

/* CRT curvature */
#screen::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: radial-gradient(ellipse at center, transparent 60%, rgba(0,0,0,0.4) 100%);
  pointer-events: none;
  z-index: 50;
}

/* Scanlines overlay */
#scanlines {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
  pointer-events: none;
  z-index: 45;
  mix-blend-mode: multiply;
}

#webgl-canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
}

/* ======== TOP BAR ======== */
#top-bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 36px;
  background: linear-gradient(180deg, rgba(0, 20, 12, 0.95), rgba(0, 12, 8, 0.85));
  border-bottom: 1px solid rgba(0, 180, 120, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  z-index: 30;
  font-size: 13px;
  color: var(--accent-dim);
  letter-spacing: 1px;
  user-select: none;
}
#top-bar .title {
  color: var(--accent);
  font-size: 14px;
  text-shadow: 0 0 8px rgba(0, 200, 120, 0.4);
}
#top-bar .sys-time {
  color: #44aa66;
  font-size: 13px;
}

/* ======== STATS BAR ======== */
#stats-bar {
  position: absolute;
  top: 36px; left: 0; right: 0;
  height: 28px;
  background: rgba(0, 12, 8, 0.7);
  border-bottom: 1px solid rgba(0, 180, 120, 0.1);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 18px;
  z-index: 30;
  font-size: 12px;
  color: #336644;
  letter-spacing: 1px;
  user-select: none;
}
#stats-bar .stat-val { color: #44aa66; }
#stats-bar .stat-warn { color: var(--warn); }
#stats-bar .stat-danger { color: var(--danger); }

/* ======== INFECTION HP BAR ======== */
#infection-bar-wrap {
  position: absolute;
  top: 65px; left: 12px; right: 12px;
  height: 10px;
  z-index: 31;
  background: rgba(0, 20, 12, 0.6);
  border: 1px solid rgba(0, 180, 120, 0.15);
  border-radius: 2px;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.5s;
}
#infection-bar-wrap.visible { opacity: 1; }
#infection-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #44aa22, #88cc00, #ccaa00, #ff6600, #ff3300, #ff0033);
  background-size: 600% 100%;
  transition: width 0.3s ease;
  box-shadow: 0 0 8px rgba(255, 100, 0, 0.5);
  border-radius: 2px;
}
#infection-bar-label {
  position: absolute;
  top: -1px;
  right: 8px;
  font-size: 9px;
  color: #ff8844;
  letter-spacing: 1px;
  line-height: 12px;
}

/* ======== DANGER ALERTS ======== */
#danger-alert {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 80;
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
#danger-alert.active { opacity: 1; }
#danger-alert .alert-icon {
  font-size: 64px;
  line-height: 1;
  filter: drop-shadow(0 0 16px rgba(255, 30, 30, 0.9));
}
#danger-alert .alert-text {
  font-size: 22px;
  font-weight: bold;
  color: #ff2233;
  letter-spacing: 6px;
  text-shadow: 0 0 12px rgba(255, 30, 30, 0.9), 0 0 40px rgba(255, 0, 30, 0.5);
  margin-top: 6px;
}
#danger-alert .alert-sub {
  font-size: 14px;
  color: #ff6644;
  letter-spacing: 3px;
  margin-top: 6px;
  text-shadow: 0 0 8px rgba(255, 80, 40, 0.6);
}

/* ======== AI INTERPRETATION WINDOW ======== */
#ai-window {
  position: absolute;
  top: 80px; right: 12px;
  z-index: 31;
  width: 280px;
  max-height: 240px;
  background: rgba(0, 6, 12, 0.85);
  border: 1px solid rgba(60, 140, 255, 0.25);
  border-radius: 3px;
  padding: 8px 10px;
  overflow: hidden;
  user-select: none;
}
#ai-window .ai-title {
  font-size: 12px;
  color: #3388cc;
  letter-spacing: 2px;
  border-bottom: 1px solid rgba(60, 140, 255, 0.15);
  padding-bottom: 4px;
  margin-bottom: 6px;
}
#ai-window .ai-line {
  font-size: 12px;
  color: #5599bb;
  line-height: 1.6;
  margin: 3px 0;
  opacity: 0.9;
}
#ai-window .ai-line.action { color: #44ccaa; }
#ai-window .ai-line.threat { color: #ff6644; }
#ai-window .ai-line.event { color: #ccaa44; }
#ai-window .ai-cursor {
  display: inline-block;
  width: 6px;
  height: 12px;
  background: #3388cc;
  animation: aiCursorBlink 1s step-end infinite;
  vertical-align: middle;
  margin-left: 2px;
}
@keyframes aiCursorBlink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

/* ======== EVENT LOG ======== */
#event-log {
  position: absolute;
  top: 80px; left: 12px;
  z-index: 30;
  font-size: 13px;
  color: var(--accent);
  user-select: none;
  max-width: 500px;
  max-height: 160px;
  overflow: hidden;
}
.event-line {
  opacity: 1;
  transition: opacity 2s;
  margin: 3px 0;
  text-shadow: 0 0 6px rgba(0, 200, 120, 0.4);
  white-space: nowrap;
}
.event-line.danger { color: var(--danger); text-shadow: 0 0 8px rgba(255, 50, 50, 0.6); }
.event-line.warn { color: var(--warn); text-shadow: 0 0 8px rgba(255, 170, 30, 0.6); }
.event-line.critical { color: #ff0044; font-size: 15px; text-shadow: 0 0 12px rgba(255, 0, 60, 0.9); }

/* ======== POPULATION CHART ======== */
#pop-chart-panel {
  position: absolute;
  bottom: 12px; right: 12px;
  z-index: 31;
  width: 320px;
  height: 180px;
  background: rgba(0, 8, 4, 0.8);
  border: 1px solid rgba(0, 180, 120, 0.2);
  border-radius: 3px;
  padding: 6px;
  user-select: none;
}
#pop-chart-panel .chart-title {
  font-size: 11px;
  color: #337755;
  letter-spacing: 2px;
  text-align: center;
  margin-bottom: 3px;
}
#pop-chart-canvas {
  width: 100%;
  height: calc(100% - 16px);
}

/* ======== INFO PANEL (organism details on click) ======== */
#info-panel {
  position: absolute;
  bottom: 12px; left: 12px;
  z-index: 31;
  font-size: 13px;
  color: #44aa66;
  line-height: 1.7;
  max-width: 380px;
  background: rgba(0, 8, 4, 0.8);
  padding: 10px 14px;
  border: 1px solid rgba(0, 180, 120, 0.2);
  border-radius: 3px;
  user-select: none;
  display: none;
}
#info-panel.visible { display: block; }
#info-panel .label { color: #227744; }
#info-panel .val { color: var(--accent); }
#info-panel .species-name { color: #00ffaa; font-size: 15px; letter-spacing: 2px; }

/* ======== CONTROLS HELP ======== */
#controls-help {
  position: absolute;
  bottom: 200px; right: 12px;
  z-index: 30;
  font-size: 12px;
  color: #335533;
  text-align: right;
  user-select: none;
  line-height: 2;
}
#controls-help span { color: #558855; }

/* ======== PAUSE OVERLAY ======== */
#pause-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 4, 2, 0.5);
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 28px;
  letter-spacing: 10px;
}
#pause-overlay.active { display: flex; }

/* ======== BOOT SEQUENCE ======== */
#boot {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  background: #000408;
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  flex-direction: column;
  color: var(--accent-dim);
  font-size: 14px;
  transition: opacity 1.5s;
  padding: 40px;
  overflow: hidden;
}
#boot.done { opacity: 0; pointer-events: none; }
#boot div { margin: 3px 0; opacity: 0; transition: opacity 0.3s; }
#boot .ok { color: var(--accent); }
#boot .warn { color: var(--warn); }
#boot .err { color: var(--danger); }

/* ======== FULLSCREEN ======== */
body:fullscreen #monitor,
body:-webkit-full-screen #monitor {
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

/* ======== SCREEN EFFECTS ======== */
#screen-flash {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 40;
  opacity: 0;
  transition: opacity 0.1s;
}
#screen.shake {
  animation: screenShake 0.15s ease-in-out;
}
@keyframes screenShake {
  0%, 100% { transform: translate(0,0); }
  20% { transform: translate(-3px, 2px); }
  40% { transform: translate(3px, -1px); }
  60% { transform: translate(-1px, 3px); }
  80% { transform: translate(2px, -3px); }
}

/* ======== NEON NIGHTLIFE OVERRIDE ======== */
@keyframes rainbowPulse {
  0% { filter: hue-rotate(0deg) saturate(1.15); }
  100% { filter: hue-rotate(360deg) saturate(1.15); }
}
body {
  background:
    repeating-linear-gradient(116deg, rgba(34,211,238,0.10) 0 1px, transparent 1px 46px),
    repeating-linear-gradient(64deg, rgba(236,72,153,0.10) 0 1px, transparent 1px 54px),
    linear-gradient(135deg, #02030a, #0b0618 44%, #030d16 72%, #120008);
}
#monitor {
  background:
    linear-gradient(145deg, rgba(34,211,238,0.28), rgba(25,20,38,0.96), rgba(236,72,153,0.22)) padding-box,
    conic-gradient(from 120deg, #22d3ee, #a855f7, #ec4899, #f5c542, #10b981, #22d3ee) border-box;
  border: 2px solid transparent;
  box-shadow:
    0 0 0 2px rgba(255,255,255,0.08),
    inset 0 2px 4px rgba(255,255,255,0.08),
    0 8px 40px rgba(0,0,0,0.8),
    0 0 42px rgba(34,211,238,0.32),
    0 0 72px rgba(236,72,153,0.22);
  animation: rainbowPulse 12s linear infinite;
}
#screen {
  box-shadow:
    inset 0 0 95px rgba(34,211,238,0.10),
    inset 0 0 120px rgba(236,72,153,0.06),
    0 0 26px rgba(34,211,238,0.24),
    0 0 44px rgba(236,72,153,0.16);
}
#webgl-canvas {
  filter: saturate(1.2) contrast(1.08);
}
#scanlines {
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(34,211,238,0.08) 2px, rgba(236,72,153,0.08) 4px);
}
#monitor-brand, #system-status, #ai-window .ai-title {
  text-shadow: 0 0 10px rgba(34,211,238,0.7), 0 0 20px rgba(236,72,153,0.45);
}

/* NSP IDG return chrome — hub polish A */
.nsp-return{position:fixed;z-index:10050;top:10px;left:10px;display:flex;gap:8px;flex-wrap:wrap;pointer-events:none}
.nsp-return a{pointer-events:auto;min-height:40px;padding:0 12px;display:inline-grid;place-items:center;border-radius:5px;text-decoration:none;font:800 10px/1 Inter,Segoe UI,system-ui,sans-serif;letter-spacing:.1em;text-transform:uppercase;border:1px solid rgba(102,247,237,.45);background:linear-gradient(145deg,rgba(3,7,16,.92),rgba(10,8,24,.8));color:#66f7ed;backdrop-filter:blur(10px);box-shadow:0 8px 24px rgba(0,0,0,.35)}
.nsp-return a:hover{border-color:#f7ce66;color:#f7ce66}
.nsp-return a.secondary{border-color:rgba(148,163,184,.35);color:#94a3b8;font-weight:700}
.nsp-return a.secondary:hover{border-color:#66f7ed;color:#66f7ed}
