:root {
  --bg: #0a0e16;
  --fg: #e6edf6;
  --muted: #8a94a6;
  --panel: rgba(14, 20, 32, 0.92);
  --border: rgba(255, 255, 255, 0.08);
  --accent: #4ec3ff;
  --good: #5fd07c;
  --sev-r: #ff5e6c;
  --sev-o: #ff9a3c;
  --sev-y: #ffd166;
  --shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  overflow: hidden;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.hud-block {
  pointer-events: auto;
  position: absolute;
}

#hud-tl {
  top: 16px;
  left: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
}

#hud-tr {
  top: 16px;
  right: 16px;
}

#hud-br {
  bottom: 16px;
  right: 16px;
  color: var(--muted);
  font-size: 11px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  max-width: 360px;
  text-align: right;
  line-height: 1.5;
}

#hud-bottom {
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
}

#hud-clock {
  font-family: var(--mono);
  font-size: 14px;
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  letter-spacing: 0.04em;
}

.badge {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  padding: 6px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  color: var(--fg);
  cursor: pointer;
  text-decoration: none;
  font-family: var(--sans);
}

.badge:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.badge.alerts {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.04em;
}

.sev {
  display: inline-flex;
  align-items: center;
  padding: 0 4px;
  border-radius: 3px;
  font-weight: 600;
}

.sev-r { color: var(--sev-r); }
.sev-o { color: var(--sev-o); }
.sev-y { color: var(--sev-y); }

#hud-workers {
  display: flex;
  gap: 12px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}

.worker-chip {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  font-family: var(--mono);
  white-space: nowrap;
}

.worker-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #444;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.4) inset;
}

.worker-dot.active {
  background: var(--good);
  box-shadow: 0 0 8px rgba(95, 208, 124, 0.7);
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.2); }
}

.worker-name { color: var(--muted); }

#panel,
#alerts-panel {
  pointer-events: auto;
  top: 70px;
  right: 16px;
  width: min(380px, calc(100vw - 32px));
  max-height: calc(100vh - 110px);
  overflow: auto;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(6px);
}

#panel header,
#alerts-panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

#panel header h2,
#alerts-panel header h2 {
  font-size: 16px;
  margin: 0;
  font-family: var(--mono);
}

#panel-close,
#alerts-close {
  background: transparent;
  color: var(--fg);
  border: 0;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
  border-radius: 4px;
}

#panel-close:hover,
#alerts-close:hover {
  background: rgba(255, 255, 255, 0.06);
}

#panel-status {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

#panel-events {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-family: var(--mono);
  font-size: 11px;
}

.evt {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.evt-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.evt-kind { color: var(--accent); }
.evt-time { color: var(--muted); }

#alerts-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#alerts-list li {
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.02);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#alerts-list .badge {
  font-size: 10px;
  padding: 2px 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#banner {
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 12px;
  box-shadow: var(--shadow);
}

#fallback-2d {
  padding: 24px;
  max-width: 900px;
  margin: 0 auto;
  overflow: auto;
  height: 100vh;
}

#fallback-2d h1 {
  font-size: 20px;
  margin: 0 0 8px;
}

#fallback-2d table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
}

#fallback-2d th,
#fallback-2d td {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  font-family: var(--mono);
}

#fallback-2d th {
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 10px;
}

#fallback-2d .status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

#fallback-2d .status::before {
  content: "■";
  font-size: 10px;
}

.status-LIVE_READY,
.status-GREEN { color: var(--good); }
.status-DEGRADED { color: var(--sev-y); }
.status-DOWN { color: var(--sev-r); }
.status-PARKED { color: var(--muted); }
.status-LICENSING_HOLD { color: var(--accent); }
.status-SOFT_LAUNCH { color: var(--sev-o); }

@media (max-width: 720px) {
  #hud-bottom { width: calc(100vw - 32px); }
  #hud-br { display: none; }
  #panel, #alerts-panel { width: calc(100vw - 32px); right: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  .worker-dot.active { animation: none; }
}
