:root {
  --bg: #070a14;
  --panel: rgba(10, 14, 24, 0.88);
  --border: rgba(120, 200, 255, 0.28);
  --neon: #2de2ff;
  --magenta: #ff4fd8;
  --text: #e8eef8;
  --muted: #9aa8bc;
  --danger: #ff5a5a;
  --ok: #4dffc3;
  --font: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font-family: var(--font);
}
.login-body {
  min-height: 100%;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(255,79,216,0.12), transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(45,226,255,0.1), transparent 50%),
    var(--bg);
}
.login-card {
  width: min(380px, 92vw);
  padding: 28px 24px;
  border-radius: 16px;
  background: var(--panel);
  border: 1px solid var(--border);
  box-shadow: 0 0 40px rgba(45,226,255,0.08);
}
.login-brand { display: flex; align-items: center; gap: 10px; }
.login-brand h1 { margin: 0; font-size: 1.35rem; letter-spacing: 0.04em; }
.neon-dot {
  width: 14px; height: 14px; border-radius: 4px;
  background: var(--neon);
  box-shadow: 0 0 14px var(--neon);
}
.muted { color: var(--muted); font-size: 0.9rem; line-height: 1.4; }
.login-card label { display: block; margin: 14px 0 6px; font-size: 0.85rem; color: var(--muted); }
.login-card input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border); background: #0a101c; color: var(--text);
  font-size: 1rem;
}
.login-card button {
  margin-top: 16px; width: 100%; padding: 12px;
  border: none; border-radius: 10px; cursor: pointer;
  background: var(--neon); color: #061018; font-weight: 700;
}
.err { color: var(--danger); margin-top: 10px; font-size: 0.9rem; }

.app {
  display: grid;
  grid-template-columns: minmax(240px, 300px) 1fr;
  grid-template-rows: auto 1fr;
  height: 100%;
  gap: 0;
}
@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr;
    height: auto;
    min-height: 100%;
  }
  #sidebar { order: 2; max-height: 40vh; overflow: auto; }
  #stage-wrap { order: 1; min-height: 52vh; }
}
.topbar {
  grid-column: 1 / -1;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 14px;
  background: rgba(8,10,18,0.95);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 1rem; }
.badge {
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em;
  padding: 4px 8px; border-radius: 999px;
  border: 1px solid var(--magenta); color: var(--magenta);
  text-transform: uppercase;
}
.badge.warn { border-color: #ffb347; color: #ffb347; }
.spacer { flex: 1; }
.btn {
  border: 1px solid var(--border); background: rgba(255,255,255,0.05);
  color: var(--text); border-radius: 10px; padding: 8px 12px;
  cursor: pointer; font-size: 0.85rem; font-weight: 600;
}
.btn.primary { background: var(--neon); color: #061018; border-color: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }

#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 12px;
  overflow: auto;
  display: flex; flex-direction: column; gap: 12px;
}
.panel {
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px;
  background: rgba(0,0,0,0.25);
}
.panel h2 {
  margin: 0 0 8px; font-size: 0.75rem; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--muted);
}
.team-row {
  display: flex; align-items: center; gap: 8px;
  padding: 8px; border-radius: 10px;
  border: 1px solid transparent; cursor: pointer;
}
.team-row:hover, .team-row.active { border-color: var(--border); background: rgba(255,255,255,0.04); }
.dot { width: 10px; height: 10px; border-radius: 99px; flex: 0 0 auto; }
.team-meta { min-width: 0; flex: 1; }
.team-meta strong { display: block; font-size: 0.9rem; }
.team-meta span { display: block; font-size: 0.75rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.state-pill {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.04em;
  padding: 2px 6px; border-radius: 6px; background: #1a2233; color: var(--muted);
}
.state-pill.working { color: var(--ok); }
.state-pill.waiting { color: #ffb347; }
.state-pill.error { color: var(--danger); }
.state-pill.done { color: var(--neon); }

.feed-item {
  font-size: 0.78rem; padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  color: var(--muted);
}
.feed-item b { color: var(--text); }
.feed-item time { color: #6a7a90; font-variant-numeric: tabular-nums; }

#stage-wrap {
  position: relative;
  min-height: 0;
  background: #05070f;
}
#c {
  width: 100%; height: 100%;
  display: block; touch-action: none;
}
#hud {
  position: absolute; left: 12px; bottom: 12px; right: 12px;
  display: flex; flex-wrap: wrap; gap: 8px; pointer-events: none;
}
#hud .chip {
  pointer-events: none;
  background: rgba(8,10,18,0.85);
  border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 10px; font-size: 0.75rem;
}
#nameplate {
  position: absolute; left: 50%; top: 14px; transform: translateX(-50%);
  background: rgba(8,10,18,0.92); border: 1px solid var(--border);
  border-radius: 12px; padding: 8px 14px; font-size: 0.85rem;
  max-width: 90%; display: none;
}
#sim-banner {
  position: absolute; top: 14px; right: 14px;
  background: rgba(255,79,216,0.15);
  border: 1px solid var(--magenta); color: var(--magenta);
  border-radius: 999px; padding: 6px 12px; font-size: 0.75rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  display: none;
}
