:root {
  color-scheme: light;
  --ink: #17211c;
  --muted: #68736d;
  --paper: #f6f2e8;
  --panel: rgba(255, 253, 247, 0.94);
  --line: rgba(23, 33, 28, 0.14);
  --green: #0e6448;
  --green-dark: #093f31;
  --green-soft: #e7f1e9;
  --red: #a72f40;
  --gold: #c28c27;
  --blue: #275f7e;
  --shadow: 0 24px 70px rgba(23, 33, 28, 0.1);
  --radius: 18px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 1rem;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--ink);
  background:
    linear-gradient(115deg, rgba(14, 100, 72, 0.11), transparent 28rem),
    linear-gradient(180deg, #eee8da 0, var(--paper) 25rem, #eef3ed 100%);
  font-family: "Avenir Next", "Trebuchet MS", Verdana, sans-serif;
  line-height: 1.45;
}

button,
a {
  font: inherit;
}

a {
  color: var(--green);
  font-weight: 750;
}

button {
  border: 0;
  cursor: pointer;
}

.page-glow {
  position: fixed;
  z-index: -1;
  top: -18rem;
  right: -14rem;
  width: 42rem;
  height: 42rem;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(194, 140, 39, 0.2), transparent 67%);
  pointer-events: none;
}

.site-header {
  display: flex;
  width: min(1240px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.1rem 0;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 3.2rem;
  height: 3.2rem;
  place-items: center;
  border-radius: 50%;
  color: #fffaf0;
  background: var(--green);
  box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.16);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.78rem;
  letter-spacing: 0.05em;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.18rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.72rem;
}

.site-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.site-header nav a,
.section-nav a {
  padding: 0.5rem 0.72rem;
  border-radius: 999px;
  color: var(--ink);
  text-decoration: none;
  font-size: 0.82rem;
}

.site-header nav a:hover,
.section-nav a:hover {
  color: #fff;
  background: var(--green);
}

.game-page {
  width: min(1240px, calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.2rem 0 3rem;
}

.utility-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.back-link {
  color: var(--ink);
  text-decoration: none;
}

.connection {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
}

.connection-dot {
  width: 0.58rem;
  height: 0.58rem;
  border-radius: 50%;
  background: #9a9f9b;
}

.connection[data-kind="live"] .connection-dot {
  background: #43a568;
  box-shadow: 0 0 0 5px rgba(67, 165, 104, 0.14);
}

.connection[data-kind="error"] .connection-dot {
  background: var(--red);
}

.state-card {
  display: flex;
  min-height: 20rem;
  padding: 2rem;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: left;
}

.state-card[hidden] {
  display: none;
}

.state-card h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
}

.state-card p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.state-card--error {
  border-color: rgba(167, 47, 64, 0.3);
}

.state-icon,
.loader {
  display: grid;
  flex: 0 0 auto;
  width: 3.4rem;
  height: 3.4rem;
  place-items: center;
  border-radius: 50%;
  background: var(--green-soft);
  color: var(--green);
  font-size: 1.4rem;
  font-weight: 900;
}

.loader {
  border: 4px solid var(--green-soft);
  border-top-color: var(--green);
  background: transparent;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.state-actions {
  display: flex;
  margin-top: 1rem;
  align-items: center;
  gap: 0.8rem;
}

.state-actions button,
.button-link {
  display: inline-flex;
  padding: 0.68rem 1rem;
  border-radius: 999px;
  color: #fff;
  background: var(--green);
  text-decoration: none;
  font-weight: 800;
}

.scoreboard {
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 26px;
  color: #fffaf0;
  background:
    radial-gradient(circle at 12% 0, rgba(194, 140, 39, 0.26), transparent 26rem),
    linear-gradient(125deg, #114f3d, #0b2922 67%, #162b24);
  box-shadow: 0 28px 76px rgba(9, 63, 49, 0.24);
}

.scoreboard-topline {
  display: flex;
  padding: 1rem 1.25rem;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.11);
}

.status-badge,
.game-start {
  display: inline-flex;
  align-items: center;
}

.status-badge {
  padding: 0.36rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-badge[data-kind="live"] {
  background: var(--red);
}

.status-badge[data-kind="final"] {
  background: rgba(255, 255, 255, 0.2);
}

.game-start,
.feed-delay {
  margin-left: 0.65rem;
  color: rgba(255, 250, 240, 0.68);
  font-size: 0.78rem;
}

.matchup {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 11rem minmax(0, 1fr);
  align-items: center;
  gap: 1.4rem;
  padding: 2rem 1.8rem;
}

.team {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.team--home {
  text-align: right;
}

.team-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 0.85rem;
}

.team-identity--home {
  justify-content: flex-end;
}

.team-logo,
.team-fallback {
  width: 4rem;
  height: 4rem;
  flex: 0 0 auto;
  object-fit: contain;
}

.team-logo {
  padding: 0.25rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.94);
}

.team-fallback {
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.4rem;
}

.team h1 {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 3vw, 2.4rem);
  line-height: 1;
}

.team p {
  margin: 0.35rem 0 0;
  color: rgba(255, 250, 240, 0.6);
  font-size: 0.78rem;
}

.side-label {
  display: block;
  margin-bottom: 0.3rem;
  color: rgba(255, 250, 240, 0.5);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.team-score {
  font-size: clamp(3rem, 7vw, 6rem);
  font-variant-numeric: tabular-nums;
  line-height: 0.9;
}

.game-state {
  text-align: center;
}

.inning-state {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 700;
}

.outs {
  display: flex;
  margin: 0.65rem 0 0.45rem;
  justify-content: center;
  gap: 0.38rem;
}

.outs span {
  width: 0.62rem;
  height: 0.62rem;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 50%;
}

.outs span.is-on {
  border-color: var(--gold);
  background: var(--gold);
}

.game-state-detail {
  color: rgba(255, 250, 240, 0.58);
  font-size: 0.76rem;
}

.game-meta {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-top: 1px solid rgba(255, 255, 255, 0.11);
}

.game-meta div {
  padding: 0.9rem 1.1rem;
  border-right: 1px solid rgba(255, 255, 255, 0.11);
}

.game-meta div:last-child {
  border-right: 0;
}

.game-meta span,
.game-meta strong {
  display: block;
}

.game-meta span {
  color: rgba(255, 250, 240, 0.5);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

.game-meta strong {
  margin-top: 0.18rem;
  overflow-wrap: anywhere;
  font-size: 0.82rem;
}

.section-nav {
  display: flex;
  margin: 1rem 0;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.section-nav a {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.panel {
  margin-top: 1rem;
  padding: 1.15rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-heading {
  display: flex;
  margin-bottom: 0.95rem;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.panel-heading h2,
.panel-heading p {
  margin: 0;
}

.panel-heading h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1;
}

.eyebrow {
  margin-bottom: 0.25rem !important;
  color: var(--green);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.source-time {
  color: var(--muted);
  font-size: 0.75rem;
}

.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.data-table {
  width: 100%;
  min-width: 700px;
  border-collapse: collapse;
  font-size: 0.82rem;
}

.data-table th,
.data-table td {
  padding: 0.66rem 0.7rem;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.data-table th {
  color: var(--muted);
  background: rgba(14, 100, 72, 0.06);
  font-size: 0.65rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
}

.data-table th:first-child,
.data-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 10rem;
  text-align: left;
  background: #fffdf8;
}

.data-table thead th:first-child {
  z-index: 2;
  background: #edf3ec;
}

.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tbody tr:hover td {
  background-color: #f5f8f3;
}

.data-table .total-cell {
  color: var(--green-dark);
  background: rgba(194, 140, 39, 0.11);
  font-weight: 900;
}

.data-table .player-cell {
  white-space: normal;
}

.data-table td.empty-table-cell {
  position: static;
  min-width: 0;
  padding: 1.4rem;
  color: var(--muted);
  background: #fffdf8;
  text-align: center;
  white-space: normal;
}

.player-cell strong,
.player-cell span {
  display: block;
}

.player-cell span {
  color: var(--muted);
  font-size: 0.7rem;
}

.empty-copy {
  padding: 1.2rem;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}

.situation-grid,
.feed-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.situation-content {
  display: grid;
  grid-template-columns: 11rem minmax(0, 1fr);
  gap: 1.2rem;
  align-items: center;
}

.diamond-wrap {
  text-align: center;
}

.diamond {
  position: relative;
  width: 7rem;
  height: 6.7rem;
  margin: 0 auto;
}

.base {
  position: absolute;
  width: 1.45rem;
  height: 1.45rem;
  border: 2px solid var(--gold);
  background: transparent;
  transform: rotate(45deg);
}

.base.is-occupied {
  background: var(--gold);
  box-shadow: 0 0 0 5px rgba(194, 140, 39, 0.12);
}

.base--second {
  top: 0.5rem;
  left: 2.8rem;
}

.base--third {
  top: 2.8rem;
  left: 0.55rem;
}

.base--first {
  top: 2.8rem;
  right: 0.55rem;
}

.home-plate {
  position: absolute;
  bottom: 0.25rem;
  left: 2.95rem;
  width: 1.2rem;
  height: 1rem;
  background: var(--ink);
  clip-path: polygon(0 0, 100% 0, 88% 68%, 50% 100%, 12% 68%);
}

.diamond-wrap p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.72rem;
}

.situation-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
  margin: 0;
}

.situation-list div {
  padding: 0.68rem;
  border-radius: 10px;
  background: var(--green-soft);
}

.situation-list dt {
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.situation-list dd {
  margin: 0.14rem 0 0;
  overflow-wrap: anywhere;
  font-size: 0.86rem;
  font-weight: 800;
}

.latest-play {
  min-height: 9rem;
}

.latest-play:not(.empty-copy) {
  padding: 0.2rem;
}

.latest-play .play-inning {
  color: var(--red);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.latest-play p {
  margin: 0.35rem 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.18rem;
}

.stat-controls {
  display: grid;
  justify-items: end;
  gap: 0.45rem;
}

.segmented {
  display: inline-flex;
  padding: 0.2rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #eeeae0;
}

.segmented button {
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 0.72rem;
  font-weight: 800;
}

.segmented button[aria-selected="true"] {
  color: #fff;
  background: var(--green);
}

.count-pill {
  padding: 0.32rem 0.58rem;
  border-radius: 999px;
  color: var(--green);
  background: var(--green-soft);
  font-size: 0.68rem;
  font-weight: 900;
}

.timeline {
  display: grid;
  gap: 0.7rem;
  max-height: 42rem;
  overflow-y: auto;
}

.timeline-item {
  position: relative;
  padding: 0.8rem 0.8rem 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.52);
}

.timeline-item::before {
  position: absolute;
  top: 0.8rem;
  bottom: 0.8rem;
  left: 0;
  width: 3px;
  border-radius: 3px;
  background: var(--green);
  content: "";
}

.timeline-item.is-impact::before {
  background: var(--red);
}

.timeline-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  color: var(--muted);
  font-size: 0.65rem;
  font-weight: 850;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.timeline-item p {
  margin: 0.35rem 0 0;
  font-size: 0.86rem;
}

.chips {
  display: flex;
  margin-top: 0.55rem;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.chip {
  padding: 0.22rem 0.46rem;
  border-radius: 999px;
  color: var(--green-dark);
  background: var(--green-soft);
  font-size: 0.64rem;
  font-weight: 800;
}

.chip.is-impact {
  color: var(--red);
  background: rgba(167, 47, 64, 0.1);
}

.game-footer {
  display: flex;
  margin-top: 1rem;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.7rem 1rem;
  color: var(--muted);
  font-size: 0.72rem;
}

@media (max-width: 900px) {
  .matchup {
    grid-template-columns: minmax(0, 1fr) 7rem minmax(0, 1fr);
    padding: 1.5rem 1rem;
  }

  .team-identity {
    display: grid;
  }

  .team-identity--home {
    justify-items: end;
  }

  .team-logo,
  .team-fallback {
    width: 3.2rem;
    height: 3.2rem;
  }

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

  .game-meta div:nth-child(2) {
    border-right: 0;
  }

  .game-meta div:nth-child(-n+2) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.11);
  }

  .panel-heading--stats {
    display: grid;
  }

  .stat-controls {
    justify-items: start;
  }
}

@media (max-width: 700px) {
  .site-header {
    align-items: flex-start;
  }

  .brand small {
    display: none;
  }

  .site-header nav {
    justify-content: flex-end;
  }

  .site-header nav a {
    padding: 0.38rem 0.45rem;
    font-size: 0.72rem;
  }

  .utility-row,
  .scoreboard-topline {
    align-items: flex-start;
  }

  .scoreboard-topline {
    display: grid;
  }

  .feed-delay {
    margin-left: 0;
  }

  .matchup {
    grid-template-columns: 1fr 4rem 1fr;
    gap: 0.55rem;
  }

  .team {
    display: grid;
  }

  .team--home {
    justify-items: end;
  }

  .team--away .team-score {
    grid-row: 2;
  }

  .team--home .team-score {
    grid-row: 2;
  }

  .team-score {
    font-size: 3.2rem;
  }

  .team-logo,
  .team-fallback {
    display: none !important;
  }

  .team h1 {
    font-size: 1.1rem;
  }

  .game-state-detail {
    display: none;
  }

  .inning-state {
    font-size: 0.95rem;
  }

  .game-meta,
  .situation-grid,
  .feed-grid,
  .situation-content {
    grid-template-columns: 1fr;
  }

  .game-meta div {
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.11);
  }

  .game-meta div:last-child {
    border-bottom: 0;
  }

  .section-nav {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 0.3rem;
  }

  .section-nav a {
    flex: 0 0 auto;
  }

  .panel {
    padding: 0.9rem;
  }

  .panel-heading {
    display: grid;
  }

  .stat-controls {
    width: 100%;
    justify-items: stretch;
  }

  .segmented {
    width: 100%;
  }

  .segmented button {
    flex: 1;
  }

  .game-footer {
    display: grid;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .loader {
    animation: none;
  }
}
