:root {
  --background: #000000;
  --panel: #0b0c0a;
  --line: #30342f;
  --muted: #9ca39b;
  --text: #f5f7f4;
  --signal: #00e676;
  --red-team: #ff3b30;
  --blue-team: #3794ff;
}

* { box-sizing: border-box; }

html { background: var(--background); }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(90deg, transparent 49.9%, rgba(255,255,255,.025) 50%, transparent 50.1%),
    var(--background);
  color: var(--text);
  font-family: "IBM Plex Mono", "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

.scoreboard {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 44px);
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: clamp(14px, 1.6vw, 20px);
}

.masthead,
.status-line {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 18px;
}

.company,
.metric-label,
.team-position {
  margin: 0;
  color: var(--muted);
  font-size: clamp(.7rem, 1vw, .86rem);
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1 {
  margin: 7px 0 0;
  font-size: clamp(2.6rem, 6vw, 5.4rem);
  line-height: .84;
  letter-spacing: -.08em;
  text-transform: uppercase;
}

.brand {
  display: flex;
  align-items: center;
  gap: clamp(18px, 3vw, 42px);
  min-width: 0;
}

.brand-logo {
  width: clamp(170px, 22vw, 310px);
  height: auto;
  flex: 0 0 auto;
}

.connection {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: .82rem;
  white-space: nowrap;
}

.connection-dot {
  width: 9px;
  height: 9px;
  background: var(--signal);
  box-shadow: 0 0 18px var(--signal);
}

body[data-state="error"] .connection-dot { background: var(--red-team); box-shadow: none; }
body[data-state="stale"] .connection-dot { background: #ffb800; box-shadow: none; }

.leadership {
  position: relative;
  height: clamp(390px, 45vh, 540px);
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--panel);
}

.leadership img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center 32%;
  filter: saturate(.78) contrast(1.04);
}

.leadership::after {
  content: "";
  position: absolute;
  inset: 35% 0 0;
  background: linear-gradient(transparent, rgba(0, 0, 0, .92));
  pointer-events: none;
}

.leadership figcaption {
  position: absolute;
  z-index: 1;
  inset: auto 0 0;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 18px clamp(18px, 2.4vw, 34px);
  color: var(--text);
  font-size: clamp(.72rem, 1vw, .92rem);
}

.leadership figcaption span:last-child { text-align: right; }
.leadership figcaption strong { color: var(--signal); }

.race {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  min-height: 420px;
}

.team {
  --team-color: var(--signal);
  display: grid;
  grid-template-rows: auto auto 1fr;
  border: 1px solid var(--line);
  background: var(--panel);
  min-width: 0;
}

.team-red { --team-color: var(--red-team); }
.team-blue { --team-color: var(--blue-team); }
.team.is-leading { border-color: var(--signal); }

.team-heading,
.score-block,
.bar-zone { padding: clamp(16px, 2.4vw, 34px); }

.team-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.team-heading h2 {
  margin: 0;
  max-width: 80%;
  font-size: clamp(1.2rem, 2.4vw, 2.5rem);
  line-height: 1;
}

.team-position { order: 2; text-align: right; }
.team-position span { display: block; color: var(--text); font-size: 1.5em; margin-top: 5px; }

.score-block { border-bottom: 1px solid var(--line); }
.score { display: block; margin-top: 3px; font-size: clamp(3rem, 8vw, 7.6rem); line-height: .95; }

.bar-zone {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(90px, 1fr);
  grid-template-rows: 1fr auto;
  gap: 14px 18px;
  min-height: 280px;
}

.bar-scale {
  grid-row: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  color: var(--muted);
  font-size: .64rem;
}

.bar-track {
  grid-column: 2;
  grid-row: 1;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  background: repeating-linear-gradient(to top, transparent 0 24%, var(--line) 25%);
}

.bar-fill {
  --progress: 0%;
  position: absolute;
  inset: auto 0 0;
  height: var(--progress);
  background: var(--team-color);
  transition: height 500ms ease;
}

.bar-fill::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(135deg, transparent 0 9px, rgba(0,0,0,.2) 10px 12px);
}

.bar-value {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.bar-value strong { font-size: clamp(1.25rem, 2vw, 2rem); }
.progress-accessible { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }

.versus {
  display: grid;
  place-items: center;
  width: clamp(42px, 6vw, 86px);
  color: var(--muted);
  font-size: .68rem;
  letter-spacing: .18em;
  writing-mode: vertical-rl;
}

.status-line {
  align-items: center;
  border-top: 1px solid var(--line);
  border-bottom: 0;
  padding: 18px 0 0;
  color: var(--muted);
  font-size: clamp(.72rem, 1vw, .9rem);
}

.status-line p { margin: 0; }
#lead-status { color: var(--text); }

@media (max-width: 760px) {
  .scoreboard { min-height: auto; }
  .masthead, .status-line { align-items: flex-start; flex-direction: column; gap: 12px; }
  .brand { align-items: flex-start; flex-direction: column; gap: 14px; }
  .brand-logo { width: min(300px, 82vw); }
  .leadership { height: 300px; }
  .leadership img { object-position: 42% center; }
  .leadership figcaption { flex-direction: column; gap: 8px; }
  .leadership figcaption span:last-child { text-align: left; }
  .race { grid-template-columns: 1fr; min-height: 0; }
  .versus { width: auto; height: 42px; writing-mode: horizontal-tb; }
  .team { min-height: 520px; }
  .team-heading h2 { max-width: 70%; }
}

@media (prefers-reduced-motion: reduce) {
  .bar-fill { transition: none; }
}
