/* CSS Custom Properties for consistent color scheme based on favicon blue #1e88ea */
:root {
  /* Primary Colors */
  --primary: #1e88ea;
  --primary-light: #4fc3f7;
  --primary-dark: #0277bd;
  --secondary: #ff9800;
  --secondary-light: #ffb74d;
  --secondary-dark: #f57c00;
  --success: #4caf50;
  --warning: #ff9800;
  --danger: #f44336;
  --info: #2196f3;

  /* Neutral Colors */
  --white: #ffffff;
  --black: #000000;
  --gray-50: #fafafa;
  --gray-100: #f5f5f5;
  --gray-200: #eeeeee;
  --gray-300: #e0e0e0;
  --gray-400: #bdbdbd;
  --gray-500: #9e9e9e;
  --gray-600: #757575;
  --gray-700: #616161;
  --gray-800: #424242;
  --gray-900: #212121;

  /* Background Colors */
  --bg-primary: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  --bg-card: var(--white);
  --bg-light: #f8fafc;
  --bg-highlight: #fff8e1;

  /* Text Colors */
  --text-primary: var(--gray-900);
  --text-secondary: var(--gray-700);
  --text-muted: var(--gray-600);

  /* Border Colors */
  --border-light: var(--gray-300);
  --border-medium: #e1e5e9;
  --border-dark: #d0d2d5;

  /* Shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

/* Main container styles */
.container {
  width: 100%;
  min-height: 100vh;
}

/* CSS reset and base styles */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-primary);
}

#play-by-play {
  overflow: scroll;
  height: 330px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-medium);
}

#play-by-play div:not(.plate-appearance-container, .game-event-container) {
  padding: 2px 2px 2px 30px;
  text-align: left;
}

#play-by-play div.plate-appearance, #play-by-play div.game-event {
  padding: 10px;
  text-align: left;
  transition: background-color 0.2s ease;
  border-bottom: 1px solid var(--border-dark);
}

#play-by-play .plate-appearance .toggle-icon {
  display: inline;
}

#play-by-play .toggle-icon {
  display: none;
  float: right;
  transition: transform 0.2s ease;
}

#play-by-play .plate-appearance-container.selected .toggle-icon {
  transform: rotate(180deg);
}

#play-by-play div.plate-appearance-container:nth-child(odd) {
  background-color: var(--bg-light);
}

#play-by-play div.plate-appearance-container:nth-child(even) {
  background-color: var(--bg-card);
}

#play-by-play div.game-event {
  background-color: var(--bg-highlight);
  border-left: 4px solid var(--secondary);
  font-weight: 500;
}

#play-by-play div.run-scoring {
  background: linear-gradient(135deg, #fff9c4 0%, #ffeb3b 100%);
  font-weight: bold;
  color: var(--secondary-dark);
}

#play-by-play div.run-scoring.plate-appearance {
  border-left: 4px solid var(--secondary-dark);
}

#play-by-play div:not(.selected) div.pitch {
  display: none !important;
}

#game-view {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-primary);
}

table.stats-table td {
  font-family: sans-serif;
  text-align: center;
  padding: 3px;
}
table.stats-table tr td:first-of-type {
  text-align: left;
}
table.stats-table thead td, table.stats-table tfoot td {
  font-weight: bold;
  background-color: var(--gray-200);
}
table.stats-table thead td {
  cursor: pointer;
}
table.stats-table tbody tr:nth-child(even) td {
  background-color: var(--gray-100);
}
table.stats-table tbody tr:hover td {
  background-color: var(--secondary-light);
}

.balls-in-play {
  padding: 10px;
  margin-top: 10px;
  display: flex;
  /* break at 768px */
  flex-wrap: wrap;
  /* background-color: var(--bg-card); */
  border-radius: 8px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-medium);
}
.balls-in-play .position {
  width: 448px;
  margin: 0 10px 10px 0;
  background-color: var(--bg-light);
  border-radius: 6px;
  padding: 10px;
  border: 1px solid var(--border-medium);
}
.balls-in-play .position h3 {
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 10px;
  font-weight: 600;
}

.balls-in-play .position h5 {
  margin: 0;
}

svg {
  height: auto;
  width: 100%;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.1));
}

/* Team color styles */
.fielder-text {
  fill: var(--fielding-primary, white);
  stroke: var(--fielding-secondary, black);
  stroke-width: 1px;
}

.batter-text, .runner-text {
  fill: var(--batting-primary, black);
  stroke: var(--batting-secondary, white);
  stroke-width: 1px;
}

.away-team-colors {
  --team-primary: var(--away-primary);
  --team-secondary: var(--away-secondary);
}

.home-team-colors {
  --team-primary: var(--home-primary);
  --team-secondary: var(--home-secondary);
}

#play-by-play div.game-event-away {
  border-left: 4px solid var(--away-primary);
  background: linear-gradient(135deg, rgb(from var(--away-primary) r g b / 0.08) 0%, rgb(from var(--home-primary) r g b / 0.08) 100%);
}

#play-by-play div.game-event-home {
  border-left: 4px solid var(--home-primary);
  background: linear-gradient(135deg, rgb(from var(--home-primary) r g b / 0.08) 0%, rgb(from var(--away-primary) r g b / 0.08) 100%);
}

.pie-chart {
  display: inline-block;
  max-width: 400px;
  margin: 20px auto;
}

/* Welcome page styles */
.welcome-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  font-family: Arial, sans-serif;
  background: var(--bg-primary);
  min-height: 100vh;
}

.welcome-title {
  text-align: center;
  font-size: 2.5em;
  color: var(--text-primary);
  margin-bottom: 30px;
}

.welcome-subtitle {
  text-align: center;
  font-size: 1.2em;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.section-title {
  font-size: 1.8em;
  margin-bottom: 20px;
  border-bottom: 2px solid currentColor;
  padding-bottom: 10px;
}

.section-spacing {
  margin-bottom: 40px;
}

.games-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.seasons-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
}

.section-title.in-progress {
  color: var(--success);
}

.section-title.current-seasons {
  color: var(--primary);
}

.section-title.all-seasons {
  color: var(--text-secondary);
}

.game-card {
  background: var(--bg-card);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 20px;
  flex: 1 1 300px;
  border-left: 4px solid var(--success);
}

.game-team {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
}

.game-team.away,
.game-team.home {
  font-weight: bold;
  color: var(--text-primary);
}

.game-score {
  font-weight: bold;
  color: var(--danger);
}

.game-details {
  margin: 0 0 15px 0;
  color: var(--text-muted);
  font-size: 0.9em;
}

.game-link {
  color: var(--primary);
  text-decoration: none;
  font-weight: bold;
}

.season-card {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: var(--white);
  border-radius: 8px;
  padding: 20px;
  cursor: pointer;
  flex: 1 1 200px;
  text-align: center;
  box-shadow: var(--shadow);
}

.season-title {
  margin: 0 0 10px 0;
  font-size: 1.5em;
}

.season-description {
  margin: 0;
  font-size: 0.9em;
}

.seasons-container {
  background: var(--bg-card);
  border-radius: 8px;
  padding: 20px;
  box-shadow: var(--shadow);
}

.season-select {
  width: 100%;
  max-width: 400px;
  padding: 10px;
  border: 1px solid var(--border-light);
  border-radius: 4px;
  margin-bottom: 20px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.games-list {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.games-list-items {
  list-style: none;
  padding: 0;
}

.season-content {
  margin-top: 20px;
}

.season-content-title {
  font-size: 1.5em;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.games-column {
  flex: 1 1 45%;
  min-width: 300px;
}

.games-column h4 {
  color: var(--primary);
  margin-bottom: 10px;
}

.games-column.teams h4 {
  color: var(--secondary);
}

.game-item {
  margin-bottom: 8px;
}

.game-item a {
  color: var(--primary);
  text-decoration: none;
}

.game-item.teams a {
  color: var(--secondary);
  text-decoration: none;
}

.game-winner {
  font-weight: bold;
}

.game-location {
  color: var(--text-muted);
  font-size: 0.8em;
}

.new-item {
  margin-top: 10px;
}

.new-item a {
  color: var(--success);
  text-decoration: none;
  font-weight: bold;
}

.no-content {
  color: var(--text-muted);
  font-style: italic;
}

/* Team page styles */
.spray-toggle {
  text-decoration: underline dotted;
  cursor: pointer;
  color: var(--primary);
  font-size: large;
}

/* Spray chart interactive wrapper and tooltip */
.spray-chart-wrapper {
  position: relative;
  display: inline-flex;
  width: 100%;
  justify-content: center;
}

.spray-chart-wrapper svg {
  max-width: calc(50vh);
}

.spray-tooltip {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--border-medium);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  padding: 10px 14px;
  min-width: 180px;
  max-width: 260px;
  z-index: 100;
  font-size: 0.88em;
  color: var(--text-primary);
}

.spray-tooltip-close {
  position: absolute;
  top: 4px;
  right: 8px;
  background: none;
  border: none;
  font-size: 1em;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 2px 4px;
}

.spray-tooltip-close:hover {
  color: var(--text-primary);
}

.spray-tooltip-inning {
  font-size: 0.82em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.spray-tooltip-human {
  font-weight: 600;
  margin-bottom: 4px;
  line-height: 1.3;
}

.spray-tooltip-details {
  font-size: 0.82em;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.spray-tooltip-link {
  display: inline-block;
  font-size: 0.82em;
  color: var(--primary);
  text-decoration: underline;
}

.spray-tooltip-link:hover {
  color: var(--primary-dark);
}

/* Login page styles */
.login-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  font-family: Arial, sans-serif;
  background: var(--bg-primary);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  background: var(--bg-card);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  padding: 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.login-title {
  font-size: 2em;
  color: var(--text-primary);
  margin-bottom: 30px;
}

.login-subtitle {
  color: var(--text-muted);
  margin-bottom: 30px;
  font-size: 1.1em;
}

.login-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.login-button {
  display: inline-block;
  background: var(--primary);
  color: var(--white);
  padding: 12px 24px;
  border-radius: 6px;
  text-decoration: none;
  font-weight: bold;
  transition: background 0.3s;
  box-shadow: var(--shadow);
}

.login-button:hover {
  background: var(--primary-dark);
}

/* Link Styles */
a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-dark);
  text-decoration: underline;
}

.inline-link {
  color: var(--primary);
  text-decoration: underline;
  font-weight: normal;
}

.inline-link:hover {
  color: var(--primary-dark);
  text-decoration: none;
}

/* Responsive Design */
@media screen and (max-width: 768px) {
  .welcome-container {
    padding: 15px;
  }

  .welcome-title {
    font-size: 2em;
    margin-bottom: 20px;
  }

  .welcome-subtitle {
    font-size: 1em;
    margin-bottom: 15px;
  }

  .section-title {
    font-size: 1.5em;
    margin-bottom: 15px;
  }

  .section-spacing {
    margin-bottom: 30px;
  }

  .games-grid {
    flex-direction: column;
    gap: 15px;
  }

  .seasons-grid {
    flex-direction: column;
    gap: 12px;
  }

  .game-card {
    flex: none;
    width: 100%;
    padding: 15px;
  }

  .season-card {
    flex: none;
    width: 100%;
    padding: 15px;
  }

  .season-title {
    font-size: 1.3em;
  }

  .seasons-container {
    padding: 15px;
  }

  .season-select {
    max-width: 100%;
    margin-bottom: 15px;
  }

  .games-list {
    flex-direction: column;
    gap: 15px;
  }

  .games-column {
    flex: none;
    width: 100%;
    min-width: unset;
  }

  .season-content-title {
    font-size: 1.3em;
  }

  /* Team and Person page responsive */
  .stats-section {
    margin-bottom: 20px;
  }

  .stats-card {
    margin-bottom: 20px;
  }

  .stats-card-title {
    font-size: 1.2em;
  }

  .charts-container {
    flex-direction: column;
    gap: 15px;
  }

  .chart-card {
    flex: none;
    width: 100%;
  }

  /* Login page responsive */
  .login-container {
    padding: 15px;
  }

  .login-card {
    padding: 30px 20px;
  }

  .login-title {
    font-size: 1.8em;
  }
}

@media screen and (max-width: 1024px) and (min-width: 769px) {
  .welcome-container {
    padding: 20px;
  }

  .games-grid {
    gap: 15px;
  }

  .seasons-grid {
    gap: 12px;
  }

  .game-card {
    flex: 1 1 250px;
  }

  .season-card {
    flex: 1 1 180px;
  }

  .games-list {
    gap: 15px;
  }

  .games-column {
    flex: 1 1 40%;
    min-width: 250px;
  }
}

/* Table responsive behavior */
@media screen and (max-width: 768px) {
  .stats-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .stats-table {
    min-width: 600px;
    font-size: 0.9em;
  }

  .stats-table th,
  .stats-table td {
    padding: 8px 6px;
    white-space: nowrap;
  }

  /* Spray chart responsive */
  .balls-in-play {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    justify-content: center;
  }

  .balls-in-play .position {
    flex: 1 1 200px;
    max-width: 300px;
  }

  .balls-in-play h5 {
    font-size: 0.9em;
    margin-bottom: 10px;
  }
}