/* Layout: a scoreboard-green masthead over one reading column of standings tables.
   On narrow screens each table scrolls sideways with the team column pinned. */

@font-face {
  font-family: "Big Shoulders Display";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/big-shoulders-display-latin-wght-normal.woff2") format("woff2");
}

@font-face {
  font-family: "Public Sans";
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("fonts/public-sans-latin-wght-normal.woff2") format("woff2");
}

:root {
  /* Color */
  --bg: #f4f6f2;          /* chalk, faint green bias */
  --surface: #ffffff;
  --ink: #16201a;
  --muted: #5b685f;
  --rule: #dde3dc;
  --row-hover: #eef3ec;
  --panel: #f8faf6;
  --board: #1d4d36;       /* hand-operated scoreboard green */
  --board-ink: #f3f1e7;   /* painted-panel white */
  --board-dim: rgba(243, 241, 231, 0.72);
  --accent-text: #1d4d36;
  --bulb: #f0b429;        /* scoreboard bulb, used for clinch markers and the cut line */
  --bulb-ink: #2b1e00;
  --pos: #1c7a44;
  --neg: #b2362e;
  --away: #23885a;        /* simulator series: away team */
  --home: #e39b00;        /* simulator series: home team */

  /* Type */
  --font-display: "Big Shoulders Display", "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  --font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --radius: 10px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1411;
    --surface: #151d18;
    --ink: #e6ece6;
    --muted: #97a69c;
    --rule: #26332b;
    --row-hover: #1b2620;
    --panel: #111914;
    --board: #163b29;
    --board-ink: #f3f1e7;
    --board-dim: rgba(243, 241, 231, 0.7);
    --accent-text: #8fd0aa;
    --bulb: #f2bd3d;
    --bulb-ink: #2b1e00;
    --pos: #5ec98c;
    --neg: #f07c71;
    --away: #23885a;
    --home: #c98500;
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
}

.wrap {
  width: 100%;
  max-width: 1120px;
  margin-inline: auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Masthead ---------------------------------------------------------------- */

.masthead {
  background-color: var(--board);
  /* faint vertical seams, like the panels of a manual scoreboard */
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.035) 0 1px,
    transparent 1px 72px
  );
  color: var(--board-ink);
  padding-top: env(safe-area-inset-top, 0px);
}

.masthead-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px 32px;
  padding-block: 28px 22px;
}

.brand {
  display: grid;
  gap: 6px;
  min-width: 0;
}

h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.5rem, 7vw, 4rem);
  line-height: 0.88;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-wrap: balance;
}

.status {
  margin: 0;
  color: var(--board-dim);
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.tabs {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.22);
}

.tabs a {
  padding: 7px 14px;
  border-radius: 999px;
  color: var(--board-dim);
  font-weight: 600;
  font-size: 0.875rem;
  text-decoration: none;
  white-space: nowrap;
}

.tabs a:hover {
  color: var(--board-ink);
}

.tabs a[aria-current="page"] {
  background: var(--board-ink);
  color: var(--board);
}

.season {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--board-dim);
}

.season select {
  color-scheme: dark;
  appearance: none;
  padding: 7px 30px 7px 14px;
  border: 1px solid rgba(243, 241, 231, 0.35);
  border-radius: 999px;
  background: transparent
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23f3f1e7' stroke-width='1.5'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  color: var(--board-ink);
  font: 600 0.875rem var(--font-body);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  cursor: pointer;
}

.season select:disabled {
  opacity: 0.5;
  cursor: default;
}

.tabs a:focus-visible,
.season select:focus-visible,
.retry:focus-visible {
  outline: 2px solid var(--bulb);
  outline-offset: 2px;
}

/* Content ----------------------------------------------------------------- */

main {
  display: grid;
  gap: 40px;
  padding-block: 32px 24px;
}

.league {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.league h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.875rem;
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.blocks {
  display: grid;
  gap: 16px;
}

.block {
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}

.block-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 14px 16px 10px;
}

.block-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1.1;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--accent-text);
}

.block-head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.notice {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
}

.notice strong {
  color: var(--ink);
}

.notice.error {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.retry {
  padding: 7px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--board);
  color: var(--board-ink);
  font: 600 0.875rem var(--font-body);
  cursor: pointer;
}

/* Tables ------------------------------------------------------------------ */

.table-scroll {
  overflow-x: auto;
  container-type: inline-size; /* lets the game panel size itself to the visible width */
  -webkit-overflow-scrolling: touch;
}

.standings {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.standings th,
.standings td {
  padding: 9px 10px;
  text-align: right;
  border-top: 1px solid var(--rule);
}

.standings thead th {
  border-top: 0;
  padding-block: 6px 8px;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.standings thead abbr {
  text-decoration: none;
  cursor: help;
}

.standings th.team {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 232px;
  padding-left: 16px;
  text-align: left;
  background: var(--surface);
  font-weight: 500;
}

.standings tr.team-row {
  cursor: pointer;
}

.standings tr.team-row:hover > *,
.standings tr.team-row.open > * {
  background: var(--row-hover);
}

.standings td:last-child {
  padding-right: 16px;
}

/* gap between the record block and the situational columns */
.standings .col-l10 {
  padding-left: 22px;
}

.team-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.team-toggle:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 4px;
  border-radius: 4px;
}

.name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chev {
  flex: none;
  width: 7px;
  height: 7px;
  margin: -3px 2px 0 auto;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.15s ease;
}

.team-toggle[aria-expanded="true"] .chev {
  margin-top: 3px;
  transform: rotate(-135deg);
}

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

.rank {
  min-width: 1.4em;
  color: var(--muted);
  font-size: 0.8125rem;
  text-align: right;
}

.abbr {
  min-width: 2.4em;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.0625rem;
  letter-spacing: 0.03em;
  color: var(--accent-text);
}

.clinch {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: var(--bulb);
  color: var(--bulb-ink);
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
}

.lg {
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 600;
}

.pos {
  color: var(--pos);
}

.neg {
  color: var(--neg);
}

.standings tr.cut > * {
  border-bottom: 2px dashed var(--bulb);
}

.standings tr.cut + tr > * {
  border-top: 0;
}

/* Game panel -------------------------------------------------------------- */

.standings .games-row > td {
  padding: 0;
  text-align: left;
  white-space: normal;
  background: var(--panel);
}

.games-panel {
  position: sticky;
  left: 0;
  width: 100cqw;
  padding: 14px 16px 16px;
}

.games-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr);
  gap: 18px 40px;
}

.games-grid.single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 620px;
}

.games-col {
  min-width: 0;
}

.games-col h4 {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.game-list {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.game {
  display: grid;
  grid-template-columns: 1.5rem 3.5rem minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px 10px;
  padding-block: 7px;
  border-top: 1px solid var(--rule);
}

.game:first-child {
  padding-top: 0;
  border-top: 0;
}

.result {
  display: inline-grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

.result.win {
  color: var(--pos);
  background: color-mix(in srgb, var(--pos) 15%, transparent);
}

.result.loss {
  color: var(--neg);
  background: color-mix(in srgb, var(--neg) 15%, transparent);
}

.result.tie {
  color: var(--muted);
  background: var(--rule);
}

.score {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.opp {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opp b {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--accent-text);
}

.ha,
.opp-name,
.date,
.meta,
.games-note {
  color: var(--muted);
}

.ha,
.date,
.meta {
  font-size: 0.8125rem;
}

.date {
  font-variant-numeric: tabular-nums;
}

.game .meta {
  grid-column: 2 / -1;
}

.games-col p {
  margin: 0;
}

.next-when {
  font-weight: 600;
}

.games-col .next-opp {
  margin-block: 2px 4px;
}

.games-col .meta + .meta {
  margin-top: 2px;
}

.games-retry {
  margin-left: 6px;
  padding: 3px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 600 0.8125rem var(--font-body);
  cursor: pointer;
}

@container (max-width: 640px) {
  .games-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .opp-name {
    display: none;
  }
}

/* Simulator ---------------------------------------------------------------- */

.swatch {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.swatch.away {
  background: var(--away);
}

.swatch.home {
  background: var(--home);
}

.sim,
.sim-output {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.sim {
  gap: 20px;
}

.sim-intro {
  display: grid;
  gap: 8px;
  max-width: 70ch;
}

.sim-intro h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.875rem;
  line-height: 1;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.sim-intro p {
  margin: 0;
  color: var(--muted);
}

.sim-setup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 16px 20px;
  padding: 16px;
}

.sim-team {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.sim-role,
.sim-kicker,
.homers-label,
.sim-tag {
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sim-role {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}

.sim-field {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.sim-field select {
  width: 100%;
  min-width: 0;
  padding: 9px 34px 9px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  appearance: none;
  background-color: var(--surface);
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  color: var(--ink);
  font: 500 0.9375rem var(--font-body);
  text-overflow: ellipsis;
  cursor: pointer;
}

.sim-field select:disabled {
  opacity: 0.6;
  cursor: default;
}

.sim-swap {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-top: 22px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
}

.sim-swap:hover,
.sim-button:hover {
  background: var(--row-hover);
}

.sim-field select:focus-visible,
.sim-swap:focus-visible,
.sim-button:focus-visible,
.mc-col:focus-visible,
.sim-method summary:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.sim-output.is-busy {
  opacity: 0.55;
  transition: opacity 0.15s;
}

.sim-summary {
  display: grid;
  gap: 18px;
  padding: 18px 16px;
}

.sim-headline {
  display: grid;
  gap: 6px;
}

.sim-kicker {
  margin: 0;
  color: var(--muted);
}

.sim-headline h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.625rem, 4.5vw, 2.375rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-wrap: balance;
}

.sim-likely {
  margin: 0;
  color: var(--muted);
}

.sim-likely strong {
  color: var(--ink);
}

.winbar {
  display: grid;
  gap: 6px;
}

.winbar-labels {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.875rem;
}

.winbar-labels span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.winbar-labels b {
  font-variant-numeric: tabular-nums;
}

.winbar-track {
  display: flex;
  gap: 2px;
  height: 14px;
}

.winbar-track .seg {
  min-width: 4px;
  border-radius: 4px;
}

.seg.away,
.mc-bar.away {
  background: var(--away);
}

.seg.home,
.mc-bar.home {
  background: var(--home);
}

.sim-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px 16px;
  margin: 0;
  padding-top: 14px;
  border-top: 1px solid var(--rule);
}

.sim-stats div {
  display: grid;
  gap: 2px;
}

.sim-stats dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.sim-stats dd {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.sim-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.sim-card {
  display: flex;
  flex-direction: column;
}

.sim-card-body {
  padding: 0 16px 16px;
}

.block-head h3 .swatch {
  margin-right: 8px;
  vertical-align: 0.05em;
}

.sim-button {
  padding: 6px 14px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: 600 0.8125rem var(--font-body);
  cursor: pointer;
}

/* margin chart */
.chart-host {
  position: relative;
}

.margin-chart {
  display: grid;
  gap: 6px;
}

.mc-plot {
  display: flex;
  gap: 2px;
  height: 168px;
  padding-top: 20px;
  border-bottom: 1px solid var(--rule);
}

.mc-col {
  position: relative;
  flex: 1 1 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-width: 0;
  border-radius: 4px 4px 0 0;
}

.mc-col:hover {
  background: var(--row-hover);
}

.mc-bar {
  width: 100%;
  max-width: 30px;
  height: var(--h);
  border-radius: 4px 4px 0 0;
}

.mc-val {
  position: absolute;
  bottom: calc(var(--h) + 4px);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.mc-split {
  margin-left: 10px;
}

.mc-axis {
  display: flex;
  gap: 2px;
}

.mc-axis span {
  flex: 1 1 0;
  min-width: 0;
  color: var(--muted);
  font-size: 0.75rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.mc-legend {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.mc-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chart-tip {
  position: absolute;
  z-index: 3;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--surface);
  font-size: 0.75rem;
  font-weight: 500;
  white-space: nowrap;
  pointer-events: none;
  transform: translate(-50%, calc(-100% - 8px));
}

/* small tables */
.mini {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.mini th,
.mini td {
  padding: 7px 8px;
  border-top: 1px solid var(--rule);
  text-align: right;
  white-space: nowrap;
}

.mini thead th {
  padding-top: 0;
  border-top: 0;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.mini th[scope="row"],
.mini thead th:first-child,
.mini.lineup thead th:nth-child(2) {
  text-align: left;
}

.mini th[scope="row"] {
  font-weight: 500;
}

.mini th[scope="row"] .swatch {
  margin-right: 8px;
}

.mini.lineup thead th:first-child,
.mini.lineup td:first-child {
  padding-left: 16px;
  color: var(--muted);
  text-align: right;
}

.mini.lineup th:last-child,
.mini.lineup td:last-child {
  padding-right: 16px;
}

/* one simulated game */
.sim-final {
  margin: 0 0 12px;
  font-size: 1.0625rem;
}

.linescore {
  min-width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.linescore th,
.linescore td {
  min-width: 2em;
  padding: 7px 6px;
  border-top: 1px solid var(--rule);
  text-align: center;
}

.linescore thead th {
  border-top: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.linescore th[scope="row"] {
  padding-left: 0;
  text-align: left;
  white-space: nowrap;
  color: var(--accent-text);
  font-family: var(--font-display);
  font-size: 1.0625rem;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.linescore th[scope="row"] .swatch {
  margin-right: 8px;
}

.linescore .tot {
  font-weight: 700;
}

.linescore td.tot:nth-last-child(2),
.linescore th.tot:nth-last-child(2) {
  border-left: 1px solid var(--rule);
}

.linescore tr:not(.won) td.tot:nth-last-child(2) {
  color: var(--muted);
}

.homers {
  display: grid;
  gap: 4px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
  color: var(--muted);
  font-size: 0.875rem;
}

.homers strong {
  margin-right: 6px;
  color: var(--ink);
}

.sim-staff {
  display: grid;
  gap: 6px;
  padding-top: 12px;
}

.sim-staff p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.sim-tag {
  margin-right: 6px;
  color: var(--ink);
}

.sim-note {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
}

.sim-method summary {
  padding: 14px 16px;
  font-weight: 600;
  cursor: pointer;
}

.sim-method-body {
  max-width: 80ch;
  padding: 0 16px 16px;
  color: var(--muted);
}

.sim-method-body p {
  margin: 0 0 10px;
}

.sim-method-body ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 1.1em;
}

.sim-method-body strong {
  color: var(--ink);
}

@media (max-width: 860px) {
  .sim-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .tabs a {
    padding: 7px 10px;
    font-size: 0.8125rem;
  }

  .sim-setup {
    grid-template-columns: minmax(0, 1fr);
  }

  .sim-swap {
    justify-self: center;
    margin-top: 0;
    transform: rotate(90deg);
  }

  .sim-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mc-split {
    margin-left: 6px;
  }

  .linescore {
    width: 100%;
  }

  .linescore th,
  .linescore td {
    min-width: 0;
    padding-inline: 2px;
    font-size: 0.875rem;
  }

  .linescore th[scope="row"] .swatch {
    margin-right: 4px;
  }
}

/* World Baseball Classic -------------------------------------------------- */

.wbc,
.wbc-root,
.wbc-col {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.wbc {
  gap: 20px;
}

.wbc-col {
  align-content: start;
}

.sim-button.primary {
  border-color: transparent;
  background: var(--board);
  color: var(--board-ink);
}

.sim-button.primary:hover {
  background: var(--board);
  filter: brightness(1.15);
}

.sim-button:disabled {
  opacity: 0.5;
  cursor: default;
  filter: none;
}

.wbc-pick {
  display: grid;
  gap: 16px;
  padding: 16px;
}

.wbc-teams {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 8px;
}

.wbc-team {
  display: grid;
  align-content: start;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.wbc-team:hover {
  background: var(--row-hover);
}

.wbc-team[aria-pressed="true"] {
  border-color: var(--accent-text);
  box-shadow: inset 0 0 0 1px var(--accent-text);
  background: var(--row-hover);
}

.wbc-team:focus-visible,
.wbc-play:focus-visible,
.wbc-actions .sim-button:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.wbc-team-abbr,
.wbc-abbr,
.wbc-abbr-sm,
.wbc-opp b {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.03em;
  color: var(--accent-text);
}

.wbc-team-abbr {
  font-size: 1.375rem;
  line-height: 1;
}

.wbc-team-name {
  font-size: 0.875rem;
  font-weight: 600;
}

.wbc-team-odds {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.wbc-start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
}

.wbc-start .sim-button,
.wbc-play {
  padding: 10px 22px;
  font-size: 0.9375rem;
}

.wbc-start p,
.wbc-sub,
.wbc-note,
.wbc-muted,
.wbc-actions span {
  margin: 0;
  color: var(--muted);
}

.wbc-start p,
.wbc-note,
.wbc-actions span {
  font-size: 0.875rem;
}

.wbc-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 16px;
}

.wbc-head h2 {
  margin: 4px 0 2px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 6vw, 2.75rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.wbc-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.wbc-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.wbc-next,
.wbc-result,
.wbc-banner {
  display: grid;
  gap: 12px;
  padding: 16px;
}

.wbc-next p,
.wbc-result p,
.wbc-banner p {
  margin: 0;
}

.wbc-matchup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.wbc-side {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.wbc-side:last-child {
  justify-items: end;
  text-align: right;
}

.wbc-abbr {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 2.25rem;
  line-height: 1;
}

.wbc-starter {
  color: var(--muted);
  font-size: 0.8125rem;
}

.wbc-vs {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wbc-play {
  justify-self: start;
}

.wbc-result h3,
.wbc-banner h3 {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.75rem;
  line-height: 1;
  text-transform: uppercase;
  text-wrap: balance;
}

.wbc-result:focus {
  outline: none;
}

.wbc-result.is-win,
.wbc-banner.is-win {
  border-color: var(--bulb);
  box-shadow: inset 0 0 0 1px var(--bulb);
}

.wbc-pill {
  display: inline-grid;
  place-items: center;
  min-width: 1.5rem;
  height: 1.375rem;
  padding: 0 5px;
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
}

.wbc-pill.win {
  color: var(--pos);
  background: color-mix(in srgb, var(--pos) 15%, transparent);
}

.wbc-pill.loss {
  color: var(--neg);
  background: color-mix(in srgb, var(--neg) 15%, transparent);
}

.wbc-pill.q {
  min-width: 1.25rem;
  height: 1.125rem;
  background: var(--bulb);
  color: var(--bulb-ink);
  font-size: 0.6875rem;
}

.wbc-result h3 .wbc-pill {
  height: 1.75rem;
  min-width: 1.75rem;
  font-size: 0.9375rem;
}

.linescore tr.you th[scope="row"] {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
}

.wbc-elsewhere ul {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 16px;
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.wbc-elsewhere li span {
  color: var(--muted);
  font-size: 0.75rem;
}

.mini.wbc-games th,
.mini.wbc-games td {
  text-align: left;
}

.mini.wbc-games td:last-child {
  padding-right: 16px;
  text-align: right;
}

.mini.wbc-games th[scope="row"] {
  padding-left: 16px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.mini.wbc-games tr:first-child > * {
  border-top: 0;
}

.mini.wbc-games tr.is-next > * {
  background: var(--row-hover);
}

.mini.wbc-games tr.off td {
  color: var(--muted);
}

.wbc-opp {
  white-space: nowrap;
}

.mini.wbc-standings th[scope="row"] {
  padding-left: 16px;
}

.mini.wbc-standings thead th:first-child {
  padding-left: 16px;
}

.mini.wbc-standings th:last-child,
.mini.wbc-standings td:last-child {
  padding-right: 16px;
}

.mini.wbc-standings tr.you > * {
  background: var(--row-hover);
  font-weight: 600;
}

.wbc-others {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 16px;
  padding-bottom: 12px;
}

.wbc-others .sim-kicker {
  padding: 0 16px 6px;
}

.wbc-bracket {
  display: grid;
  grid-template-columns: repeat(3, minmax(118px, 1fr));
  gap: 14px;
  min-width: 400px;
  padding: 0 16px 16px;
}

.wbc-round {
  display: grid;
  gap: 8px;
  align-content: space-around;
}

.wbc-round .sim-kicker {
  align-self: start;
}

.wbc-slot {
  border: 1px solid var(--rule);
  border-radius: 6px;
  overflow: hidden;
  font-size: 0.875rem;
  font-variant-numeric: tabular-nums;
}

.wbc-slot-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 5px 8px;
}

.wbc-slot-line + .wbc-slot-line {
  border-top: 1px solid var(--rule);
}

.wbc-slot-line.won {
  font-weight: 700;
}

.wbc-slot-line.you {
  background: var(--row-hover);
  color: var(--accent-text);
}

.wbc-slot.is-empty {
  display: grid;
  gap: 2px;
  padding: 6px 8px;
  border-style: dashed;
  color: var(--muted);
  font-size: 0.75rem;
}

.wbc-champ {
  margin: 4px 0 0;
  font-size: 0.875rem;
}

@media (max-width: 860px) {
  .wbc-layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .controls {
    min-width: 0;
  }

  .tabs {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  .wbc-teams {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .wbc-abbr {
    font-size: 1.75rem;
  }

  .wbc-oppname {
    display: none;
  }

  .mini.wbc-games th[scope="row"] {
    white-space: normal;
  }
}

/* Team panel tabs and players ------------------------------------------------ */

.seg {
  display: inline-flex;
  gap: 2px;
  margin-bottom: 14px;
  padding: 3px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--surface);
}

.seg-btn {
  padding: 6px 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: 600 0.8125rem var(--font-body);
  cursor: pointer;
}

.seg-btn:hover {
  color: var(--ink);
}

.seg-btn[aria-selected="true"] {
  background: var(--board);
  color: var(--board-ink);
}

.seg-btn:focus-visible,
.player-link:focus-visible,
.back-link:focus-visible {
  outline: 2px solid var(--accent-text);
  outline-offset: 2px;
}

.roster-grid {
  display: grid;
  gap: 18px;
}

.mini.roster th,
.mini.roster td {
  padding-block: 6px;
}

.mini.roster .roster-name {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 11rem;
  padding-left: 0;
  background: var(--panel);
  text-align: left;
}

.player-link {
  color: inherit;
  font-weight: 500;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, currentColor 30%, transparent);
  text-underline-offset: 3px;
}

.player-link:hover {
  color: var(--accent-text);
  text-decoration-color: currentColor;
}

/* Player page ---------------------------------------------------------------- */

.player {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.back-link {
  justify-self: start;
  color: var(--accent-text);
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
}

.player-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
}

.player-id {
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 0;
}

.player-number {
  display: grid;
  place-items: center;
  flex: none;
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: var(--board);
  color: var(--board-ink);
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
}

.player-head h2 {
  margin: 4px 0 0;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 6vw, 3rem);
  line-height: 0.95;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  text-wrap: balance;
}

.player-nick {
  margin: 4px 0 0;
  color: var(--muted);
}

.player-season {
  min-width: 8rem;
}

.player-bio {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  margin: 0;
  padding: 14px 16px;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--surface);
}

.player-bio div {
  display: grid;
  gap: 2px;
}

.player-bio dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.player-bio dd {
  margin: 0;
  font-weight: 500;
}

.player-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.player-card {
  min-width: 0;
}

.player-card-body {
  padding: 0 16px 16px;
}

.player-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 14px 16px;
  margin: 0;
}

.player-tiles div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.player-tiles .wide {
  grid-column: span 2;
}

.player-tiles .wide dd {
  white-space: nowrap;
}

.player-tiles dt {
  color: var(--muted);
  font-size: 0.75rem;
}

.player-tiles dd {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.player-tiles div:has(dt[title]),
.player-tiles div[title] {
  cursor: help;
}

.mini.player-table th[scope="row"] {
  padding-left: 16px;
  white-space: nowrap;
}

.mini.player-table thead th:first-child {
  padding-left: 16px;
}

.mini.player-table th:last-child,
.mini.player-table td:last-child {
  padding-right: 16px;
}

.player-team {
  margin-left: 6px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.mini.player-table tr.is-current > * {
  background: var(--row-hover);
}

.mini.player-table tr.is-total > * {
  font-weight: 700;
  border-top: 2px solid var(--rule);
}

.player-awards {
  display: grid;
  margin: 0;
  padding: 0 16px 12px;
  list-style: none;
}

.player-awards li {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 2px 16px;
  padding-block: 7px;
  border-top: 1px solid var(--rule);
  font-size: 0.875rem;
}

.player-awards li:first-child {
  border-top: 0;
}

.player-award-count {
  color: var(--muted);
  font-size: 0.8125rem;
}

.player-award-years {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 860px) {
  .player-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .mini.roster .roster-name {
    min-width: 8.5rem;
  }

  .player-number {
    width: 52px;
    height: 52px;
    font-size: 1.625rem;
  }
}

/* Same column grid in every table, so divisions line up as you scroll. */
@media (min-width: 900px) {
  .standings {
    table-layout: fixed;
  }

  .standings thead th {
    width: 3.75rem;
  }

  .standings thead th.narrow {
    width: 3rem;
  }

  .standings thead th.wide {
    width: 4.5rem;
  }

  .standings thead th.col-l10 {
    width: 4.75rem;
  }

  .standings thead th:last-child {
    width: 4.25rem;
  }

  .standings thead th.team {
    width: auto;
  }
}

/* Footer ------------------------------------------------------------------ */

.site-footer {
  display: grid;
  gap: 12px;
  padding-block: 8px 40px;
  color: var(--muted);
  font-size: 0.8125rem;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin: 0;
}

.legend div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.legend dt,
.legend dd {
  margin: 0;
}

.credit {
  margin: 0;
}

/* Narrow screens ---------------------------------------------------------- */

@media (max-width: 640px) {
  .masthead-inner {
    padding-block: 22px 18px;
  }

  .controls {
    width: 100%;
    justify-content: space-between;
  }

  main {
    gap: 32px;
    padding-block: 24px 16px;
  }

  .standings th.team {
    min-width: 0;
    padding-left: 12px;
    box-shadow: 1px 0 0 var(--rule);
  }

  .standings th,
  .standings td {
    padding-inline: 8px;
  }

  /* phones show the abbreviation; the full name stays available to screen readers */
  .name {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }

  .team-cell {
    gap: 8px;
  }
}

@media (max-width: 380px) {
  .tabs a {
    padding-inline: 11px;
  }

  .season > span {
    display: none;
  }
}
