:root {
  --bg: #050507;
  --panel-bg: rgba(12, 10, 14, 0.9);
  --border: #5c0a12;
  --border-bright: #ff1e38;
  --red: #ff1e38;
  --red-dark: #7a000d;
  --green: #00ff66;
  --amber: #ffb000;
  --text: #e6e6eb;
  --muted: #8a8a99;
  --font-mono: 'Consolas', 'Courier New', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
}

/* Matrix background canvas */
#bgMatrix {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.18;
  z-index: 0;
  pointer-events: none;
}

/* CRT scanlines & vignette */
.scanlines {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0) 0px,
    rgba(255, 255, 255, 0) 2px,
    rgba(0, 0, 0, 0.28) 3px,
    rgba(0, 0, 0, 0.28) 4px
  );
}

.vignette {
  position: fixed;
  inset: 0;
  z-index: 91;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 55%, rgba(180, 0, 20, 0.35) 100%);
}

.red-flash {
  position: fixed;
  inset: 0;
  z-index: 92;
  pointer-events: none;
  background: rgba(255, 0, 30, 0);
  transition: background 0.1s ease;
}

.red-flash.active {
  background: rgba(255, 0, 30, 0.32);
}

/* Bait Banner */
.bait-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 120;
  background: linear-gradient(90deg, #8b0000, #ff0022, #8b0000);
  color: #fff;
  font-size: 13px;
  font-weight: bold;
  letter-spacing: 1px;
  padding: 6px 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 2px 18px rgba(255, 0, 34, 0.7);
}

.bait-banner.hidden {
  display: none;
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  animation: blink 0.5s infinite;
}

/* Main Shell */
.main-shell {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding: 34px 10px 8px;
  gap: 8px;
  transition: transform 0.05s linear;
}

.main-shell.no-banner {
  padding-top: 8px;
}

.main-shell.shake {
  animation: screenShake 0.28s linear infinite;
}

.main-shell.heavy-glitch {
  animation: glitchSkew 0.15s steps(2) infinite;
  filter: contrast(1.4) saturate(1.8);
}

/* Top Bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(24, 4, 8, 0.95);
  border: 1px solid var(--border-bright);
  padding: 8px 14px;
  box-shadow: 0 0 18px rgba(255, 30, 56, 0.35);
  flex-wrap: wrap;
  gap: 8px;
}

.top-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.alert-badge {
  background: var(--red);
  color: #000;
  font-weight: 900;
  padding: 3px 8px;
  font-size: 12px;
  letter-spacing: 1px;
  animation: blink 0.6s infinite;
}

.glitch-text {
  position: relative;
  font-weight: bold;
  font-size: 14px;
  color: #fff;
  letter-spacing: 1px;
}

.top-right {
  display: flex;
  gap: 16px;
  font-size: 12px;
  flex-wrap: wrap;
}

.meta-item {
  color: var(--muted);
}

.danger { color: var(--red); }
.warn { color: var(--amber); }
.ok { color: var(--green); }

.timer-glow {
  color: #ff334b;
  text-shadow: 0 0 10px rgba(255, 30, 56, 0.9);
  font-size: 14px;
}

/* Main Grid */
.grid-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1.05fr 1.45fr 0.95fr;
  gap: 8px;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  box-shadow: inset 0 0 24px rgba(255, 0, 30, 0.08);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: rgba(45, 6, 12, 0.9);
  border-bottom: 1px solid var(--border);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 0.6px;
}

.danger-header {
  background: linear-gradient(90deg, rgba(140, 0, 18, 0.95), rgba(50, 4, 10, 0.95));
  border-bottom-color: var(--border-bright);
}

.panel-status {
  font-size: 10px;
  color: var(--red);
}

/* Terminal Panel */
.terminal-output {
  flex: 1;
  padding: 10px;
  font-size: 11.5px;
  line-height: 1.45;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  color: #c7f9cc;
}

.term-line {
  word-break: break-all;
  margin-bottom: 2px;
}

.term-line.err { color: #ff3b52; font-weight: bold; }
.term-line.warn { color: #ffbe2e; }
.term-line.cmd { color: #5ce1e6; }
.term-line.sys { color: #ff6b81; }

/* Ransomware Center Panel */
.ransom-panel {
  border-color: var(--border-bright);
  box-shadow: 0 0 20px rgba(255, 30, 56, 0.18), inset 0 0 30px rgba(255, 0, 20, 0.12);
}

.ransom-hero {
  display: flex;
  gap: 14px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  align-items: center;
}

.skull-box {
  flex-shrink: 0;
}

.ascii-skull {
  font-size: 6.5px;
  line-height: 6.5px;
  color: var(--red);
  text-shadow: 0 0 8px rgba(255, 30, 56, 0.8);
}

.ransom-info {
  flex: 1;
  min-width: 0;
}

.glitch-title {
  font-size: 20px;
  color: var(--red);
  text-shadow: 2px 0 #00fff9, -2px 0 #ff003c;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.ransom-desc {
  font-size: 12px;
  line-height: 1.45;
  color: #ddd;
  margin-bottom: 10px;
}

.ransom-desc code {
  background: rgba(255, 30, 56, 0.25);
  color: #ff7b8a;
  padding: 1px 4px;
}

.progress-wrapper {
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid var(--border);
  padding: 8px;
}

.progress-labels {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  margin-bottom: 5px;
  color: #ff8a98;
  font-weight: bold;
}

.progress-bar {
  width: 100%;
  height: 14px;
  background: #1a060a;
  border: 1px solid var(--border-bright);
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(
    -45deg,
    #ff1e38,
    #ff1e38 10px,
    #a80014 10px,
    #a80014 20px
  );
  transition: width 0.2s linear;
  box-shadow: 0 0 12px var(--red);
}

.current-file {
  margin-top: 5px;
  font-size: 11px;
  color: var(--amber);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* File Stream */
.file-stream-box {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
}

.sub-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  border-bottom: 1px dashed #3d0d14;
  padding-bottom: 4px;
}

.file-stream {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-size: 11px;
  gap: 2px;
}

.file-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  white-space: nowrap;
}

.file-path {
  overflow: hidden;
  text-overflow: ellipsis;
  color: #ccc;
}

.file-tag {
  color: var(--red);
  font-weight: bold;
  flex-shrink: 0;
}

/* Metrics Row */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
  background: rgba(20, 4, 8, 0.9);
}

.metric-card {
  padding: 8px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-card:last-child { border-right: none; }

.metric-label {
  font-size: 10px;
  color: var(--muted);
}

.metric-val {
  font-size: 15px;
  font-weight: bold;
}

/* Right Side Panel */
.side-panel {
  gap: 8px;
  background: transparent;
  border: none;
  box-shadow: none;
}

.sub-panel {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sub-panel.flex-grow {
  flex: 1;
  min-height: 0;
}

.webcam-box {
  position: relative;
  width: 100%;
  height: 155px;
  background: #000;
}

#webcamCanvas, #netCanvas {
  width: 100%;
  height: 100%;
  display: block;
}

.webcam-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 6px 8px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  font-size: 10px;
  color: var(--red);
  text-shadow: 0 0 4px #000;
}

.subsystem-list {
  list-style: none;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
  overflow: auto;
}

.subsystem-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dotted #330b12;
  padding-bottom: 4px;
}

.tag-dead, .tag-hack, .tag-warn {
  font-size: 10px;
  padding: 1px 6px;
  font-weight: bold;
}

.tag-dead { background: rgba(255, 30, 56, 0.25); color: #ff3b52; border: 1px solid #ff1e38; }
.tag-hack { background: rgba(255, 176, 0, 0.2); color: #ffc133; border: 1px solid #ffb000; }
.tag-warn { background: rgba(180, 0, 255, 0.2); color: #d580ff; border: 1px solid #b84dff; }

/* Bottom Bar */
.bottom-bar {
  display: flex;
  align-items: center;
  background: #1b0307;
  border: 1px solid var(--border-bright);
  height: 26px;
  overflow: hidden;
  font-size: 12px;
}

.ticker-wrap {
  flex: 1;
  overflow: hidden;
  white-space: nowrap;
}

.ticker-text {
  display: inline-block;
  padding-left: 100%;
  color: #ff4d63;
  font-weight: bold;
  animation: ticker 18s linear infinite;
}

.secret-exit {
  padding: 0 10px;
  font-size: 10px;
  color: #66222c;
  cursor: default;
  border-left: 1px solid #3a0911;
  height: 100%;
  display: flex;
  align-items: center;
}

/* Cascading Error Popups */
.popup-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

.fake-popup {
  position: absolute;
  width: 340px;
  background: #120609;
  border: 2px solid var(--red);
  box-shadow: 0 10px 35px rgba(0, 0, 0, 0.85), 0 0 20px rgba(255, 30, 56, 0.5);
  pointer-events: auto;
  animation: popIn 0.12s ease-out;
}

.fake-popup-title {
  background: linear-gradient(90deg, #b80016, #ff1e38);
  color: #fff;
  padding: 5px 8px;
  font-size: 11px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.fake-popup-close {
  background: #220005;
  color: #fff;
  border: 1px solid #fff;
  width: 18px;
  height: 18px;
  line-height: 14px;
  text-align: center;
  cursor: pointer;
  font-size: 11px;
}

.fake-popup-body {
  padding: 12px;
  font-size: 12px;
  line-height: 1.4;
  color: #ffdce0;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.popup-icon {
  font-size: 24px;
  color: var(--red);
  line-height: 1;
}

.fake-popup-actions {
  padding: 0 12px 10px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.fake-popup-actions button {
  background: #2b060c;
  color: #fff;
  border: 1px solid var(--red);
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 11px;
  cursor: pointer;
}

.fake-popup-actions button:hover {
  background: var(--red);
  color: #000;
}

/* Fake BSOD Screen */
.bsod-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #0078d7;
  color: #fff;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.bsod-content {
  max-width: 780px;
}

.bsod-sad {
  font-size: 110px;
  font-weight: 300;
  margin-bottom: 18px;
  line-height: 1;
}

.bsod-main {
  font-size: 24px;
  font-weight: 300;
  line-height: 1.4;
  margin-bottom: 24px;
}

.bsod-progress {
  font-size: 22px;
  font-weight: 300;
  margin-bottom: 30px;
}

.bsod-details {
  display: flex;
  gap: 20px;
  align-items: center;
}

.bsod-qr {
  width: 96px;
  height: 96px;
  background:
    repeating-linear-gradient(90deg, #fff 0 6px, #0078d7 6px 12px),
    repeating-linear-gradient(0deg, #fff 0 6px, transparent 6px 12px);
  border: 6px solid #fff;
  flex-shrink: 0;
}

.bsod-codes p {
  font-size: 14px;
  margin-bottom: 6px;
  opacity: 0.95;
}

/* Lockdown Screen (Phase 4) */
.lockdown-screen {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: radial-gradient(circle at top, #5e000c, #180003 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.lockdown-card {
  width: 100%;
  max-width: 880px;
  background: #0c0305;
  border: 2px solid var(--red);
  box-shadow: 0 0 60px rgba(255, 0, 30, 0.55);
}

.lockdown-header {
  background: #b80016;
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 18px;
}

.lock-icon {
  font-size: 46px;
  line-height: 1;
}

.lockdown-header h2 {
  font-size: 24px;
  letter-spacing: 1px;
}

.lockdown-header p {
  font-size: 12px;
  opacity: 0.9;
  margin-top: 4px;
}

.lockdown-body {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 24px;
  padding: 24px;
}

.countdown-box {
  background: #1a0408;
  border: 1px solid var(--red);
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
}

.countdown-label {
  font-size: 11px;
  color: #ff99a6;
  margin-bottom: 6px;
}

.countdown-time {
  font-size: 36px;
  font-weight: bold;
  color: var(--red);
  text-shadow: 0 0 14px rgba(255, 30, 56, 0.9);
}

.ransom-amount, .wallet-box {
  background: #140407;
  border: 1px solid #4d0a14;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
}

.ransom-amount strong {
  font-size: 18px;
  color: var(--amber);
}

.wallet-box code {
  color: var(--green);
  word-break: break-all;
  font-size: 12px;
}

.lockdown-right h3 {
  color: var(--red);
  margin: 10px 0 6px;
  font-size: 15px;
}

.lockdown-right p {
  font-size: 13px;
  line-height: 1.5;
  color: #ddd;
  margin-bottom: 10px;
}

.decrypt-input-row {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.decrypt-input-row input {
  flex: 1;
  background: #180509;
  border: 1px solid var(--red);
  color: #fff;
  padding: 10px;
  font-family: var(--font-mono);
  font-size: 12px;
}

.decrypt-input-row button {
  background: var(--red);
  color: #000;
  border: none;
  padding: 10px 16px;
  font-weight: bold;
  font-family: var(--font-mono);
  cursor: pointer;
}

.decrypt-status {
  margin-top: 8px;
  font-size: 12px;
  min-height: 18px;
  color: var(--amber);
}

/* Prank Reveal Screen */
.prank-screen {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: radial-gradient(circle at center, #0f2e1d 0%, #070d14 75%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.prank-card {
  width: 100%;
  max-width: 560px;
  background: #101924;
  border: 2px solid #00ff66;
  border-radius: 14px;
  padding: 36px 28px;
  text-align: center;
  box-shadow: 0 0 55px rgba(0, 255, 102, 0.35);
  animation: popIn 0.25s ease-out;
}

.prank-emoji {
  font-size: 58px;
  margin-bottom: 12px;
}

.prank-card h1 {
  font-size: 32px;
  color: #00ff66;
  letter-spacing: 1px;
  margin-bottom: 12px;
  text-shadow: 0 0 14px rgba(0, 255, 102, 0.5);
}

.prank-sub {
  font-size: 16px;
  line-height: 1.6;
  color: #e2e8f0;
  margin-bottom: 18px;
}

.prank-badge {
  display: inline-block;
  background: rgba(0, 255, 102, 0.12);
  border: 1px solid #00ff66;
  color: #a7f3d0;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  margin-bottom: 24px;
}

.prank-badge code {
  color: #fff;
  font-weight: bold;
}

.prank-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.prank-actions button {
  padding: 10px 18px;
  border-radius: 8px;
  border: 1px solid #334155;
  background: #1e293b;
  color: #f8fafc;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.prank-actions button:hover {
  background: #334155;
}

.prank-actions .btn-restart {
  background: #00c853;
  border-color: #00e676;
  color: #041309;
}

.prank-actions .btn-restart:hover {
  background: #00e676;
}

/* Safe Control Modal */
.control-modal {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: rgba(0, 0, 0, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.control-card {
  width: 100%;
  max-width: 520px;
  background: #12151c;
  border: 1px solid #3a4252;
  border-radius: 8px;
  padding: 24px;
  font-family: 'Segoe UI', sans-serif;
  color: #f1f5f9;
}

.control-card h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.control-card p {
  font-size: 13px;
  color: #94a3b8;
  margin-bottom: 16px;
}

.control-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}

.control-buttons button {
  padding: 10px 12px;
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  text-align: left;
}

.control-buttons button:hover {
  background: #334155;
}

.control-buttons .btn-primary {
  grid-column: 1 / -1;
  background: #dc2626;
  border-color: #ef4444;
  color: #fff;
  text-align: center;
  font-weight: bold;
}

.control-hint {
  font-size: 12px !important;
  margin-bottom: 0 !important;
}

.hidden {
  display: none !important;
}

/* Animations */
.blink-fast { animation: blink 0.45s infinite; }
.rec-blink { animation: blink 0.8s infinite; color: #ff2a40; }

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

@keyframes ticker {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

@keyframes screenShake {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 2px); }
  50% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, -3px); }
  100% { transform: translate(2px, 2px); }
}

@keyframes glitchSkew {
  0% { transform: skewX(0deg); }
  25% { transform: skewX(4deg) translateX(-4px); }
  50% { transform: skewX(-5deg) translateX(5px); }
  75% { transform: skewX(2deg); }
  100% { transform: skewX(0deg); }
}

@keyframes popIn {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* Responsive fallback */
@media (max-width: 980px) {
  .grid-layout {
    grid-template-columns: 1fr;
    overflow-y: auto;
  }
  .lockdown-body {
    grid-template-columns: 1fr;
  }
}
