:root {
  --bg-blueprint: #050811;
  --bg-panel: rgba(11, 17, 32, 0.92);
  --bg-panel-elevated: rgba(17, 25, 45, 0.96);
  --border-subtle: rgba(56, 189, 248, 0.16);
  --border-gold: rgba(245, 158, 11, 0.45);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Section 2 Mandate: Exact Mini Metro × Read Achilles Conduit Palette */
  --line-power: #f59e0b;
  --line-copper: #f97316;
  --line-cooling: #38bdf8;
  --line-compute: #10b981;
  --line-credit: #a855f7;
  --danger-trip: #ef4444;
}

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

html,
body {
  width: 100%;
  min-height: 100%;
  background-color: var(--bg-blueprint);
  background-image:
    linear-gradient(to right, rgba(56, 189, 248, 0.06) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(56, 189, 248, 0.06) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--text-primary);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  overflow-x: hidden;
}

/* Top Architectural Navigation & Speed Bar */
.foundry-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 18px;
  background: rgba(5, 8, 17, 0.94);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 40;
  flex-wrap: wrap;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark-img {
  width: 32px;
  height: 32px;
  border-radius: 7px;
  object-fit: contain;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-gold);
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 30% 30%, rgba(245, 158, 11, 0.25), rgba(5, 8, 17, 0.95));
  font-size: 17px;
}

.brand-title {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #f8fafc;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--line-cooling);
  letter-spacing: 0.02em;
}

.speed-controls,
.mode-tabs,
.action-cluster {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-foundry {
  background: rgba(15, 23, 42, 0.92);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: 7px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-foundry:hover {
  border-color: var(--line-cooling);
  background: rgba(30, 41, 59, 0.95);
}

.btn-foundry.active,
.btn-foundry.gold {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.24), rgba(234, 88, 12, 0.18));
  border-color: var(--line-power);
  color: #fef08a;
}

.btn-foundry.emerald {
  background: rgba(16, 185, 129, 0.16);
  border-color: var(--line-compute);
  color: #a7f3d0;
}

.btn-foundry.cryo {
  background: rgba(56, 189, 248, 0.16);
  border-color: var(--line-cooling);
  color: #bae6fd;
}

.foundry-input {
  background: #0b1120;
  border: 1px solid var(--border-subtle);
  color: #f8fafc;
  padding: 6px 9px;
  border-radius: 6px;
  font-size: 12px;
}

#scenarioMapSelect {
  background: transparent;
  color: #f8fafc;
  border: none;
  font-weight: 700;
  font-size: 13px;
  width: 100%;
  cursor: pointer;
}

#scenarioMapSelect option {
  background: #0b1120;
  color: #f8fafc;
}

/* Telemetry Ribbon */
.telemetry-ribbon {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  padding: 10px 18px;
  background: rgba(8, 13, 26, 0.88);
  border-bottom: 1px solid var(--border-subtle);
}

.metric-tile {
  background: rgba(15, 23, 42, 0.75);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-radius: 8px;
  padding: 8px 12px;
}

.metric-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
}

.metric-value {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
}

.metric-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Main Workspace Grid */
.foundry-workspace {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 14px;
  padding: 14px 18px;
  min-height: calc(100vh - 145px);
}

@media (max-width: 1120px) {
  .foundry-workspace {
    grid-template-columns: 1fr;
  }
}

/* Blueprint Canvas Stage */
.blueprint-stage-card {
  background: rgba(5, 8, 17, 0.84);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.blueprint-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(11, 17, 32, 0.92);
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
}

.conduit-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.conduit-pill {
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all 0.14s ease;
}

.conduit-pill.active {
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.35);
  transform: translateY(-1px);
  background: rgba(30, 41, 59, 0.95);
}

.canvas-wrapper {
  position: relative;
  flex: 1;
  min-height: 540px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

#blueprintCanvas {
  width: 100%;
  height: 560px;
  display: block;
  cursor: crosshair;
}

.canvas-tooltip {
  position: absolute;
  pointer-events: none;
  background: rgba(8, 13, 26, 0.96);
  border: 1px solid var(--border-gold);
  border-radius: 8px;
  padding: 8px 11px;
  font-size: 11px;
  color: var(--text-primary);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.65);
  display: none;
  z-index: 20;
  max-width: 260px;
}

.blueprint-footer-legend {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 8px 14px;
  background: rgba(11, 17, 32, 0.92);
  border-top: 1px solid var(--border-subtle);
  font-size: 11px;
  color: var(--text-secondary);
}

/* Right Inspector & Read Achilles Research Sidebar */
.inspector-sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.sidebar-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: 14px;
}

.sidebar-card h3 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--line-power);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.aio-capsule-box {
  background: rgba(16, 185, 129, 0.08);
  border-left: 3px solid var(--line-compute);
  padding: 10px;
  border-radius: 6px;
  font-size: 12px;
  line-height: 1.45;
  color: #e2e8f0;
  margin-bottom: 10px;
}

.formula-pill {
  font-family: "JetBrains Mono", "SFMono-Regular", Menlo, monospace;
  font-size: 11px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.2);
  padding: 6px 8px;
  border-radius: 6px;
  color: #bae6fd;
  margin-bottom: 6px;
}

.line-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 185px;
  overflow-y: auto;
}

.line-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 6px;
  padding: 6px 9px;
  font-size: 11px;
}

/* Mode 2: Sovereign Scaling Clicker/Idle (Universal Paperclips) */
.paperclip-stage-container {
  padding: 18px;
  display: none;
}

.paperclip-stage-container.active {
  display: block;
}

.paperclip-stepper {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.pc-step-card {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px 14px;
  opacity: 0.65;
  transition: all 0.2s ease;
}

.pc-step-card.active {
  opacity: 1;
  border-color: var(--line-power);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.14), rgba(15, 23, 42, 0.92));
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.2);
}

.pc-step-tag {
  font-size: 10px;
  font-weight: 800;
  color: var(--line-cooling);
  letter-spacing: 0.06em;
}

.pc-step-name {
  font-size: 14px;
  font-weight: 800;
  color: #f8fafc;
  margin-top: 2px;
}

.pc-step-range {
  font-size: 11px;
  color: var(--line-compute);
  margin-top: 2px;
}

.paperclip-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
  gap: 16px;
}

.lever-row {
  margin-bottom: 12px;
}

.lever-row label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.lever-row input[type="range"] {
  width: 100%;
  accent-color: var(--line-power);
}

.upgrade-card {
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Modals (CapEx Weekly Draft, Post-Run Export, AI OR Advisor, Unified Profile & Community Dashboard) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 14, 0.84);
  backdrop-filter: blur(8px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-backdrop.open {
  display: flex;
}

.modal-card {
  background: var(--bg-panel-elevated);
  border: 1px solid var(--border-gold);
  border-radius: 14px;
  max-width: 880px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
}

.capex-draft-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.capex-option-card {
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.16s ease;
}

.capex-option-card:hover {
  border-color: var(--line-power);
  transform: translateY(-2px);
}

.genome-bar-track {
  width: 100%;
  height: 8px;
  background: rgba(15, 23, 42, 0.9);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 4px;
}

.genome-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--line-cooling), var(--line-compute), var(--line-power));
  border-radius: 999px;
}

.passport-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.passport-item {
  background: rgba(15, 23, 42, 0.85);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 11px;
  text-decoration: none;
  color: var(--text-primary);
  transition: border-color 0.14s ease;
}

.passport-item:hover {
  border-color: var(--line-cooling);
}

.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  margin-top: 10px;
}

.leaderboard-table th,
.leaderboard-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.toast-banner {
  position: fixed;
  bottom: 18px;
  right: 18px;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid var(--line-compute);
  color: #ecfdf5;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  z-index: 200;
  display: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
}
