:root {
  --hud-bg: #0000008c;
  --hud-border: rgba(255, 255, 255, 0.35);
  --hud-border-soft: rgba(255, 255, 255, 0.2);
  --hud-text: rgba(255, 255, 255, 0.96);
  --hud-muted: rgba(255, 255, 255, 0.68);
  --hud-accent: rgba(255, 255, 255, 0.96);
  --hud-button: rgba(255, 255, 255, 0.08);
  --hud-button-hover: rgba(255, 255, 255, 0.14);
  color-scheme: dark;
  font-family:
    "Segoe UI", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    sans-serif;
  background: #000;
  color: #fff;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #000;
}

#scene {
  display: block;
  width: 100vw;
  height: 100vh;
  background: #000;
  cursor: grab;
}

#scene:active {
  cursor: grabbing;
}

#attribution {
  position: fixed;
  left: 50%;
  bottom: 10px;
  z-index: 10;
  width: min(620px, calc(100vw - 24px));
  margin: 0;
  color: rgba(255, 255, 255, 0.52);
  font-size: 10px;
  line-height: 1.35;
  letter-spacing: 0;
  text-align: center;
  text-shadow: 0 0 6px #000;
  transform: translateX(-50%);
  pointer-events: none;
}

#hud {
  position: fixed;
  left: 12px;
  top: 12px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 24px));
  padding: 8px 10px 10px;
  border: 1px solid var(--hud-border);
  background: var(--hud-bg);
  color: var(--hud-text);
  font-size: 12px;
  line-height: 1.4;
  pointer-events: none;
  text-shadow: 0 0 6px #000;
}

#hud p,
#hud dl,
#hud dt,
#hud dd {
  margin: 0;
  letter-spacing: 0;
}

.hud-row,
.hud-header {
  display: flex;
  gap: 10px;
  align-items: center;
}

.hud-header {
  justify-content: space-between;
}

.hud-heading,
.hud-body,
.hud-section {
  display: flex;
  flex-direction: column;
}

.hud-heading {
  gap: 2px;
  min-width: 0;
}

.hud-body {
  gap: 10px;
}

.hud-kicker,
.section-title {
  color: var(--hud-muted);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.hud-title {
  color: var(--hud-text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.hud-pill {
  border: 1px solid var(--hud-border);
  padding: 4px 9px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--hud-accent);
  font-size: 11px;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.hud-section {
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--hud-border-soft);
  background: rgba(255, 255, 255, 0.02);
}

.stat-grid {
  display: grid;
  gap: 4px;
  font-variant-numeric: tabular-nums;
}

.stat-row {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 10px;
  align-items: baseline;
  min-width: 0;
}

.stat-row dt {
  color: var(--hud-muted);
  white-space: nowrap;
}

.stat-row dd {
  min-width: 0;
  overflow: hidden;
  color: var(--hud-accent);
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#trace-source {
  overflow: hidden;
  color: var(--hud-muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#hud-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  pointer-events: none;
}

#train-toggle,
#flow-toggle {
  pointer-events: auto;
  min-width: 0;
  padding: 7px 9px;
  border: 1px solid var(--hud-border);
  border-radius: 0;
  background: var(--hud-button);
  color: var(--hud-text);
  font: inherit;
  line-height: 1.2;
  letter-spacing: 0;
  cursor: pointer;
  transition:
    background-color 0.18s ease,
    border-color 0.18s ease,
    transform 0.18s ease;
}

#train-toggle:hover,
#flow-toggle:hover {
  border-color: rgba(255, 255, 255, 0.48);
  background: var(--hud-button-hover);
}

#train-toggle:active,
#flow-toggle:active {
  transform: translateY(1px);
}

#flow-toggle[aria-pressed="true"] {
  border-color: rgba(255, 255, 255, 0.75);
}

#train-toggle:disabled,
#flow-toggle:disabled {
  cursor: default;
  opacity: 0.55;
}

#trace-help {
  color: var(--hud-muted);
  font-size: 10px;
}

@media (max-width: 680px) {
  #hud {
    left: 8px;
    top: 8px;
    width: min(360px, calc(100vw - 16px));
  }
}
