:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #10231c;
  background: #f3f6f3;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #10231c;
  --muted: #66766e;
  --line: #e5ebe6;
  --green: #0d6b43;
  --dark-green: #082e22;
  --pt: #cf3b42;
  --pl: #27804d;
  --surface: #fff;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  margin: 0;
  background:
    radial-gradient(ellipse at 78% 2%, rgba(26, 116, 73, .08), transparent 34rem),
    #f3f6f3;
}

button, a { font: inherit; }
a { color: inherit; }

.page {
  width: min(1180px, calc(100% - 48px));
  margin: 0 auto;
}

.topbar {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  width: 42px;
  height: 31px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 4px;
  background: #12814b;
  box-shadow: 0 3px 10px #10231c1c;
}

.brand-mark::before {
  width: 27px;
  height: 21px;
  content: "";
  background: #f2cb48;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}

.brand-mark span {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #2855a4;
}

.brand-kicker, .brand-copy strong { display: block; }
.brand-kicker, .section-kicker, .eyebrow, .metric-heading, .refresh-label, .state-panel-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .12em;
}
.brand-kicker { margin-bottom: 3px; color: #718077; }
.brand-copy strong { font-size: 16px; letter-spacing: .045em; }
.brand-copy strong span { color: var(--green); }

.official-link {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border: 1px solid #d7e2da;
  border-radius: 9px;
  color: #0d5a39;
  background: #ffffffb8;
  font-size: 12px;
  font-weight: 750;
  text-decoration: none;
}
.official-link:hover { border-color: #a9c9b4; background: #fff; }

.hero {
  position: relative;
  min-height: 267px;
  display: flex;
  align-items: center;
  padding: 38px 54px;
  overflow: hidden;
  border-radius: 20px;
  color: #fff;
  background:
    linear-gradient(105deg, rgba(5, 43, 30, .99) 0%, rgba(7, 62, 41, .94) 56%, rgba(7, 70, 42, .78) 100%),
    #082e22;
  box-shadow: 0 14px 35px #12352421;
}

.hero::after {
  position: absolute;
  inset: 0;
  content: "";
  opacity: .12;
  background-image: radial-gradient(#fff 1px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(90deg, transparent 28%, #000);
  pointer-events: none;
}

.hero-copy { position: relative; z-index: 1; max-width: 570px; }
.eyebrow { display: flex; align-items: center; gap: 8px; margin: 0 0 13px; color: #b7d8c3; }
.live-dot, .status-dot { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #79d792; }
.hero h1 { margin: 0; font-size: clamp(33px, 5vw, 49px); line-height: 1.03; letter-spacing: -.045em; }
.hero h1 span { color: #d8eddf; }
.hero-description { max-width: 495px; margin: 15px 0 20px; color: #d0e1d7; font-size: 14px; line-height: 1.55; }
.source-state { display: flex; align-items: center; flex-wrap: wrap; gap: 11px; }
.status-pill { display: inline-flex; align-items: center; gap: 8px; padding: 7px 10px; border: 1px solid #ffffff31; border-radius: 99px; background: #ffffff10; font-size: 11px; font-weight: 750; }
.status-pill[data-tone="pending"] .status-dot { background: #eac75c; }
.status-pill[data-tone="stale"] .status-dot { background: #eac75c; }
.status-pill[data-tone="error"] .status-dot { background: #ff8a83; }
.status-pill[data-tone="success"] .status-dot { background: #79d792; }
.source-caption { color: #b8d0c2; font-size: 11px; }

.hero-flag {
  position: absolute;
  top: 50%;
  right: 4%;
  width: 34%;
  height: 82%;
  display: grid;
  place-items: center;
  opacity: .2;
  transform: translateY(-50%) rotate(-7deg);
}
.flag-diamond {
  position: absolute;
  width: min(315px, 82%);
  aspect-ratio: 1.5;
  display: grid;
  place-items: center;
  background: #f1cd52;
  clip-path: polygon(50% 0, 100% 50%, 50% 100%, 0 50%);
}
.flag-globe { width: 38%; aspect-ratio: 1; border-radius: 50%; background: #3063ac; }
.flag-ribbon {
  position: absolute;
  top: 54%;
  width: 36%;
  padding: 2px 4px;
  color: #fff;
  background: #3063ac;
  font-size: 6px;
  font-weight: 900;
  letter-spacing: .12em;
  text-align: center;
  transform: rotate(8deg);
}

.refresh-row {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 11px 3px;
}
.refresh-info, .refresh-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.refresh-label { color: #849087; font-size: 9px; }
.refresh-info time { color: #34483c; font-size: 11px; font-weight: 700; }
.refresh-separator { color: #b3beb6; }
.countdown-copy { color: var(--muted); font-size: 11px; }
.countdown-copy strong { color: var(--ink); font-variant-numeric: tabular-nums; }
.refresh-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid #dce6df;
  border-radius: 8px;
  color: #fff;
  background: #0d6b43;
  cursor: pointer;
  font-size: 11px;
  font-weight: 750;
  transition: background .15s ease, transform .15s ease;
}
.refresh-button:hover:not(:disabled) { background: #095634; transform: translateY(-1px); }
.refresh-button:disabled { cursor: wait; opacity: .7; }
.refresh-button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.7; }

.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric {
  min-height: 127px;
  padding: 16px 17px 13px;
  border: 1px solid #e7ece8;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 4px 14px #18332208;
}
.metric-heading { display: flex; align-items: center; gap: 7px; color: #718076; font-size: 9px; }
.metric-icon { color: #138150; font-size: 14px; line-height: 1; }
.metric-value { display: flex; align-items: baseline; gap: 3px; margin-top: 13px; color: #13271e; font-variant-numeric: tabular-nums; }
.metric-value strong { font-size: clamp(22px, 2.3vw, 30px); letter-spacing: -.045em; }
.metric-value > span { color: #68786e; font-size: 14px; }
.metric-note { margin: 6px 0 0; color: #89958d; font-size: 10px; }
.progress-track { height: 5px; margin-top: 9px; overflow: hidden; border-radius: 9px; background: #e8eee9; }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: #17834f; transition: width .3s ease; }
.metric-progress .metric-note { margin-top: 5px; }

.section-block {
  margin-top: 20px;
  padding: 22px 24px;
  border: 1px solid #e7ece8;
  border-radius: 14px;
  background: var(--surface);
  box-shadow: 0 4px 14px #18332208;
}
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.section-kicker { margin: 0 0 5px; color: #16804e; font-size: 9px; }
.section-heading h2 { margin: 0; font-size: 19px; letter-spacing: -.025em; }
.leader-difference { color: #637369; font-size: 11px; font-weight: 650; text-align: right; }
.candidate-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.candidate-card {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 15px;
  padding: 15px;
  overflow: hidden;
  border: 1px solid #e6ece7;
  border-radius: 11px;
  background: linear-gradient(145deg, #fff 0%, #f9fbf9 100%);
}
.candidate-card[data-party="PT"] { --candidate-color: var(--pt); }
.candidate-card[data-party="PL"] { --candidate-color: var(--pl); }
.candidate-card[data-leading="true"] { border-color: color-mix(in srgb, var(--candidate-color, #15804d) 45%, white); }
.candidate-card[data-leading="true"]::before { position: absolute; inset: 0 auto 0 0; width: 3px; content: ""; background: var(--candidate-color, #15804d); }
.candidate-photo {
  position: relative;
  width: 76px;
  height: 90px;
  align-self: center;
  overflow: hidden;
  border-radius: 8px;
  background: linear-gradient(145deg, #d8e8de, #f0f4ef);
}
.candidate-photo img { width: 100%; height: 100%; object-fit: cover; object-position: center top; }
.photo-fallback { position: absolute; inset: 0; display: grid; place-items: center; color: #38634b; font-size: 20px; font-weight: 850; }
.photo-fallback[hidden] { display: none; }
.candidate-copy { min-width: 0; align-self: center; }
.candidate-badges { min-height: 18px; display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.party-badge { padding: 3px 6px; border-radius: 4px; color: #435348; background: #eef2ef; font-size: 9px; font-weight: 850; letter-spacing: .04em; }
.candidate-card[data-party="PT"] .party-badge { color: #a83238; background: #fae9e9; }
.candidate-card[data-party="PL"] .party-badge { color: #21623e; background: #e8f4eb; }
.leader-badge { color: #6d766f; font-size: 8px; font-weight: 800; letter-spacing: .055em; text-transform: uppercase; }
.candidate-name { margin: 0; overflow-wrap: anywhere; font-size: 14px; line-height: 1.25; }
.candidate-party-name { margin: 3px 0 10px; color: #758179; font-size: 10px; }
.candidate-results { display: flex; align-items: baseline; flex-wrap: wrap; gap: 7px; }
.candidate-votes { color: #172a20; font-size: 20px; font-weight: 850; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.candidate-percent { color: #5e6d63; font-size: 11px; font-weight: 750; }
.candidate-progress { height: 5px; margin-top: 8px; overflow: hidden; border-radius: 7px; background: #e9efea; }
.candidate-progress span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--candidate-color, #8fa397); transition: width .3s ease; }
.partial-note { display: flex; align-items: center; gap: 6px; margin: 13px 0 0; color: #76847a; font-size: 10px; }
.partial-note span { color: #16804e; font-size: 14px; }
.empty-state { margin: 0; color: #76847a; font-size: 12px; line-height: 1.5; }

.map-section { margin-bottom: 25px; }
.map-heading { align-items: flex-start; }
.section-subtitle { max-width: 590px; margin: 7px 0 0; color: #77847b; font-size: 11px; line-height: 1.5; }
.map-legend { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px 13px; padding-top: 3px; }
.map-legend > span { display: inline-flex; align-items: center; gap: 5px; color: #65746a; font-size: 9px; white-space: nowrap; }
.legend-swatch { width: 10px; height: 10px; border: 1px solid #d8e1da; border-radius: 3px; }
.legend-pt { border-color: #c94349; background: #d95b5f; }
.legend-pl { border-color: #328154; background: #4d9a68; }
.legend-neutral { background: #e7ece8; }
.legend-marker { width: 9px; height: 9px; border: 2px solid #fff; border-radius: 50%; background: #60776a; box-shadow: 0 0 0 1px #53695b; }
.map-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(235px, .8fr); align-items: stretch; gap: 14px; }
.map-card, .state-card { border: 1px solid #e7ece8; border-radius: 11px; background: #fbfcfb; }
.map-card { min-width: 0; padding: 9px 12px 11px; }
.map-stage { position: relative; min-height: 300px; display: grid; place-items: center; }
.map-loading { position: absolute; z-index: 1; }
.map-stage svg { width: 100%; max-height: 420px; overflow: visible; }
.state-shape { fill: #e7ece8; stroke: #fff; stroke-width: .75; stroke-linejoin: round; vector-effect: non-scaling-stroke; cursor: pointer; transition: fill .2s ease, filter .2s ease; }
.state-shape:hover, .state-shape:focus-visible { filter: brightness(.92); outline: none; stroke: #193c2b; stroke-width: 1.6; }
.state-shape.leader-pt, .state-shape.final-pt { fill: #d85b60; }
.state-shape.leader-pl, .state-shape.final-pl { fill: #4a9865; }
.state-shape.leader-other, .state-shape.final-other { fill: #687d70; }
.state-label { fill: #30483a; font-size: 7px; font-weight: 850; text-anchor: middle; dominant-baseline: central; pointer-events: none; }
.map-marker { display: none; stroke: #fff; stroke-width: 1.6; vector-effect: non-scaling-stroke; cursor: pointer; filter: drop-shadow(0 1px 1px #17231d55); }
.map-marker.is-visible { display: block; }
.map-marker.party-pt { fill: #bd3039; }
.map-marker.party-pl { fill: #197844; }
.map-marker.party-other { fill: #44594b; }
.map-marker:focus-visible { outline: none; stroke: #172c20; stroke-width: 2.5; }
.map-footnote { margin: 0; color: #829087; font-size: 9px; line-height: 1.45; }
.state-card { padding: 17px; }
.state-panel-kicker { margin: 0 0 6px; color: #16804e; font-size: 9px; }
.state-card h3 { margin: 0; font-size: 17px; }
.state-status { min-height: 32px; margin: 6px 0 11px; color: #77847b; font-size: 10px; line-height: 1.45; }
.state-votes { display: grid; gap: 8px; }
.state-candidate { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px; border-radius: 7px; background: #f1f5f2; }
.state-candidate span { min-width: 0; overflow: hidden; color: #526258; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.state-candidate strong { color: #172a20; font-size: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.state-meta { display: grid; gap: 8px; margin: 13px 0 0; padding-top: 11px; border-top: 1px solid #e5ebe6; }
.state-meta div { display: flex; justify-content: space-between; gap: 12px; }
.state-meta dt, .state-meta dd { margin: 0; font-size: 9px; }
.state-meta dt { color: #7b887f; }
.state-meta dd { color: #31463a; font-weight: 750; text-align: right; }

.footer { display: flex; justify-content: space-between; gap: 20px; padding: 0 2px 28px; color: #75837a; font-size: 10px; line-height: 1.5; }
.footer p { margin: 0; }
.footer a { color: #12653e; font-weight: 700; }
.footer-note { max-width: 420px; text-align: right; }
.partial-note #winner-photo-notice:not([hidden]) { color: #9a4b21; font-weight: 700; }

.celebration[hidden] { display: none; }
.celebration {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  place-items: center;
  padding: 24px;
  color: #fff;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(22, 93, 63, .48), transparent 50%),
    #06130f;
  isolation: isolate;
}
.celebration-canvas { position: absolute; z-index: -1; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.celebration-content {
  position: relative;
  z-index: 1;
  display: flex;
  width: min(100%, 650px);
  max-height: 100%;
  flex-direction: column;
  align-items: center;
  overflow: auto;
  padding: 20px 16px;
  text-align: center;
}
.celebration-kicker { margin: 0 0 8px; color: #f5d66d; font-size: 11px; font-weight: 850; letter-spacing: .16em; }
.celebration-title { margin: 0; font-size: clamp(26px, 5vw, 46px); line-height: 1.1; }
.celebration-description { margin: 9px 0 18px; color: #d6e6dc; font-size: 14px; }
.celebration-portrait { display: grid; width: min(42vw, 260px); height: min(44vh, 330px); min-height: 160px; place-items: center; }
.celebration-portrait img { display: block; max-width: 100%; max-height: 100%; border: 4px solid rgba(255, 255, 255, .86); border-radius: 18px; object-fit: contain; box-shadow: 0 18px 70px rgba(0, 0, 0, .42); }
.celebration-winner { margin: 15px 0 0; font-size: clamp(20px, 4vw, 32px); line-height: 1.15; }
.celebration-identification { margin: 5px 0 0; color: #f5d66d; font-size: 13px; font-weight: 750; }
.celebration-confirmation { margin: 7px 0 18px; color: #c1d4c8; font-size: 13px; }
.celebration-return { min-height: 44px; padding: 10px 18px; border: 0; border-radius: 999px; color: #10231c; background: #f5d66d; font-size: 13px; font-weight: 800; cursor: pointer; }
.celebration-return:hover { background: #ffe88f; }
body.celebrating { overflow: hidden; }

:focus-visible { outline: 3px solid #eccf5b; outline-offset: 3px; }

@media (max-width: 850px) {
  .page { width: min(100% - 32px, 720px); }
  .hero { min-height: 250px; padding: 32px 34px; }
  .hero-flag { right: -5%; width: 38%; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric { min-height: 117px; }
  .map-heading { display: block; }
  .map-legend { justify-content: flex-start; margin-top: 13px; }
  .map-layout { grid-template-columns: minmax(0, 1.3fr) minmax(215px, .8fr); }
}

@media (max-width: 600px) {
  .page { width: calc(100% - 24px); }
  .topbar { min-height: 69px; }
  .brand-mark { width: 36px; height: 27px; }
  .brand-kicker { font-size: 8px; }
  .brand-copy strong { font-size: 14px; }
  .official-link { gap: 5px; padding: 8px 9px; font-size: 10px; }
  .hero { min-height: 246px; padding: 27px 22px; border-radius: 15px; }
  .hero-copy { max-width: 94%; }
  .hero h1 { font-size: clamp(34px, 10vw, 43px); }
  .hero-description { max-width: 340px; margin: 13px 0 16px; font-size: 12px; }
  .hero-flag { top: 10%; right: -15%; width: 50%; height: 70%; opacity: .13; transform: rotate(-8deg); }
  .flag-diamond { width: 100%; }
  .eyebrow { font-size: 8px; }
  .source-state { gap: 7px; }
  .status-pill { font-size: 10px; }
  .source-caption { font-size: 9px; }
  .refresh-row { align-items: flex-start; min-height: 74px; padding: 12px 1px; }
  .refresh-info { max-width: 54%; align-items: flex-start; gap: 3px 6px; }
  .refresh-info .refresh-label:nth-of-type(2), .refresh-separator { display: none; }
  .refresh-info time { width: 100%; font-size: 10px; }
  .refresh-actions { justify-content: flex-end; gap: 6px; }
  .countdown-copy { font-size: 9px; }
  .refresh-button { padding: 8px; font-size: 9px; }
  .refresh-button svg { width: 13px; height: 13px; }
  .metrics { gap: 8px; }
  .metric { min-height: 105px; padding: 12px; border-radius: 10px; }
  .metric-heading { gap: 5px; font-size: 8px; letter-spacing: .08em; }
  .metric-value { margin-top: 10px; }
  .metric-value strong { font-size: clamp(20px, 7vw, 27px); }
  .metric-note { font-size: 9px; }
  .section-block { margin-top: 13px; padding: 16px 13px; border-radius: 12px; }
  .section-heading { align-items: flex-start; margin-bottom: 12px; }
  .section-heading h2 { font-size: 17px; }
  .section-kicker { font-size: 8px; }
  .leader-difference { max-width: 130px; padding-top: 10px; font-size: 9px; }
  .candidate-grid { gap: 8px; }
  .candidate-card { grid-template-columns: 54px minmax(0, 1fr); gap: 8px; padding: 9px 8px; border-radius: 9px; }
  .candidate-photo { width: 54px; height: 68px; border-radius: 6px; }
  .candidate-badges { gap: 4px; margin-bottom: 3px; }
  .party-badge { padding: 2px 4px; font-size: 8px; }
  .leader-badge { font-size: 7px; }
  .candidate-name { font-size: 11px; line-height: 1.22; }
  .candidate-party-name { min-height: 12px; margin: 3px 0 6px; font-size: 8px; }
  .candidate-results { gap: 4px; }
  .candidate-votes { font-size: 16px; }
  .candidate-percent { font-size: 9px; }
  .candidate-progress { height: 4px; margin-top: 6px; }
  .partial-note { align-items: flex-start; font-size: 9px; line-height: 1.4; }
  .map-layout { grid-template-columns: 1fr; gap: 9px; }
  .map-card { padding: 5px 7px 9px; }
  .map-stage { min-height: 235px; }
  .map-stage svg { max-height: 340px; }
  .map-legend { gap: 7px 10px; }
  .map-legend > span { font-size: 8px; }
  .map-footnote { padding: 0 3px; font-size: 8px; }
  .state-card { padding: 13px; }
  .state-card h3 { font-size: 15px; }
  .state-status { min-height: auto; }
  .footer { display: grid; gap: 7px; padding-bottom: 20px; font-size: 9px; }
  .footer-note { text-align: left; }
  .celebration { padding: 14px; }
  .celebration-content { padding: 14px 6px; }
  .celebration-kicker { font-size: 9px; }
  .celebration-description { margin: 7px 0 12px; font-size: 12px; }
  .celebration-portrait { width: min(58vw, 230px); height: min(42vh, 290px); }
  .celebration-winner { margin-top: 11px; }
  .celebration-identification { font-size: 11px; }
  .celebration-confirmation { margin-bottom: 14px; font-size: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
  .celebration-canvas { display: none; }
}
