:root {
  color-scheme: dark;
  --bg: #05070c;
  --bg-deep: #010309;
  --panel: #0b1019;
  --text: #f3f6fb;
  --muted: #909cac;
  --muted-strong: #bac3d0;
  --line: rgba(255, 255, 255, 0.11);
  --line-strong: rgba(255, 255, 255, 0.22);
  --accent: #e8ff5b;
  --accent-soft: rgba(232, 255, 91, 0.12);
  --sans: "Manrope", ui-sans-serif, system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html { background: var(--bg); scroll-behavior: smooth; }
body {
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at 75% -5%, rgba(48, 74, 111, 0.22), transparent 31rem), var(--bg);
  font: 16px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; }

.skip-link {
  position: fixed; top: 12px; left: 12px; z-index: 1000; padding: 10px 14px;
  color: var(--bg); background: var(--accent); border-radius: 4px; transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.site-shell { width: min(100%, 1680px); margin: 0 auto; padding: 0 36px; }
.site-header {
  display: flex; align-items: center; justify-content: space-between; min-height: 92px;
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 13px; text-decoration: none; }
.brand-mark { display: grid; grid-template-columns: repeat(3, 5px); align-items: end; gap: 3px; height: 26px; }
.brand-mark i { display: block; width: 5px; background: var(--accent); }
.brand-mark i:nth-child(1) { height: 11px; }
.brand-mark i:nth-child(2) { height: 26px; }
.brand-mark i:nth-child(3) { height: 18px; }
.brand b { font-size: 14px; letter-spacing: 0.13em; }
.header-status {
  display: flex; align-items: center; gap: 9px; color: var(--muted-strong);
  font: 11px/1.4 var(--mono); letter-spacing: 0.04em; text-transform: uppercase;
}
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }

.hero {
  display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr); align-items: end;
  gap: clamp(40px, 8vw, 130px); min-height: 350px; padding: 72px 0 58px;
}
.eyebrow, .section-label {
  margin: 0; color: var(--accent); font: 500 11px/1.3 var(--mono);
  letter-spacing: 0.16em; text-transform: uppercase;
}
.hero h1 {
  max-width: 830px; margin: 17px 0 22px; font-size: clamp(48px, 7.2vw, 112px);
  font-weight: 600; line-height: 0.88; letter-spacing: -0.075em;
}
.hero h1 span { color: #6d7684; }
.hero-intro { max-width: 650px; margin: 0; color: var(--muted-strong); font-size: clamp(16px, 1.35vw, 21px); line-height: 1.5; }
.hero-metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line); }
.hero-metrics div { min-width: 0; padding: 18px 16px 19px 0; }
.hero-metrics div + div { padding-left: 18px; border-left: 1px solid var(--line); }
.hero-metrics span { display: block; font: 500 clamp(20px, 2vw, 30px)/1.1 var(--mono); letter-spacing: -0.05em; }
.hero-metrics small { display: block; margin-top: 9px; color: var(--muted); font-size: 11px; line-height: 1.35; }

.atlas { border-top: 1px solid var(--line); }
.atlas-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 24px; min-height: 82px; }
.view-switch { display: flex; flex: 1 1 auto; min-width: 0; max-width: 100%; flex-wrap: nowrap; gap: 4px; padding: 4px; overflow-x: auto; background: rgba(255, 255, 255, 0.035); border: 1px solid var(--line); border-radius: 7px; scrollbar-width: none; }
.view-switch::-webkit-scrollbar { display: none; }
.view-button {
  flex: 0 0 52px; min-width: 52px; min-height: 38px; padding: 0 14px; color: var(--muted-strong); background: transparent;
  border: 0; border-radius: 4px; cursor: pointer; font: 600 12px/1 var(--sans); transition: color 150ms ease, background-color 150ms ease;
  white-space: nowrap;
}
.view-button:hover { color: var(--text); }
.view-button.is-active { color: #111408; background: var(--accent); }
.view-button:focus-visible, .map-reset:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.view-button small { margin-left: 2px; font: 10px var(--mono); }
#view-description { flex: 0 1 480px; min-width: 0; margin: 0; color: var(--muted); font: 11px/1.4 var(--mono); text-align: right; }

.atlas-grid { display: grid; grid-template-columns: minmax(0, 1.72fr) minmax(390px, 0.68fr); border: 1px solid var(--line); background: var(--panel); }
.map-panel {
  position: relative; min-height: 760px; overflow: hidden;
  background: url("assets/stars.svg") center / cover no-repeat, radial-gradient(circle at 55% 43%, rgba(0, 168, 255, 0.08), transparent 42%), var(--bg-deep);
}
#map { position: absolute; inset: 0; }
.map-panel::after {
  position: absolute; z-index: 2; inset: 0; pointer-events: none; content: "";
  background: radial-gradient(ellipse at 58% 38%, rgba(255,255,255,0.045), transparent 28%), radial-gradient(circle at 50% 45%, transparent 38%, rgba(1,3,9,0.5) 100%);
  mix-blend-mode: screen; opacity: 0.72;
}
.maplibregl-control-container { z-index: 4; }
.maplibregl-ctrl-attrib { color: var(--muted) !important; background: rgba(3,5,8,0.78) !important; font: 9px var(--mono) !important; }
.maplibregl-ctrl-attrib a { color: var(--muted-strong) !important; }
.map-legend {
  position: absolute; z-index: 3; bottom: 24px; left: 24px; display: flex; flex-wrap: nowrap; gap: 8px 14px;
  align-items: center; width: calc(100% - 170px); height: 40px; overflow-x: auto; overflow-y: hidden; padding: 0 14px; background: rgba(5,8,14,0.88); border: 1px solid rgba(255,255,255,0.16);
  box-shadow: 0 18px 55px rgba(0,0,0,0.34); backdrop-filter: blur(18px) saturate(140%);
}
.legend-item, .table-party, .party-name { display: inline-flex; align-items: center; gap: 8px; }
.legend-item {
  padding: 4px 0; color: var(--muted-strong); background: transparent; border: 0; border-radius: 3px;
  cursor: pointer; flex: 0 0 auto; font: 11px/1 var(--mono); transition: color 160ms ease, text-shadow 160ms ease; white-space: nowrap;
}
.legend-item:hover, .legend-item:focus-visible, .legend-item.is-active { color: var(--text); outline: 0; }
.legend-item.is-active { text-shadow: 0 0 13px color-mix(in srgb, currentColor 35%, transparent); }
.legend-item.is-active .swatch { box-shadow: 0 0 14px currentColor; }
.swatch { width: 9px; height: 9px; flex: 0 0 auto; border-radius: 50%; }
.map-reset {
  position: absolute; z-index: 3; right: 24px; bottom: 24px; min-height: 40px; padding: 0 15px; color: var(--muted-strong);
  background: rgba(5,8,14,0.88); border: 1px solid rgba(255,255,255,0.18); border-radius: 4px; backdrop-filter: blur(18px);
  cursor: pointer; font: 11px var(--mono); text-transform: uppercase;
}
.map-reset:hover { color: var(--text); border-color: var(--line-strong); }
.map-tooltip {
  position: absolute; z-index: 8; max-width: 250px; padding: 12px 14px; pointer-events: none; color: var(--text);
  background: rgba(9,14,23,0.96); border: 1px solid rgba(255,255,255,0.24); box-shadow: 0 18px 45px rgba(0,0,0,0.48), 0 0 28px rgba(0,168,255,0.1);
  backdrop-filter: blur(18px); font: 12px/1.45 var(--mono);
}
.map-tooltip strong { display: block; margin-bottom: 8px; font: 600 14px var(--sans); }
.tooltip-results { display: grid; gap: 4px; }
.tooltip-results span { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 6px; color: var(--muted-strong); }
.tooltip-results b { color: var(--text); font-weight: 500; }

.state-panel {
  min-width: 0; padding: clamp(26px, 3.4vw, 52px); border-left: 1px solid var(--line);
  background: radial-gradient(circle at 105% 0%, rgba(0,168,255,0.1), transparent 28%), linear-gradient(145deg, rgba(255,255,255,0.035), transparent 38%), var(--panel);
}
.state-identity { display: grid; grid-template-columns: 78px minmax(0, 1fr); align-items: center; gap: 19px; }
.state-identity > div { min-width: 0; }
.state-flag-frame { display: grid; gap: 7px; width: max-content; }
.state-flag { display: block; width: 72px; max-height: 50px; border: 1px solid rgba(255,255,255,0.28); border-radius: 3px; box-shadow: 0 12px 28px rgba(0,0,0,0.4), 0 0 22px rgba(0,168,255,0.08); background: rgba(255,255,255,0.04); object-fit: contain; }
.state-flag-frame span { color: var(--muted); font: 10px/1 var(--mono); letter-spacing: 0.08em; text-align: center; }
.state-identity h2 { max-width: 100%; margin: 8px 0 6px; font-size: clamp(32px, 12cqi, 54px); font-weight: 600; line-height: 0.98; letter-spacing: -0.055em; overflow-wrap: anywhere; hyphens: auto; }
.state-capital, .section-note { margin: 0; color: var(--muted); font-size: 13px; }
.election-alert { margin: 32px 0 0; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.alert-label { color: var(--muted); font: 11px/1.2 var(--mono); letter-spacing: 0.12em; }
.alert-value { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 12px; margin-top: 7px; }
.alert-value strong { min-width: 0; font-size: 20px; font-weight: 600; overflow-wrap: anywhere; }
.alert-value span { color: var(--accent); font: 12px var(--mono); text-align: right; }
.alert-value .is-annulled { color: #ef9a82; }

.data-section { padding-top: 30px; }
.election-section { margin-top: 32px; border-top: 1px solid var(--line); }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 23px; }
.section-heading > div { min-width: 0; }
.section-label { margin-bottom: 5px; color: var(--text); letter-spacing: 0.12em; }
.date-chip { flex: 0 0 auto; color: var(--muted-strong); font: 11px/1.3 var(--mono); letter-spacing: 0.04em; text-align: right; }
.mini-bars { display: grid; gap: 12px; }
.mini-row { display: grid; grid-template-columns: minmax(108px, 1.1fr) minmax(64px, 1fr) 42px; align-items: center; gap: 10px; color: var(--muted-strong); font-size: 12px; }
.party-name { min-width: 0; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.bar-track { height: 4px; overflow: hidden; background: rgba(255,255,255,0.09); border-radius: 999px; }
.bar-fill { display: block; width: var(--value, 0%); height: 100%; background: var(--party-color); border-radius: inherit; box-shadow: 0 0 12px color-mix(in srgb, var(--party-color) 45%, transparent); transition: width 420ms cubic-bezier(.2,.8,.2,1); }
.mini-value { font: 11px var(--mono); text-align: right; }
.source-link { display: inline-block; margin-top: 19px; color: var(--muted-strong); font: 10px var(--mono); letter-spacing: 0.07em; text-decoration: none; text-transform: uppercase; }
.source-link:hover { color: var(--accent); }

.overview { padding: 80px 0 64px; border-bottom: 1px solid var(--line); }
.overview h2, .polls-section h2, .methodology h2 { margin: 0; font-size: clamp(34px, 4.4vw, 66px); font-weight: 600; line-height: 1; letter-spacing: -0.055em; }
.overview > h2 { margin-bottom: 10px; }
.overview-note { margin: 0 0 34px; color: var(--muted); font: 11px var(--mono); }
.overview-note span { color: var(--accent); }
.table-wrap { overflow-x: auto; }
table { width: 100%; min-width: 780px; border-collapse: collapse; }
th { padding: 12px 14px; color: var(--muted); border-bottom: 1px solid var(--line-strong); font: 11px/1.3 var(--mono); letter-spacing: 0.08em; text-align: left; text-transform: uppercase; }
td { padding: 18px 14px; color: var(--muted-strong); border-bottom: 1px solid var(--line); font-size: 14px; }
td:first-child { color: var(--text); font-size: 15px; font-weight: 600; }
tbody tr { cursor: pointer; transition: background-color 150ms ease; }
tbody tr:hover, tbody tr.is-selected { background: rgba(255,255,255,0.035); }
.table-rating { color: var(--text); font: 500 14px var(--mono); }

.polls-section { padding: 68px 0; border-bottom: 1px solid var(--line); }
.polls-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 19px; }
.polls-heading .eyebrow { margin-bottom: 14px; }
.polls-heading .source-link { margin: 0 0 7px; }
.polls-intro { max-width: 780px; margin: 0 0 28px; color: var(--muted-strong); font-size: 14px; line-height: 1.7; }
.poll-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.poll-card { min-width: 0; padding: 24px; background: var(--panel); }
.poll-card header { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.poll-card h3 { margin: 0; font-size: 16px; letter-spacing: -0.02em; }
.poll-card time, .poll-card p { color: var(--muted); font: 10px var(--mono); }
.poll-card p { margin: 8px 0 20px; }
.poll-mini { display: flex; height: 7px; overflow: hidden; background: rgba(255,255,255,0.09); border-radius: 999px; }
.poll-mini span { height: 100%; }
.poll-values { display: flex; flex-wrap: wrap; gap: 9px 12px; margin-top: 17px; }
.poll-values span { display: inline-flex; align-items: center; gap: 6px; color: var(--muted-strong); font: 10px var(--mono); white-space: nowrap; }
.poll-values .swatch { width: 7px; height: 7px; }

.methodology { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: clamp(60px, 10vw, 160px); padding: 68px 0; border-bottom: 1px solid var(--line); }
.method-copy { display: grid; grid-template-columns: 1fr 1fr; gap: 44px; color: var(--muted-strong); font-size: 14px; line-height: 1.75; }
.method-copy p { margin: 0; }
footer { display: flex; align-items: center; justify-content: flex-end; min-height: 108px; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px 24px; }
.footer-links a { color: var(--muted); font: 10px var(--mono); text-decoration: none; }
.footer-links a:hover { color: var(--text); }
noscript { display: block; padding: 20px; color: #fff; background: #a92323; text-align: center; }

@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr; gap: 42px; }
  .hero-metrics { max-width: 720px; }
  .atlas-grid { grid-template-columns: minmax(0, 1.35fr) minmax(330px, 0.65fr); }
  .state-panel { padding: 30px; }
  .methodology { grid-template-columns: 1fr; gap: 45px; }
  .poll-cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 820px) {
  .site-shell { padding: 0 18px; }
  .site-header { min-height: 76px; }
  .header-status { max-width: 48%; text-align: right; }
  .hero { min-height: 0; padding: 52px 0 46px; }
  .hero h1 { font-size: clamp(52px, 15vw, 90px); }
  .atlas-toolbar { align-items: flex-start; flex-direction: column; padding: 16px 0; }
  .view-switch { flex-wrap: nowrap; width: 100%; overflow-x: auto; scrollbar-width: none; }
  .view-switch::-webkit-scrollbar { display: none; }
  .view-button { min-width: 52px; flex: 0 0 52px; padding: 0 8px; }
  #view-description { flex: 0 0 auto; text-align: left; }
  .atlas-grid { grid-template-columns: 1fr; }
  .map-panel { min-height: 610px; }
  .map-legend { right: 112px; bottom: 12px; left: 12px; width: auto; }
  .map-reset { right: 12px; bottom: 12px; }
  .state-panel { border-top: 1px solid var(--line); border-left: 0; }
  .overview { padding: 64px 0 54px; }
  .polls-section { padding: 58px 0 54px; }
  .methodology { padding: 56px 0; }
}

@media (max-width: 560px) {
  .site-shell { padding: 0 12px; }
  .site-header { min-height: 68px; gap: 14px; }
  .brand b { font-size: 12px; }
  .header-status { line-height: 1.35; font-size: 9px; }
  .hero { gap: 30px; padding: 36px 0 38px; }
  .hero h1 { margin-top: 13px; font-size: clamp(46px, 15.2vw, 76px); }
  .hero-metrics { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero-metrics div { padding: 14px 10px 14px 0; }
  .hero-metrics div + div { padding-left: 10px; border-top: 0; border-left: 1px solid var(--line); }
  .hero-metrics small { display: block; margin: 6px 0 0; font-size: 9px; }
  .atlas-toolbar { gap: 12px; min-height: 0; padding: 14px 0; }
  .view-button { flex: 0 0 52px; padding: 0 7px; font-size: 10px; }
  .map-panel { min-height: 0; height: clamp(280px, 62svh, 500px); }
  .map-legend { gap: 7px 12px; }
  .state-panel { padding: 24px 16px 30px; }
  .state-identity { grid-template-columns: 58px minmax(0, 1fr); gap: 12px; }
  .state-flag { width: 54px; }
  .election-alert { margin-top: 24px; }
  .data-section { padding-top: 24px; }
  .election-section { margin-top: 24px; }
  .section-heading { flex-wrap: wrap; }
  .mini-row { grid-template-columns: minmax(98px, 1fr) minmax(50px, 1fr) 40px; gap: 8px; }
  .overview, .polls-section { padding: 48px 0; }
  .overview h2, .polls-section h2, .methodology h2 { font-size: clamp(32px, 10vw, 52px); }
  .polls-heading { align-items: flex-start; gap: 16px; }
  .poll-cards { grid-template-columns: 1fr; }
  .poll-card { padding: 20px; }
  .methodology { grid-template-columns: 1fr; gap: 28px; padding: 48px 0; }
  .method-copy { grid-template-columns: 1fr; gap: 18px; }
  footer { justify-content: flex-start; min-height: 96px; }
  .footer-links { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: 0.01ms !important; }
}
