:root {
  color-scheme: dark;
  --bg: #09251d;
  --panel: #12382b;
  --panel-strong: #19513d;
  --panel-soft: rgba(255, 255, 255, 0.075);
  --line: rgba(255, 255, 255, 0.18);
  --text: #f7fff9;
  --muted: #b8d2c5;
  --accent: #f5c45f;
  --accent-strong: #ffdc7b;
  --clay: #d8a25f;
  --base: #fff5d6;
  --base-text: #173528;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, rgba(18, 72, 52, 0.96), rgba(7, 27, 21, 1) 38rem),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

.live-board {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 24px;
  display: grid;
  gap: 18px;
  align-content: start;
}

.live-header,
.replay-controls,
.score-strip,
.live-grid,
.line-score-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(8, 35, 27, 0.9);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
}

.live-header {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px 24px;
  border-top: 4px solid var(--accent);
}

.live-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.live-header-actions > button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.live-header-actions > button:hover {
  background: rgba(255, 255, 255, 0.16);
}

.transcript-dialog {
  width: min(760px, calc(100vw - 28px));
  max-width: 760px;
  max-height: min(82dvh, 760px);
  padding: 0;
  border: 2px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  background: #102f24;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.transcript-dialog::backdrop {
  background: rgba(0, 0, 0, 0.7);
}

.transcript-dialog-content {
  display: flex;
  max-height: min(82dvh, 760px);
  flex-direction: column;
  gap: 14px;
  padding: 20px;
}

.transcript-dialog-content h2 {
  color: var(--accent-strong);
}

.transcript-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0 6px 0 28px;
  overflow: auto;
  color: var(--text);
  line-height: 1.4;
  scrollbar-color: var(--muted) var(--panel);
  scrollbar-width: thin;
}

.transcript-dialog-content > button {
  min-height: 42px;
  align-self: flex-end;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: var(--base-text);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.eyebrow,
.label {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 1;
}

.status-pill {
  min-width: 156px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  text-align: center;
}

.status-pill.live {
  border-color: rgba(126, 232, 163, 0.5);
  background: #154b38;
  color: var(--text);
}

.status-pill.final {
  border-color: rgba(245, 196, 95, 0.65);
  background: #5c3117;
  color: #fff2df;
}

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

.replay-controls[hidden] {
  display: none;
}

.replay-controls button,
.replay-controls select {
  min-height: 40px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  padding: 0 12px;
  font: inherit;
  font-weight: 800;
}

.replay-controls button.primary {
  background: var(--accent);
  color: var(--base-text);
}

.replay-controls button:disabled {
  opacity: 0.45;
}

.replay-controls label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.replay-controls span {
  margin-left: auto;
  color: var(--muted);
  font-weight: 800;
}

.score-strip {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px minmax(0, 1fr);
  align-items: stretch;
  overflow: hidden;
}

.team-score,
.game-state {
  min-height: 160px;
  display: grid;
  place-items: center;
  padding: 18px;
  text-align: center;
}

.team-score {
  gap: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0));
}

.team-score span {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: #d8eee4;
  font-size: clamp(1.2rem, 3vw, 2.1rem);
  font-weight: 800;
}

.team-score strong {
  font-size: clamp(5.5rem, 16vw, 11rem);
  line-height: 0.85;
}

.game-state {
  border-left: 1px solid var(--line);
  border-right: 1px solid var(--line);
  background: rgba(245, 196, 95, 0.09);
  justify-items: center;
  text-align: center;
}

.game-state strong {
  width: 100%;
  font-size: clamp(1.7rem, 4vw, 3.5rem);
  line-height: 1;
  text-align: center;
}

.game-state span {
  width: 100%;
  color: var(--accent);
  font-size: clamp(1.1rem, 2.4vw, 1.8rem);
  font-weight: 800;
  text-align: center;
}

body.final-game .game-state strong {
  color: var(--accent-strong);
}

.live-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) minmax(300px, 420px);
  align-items: stretch;
  height: 560px;
  overflow: hidden;
}

.field-panel {
  min-height: 560px;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(38, 120, 62, 0.18), rgba(9, 43, 31, 0.92)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 0 12.5%, transparent 12.5% 25%, rgba(255, 255, 255, 0.035) 25% 37.5%, transparent 37.5% 50%, rgba(255, 255, 255, 0.035) 50% 62.5%, transparent 62.5% 75%, rgba(255, 255, 255, 0.035) 75% 87.5%, transparent 87.5%),
    #15583d;
}

.diamond-score-strip {
  width: min(100%, 520px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(5, 28, 21, 0.64);
  overflow: hidden;
}

.diamond-score-strip div {
  min-width: 0;
  display: grid;
  gap: 4px;
  place-items: center;
  padding: 8px 10px;
  text-align: center;
}

.diamond-score-strip div + div {
  border-left: 1px solid var(--line);
}

.diamond-score-strip span {
  max-width: 100%;
  overflow-wrap: anywhere;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
}

.diamond-score-strip strong {
  color: var(--text);
  font-size: 1.45rem;
  line-height: 1;
}

.diamond-score-strip div:nth-child(2) strong {
  color: var(--accent);
  font-size: 1rem;
}

.live-matchup-panel {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(250px, 0.95fr);
  gap: 18px;
  align-items: stretch;
}

.live-batter-group,
.live-runners-group {
  min-width: 0;
  display: grid;
  gap: 12px;
  align-content: start;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 28, 21, 0.58);
}

.live-player-tile {
  min-width: 0;
  display: grid;
  gap: 5px;
  align-content: center;
  min-height: 82px;
  padding: 12px;
  border-radius: 7px;
  background: rgba(255, 245, 214, 0.97);
  color: var(--base-text);
  font-weight: 900;
  line-height: 1.15;
  overflow-wrap: anywhere;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.live-player-tile-primary {
  min-height: 152px;
  border: 3px solid var(--accent);
  font-size: clamp(1.9rem, 4.6vw, 3.4rem);
}

.live-player-tile-small {
  min-height: 92px;
  font-size: 1.05rem;
}

.live-player-tile-small span {
  color: #4c6659;
  font-size: 0.72rem;
  text-transform: uppercase;
}

.live-player-tile-small strong {
  font-size: 1.18rem;
}

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

body.final-game .live-matchup-panel {
  opacity: 0.72;
}

.details-panel {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 12px;
  align-content: stretch;
  padding: 24px;
  border-left: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.16);
  min-height: 0;
  overflow: hidden;
}

.details-card {
  min-height: 0;
  overflow: hidden;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  background: var(--panel-soft);
}

.at-bat-card {
  border-color: rgba(245, 196, 95, 0.38);
}

.details-panel h2 {
  margin-bottom: 5px;
  font-size: clamp(1.65rem, 3.5vw, 2.7rem);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.details-panel p:not(.label) {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.35;
}

.batter-summary {
  margin-top: 10px;
  color: #e7f6ee !important;
  font-weight: 700;
}

.on-base-panel {
  width: min(100%, 520px);
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(5, 28, 21, 0.7);
}

.on-base-panel .label {
  margin-bottom: 8px;
}

.on-base-list {
  display: grid;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
}

.on-base-list span {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 10px;
  align-items: center;
  min-height: 74px;
  padding: 11px 12px;
  border-radius: 7px;
  background: rgba(255, 245, 214, 0.97);
  color: var(--base-text);
  overflow-wrap: anywhere;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.on-base-list strong {
  grid-column: 1 / -1;
  color: var(--accent);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.on-base-list em {
  grid-row: 2;
  grid-column: 2;
  min-width: 42px;
  padding: 5px 7px;
  border-radius: 4px;
  background: #174a38;
  color: var(--text);
  font-style: normal;
  font-size: 0.78rem;
  text-align: center;
}

.on-base-list .lead-runner {
  border: 2px solid var(--accent);
}

.recent-plays {
  display: grid;
  gap: 8px;
  max-height: 9.4rem;
  overflow: hidden;
  margin: 0;
  padding-left: 1.15rem;
  color: var(--muted);
}

.recent-plays li {
  line-height: 1.28;
}

.line-score-panel {
  overflow-x: auto;
  border-bottom: 4px solid rgba(245, 196, 95, 0.35);
}

.line-score-panel table {
  width: 100%;
  border-collapse: collapse;
  min-width: 640px;
}

.line-score-panel th,
.line-score-panel td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-size: 1.1rem;
}

.line-score-panel th:first-child,
.line-score-panel td:first-child {
  text-align: left;
}

.line-score-panel thead th {
  color: var(--accent);
  font-size: 0.8rem;
  text-transform: uppercase;
}

.line-score-panel tbody th {
  max-width: 320px;
  overflow-wrap: anywhere;
}

@media (min-width: 1000px) {
  .live-board {
    width: min(1040px, 100%);
    padding: 14px;
    gap: 12px;
  }

  .live-header {
    min-height: 76px;
    padding: 14px 18px;
  }

  h1 {
    font-size: 2.75rem;
  }

  .score-strip {
    grid-template-columns: minmax(0, 1fr) 200px minmax(0, 1fr);
  }

  .team-score,
  .game-state {
    min-height: 126px;
    padding: 12px;
  }

  .team-score strong {
    font-size: 6.25rem;
  }

  .team-score span {
    font-size: 1.45rem;
  }

  .game-state strong {
    font-size: 2.4rem;
  }

  .game-state span {
    font-size: 1.25rem;
  }

  .live-grid {
    grid-template-columns: minmax(310px, 1fr) minmax(270px, 350px);
    height: 520px;
    min-height: 520px;
  }

  .field-panel {
    min-height: 520px;
    padding: 16px;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .details-panel {
    gap: 12px;
    padding: 16px;
  }

  .details-card {
    padding: 12px;
  }

  .details-panel h2 {
    font-size: 2.2rem;
  }

  .details-panel p:not(.label) {
    font-size: 0.95rem;
  }

  .recent-plays {
    gap: 6px;
    max-height: 8.1rem;
  }

  .line-score-panel th,
  .line-score-panel td {
    padding: 8px 10px;
    font-size: 0.95rem;
  }
}

@media (max-width: 760px) {
  .live-board {
    padding: 12px;
  }

  .live-header,
  .replay-controls,
  .score-strip,
  .live-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .live-grid {
    height: auto;
    min-height: 0;
  }

  .live-header {
    min-height: 76px;
    padding: 14px 16px;
  }

  h1 {
    font-size: 2.2rem;
  }

  .replay-controls span {
    margin-left: 0;
  }

  .score-strip {
    grid-template-columns: 1fr;
  }

  .game-state,
  .details-panel {
    border-left: 0;
    border-right: 0;
  }

  .team-score,
  .game-state {
    min-height: 118px;
  }

  .field-panel {
    min-height: 430px;
    gap: 12px;
    padding: 14px;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .diamond-score-strip {
    width: 100%;
  }

  .diamond-score-strip div {
    padding: 7px 6px;
  }

  .diamond-score-strip span {
    font-size: 0.72rem;
  }

  .diamond-score-strip strong {
    font-size: 1.25rem;
  }

  .live-matchup-panel {
    grid-template-columns: 1fr;
  }

  .live-player-tile-primary {
    min-height: 118px;
    font-size: 1.9rem;
  }

  .up-next-grid {
    grid-template-columns: 1fr;
  }

  .on-base-list {
    grid-template-columns: 1fr;
  }

  .details-panel {
    grid-template-rows: none;
  }

  .line-score-panel table {
    min-width: 0;
  }

  .line-score-panel th,
  .line-score-panel td {
    padding: 8px 5px;
    font-size: 0.82rem;
  }

  .line-score-panel thead th {
    font-size: 0.68rem;
  }

  .line-score-panel tbody th {
    max-width: 92px;
  }
}

@keyframes runner-arrive {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
