:root {
  --bg: #0a0a0a;
  --text: #e0e0e0;
  --accent: #4af;
  --panel-bg: #151515;
  --panel-border: #222;
  --progress-bar: #4af;
  --shadow-bar: rgba(120, 0, 200, 0.25);
  --status-connected: #4a4;
  --pred-explore: #c89030;
  --pred-exploit: #0cc;
  --handoff-marker: #c89030;
  --text-muted: #888;
  --text-value: #ccc;
  --text-dim: #aaa;
  --progress-track-bg: #181818;
  --marker-color: #444;
  --marker-l4-color: #000;
  --chart-bg: #111;
  --chart-grid: #222;
  --table-border: #333;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 16px;
  padding: 16px;
}
h1 {
  font-size: 18px;
  font-weight: 400;
  letter-spacing: 4px;
  text-transform: uppercase;
  color: var(--accent);
}
canvas {
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  image-rendering: pixelated;
  max-width: calc(100vw - 32px);
  height: auto;
}
#progress-wrap {
  height: 14px;
  background: var(--progress-track-bg);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
#shadow-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: var(--shadow-bar);
  transition: width 0.1s;
  z-index: 0;
}
#progress-bar {
  position: relative;
  height: 100%;
  width: 0%;
  background: var(--progress-bar);
  transition: width 0.1s;
  z-index: 1;
}
#progress-wrap .phase-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: var(--marker-color);
  z-index: 1;
}
#marker-l4 {
  background: repeating-linear-gradient(
    to bottom,
    var(--marker-l4-color) 0,
    var(--marker-l4-color) 2px,
    transparent 2px,
    transparent 4px
  );
  z-index: 2;
}
#marker-handoff {
  background: var(--handoff-marker);
  z-index: 2;
}
#progress-pct {
  position: absolute;
  right: 4px;
  top: 0;
  font-size: 9px;
  line-height: 14px;
  color: var(--text-dim);
  z-index: 3;
  pointer-events: none;
}
#shadow-delta {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 0;
  font-size: 9px;
  line-height: 14px;
  color: var(--text-dim);
  z-index: 3;
  pointer-events: none;
  text-shadow:
    0 0 3px var(--progress-track-bg),
    0 0 3px var(--progress-track-bg);
  white-space: nowrap;
}
#prediction-banner {
  font-size: 12px;
  letter-spacing: 1px;
  text-align: center;
  min-height: 16px;
}
#prediction-banner.explore {
  color: var(--pred-explore);
}
#prediction-banner.exploit {
  color: var(--pred-exploit);
}
#hud {
  display: flex;
  gap: 32px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
  justify-content: center;
}
#hud span {
  color: var(--text-value);
}
#toggles {
  display: flex;
  gap: 16px;
}
.toggle-btn {
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.toggle-btn:hover {
  color: var(--text-value);
}
.toggle-btn.active {
  color: var(--accent);
}
#legend {
  display: none;
  gap: 16px;
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
  justify-content: center;
}
#legend.visible {
  display: flex;
}
.swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 4px;
  vertical-align: middle;
}
.cnt {
  color: var(--text-dim);
  margin-left: 4px;
}
#debug-flags {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  justify-content: center;
  padding-top: 6px;
  border-top: 1px solid var(--panel-border);
  margin-top: 4px;
}
#debug-flags label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
#debug-flags input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}
#history-panel {
  display: none;
  max-width: calc(100vw - 32px);
  overflow-x: auto;
}
#history-panel.visible {
  display: block;
}
#history-panel table {
  border-collapse: collapse;
  font-size: 11px;
  color: var(--text-dim);
  width: 100%;
}
#history-panel th {
  color: var(--text-muted);
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--table-border);
  text-align: right;
  white-space: nowrap;
}
#history-panel th:first-child {
  text-align: left;
}
#history-panel td {
  padding: 3px 10px;
  text-align: right;
  white-space: nowrap;
}
#history-panel td:first-child {
  text-align: left;
}
#history-panel tr:hover td {
  color: var(--text-value);
}
.result-won {
  color: var(--accent) !important;
}
.result-lost {
  color: #f66 !important;
}
.shadow-faster {
  color: var(--status-connected) !important;
}
.shadow-slower {
  color: #f66 !important;
}
.pred-good {
  color: var(--status-connected) !important;
}
.pred-ok {
  color: var(--pred-explore) !important;
}
.pred-bad {
  color: #f66 !important;
}
.died-row td {
  background: rgba(255, 60, 60, 0.12) !important;
  color: #f66 !important;
  font-weight: bold;
  text-align: left !important;
}
#status {
  font-size: 12px;
  color: var(--text-muted);
}
#status.connected {
  color: var(--status-connected);
}
#dashboard {
  display: none;
  max-width: calc(100vw - 32px);
  width: 100%;
  max-width: 720px;
}
#dashboard.visible {
  display: block;
}
#dash-stats {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 12px;
}
.stat-card {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 8px 14px;
  text-align: center;
  min-width: 90px;
}
.stat-card .stat-label {
  font-size: 9px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.stat-card .stat-value {
  font-size: 20px;
  color: var(--text-value);
  margin-top: 2px;
}
.stat-card .stat-value.good {
  color: var(--accent);
}
.stat-card .stat-value.great {
  color: var(--status-connected);
}
.stat-card .stat-value.warn {
  color: var(--pred-explore);
}
#dash-main-chart {
  background: var(--chart-bg);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 8px;
}
#dash-secondary {
  display: flex;
  gap: 8px;
}
#dash-secondary > div {
  flex: 1;
  background: var(--chart-bg);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  padding: 8px;
}
#dash-empty {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px 0;
}
