:root {
  --bg-deep: #050811;
  --panel-bg: rgba(10, 16, 30, 0.88);
  --panel-solid: #0b1324;
  --panel-border: rgba(56, 189, 248, 0.25);
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-cyan: #38bdf8;
  --accent-emerald: #10b981;
  --accent-amber: #fbbf24;
  --accent-crimson: #ef4444;
  --font-sans: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'Cascadia Code', 'Fira Code', 'Consolas', 'Courier New', monospace;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

.hidden {
  display: none !important;
}

/* ================= 3D CANVAS & OVERLAY LAYERS ================= */

#vault-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

#vault-labels {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}

.vault-node-callout {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: auto;
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid rgba(239, 68, 68, 0.75);
  background: rgba(11, 18, 34, 0.88);
  backdrop-filter: blur(8px);
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  white-space: nowrap;
}

.vault-node-callout:hover,
.vault-node-callout.hovered {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.45);
  background: rgba(14, 28, 52, 0.95);
}

.vault-node-callout.unlocked {
  border-color: rgba(16, 185, 129, 0.75);
  background: rgba(6, 40, 31, 0.88);
}

.callout-code {
  font-weight: 700;
  color: #fca5a5;
  letter-spacing: 0.04em;
}

.vault-node-callout.hovered .callout-code {
  color: var(--accent-cyan);
}

.vault-node-callout.unlocked .callout-code {
  color: #34d399;
}

.callout-title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 12px;
}

/* FX Overlay */
.fx-overlay {
  position: fixed;
  inset: 0;
  z-index: 4;
  pointer-events: none;
  transition: background 0.25s ease;
}

.fx-overlay.panic-pulse {
  animation: panicVignette 1.1s infinite ease-in-out;
}

.fx-overlay.error-flash {
  background: radial-gradient(circle, rgba(239, 68, 68, 0.14) 25%, rgba(220, 38, 38, 0.55) 100%);
}

.fx-overlay.busted-strobe {
  animation: bustedStrobe 0.55s infinite linear;
}

@keyframes panicVignette {
  0%, 100% {
    box-shadow: inset 0 0 70px rgba(239, 68, 68, 0.15);
  }
  50% {
    box-shadow: inset 0 0 130px rgba(239, 68, 68, 0.48);
  }
}

@keyframes bustedStrobe {
  0%, 49% {
    box-shadow: inset 0 0 160px rgba(239, 68, 68, 0.55);
  }
  50%, 100% {
    box-shadow: inset 0 0 160px rgba(59, 130, 246, 0.55);
  }
}

/* Toast */
.floating-toast {
  position: fixed;
  top: 136px;
  left: 50%;
  transform: translate(-50%, -14px);
  z-index: 60;
  padding: 10px 18px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid var(--accent-cyan);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
}

.floating-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.floating-toast.success {
  border-color: var(--accent-emerald);
  color: #a7f3d0;
}

.floating-toast.warn {
  border-color: var(--accent-amber);
  color: #fde68a;
}

/* ================= SHARED CONTROLS & OVERLAYS ================= */

.screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at center, rgba(5, 8, 17, 0.42), rgba(5, 8, 17, 0.85));
  overflow-y: auto;
}

.glass-card {
  width: 100%;
  max-width: 820px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 28px;
  backdrop-filter: blur(14px);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.72), inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.top-bar-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.lang-switch {
  display: inline-flex;
  border-radius: 8px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  overflow: hidden;
  background: rgba(15, 23, 42, 0.75);
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.lang-btn.active {
  background: var(--accent-cyan);
  color: #061224;
}

.icon-btn {
  border: 1px solid rgba(148, 163, 184, 0.32);
  background: rgba(15, 23, 42, 0.78);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.icon-btn:hover {
  border-color: var(--accent-cyan);
  background: rgba(30, 41, 59, 0.9);
}

.icon-btn.muted {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.4);
}

.icon-btn.danger {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.45);
}

.icon-btn.danger:hover {
  background: rgba(127, 29, 29, 0.55);
}

.brand-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  color: var(--accent-cyan);
  text-transform: uppercase;
  margin-bottom: 6px;
}

.hero-title {
  margin: 0 0 10px;
  font-size: clamp(26px, 4vw, 40px);
  font-weight: 800;
  letter-spacing: 0.03em;
  background: linear-gradient(90deg, #f8fafc 0%, #38bdf8 60%, #a78bfa 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-tagline {
  margin: 0 0 22px;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.55;
}

.section-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.diff-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.diff-card {
  text-align: left;
  background: rgba(15, 23, 42, 0.72);
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 12px;
  padding: 14px;
  color: var(--text-main);
  cursor: pointer;
  transition: transform 0.15s, border-color 0.2s, box-shadow 0.2s;
}

.diff-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56, 189, 248, 0.55);
}

.diff-card.selected {
  border-color: var(--accent-cyan);
  background: rgba(14, 34, 61, 0.88);
  box-shadow: 0 0 22px rgba(56, 189, 248, 0.25);
}

.diff-name {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
  color: var(--accent-cyan);
  margin-bottom: 4px;
}

.diff-card[data-diff="mastermind"] .diff-name {
  color: var(--accent-amber);
}

.diff-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #cbd5e1;
  margin-bottom: 6px;
}

.diff-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

.menu-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.record-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
}

.record-pill strong {
  color: var(--accent-amber);
  margin-left: 6px;
}

.primary-btn {
  border: none;
  border-radius: 10px;
  padding: 12px 24px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #041322;
  background: linear-gradient(135deg, #38bdf8, #0ea5e9);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(14, 165, 233, 0.35);
  transition: transform 0.14s, filter 0.14s;
}

.primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.primary-btn.emerald {
  background: linear-gradient(135deg, #34d399, #10b981);
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
}

.secondary-btn {
  border: 1px solid rgba(148, 163, 184, 0.36);
  border-radius: 10px;
  padding: 11px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-main);
  background: rgba(15, 23, 42, 0.72);
  cursor: pointer;
}

.secondary-btn:hover {
  border-color: var(--accent-cyan);
}

.controls-tip {
  margin-top: 14px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* ================= BRIEFING ================= */

.brief-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.brief-badge {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.16);
  border: 1px solid rgba(56, 189, 248, 0.45);
  color: var(--accent-cyan);
}

.brief-kpis {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 16px 0 20px;
}

.kpi-box {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  padding: 12px;
}

.kpi-lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.kpi-val {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
  color: var(--text-main);
}

.kpi-val.gold { color: var(--accent-amber); }
.kpi-val.danger { color: #fca5a5; }

.brief-modules-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.brief-module-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

.mod-code {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
}

.mod-title {
  font-size: 13px;
  font-weight: 700;
}

.mod-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.brief-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* ================= GAMEPLAY TACTICAL HUD ================= */

#hud-gameplay {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 14px 18px;
}

.hud-top {
  pointer-events: auto;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-radius: 14px;
  background: rgba(9, 14, 28, 0.84);
  border: 1px solid rgba(56, 189, 248, 0.24);
  backdrop-filter: blur(10px);
}

.hud-metrics {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-stat {
  display: flex;
  flex-direction: column;
}

.hud-lbl {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

.hud-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
}

.hud-val.gold {
  color: var(--accent-amber);
}

.hud-center {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.timer-box {
  text-align: center;
  min-width: 96px;
}

.timer-val {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 800;
  color: var(--accent-cyan);
  line-height: 1.05;
}

.timer-val.panic {
  color: var(--accent-crimson);
  animation: timerPulse 0.75s infinite alternate;
}

@keyframes timerPulse {
  from { text-shadow: 0 0 6px rgba(239, 68, 68, 0.4); }
  to { text-shadow: 0 0 18px rgba(239, 68, 68, 0.95); }
}

.police-box {
  min-width: 155px;
  max-width: 280px;
  flex: 1;
}

.police-top {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  margin-bottom: 6px;
  gap: 8px;
}

.eta-status {
  color: #cbd5e1;
  font-weight: 700;
}

.eta-status.warning {
  color: var(--accent-amber);
}

.eta-status.critical {
  color: #fca5a5;
}

.police-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
}

.police-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #f59e0b, #ef4444);
  transition: width 0.25s linear;
}

.police-marker {
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #ef4444;
  border: 2px solid #ffffff;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.9);
  transition: left 0.25s linear;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Bottom Quick-Dock */
.hud-bottom {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.camera-hint-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(9, 14, 28, 0.72);
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.18);
}

.lock-dock {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 220px));
  justify-content: center;
  width: 100%;
  max-width: 900px;
  gap: 10px;
}

.dock-lock-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(9, 14, 28, 0.86);
  backdrop-filter: blur(8px);
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: transform 0.14s, border-color 0.2s, box-shadow 0.2s;
}

.dock-lock-btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
}

.dock-lock-btn.active {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.32);
}

.dock-lock-btn.unlocked {
  border-color: rgba(16, 185, 129, 0.6);
  background: rgba(6, 36, 28, 0.85);
}

.dock-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dock-info {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.dock-code {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.dock-name {
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dock-badge {
  font-family: var(--font-mono);
  font-size: 9px;
  font-weight: 800;
  padding: 3px 6px;
  border-radius: 5px;
  background: rgba(239, 68, 68, 0.16);
  color: #fca5a5;
}

.dock-lock-btn.unlocked .dock-badge {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

/* ================= PUZZLE TERMINAL MODAL ================= */

#modal-puzzle {
  z-index: 30;
  background: rgba(4, 7, 15, 0.72);
}

.terminal-card {
  width: 100%;
  max-width: 780px;
  max-height: calc(100vh - 110px);
  display: flex;
  flex-direction: column;
  background: var(--panel-solid);
  border: 1px solid rgba(56, 189, 248, 0.42);
  border-radius: 16px;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.85);
  overflow: hidden;
}

.terminal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(15, 23, 42, 0.95);
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.terminal-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.terminal-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
}

.terminal-module-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pz-lock-code {
  font-family: var(--font-mono);
  font-weight: 800;
  font-size: 13px;
}

.pz-module-title {
  font-size: 15px;
  font-weight: 700;
}

.terminal-badges {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.16);
  color: var(--accent-cyan);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

.pill-badge.stage {
  background: rgba(251, 191, 36, 0.14);
  color: var(--accent-amber);
  border-color: rgba(251, 191, 36, 0.35);
}

.terminal-body {
  padding: 18px 22px;
  overflow-y: auto;
  flex: 1;
}

.pz-prompt {
  margin: 0 0 6px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.45;
  color: #f8fafc;
}

.pz-context {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--text-muted);
}

/* Code Widgets */
.code-box {
  background: #060b16;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 10px;
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  overflow-x: auto;
  margin-bottom: 14px;
}

.code-line {
  display: flex;
  gap: 14px;
  white-space: pre;
}

.code-line.bug-line {
  background: rgba(239, 68, 68, 0.18);
  margin: 0 -14px;
  padding: 0 14px;
  border-left: 3px solid var(--accent-crimson);
}

.line-num {
  color: #475569;
  min-width: 18px;
  text-align: right;
  user-select: none;
}

.tok-kw { color: #c084fc; font-weight: 600; }
.tok-fn { color: #38bdf8; }
.tok-num { color: #fbbf24; }
.tok-cmt { color: #64748b; font-style: italic; }

.num-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.terminal-input {
  flex: 1;
  max-width: 280px;
  background: #060b16;
  border: 1px solid rgba(56, 189, 248, 0.45);
  border-radius: 8px;
  padding: 11px 14px;
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
  outline: none;
}

.terminal-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.3);
}

.unit-pill {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-cyan);
}

.sub-label {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.patch-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.patch-opt-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  padding: 10px 14px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.72);
  color: var(--text-main);
  font-family: var(--font-mono);
  font-size: 13px;
  cursor: pointer;
}

.patch-opt-btn:hover {
  border-color: rgba(56, 189, 248, 0.6);
}

.patch-opt-btn.selected {
  border-color: var(--accent-cyan);
  background: rgba(14, 34, 61, 0.9);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.22);
}

.opt-key {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  background: rgba(148, 163, 184, 0.16);
  color: var(--accent-cyan);
  flex-shrink: 0;
}

/* Sequence / Tree / Ops / Sort */
.tree-svg-wrap,
.schematic-wrap {
  background: #060b16;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 14px;
  display: flex;
  justify-content: center;
}

.tree-svg,
.circuit-svg {
  width: 100%;
  max-width: 440px;
  height: auto;
}

.tree-edge,
.cir-link {
  stroke: rgba(56, 189, 248, 0.55);
  stroke-width: 2.2;
}

.tree-node-circle {
  fill: #0f172a;
  stroke: #a78bfa;
  stroke-width: 2.4;
}

.tree-node-g.picked .tree-node-circle {
  fill: #064e3b;
  stroke: #10b981;
}

.tree-node-text {
  fill: #f8fafc;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 800;
}

.cir-node {
  fill: #0f172a;
  stroke: #38bdf8;
  stroke-width: 2.2;
}

.cir-node.vault {
  stroke: #34d399;
}

.cir-lbl {
  fill: #f8fafc;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 800;
}

.cir-wt {
  fill: #fbbf24;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.ops-ribbon,
.sort-initial-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px;
  border-radius: 10px;
  background: #060b16;
  border: 1px solid rgba(148, 163, 184, 0.22);
  margin-bottom: 14px;
}

.op-pill {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.14);
  color: #7dd3fc;
}

.op-pill.pop {
  background: rgba(251, 191, 36, 0.16);
  color: #fde68a;
}

.sort-box {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 8px;
  background: rgba(167, 139, 250, 0.15);
  border: 1px solid rgba(167, 139, 250, 0.45);
  color: #ddd6fe;
}

.seq-slots {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.seq-slot {
  min-width: 48px;
  height: 44px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px dashed rgba(148, 163, 184, 0.4);
  background: #060b16;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
}

.seq-slot.filled {
  border-style: solid;
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
}

.slot-empty { color: #475569; }

.seq-pool-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.seq-actions {
  display: flex;
  gap: 6px;
}

.mini-btn {
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.mini-btn:hover {
  color: var(--text-main);
  border-color: var(--accent-cyan);
}

.chip-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hex-chip {
  min-width: 54px;
  height: 44px;
  border-radius: 9px;
  border: 1px solid rgba(167, 139, 250, 0.6);
  background: rgba(30, 27, 75, 0.65);
  color: #f8fafc;
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.hex-chip:hover:not(:disabled) {
  border-color: var(--accent-cyan);
  transform: translateY(-1px);
}

.hex-chip.used {
  opacity: 0.3;
  cursor: default;
}

/* Pipeline Order & Slot Match */
.pipeline-slots,
.pipeline-pool {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.pipe-slot,
.stage-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px dashed rgba(148, 163, 184, 0.35);
  background: #060b16;
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.pipe-slot.filled {
  border-style: solid;
  border-color: var(--accent-amber);
  background: rgba(45, 31, 8, 0.45);
}

.pipe-num {
  font-family: var(--font-mono);
  font-weight: 800;
  color: var(--accent-amber);
}

.stage-chip {
  border-style: solid;
  border-color: rgba(56, 189, 248, 0.38);
  background: rgba(15, 23, 42, 0.8);
}

.stage-chip.used {
  opacity: 0.3;
  cursor: default;
}

.match-hint-bar {
  font-size: 12px;
  color: var(--accent-cyan);
  margin-bottom: 10px;
}

.match-grid {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 14px;
}

.match-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-chip,
.match-port {
  padding: 10px 12px;
  border-radius: 9px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.match-chip.active {
  border-color: var(--accent-cyan);
  background: rgba(14, 42, 74, 0.9);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
}

.match-chip.used {
  opacity: 0.32;
  cursor: default;
}

.match-port {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.match-port.filled {
  border-color: var(--accent-emerald);
  background: rgba(6, 40, 31, 0.72);
}

.port-desc {
  font-size: 12px;
  color: #cbd5e1;
}

.port-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.14);
  color: var(--accent-cyan);
  white-space: nowrap;
}

/* Binary Switches */
.binary-target-card {
  background: #060b16;
  border: 1px solid rgba(52, 211, 153, 0.35);
  border-radius: 10px;
  padding: 12px 16px;
  margin-bottom: 14px;
}

.binary-target-code {
  font-family: var(--font-mono);
  font-size: 18px;
  font-weight: 800;
  color: #6ee7b7;
}

.binary-bank {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
}

.bit-switch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 10px 4px;
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: #060b16;
  color: var(--text-muted);
  cursor: pointer;
}

.bit-switch.on {
  border-color: var(--accent-emerald);
  background: rgba(6, 52, 40, 0.7);
  color: #6ee7b7;
  box-shadow: 0 0 14px rgba(16, 185, 129, 0.28);
}

.bit-weight {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.bit-rail {
  width: 24px;
  height: 40px;
  border-radius: 999px;
  background: #1e293b;
  position: relative;
  padding: 3px;
}

.bit-knob {
  display: block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #64748b;
  transform: translateY(16px);
  transition: transform 0.15s, background 0.15s;
}

.bit-switch.on .bit-knob {
  transform: translateY(0);
  background: #34d399;
}

.bit-val {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 800;
}

/* Feedback & Crew Comms Hint Panel */
.pz-feedback {
  min-height: 20px;
  margin-top: 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
}

.pz-feedback.ok { color: #34d399; }
.pz-feedback.err { color: #fca5a5; }
.pz-feedback.warn { color: var(--accent-amber); }

.comms-panel {
  margin-top: 14px;
  padding: 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.2);
}

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

.comms-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.hint-btn {
  border: 1px solid rgba(251, 191, 36, 0.5);
  background: rgba(69, 44, 6, 0.55);
  color: #fde68a;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  padding: 6px 12px;
  border-radius: 7px;
  cursor: pointer;
}

.hint-btn:disabled {
  opacity: 0.45;
  cursor: default;
}

.hint-cost {
  font-size: 11px;
  color: var(--text-muted);
}

.hint-log {
  font-size: 12px;
  line-height: 1.45;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hint-placeholder {
  color: var(--text-muted);
  font-style: italic;
}

.hint-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  color: var(--accent-amber);
}

.terminal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 14px 20px;
  background: rgba(15, 23, 42, 0.95);
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

/* ================= WIN / BUSTED DEBRIEF ================= */

.end-card {
  max-width: 660px;
}

.end-card.win {
  border-color: rgba(16, 185, 129, 0.6);
}

.end-card.busted {
  border-color: rgba(239, 68, 68, 0.65);
}

.end-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  margin-bottom: 6px;
}

.end-card.win .end-tag { color: #34d399; }
.end-card.busted .end-tag { color: #fca5a5; }

.end-title {
  margin: 0 0 8px;
  font-size: 32px;
  font-weight: 800;
}

.end-subtitle {
  margin: 0 0 18px;
  color: var(--text-muted);
  font-size: 14px;
}

.end-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.end-stat {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  padding: 12px;
}

.end-stat.span-2 {
  grid-column: span 2;
}

.end-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 18px;
}

/* ================= PHASE 1 INFILTRATION BOTTOM HUD ================= */

.hud-infiltrate-bottom {
  pointer-events: none;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  width: 100%;
}

.dpad-card,
.objective-card,
.minimap-card {
  pointer-events: auto;
  background: rgba(9, 14, 28, 0.86);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  padding: 10px 12px;
}

.dpad-grid {
  display: grid;
  grid-template-columns: repeat(3, 40px);
  grid-template-rows: repeat(2, 40px);
  gap: 5px;
}

.dpad-btn {
  border: 1px solid rgba(56, 189, 248, 0.42);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.9);
  color: var(--accent-cyan);
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: none;
  transition: background 0.1s, transform 0.1s;
}

.dpad-btn:active {
  background: rgba(56, 189, 248, 0.28);
  transform: scale(0.95);
}

.objective-card {
  flex: 1;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.obj-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent-cyan);
}

.obj-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  color: #e2e8f0;
}

.obj-item.done {
  color: #6ee7b7;
  text-decoration: line-through;
}

.obj-check {
  width: 14px;
  height: 14px;
  border-radius: 4px;
  border: 1.5px solid rgba(148, 163, 184, 0.65);
  background: rgba(15, 23, 42, 0.8);
  flex-shrink: 0;
}

.obj-item.done .obj-check {
  border-color: var(--accent-emerald);
  background: var(--accent-emerald);
}

.obj-controls-hint {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

.minimap-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.minimap-hdr {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

#minimap-canvas {
  border-radius: 8px;
  border: 1px solid rgba(56, 189, 248, 0.35);
  display: block;
}

/* ================= RESPONSIVE ================= */

@media (max-width: 820px) {
  .diff-grid,
  .brief-kpis,
  .brief-modules-grid,
  .pipeline-slots,
  .pipeline-pool,
  .match-grid,
  .end-stats-grid {
    grid-template-columns: 1fr;
  }

  .end-stat.span-2 {
    grid-column: span 1;
  }

  .binary-bank {
    grid-template-columns: repeat(4, 1fr);
  }

  .hud-top {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .lock-dock {
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }

  .hud-infiltrate-bottom {
    flex-wrap: wrap;
    gap: 8px;
  }

  .objective-card {
    order: -1;
    flex-basis: 100%;
    max-width: none;
  }

  #minimap-canvas {
    width: 108px;
    height: 108px;
  }
}
