:root {
  --color-home: #f2545b;
  --color-away: #2b6cb0;
  --color-bg: #0f172a;
  --color-surface: #1e293b;
  --color-text: #f1f5f9;
}

* { box-sizing: border-box; }

.connection-lost-banner {
  display: none;
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.6rem 1rem;
  text-align: center;
  font-weight: 600;
  background: var(--color-home);
  color: white;
}

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
}

.topbar {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 1rem 1.5rem;
  background: var(--color-surface);
}

.topbar h1 { margin: 0; font-size: 1.25rem; }

.tabs { display: flex; flex-wrap: wrap; gap: 1rem; }
.tabs a {
  color: var(--color-text);
  text-decoration: none;
  padding: 0.4rem 0.8rem;
  border-radius: 0.4rem;
}
.tabs a.active { background: #334155; font-weight: 600; }
.tabs a.logout { margin-left: auto; opacity: 0.7; }

.period-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0.8rem;
  background: #0f172a;
  border-radius: 0.4rem;
}
.period-buttons { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.period-btn {
  padding: 0.3rem 0.7rem;
  border: 1px solid #334155;
  border-radius: 0.3rem;
  background: transparent;
  color: var(--color-text);
  font-weight: 600;
  cursor: pointer;
}
.period-btn:hover { background: #1e293b; }
.period-btn.active { background: var(--color-away); border-color: var(--color-away); }
.period-totals { display: flex; flex-wrap: wrap; align-items: center; gap: 0.9rem; font-size: 0.85rem; }
.period-score-line { display: flex; flex-direction: column; align-items: center; opacity: 0.85; }
.period-score-label { font-size: 0.7rem; opacity: 0.7; }
.period-score-value { font-weight: 600; }
.period-score-total { font-size: 1.3rem; font-weight: 700; margin-left: 0.5rem; }

main { padding: 1.5rem; }

.overview .score-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  font-size: 3rem;
  font-weight: 700;
  text-align: center;
}
.overview .team.home .score { color: var(--color-home); }
.overview .team.away .score { color: var(--color-away); }
.overview .team-label, .overview .period-label { display: block; font-size: 1rem; font-weight: 400; opacity: 0.7; }
.overview .fouls-row, .overview .last-action-row {
  margin-top: 1.5rem;
  text-align: center;
  font-size: 1.25rem;
}

.chart-container { max-width: 900px; margin: 0 auto; }

.chart-teams { display: flex; justify-content: space-between; gap: 1rem; margin-bottom: 0.75rem; font-size: 1.25rem; font-weight: 700; }
.chart-team.home { color: var(--color-home); }
.chart-team.away { color: var(--color-away); text-align: right; }
.chart-frame { position: relative; height: 420px; }
.biggest-lead-row { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem 2rem; margin-top: 1rem; font-size: 1.05rem; }
.biggest-lead-title { opacity: 0.7; }
.biggest-lead-row .chart-team { font-size: inherit; text-align: left; }

.comparison-rows { display: flex; flex-direction: column; gap: 0.9rem; margin-top: 1.25rem; }
.comparison-label { text-align: center; font-size: 0.9rem; color: #94a3b8; margin-bottom: 0.25rem; }
.comparison-line { display: grid; grid-template-columns: 8.5rem 1fr 1fr 8.5rem; align-items: center; gap: 0.5rem; }
.comparison-value { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.comparison-value.home { text-align: left; color: var(--color-home); }
.comparison-value.away { text-align: right; color: var(--color-away); }
.comparison-half { display: flex; height: 0.9rem; background: rgba(148, 163, 184, 0.12); }
.comparison-half.home { justify-content: flex-end; border-radius: 0.45rem 0 0 0.45rem; }
.comparison-half.away { justify-content: flex-start; border-radius: 0 0.45rem 0.45rem 0; }
.comparison-bar { height: 100%; }
.comparison-bar.home { background: var(--color-home); border-radius: 0.45rem 0 0 0.45rem; }
.comparison-bar.away { background: var(--color-away); border-radius: 0 0.45rem 0.45rem 0; }

@media (max-width: 600px) {
  .comparison-line { grid-template-columns: 5.2rem 1fr 1fr 5.2rem; font-size: 0.72rem; gap: 0.3rem; }
  .chart-frame { height: 320px; }
}

.login-page {
  max-width: 360px;
  margin: 4rem auto;
  padding: 2rem;
  background: var(--color-surface);
  border-radius: 0.5rem;
  text-align: center;
}
.login-page h1 { font-size: 1.1rem; margin-bottom: 1.5rem; }

form label { display: block; margin-bottom: 0.75rem; text-align: left; }
form input { width: 100%; padding: 0.5rem; margin-top: 0.25rem; border-radius: 0.3rem; border: 1px solid #475569; background: #0f172a; color: var(--color-text); }
form button { width: 100%; padding: 0.6rem; margin-top: 0.5rem; border: none; border-radius: 0.3rem; background: var(--color-away); color: white; font-weight: 600; cursor: pointer; }
form .error { color: var(--color-home); }

.boxscore-section h2 { margin: 1.5rem 0 0.5rem; font-size: 1.1rem; opacity: 0.85; }
.table-scroll { overflow-x: auto; }
.boxscore-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; white-space: nowrap; }
.boxscore-table th, .boxscore-table td { padding: 0.4rem 0.6rem; text-align: right; border-bottom: 1px solid #334155; }
.boxscore-table th:nth-child(2), .boxscore-table td:nth-child(2) { text-align: left; }
.boxscore-table th { color: #94a3b8; font-weight: 600; text-align: right; }
.boxscore-table th:nth-child(1), .boxscore-table td:nth-child(1) { text-align: center; }
.boxscore-table tr.totals-row { font-weight: 700; background: #1e293b; }

.archive-table { width: 100%; border-collapse: collapse; }
.archive-table th, .archive-table td { padding: 0.5rem 0.8rem; text-align: left; border-bottom: 1px solid #334155; }
.archive-table th { color: #94a3b8; font-weight: 600; }
.archive-table a { color: var(--color-away); text-decoration: none; font-weight: 600; }
.archive-table a:hover { text-decoration: underline; }
.archive-empty-hint { opacity: 0.7; text-align: center; margin-top: 2rem; }

.top3-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1.5rem; }
.top3-card { background: var(--color-surface); border-radius: 0.5rem; padding: 1rem 1.25rem; }
.top3-card h3 { margin: 0 0 0.75rem; font-size: 1rem; }
.top3-card ol { margin: 0; padding-left: 1.25rem; }
.top3-card li { margin-bottom: 0.3rem; }

.overview .team-code { display: block; font-size: 0.85rem; font-weight: 600; letter-spacing: 0.08em; opacity: 0.55; min-height: 1.1em; }
.overview .team-label { font-size: 1.15rem; font-weight: 700; opacity: 1; }
.overview .team.home .team-label { color: var(--color-home); }
.overview .team.away .team-label { color: var(--color-away); }
.fouls-team.home { color: var(--color-home); }
.fouls-team.away { color: var(--color-away); }

.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 1.25rem; margin-top: 2.5rem; text-align: left; }
.info-grid:empty { display: none; }
.info-card { background: var(--color-surface); border-radius: 0.5rem; padding: 1rem 1.25rem; min-width: 0; }
.info-card-title { margin: 0 0 0.75rem; font-size: 0.85rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: #94a3b8; }
.roster-card.home { border-top: 3px solid var(--color-home); }
.roster-card.away { border-top: 3px solid var(--color-away); }

.info-list { display: grid; grid-template-columns: max-content 1fr; gap: 0.35rem 1rem; margin: 0; font-size: 0.95rem; }
.info-list dt { color: #94a3b8; }
.info-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.info-plain-list { margin: 0; padding: 0; list-style: none; font-size: 0.95rem; }
.info-plain-list li { padding: 0.25rem 0; }
.coach-row { display: grid; grid-template-columns: 1fr; gap: 0.1rem; padding: 0.5rem 0 !important; border-bottom: 1px solid #334155; }
.coach-row:last-child { border-bottom: none; }
.coach-team { font-size: 0.8rem; font-weight: 700; }
.coach-team.home { color: var(--color-home); }
.coach-team.away { color: var(--color-away); }
.coach-name { font-weight: 600; }
.coach-facts { font-size: 0.85rem; color: #94a3b8; }

.roster-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.roster-table th, .roster-table td { padding: 0.3rem 0.4rem; text-align: left; border-bottom: 1px solid #334155; white-space: nowrap; }
.roster-table th { color: #94a3b8; font-weight: 600; }
.roster-table .roster-nr { text-align: right; width: 2.5rem; font-variant-numeric: tabular-nums; }
.roster-table th:first-child { text-align: right; }

.top3 { max-width: 900px; margin: 0 auto; }
.top3-categories { display: flex; flex-direction: column; gap: 1rem; }
.top3-cat { background: var(--color-surface); border-radius: 0.75rem; padding: 0.9rem 1.1rem; }
.top3-cat h3 { margin: 0 0 0.7rem; text-align: center; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: #94a3b8; }
.top3-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
.top3-leader { display: flex; align-items: center; gap: 0.75rem; padding: 0.55rem 0.75rem; border-radius: 0.5rem; margin-bottom: 0.25rem; }
.top3-side.home .top3-leader { background: rgba(242, 84, 91, 0.16); }
.top3-side.away .top3-leader { background: rgba(43, 108, 176, 0.22); }
.top3-big { font-size: 2.4rem; font-weight: 700; line-height: 1; min-width: 3.2rem; text-align: center; font-variant-numeric: tabular-nums; }
.top3-side.home .top3-big { color: var(--color-home); }
.top3-side.away .top3-big { color: #4c8fd6; }
.top3-name { font-size: 1.15rem; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.top3-nr { font-size: 0.8rem; color: #94a3b8; }
.top3-rest { display: flex; align-items: center; gap: 0.75rem; padding: 0.35rem 0.75rem; border-bottom: 1px solid #334155; }
.top3-rest:last-child { border-bottom: none; }
.top3-rest-value { min-width: 3.2rem; text-align: center; font-size: 1.3rem; font-weight: 700; font-variant-numeric: tabular-nums; color: var(--color-text); }
.top3-rest-who { display: flex; align-items: baseline; gap: 0.5rem; min-width: 0; }
.top3-rest-name { font-size: 1rem; color: #cbd5e1; overflow-wrap: anywhere; }
.top3-empty { padding: 0.6rem 0.75rem; color: #64748b; }

@media (max-width: 600px) {
  .top3-big { font-size: 1.8rem; min-width: 2.4rem; }
  .top3-name { font-size: 1rem; }
  .top3-rest-value { min-width: 2.4rem; font-size: 1.1rem; }
  .top3-rest-name { font-size: 0.9rem; }
}

.pbp { max-width: 900px; margin: 0 auto; }
.pbp-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.pbp-count { color: #94a3b8; font-size: 0.9rem; }
.pbp-list { display: flex; flex-direction: column; }
.pbp-period { margin: 1rem 0 0.4rem; padding: 0.3rem 0.75rem; font-size: 0.8rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: #94a3b8; border-bottom: 1px solid #334155; }
.pbp-row { display: grid; grid-template-columns: 3.6rem minmax(0, 1fr) auto; gap: 0.75rem; align-items: center; padding: 0.5rem 0.75rem; border-left: 4px solid transparent; border-bottom: 1px solid #1e293b; }
.pbp-row.home { border-left-color: var(--color-home); }
.pbp-row.away { border-left-color: var(--color-away); }
.pbp-clock { font-variant-numeric: tabular-nums; color: #94a3b8; font-size: 0.9rem; }
.pbp-line { display: flex; flex-wrap: wrap; gap: 0.15rem 0.6rem; align-items: baseline; }
.pbp-who { font-weight: 700; }
.pbp-row.home .pbp-who { color: #ff7a80; }
.pbp-row.away .pbp-who { color: #5b9ce0; }
.pbp-what { color: var(--color-text); }
.pbp-extra { margin-top: 0.15rem; font-size: 0.85rem; color: #94a3b8; }
.pbp-score { display: flex; align-items: baseline; gap: 0.6rem; font-variant-numeric: tabular-nums; color: #64748b; font-size: 0.9rem; white-space: nowrap; }
.pbp-points { font-weight: 700; font-size: 1.05rem; }
.pbp-row.home .pbp-points { color: var(--color-home); }
.pbp-row.away .pbp-points { color: #4c8fd6; }
.pbp-scoring { background: rgba(148, 163, 184, 0.09); }
.pbp-scoring .pbp-what { font-weight: 600; }
.pbp-scoring .pbp-result { color: var(--color-text); font-weight: 600; }
.pbp-miss .pbp-what, .pbp-miss .pbp-who { opacity: 0.6; }
.pbp-quiet { opacity: 0.65; }
.pbp-empty { padding: 2rem; text-align: center; color: #64748b; }

@media (max-width: 600px) {
  .pbp-row { grid-template-columns: 3rem minmax(0, 1fr) auto; gap: 0.5rem; padding: 0.45rem 0.5rem; }
}

.archive-date, .archive-time { white-space: nowrap; font-variant-numeric: tabular-nums; }
.archive-time { color: #94a3b8; }
