/* SM-liiga Kokoonpanot – Minimal Dark Theme */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2129;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --gold: #ffd700;
  --redbull: #db0a40;
  --positive: #3fb950;
  --negative: #f85149;
  --line-bg: rgba(56, 68, 82, 0.3);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

/* Header */
header {
  text-align: center;
  padding: 1.5rem 1rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
  margin-bottom: 0.25rem;
}

/* Main */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* Tabs */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--border);
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.15rem;
  padding: 0.75rem 1rem;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-date {
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.8;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.no-games {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}

.no-games a {
  color: var(--accent);
}

/* Round sub-heading (used when next round is not today) */
.round-heading {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  padding: 0.5rem 0 0.75rem;
  text-align: center;
}

/* No games today banner */
.no-games-today {
  text-align: center;
  padding: 1.25rem 1rem;
  color: var(--text-dim);
  font-size: 0.9rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin: 1.5rem 0;
}

/* Game card */
.game-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 1.5rem;
  overflow: hidden;
  scroll-margin-top: 1rem;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.5rem;
  gap: 1.5rem;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.team {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
}

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

.away-team {
  justify-content: flex-start;
}

.team-logo {
  width: 36px;
  height: 36px;
  object-fit: contain;
}

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

.score-info {
  text-align: center;
  min-width: 80px;
}

.score {
  font-size: 1.5rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.finish-type {
  display: block;
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.game-time {
  font-size: 0.85rem;
  color: var(--text-dim);
}

/* Rosters container: two columns */
.rosters-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.team-roster {
  padding: 0.75rem;
}

.team-roster:first-child {
  border-right: 1px solid var(--border);
}

.roster-title {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  padding: 0.25rem 0.5rem 0.5rem;
  text-align: center;
}

/* Line groups */
.line-group {
  margin-bottom: 0.5rem;
  border-radius: 6px;
  overflow: hidden;
  background: var(--line-bg);
}

.line-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  padding: 0.3rem 0.5rem 0.15rem;
}

/* Player rows */
.player-row {
  display: flex;
  flex-direction: column;
}

.player-cell {
  display: flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
  gap: 0.25rem;
  position: relative;
  border-bottom: 1px solid rgba(48, 54, 61, 0.4);
  min-height: 32px;
}

.player-cell:last-child {
  border-bottom: none;
}

.player-cell.golden-helmet {
  background: rgba(255, 215, 0, 0.06);
}

.player-cell.u20-best {
  border-left: 2px solid var(--redbull);
}

.player-cell.goalie-starter {
  background: rgba(88, 166, 255, 0.08);
  border-left: 2px solid var(--accent);
}

.player-info {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  flex: 1;
}

.jersey {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  min-width: 28px;
  font-variant-numeric: tabular-nums;
}

.player-name {
  font-size: 0.8rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.role {
  font-size: 0.65rem;
  color: var(--text-dim);
  min-width: 18px;
}

.badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 0 3px;
  border-radius: 2px;
  vertical-align: super;
  flex-shrink: 0;
}

.badge.captain {
  color: var(--gold);
}

.badge.alt-captain {
  color: var(--text-dim);
}

.badge.starter {
  color: var(--accent);
  font-size: 0.7rem;
}

.badge.golden {
  font-size: 0.75rem;
}

.badge.redbull {
  color: var(--redbull);
  border: 1px solid var(--redbull);
  border-radius: 3px;
  line-height: 1.4;
  font-size: 0.55rem;
}

/* Match-specific stats (highlighted) */
.match-stats {
  display: flex;
  gap: 0.3rem;
  font-size: 0.65rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
  background: rgba(255, 215, 0, 0.10);
  border-radius: 3px;
  padding: 0 4px;
}

.match-stats span {
  white-space: nowrap;
}

.ms-g {
  color: var(--text);
}

.ms-a {
  color: var(--accent);
}

.ms-pm.positive {
  color: var(--positive);
}

.ms-pm.negative {
  color: var(--negative);
}

.ms-pim {
  color: var(--gold);
}

/* Penalty minutes in season stats */
.stat-pim {
  color: var(--gold);
}

/* Stats inline */
.player-stats {
  display: flex;
  gap: 0;
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  color: var(--text-dim);
  flex-shrink: 0;
}

.player-stats > span,
.player-stats > .stat-scoring {
  text-align: right;
  flex-shrink: 0;
}

/* Fixed column widths for alignment */
.player-stats > span:first-child { /* games */
  width: 22px;
}

.stat-scoring {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.1rem;
  white-space: nowrap;
  width: 68px;
}

.stat-scoring > span {
  text-align: right;
}

.stat-scoring > .stat-goals,
.stat-scoring > span:nth-child(3) { /* assists */
  min-width: 14px;
}

.stat-scoring > .stat-points {
  min-width: 16px;
}

.stat-sep {
  color: var(--text-dim);
  opacity: 0.5;
  font-size: 0.55rem;
  min-width: 0 !important;
}

.stat-goals {
  color: var(--text);
  font-weight: 600;
}

.stat-points {
  color: var(--accent);
  font-weight: 600;
}

.stat-pm {
  width: 26px;
}

.stat-pim {
  width: 24px;
}

.stat-toi {
  width: 34px;
}

.stat-pm.positive {
  color: var(--positive);
}

.stat-pm.negative {
  color: var(--negative);
}

/* Goalie stats – own grid for clean alignment */
.goalie-stats {
  display: grid !important;
  grid-template-columns: 52px 44px 34px 50px 18px;
  gap: 0.25rem;
}

.goalie-stats > span {
  text-align: right;
  white-space: nowrap;
  width: auto;
  min-width: auto;
}

/* Stats legend */
.stats-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem 0;
  padding: 0.6rem 0.75rem;
  font-size: 0.65rem;
  color: var(--text-dim);
  border-top: 1px solid var(--border);
}

.stats-legend > span {
  white-space: nowrap;
  padding: 0 0.5rem;
  border-right: 1px solid var(--border);
}

.stats-legend > span:last-child {
  border-right: none;
}

.goalie-legend {
  border-top: none;
  padding-top: 0;
}

.goalie-legend > span:first-child {
  font-weight: 600;
  color: var(--accent);
  border-right: none;
  padding-right: 0;
}

.legend-helmet.golden {
  color: var(--gold);
}

.legend-helmet.redbull {
  color: var(--redbull);
}

/* Footer */
footer {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.75rem;
  color: var(--text-dim);
}

footer a {
  color: var(--accent);
  text-decoration: none;
}

/* ═══════════════════════════════════════════ */
/* Match Sidebar                              */
/* ═══════════════════════════════════════════ */

/* Backdrop (visible when sidebar open on narrow screens) */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.sidebar-backdrop.visible {
  display: block;
}

/* Sidebar panel */
.match-sidebar {
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  width: 240px;
  background: var(--surface);
  border-left: 1px solid var(--border);
  z-index: 200;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.match-sidebar.open {
  transform: translateX(0);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  flex-shrink: 0;
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
  transition: color 0.15s;
}

.sidebar-close:hover {
  color: var(--text);
}

.sidebar-matches {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* Individual match item */
.sb-match {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  text-decoration: none;
  color: var(--text);
  transition: background 0.15s;
}

.sb-match:hover {
  background: var(--surface-2);
}

.sb-match.active {
  background: rgba(88, 166, 255, 0.08);
  border-left: 3px solid var(--accent);
  padding-left: calc(0.75rem - 3px);
}

.sb-teams {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.78rem;
  font-weight: 500;
  min-width: 0;
}

.sb-logo {
  width: 18px;
  height: 18px;
  object-fit: contain;
  flex-shrink: 0;
}

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

.sb-vs {
  color: var(--text-dim);
  font-size: 0.7rem;
  flex-shrink: 0;
}

.sb-score-inline {
  font-weight: 700;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  flex-shrink: 0;
  white-space: nowrap;
}

.sb-info {
  text-align: center;
  font-size: 0.7rem;
  color: var(--text-dim);
  min-height: 0.85rem;
}

.sb-time {
  color: var(--text-dim);
}

.sb-finish {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-dim);
  font-size: 0.65rem;
}

/* Floating action button (toggle) */
.sidebar-fab {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 150;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.2s, opacity 0.2s, box-shadow 0.2s;
}

.sidebar-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.sidebar-fab.hidden {
  transform: scale(0);
  opacity: 0;
  pointer-events: none;
}

/* On wide screens (>=1440px), sidebar is always open */
@media (min-width: 1440px) {
  .match-sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop.visible {
    display: none;
  }

  .sidebar-fab {
    display: none;
  }

  .sidebar-close {
    display: none;
  }

  /* Shift main content to avoid overlap */
  main {
    margin-right: 240px;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .rosters-container {
    grid-template-columns: 1fr;
  }

  .team-roster:first-child {
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .game-header {
    padding: 0.75rem;
    gap: 0.75rem;
  }

  .team-name {
    font-size: 0.85rem;
  }

  .team-logo {
    width: 28px;
    height: 28px;
  }

  .player-stats {
    font-size: 0.65rem;
  }

  .stat-scoring {
    width: 60px;
  }

  .stat-pm {
    width: 24px;
  }

  .stat-pim {
    width: 22px;
  }

  .stat-toi {
    width: 30px;
  }
}

@media (max-width: 480px) {
  .player-info {
    min-width: 90px;
  }
}
