:root {
  --bg: #0b0f16;
  --ink: #e8edf5;
  --muted: #9aa6b8;
  --line: rgba(255, 255, 255, 0.12);
  --panel: rgba(12, 16, 24, 0.82);
  --accent: #f4e6c8;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, "Segoe UI", sans-serif;
  overflow: hidden;
}
#app { position: absolute; inset: 0; }
#map2d {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
  touch-action: manipulation;
}
.chrome {
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 18px 20px 8px;
  background: linear-gradient(to bottom, rgba(11, 15, 22, 0.88), rgba(11, 15, 22, 0));
  pointer-events: none;
}
.chrome > * { pointer-events: auto; }
.title-block h1 { margin: 0; font-size: 1.35rem; font-weight: 650; }
.title-block .sub { margin: 2px 0 0; color: var(--muted); font-size: 0.85rem; }
.races, .xr-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.race-btn, .ar-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(20, 26, 36, 0.9);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.race-btn.is-active, .ar-btn {
  background: #f3efe6;
  color: #111827;
  border-color: #f3efe6;
  font-weight: 650;
}
.ar-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.legend {
  position: absolute;
  left: 20px;
  bottom: 64px;
  z-index: 5;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.75rem;
  min-width: 160px;
}
.legend-title { font-weight: 650; margin-bottom: 6px; }
.legend-row { display: flex; align-items: center; gap: 8px; margin: 3px 0; color: var(--muted); }
.swatch { width: 72px; height: 10px; border-radius: 99px; }
.swatch.dem { background: linear-gradient(to right, #dbeafe, #1e3a8a); }
.swatch.rep { background: linear-gradient(to right, #fecaca, #7f1d1d); }
.legend-note { margin-top: 6px; color: var(--muted); }
.card {
  position: absolute;
  right: 20px;
  top: 92px;
  z-index: 5;
  width: min(300px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
}
.card[hidden] { display: none; }
.card h2 { margin: 0 0 4px; font-size: 1.15rem; }
.info-meta { margin: 0 0 10px; color: var(--muted); font-size: 0.8rem; }
#info-cands { list-style: none; margin: 0; padding: 0; }
#info-cands li {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 6px 0;
  border-top: 1px solid var(--line);
  font-size: 0.88rem;
}
#info-cands .party {
  font-weight: 650;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 999px;
  align-self: center;
}
#info-cands .party.DEM { background: #1d4ed8; }
#info-cands .party.REP { background: #b91c1c; }
#info-cands .party.L, #info-cands .party.GRE, #info-cands .party.IND, #info-cands .party.W, #info-cands .party.OTH { background: #3f4b5b; }
#info-cands .winner { color: var(--accent); }
.hint {
  position: absolute;
  left: 50%;
  bottom: 64px;
  transform: translateX(-50%);
  margin: 0;
  z-index: 4;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
  pointer-events: none;
  width: min(520px, calc(100vw - 200px));
}
.credits {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  z-index: 5;
  margin: 0;
  padding: 8px 20px 12px;
  font-size: 0.72rem;
  color: #8b95a8;
  background: linear-gradient(to top, rgba(11, 15, 22, 0.92), rgba(11, 15, 22, 0));
}
#debug {
  position: fixed;
  left: 8px;
  top: 8px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 16px));
  background: rgba(0,0,0,0.78);
  color: #b8f5c4;
  font: 11px/1.4 ui-monospace, monospace;
  padding: 8px 10px;
  border-radius: 8px;
  white-space: pre-wrap;
  pointer-events: none;
}
body.in-xr { background: transparent; }
body.in-xr #app { display: none; }
@media (max-width: 720px) {
  .card { top: auto; bottom: 88px; right: 12px; left: 12px; width: auto; }
  .legend, .hint { display: none; }
  .chrome { padding: 12px; }
}
