/* CSS Variables */
:root {
  --bg-primary: #1a1a2e;
  --bg-secondary: #16213e;
  --bg-tertiary: #0f3460;
  --accent: #e94560;
  --positive: #00ff88;
  --negative: #ff4757;
  --favorite: #ffd700;
  --text-primary: #eaeaea;
  --text-secondary: #a0a0a0;
  --text-muted: #666;
  --border-color: #2a2a4a;
  --row-height: 40px;
  --flash-duration: 1500ms;
}

/* Reset & Base */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
}

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

/* App Container */
.app {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  padding-bottom: 120px; /* Space for fixed timeline */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 0;
  flex-shrink: 0;
  gap: 20px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
}

.header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
}

.header-about-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.header-about-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* Region Selector Pills */
.region-selector {
  display: flex;
  gap: 8px;
}

.region-pill {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  font-weight: 500;
}

.region-pill:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.region-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.region-pill.active:hover {
  background: #d13a52;
  border-color: #d13a52;
}

/* Global Filter Bar */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  margin-bottom: 15px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.filter-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.filter-select {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.filter-select:hover,
.filter-select:focus {
  border-color: var(--accent);
}

.filter-select option {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.filter-toggle {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 5px 12px;
  border-radius: 6px;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.filter-toggle:hover {
  border-color: var(--accent);
}

.filter-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-primary);
}

/* Country Picker */
.country-picker {
  position: relative;
}

.country-picker-input-wrap {
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0 6px;
  gap: 6px;
  transition: border-color 0.2s;
  min-width: 170px;
}

.country-picker-input-wrap:focus-within {
  border-color: var(--accent);
}

.country-picker-flag {
  width: 16px;
  height: 11px;
  flex-shrink: 0;
}

.country-picker-input {
  background: transparent;
  border: none;
  color: var(--text-primary);
  padding: 5px 0;
  font-size: 0.85rem;
  outline: none;
  width: 100%;
  min-width: 0;
  font-family: inherit;
}

.country-picker-input::placeholder {
  color: var(--text-muted);
}

.country-picker-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s;
}

.country-picker-clear:hover {
  color: var(--text-primary);
}

.country-picker-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 280px;
  z-index: 9999;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.country-picker-options {
  overflow-y: auto;
  max-height: 300px;
}

.country-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s;
  font-size: 0.85rem;
  color: var(--text-primary);
}

.country-option:hover {
  background: var(--bg-tertiary);
}

.country-option.selected {
  background: rgba(233, 69, 96, 0.15);
  color: var(--accent);
}

.country-option .country-code {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* Loading & Error States */
.loading, .error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

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

.error {
  color: var(--negative);
}

.hidden {
  display: none !important;
}

/* Stats Section */
.stats-section {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 15px;
  margin-bottom: 15px;
  flex-shrink: 0;
}

.scope-selects {
  display: flex;
  gap: 8px;
}

.stats-card {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 20px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.stats-card h2 {
  font-size: 1.1rem;
  margin-bottom: 15px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
}

.scope-select {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s;
}

.scope-select:hover,
.scope-select:focus {
  border-color: var(--accent);
}

.stats-list {
  list-style: none;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
  min-height: 0;
}

.stats-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.2s;
  border-radius: 6px;
}

.stats-list li:hover {
  background: var(--bg-tertiary);
}

.stats-list li:last-child {
  border-bottom: none;
}

.stats-list .player-rank-num {
  color: var(--text-muted);
  font-size: 0.85rem;
  min-width: 28px;
  display: inline-block;
}

.stats-list .player-name {
  font-weight: 500;
}

.stats-list .player-team {
  color: var(--text-secondary);
}

.stats-list .rank-change {
  font-weight: 600;
  font-size: 0.9rem;
}

.stats-list .rank-change.positive {
  color: var(--positive);
}

.stats-list .rank-change.negative {
  color: var(--negative);
}

/* Change arrows in stats lists (like leaderboard style) */
.stats-list .change {
  font-size: 0.85rem;
  font-weight: 600;
}

.stats-list .change.up {
  color: var(--positive);
}

.stats-list .change.down {
  color: var(--negative);
}

.stats-list .change.same {
  color: var(--text-muted);
}

/* Favorite changes display (Down | Up | Net) */
.favorite-changes {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
}

.favorite-changes .change {
  white-space: nowrap;
}

.favorite-changes .change.net {
  padding-left: 8px;
  border-left: 1px solid var(--border-color);
  min-width: 32px;
  text-align: right;
}

.favorite-changes .change.small {
  font-size: 10px;
  opacity: 0.8;
  min-width: 28px;
  text-align: right;
}

.favorite-changes .rank-transition {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 6px;
  min-width: 45px;
  text-align: right;
}

.general-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.general-stats .stat-row {
  display: flex;
  justify-content: space-between;
  padding: 5px 0;
}

.general-stats .stat-label {
  color: var(--text-secondary);
}

.general-stats .stat-value {
  font-weight: 600;
}

/* Team Changes Section */
.team-changes-section {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 15px 20px;
  border: 1px solid var(--border-color);
  flex-shrink: 0;
}

.team-changes-header {
  font-size: 1rem;
  margin-bottom: 12px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.team-changes-header #team-changes-count {
  color: var(--text-muted);
  font-weight: normal;
}

.team-changes-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s, transform 0.2s;
}

.team-changes-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.team-changes-toggle .chevron {
  display: inline-block;
  transition: transform 0.2s;
}

.team-changes-section.collapsed .team-changes-toggle .chevron {
  transform: rotate(-90deg);
}

.team-changes-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  transition: max-height 0.3s ease, opacity 0.3s ease;
  overflow: hidden;
}

.team-changes-section.collapsed .team-changes-list {
  max-height: 0 !important;
  opacity: 0;
  margin-bottom: 0;
}

/* Hide collapsed team changes completely on desktop */
@media (min-width: 769px) {
  .team-changes-section.collapsed {
    display: none;
  }
}

/* Standalone team changes section (when not in row container) */
section.team-changes-section {
  margin-bottom: 15px;
}

.favorites-team-row .team-changes-section {
  margin-bottom: 0;
}

.team-change-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-tertiary);
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}

.team-change-item:hover {
  background: var(--bg-primary);
}

.team-change-item .player-name {
  color: var(--text-primary);
  font-weight: 500;
}

.team-change-item .team-arrow {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.team-change-item .old-team {
  color: var(--negative);
  text-decoration: line-through;
  opacity: 0.7;
}

.team-change-item .new-team {
  color: var(--positive);
}

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

/* Main Content */
.main-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* Leaderboard */
.leaderboard-section {
  background: var(--bg-secondary);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-color);
  flex: 1;
  min-height: 400px;
  margin-bottom: 100px;
  display: flex;
  flex-direction: column;
}

.leaderboard-header {
  display: grid;
  grid-template-columns: 70px 60px 100px 1fr 30px 40px auto;
  padding: 15px 20px;
  background: var(--bg-tertiary);
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.leaderboard {
  flex: 1;
  overflow-y: auto;
  position: relative;
  min-height: 0;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 70px 60px 100px 1fr 30px 40px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  transition: background 0.2s, transform 0.3s ease-out;
  will-change: transform;
  height: var(--row-height);
  align-items: center;
}

.leaderboard-row:hover {
  background: var(--bg-tertiary);
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.leaderboard-row .rank {
  font-weight: 700;
  color: var(--text-primary);
}

.leaderboard-row .rank.top-1 { color: #ffd700; }
.leaderboard-row .rank.top-3 { color: #c0c0c0; }
.leaderboard-row .rank.top-10 { color: #cd7f32; }

.leaderboard-row .change {
  font-size: 0.85rem;
  font-weight: 600;
}

.leaderboard-row .change.up {
  color: var(--positive);
}

.leaderboard-row .change.down {
  color: var(--negative);
}

.leaderboard-row .change.same {
  color: var(--text-muted);
}

.leaderboard-row .name {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-row .flag {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Player flags */
.player-flag {
  width: 16px;
  height: 11px;
  vertical-align: middle;
}

.modal-flag {
  width: 20px;
  height: 14px;
  margin-left: 8px;
}

.modal-team-prefix {
  color: var(--text-secondary);
}

.stats-list .player-flag {
  margin-left: 6px;
}

.leaderboard-row .team {
  color: var(--text-secondary);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leaderboard-row .chevron {
  color: var(--text-muted);
  font-size: 1rem;
  text-align: center;
  transition: color 0.2s;
}

.leaderboard-row:hover .chevron {
  color: var(--text-primary);
}

/* Row animation classes */
.leaderboard-row.animate-up {
  animation: flashGreen var(--flash-duration) linear;
}

.leaderboard-row.animate-down {
  animation: flashRed var(--flash-duration) linear;
}

@keyframes flashGreen {
  0% { background: rgba(0, 255, 136, 0.4); }
  100% { background: transparent; }
}

@keyframes flashRed {
  0% { background: rgba(255, 71, 87, 0.4); }
  100% { background: transparent; }
}

/* Timeline Section */
.timeline-section {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-secondary);
  border-radius: 12px 12px 0 0;
  padding: 15px 20px;
  border: 1px solid var(--border-color);
  border-bottom: none;
  z-index: 100;
  max-width: 1400px;
  margin: 0 auto;
}

.timeline-controls {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 10px;
}

.current-time {
  margin-left: auto;
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.expand-toggle {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.expand-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-tertiary);
}

.header-buttons {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-self: end;
  margin-right: 8px;
}

/* Compact mode - hide header, filter bar and stats */
.header,
.stats-section,
.favorites-team-row {
  transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease;
  overflow: hidden;
}

.filter-bar {
  transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease, padding 0.3s ease;
}

.app.compact .header,
.app.compact .stats-section,
.app.compact .favorites-team-row {
  opacity: 0;
  max-height: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
}

.app.compact .filter-bar {
  opacity: 0;
  max-height: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
  overflow: hidden;
}

.header {
  max-height: 100px;
}

.stats-section {
  max-height: 400px;
}

.filter-bar {
  max-height: 100px;
}

.favorites-team-row {
  max-height: 2000px; /* Large value to allow many items, will animate to 0 in compact mode */
}

.app.compact .leaderboard-section {
  margin-top: 0;
}

.control-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-btn:hover {
  transform: scale(1.1);
  background: #ff5a75;
}

.control-btn.playing {
  background: var(--positive);
}

.speed-controls {
  display: flex;
  gap: 5px;
}

.speed-btn {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.speed-btn:hover {
  border-color: var(--accent);
  color: var(--text-primary);
}

.speed-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.timeline-slider-container {
  position: relative;
}

.timeline-slider {
  width: 100%;
  height: 8px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--bg-tertiary);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  transition: transform 0.2s;
}

.timeline-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.timeline-slider::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: none;
}

.timeline-labels {
  display: flex;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.timeline-hint {
  color: var(--text-muted);
  font-size: 0.75rem;
  opacity: 0.7;
}

/* Modal */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-content {
  background: var(--bg-secondary);
  border-radius: 16px;
  padding: 30px;
  max-width: 700px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  border: 1px solid var(--border-color);
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 36px;
  height: 36px;
  border: none;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 1.5rem;
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  background: var(--accent);
}

.modal-header {
  margin-bottom: 25px;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-header h2 {
  font-size: 1.8rem;
  margin-bottom: 5px;
}

/* Favorite Button in Modal */
.favorite-btn {
  background: transparent;
  border: 2px solid var(--border-color);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.favorite-btn .star {
  font-size: 1.4rem;
  color: var(--text-muted);
  transition: all 0.2s ease;
  line-height: 1;
  margin-top: -2px;
}

.favorite-btn:hover {
  border-color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.05);
}

.favorite-btn:hover .star {
  color: var(--text-secondary);
}

.favorite-btn.active:hover {
  border-color: var(--favorite);
  background: rgba(255, 215, 0, 0.25);
}

.favorite-btn.active:hover .star {
  color: var(--favorite);
}

.favorite-btn.active {
  border-color: var(--favorite);
  background: rgba(255, 215, 0, 0.15);
}

.favorite-btn.active .star {
  color: var(--favorite);
}

/* Favorite Stars (inline in lists) */
.favorite-star {
  color: var(--favorite);
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
}

.favorite-star.small {
  font-size: 0.9rem;
  margin-right: 4px;
}

.favorite-star.large {
  font-size: 1.3rem;
}

.favorite-star:not(.active) {
  color: var(--text-muted);
  opacity: 0.5;
}

.favorite-star.active {
  color: var(--favorite);
  opacity: 1;
}

.favorite-star.display-only {
  cursor: default;
}

/* Favorites Card */
.favorites-card {
  background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(255, 215, 0, 0.05) 100%);
  border-color: rgba(255, 215, 0, 0.3);
}

/* Favorites and Team Changes row layout */
.favorites-team-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 15px;
  margin-bottom: 15px;
}

.favorites-team-row:has(.favorites-card:not(.hidden)):has(.team-changes-section:not(.hidden):not(.collapsed)) {
  grid-template-columns: 1fr 1fr;
}

/* Fallback for browsers without :has() support - use JS to add .has-both class */
.favorites-team-row.has-both {
  grid-template-columns: 1fr 1fr;
}

.favorites-team-row .favorites-card {
  margin-bottom: 0;
}

.favorites-team-row .team-changes-section {
  margin-bottom: 0;
}

.favorites-card h2 span:first-child {
  color: var(--favorite);
}

.modal-team {
  color: var(--text-secondary);
  font-size: 1rem;
}

.modal-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 15px;
  margin-bottom: 30px;
}

.modal-stat {
  background: var(--bg-tertiary);
  padding: 12px;
  border-radius: 10px;
  text-align: center;
}

.modal-stat .stat-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.modal-stat .stat-value {
  font-size: 1.4rem;
  font-weight: 700;
}

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

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

.modal-chart-container {
  background: var(--bg-tertiary);
  border-radius: 10px;
  padding: 20px;
  height: 300px;
}

/* Team History in Modal */
.modal-team-history {
  margin-top: 20px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  padding: 15px 20px;
}

.modal-team-history h3 {
  font-size: 0.95rem;
  color: var(--text-secondary);
  margin-bottom: 12px;
  font-weight: 600;
}

.team-history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.team-history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--bg-secondary);
  border-radius: 6px;
  font-size: 0.9rem;
}

.team-history-item.current {
  border-left: 3px solid var(--accent);
}

.team-history-item .team-date {
  color: var(--text-muted);
  font-size: 0.8rem;
  min-width: 90px;
}

.team-history-item .team-name {
  color: var(--text-primary);
  font-weight: 500;
}

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

.team-history-item .current-label {
  color: var(--accent);
  font-size: 0.75rem;
  margin-left: auto;
}

/* About Modal */
.about-modal-content {
  max-width: 500px;
}

.about-modal-body h2 {
  font-size: 1.5rem;
  margin-bottom: 20px;
}

.about-modal-body p {
  color: var(--text-secondary);
  line-height: 1.7;
  margin-bottom: 25px;
}

.support-section {
  margin-top: 30px;
  padding-top: 20px;
  border-top: 1px solid var(--border-color);
  text-align: center;
}

.support-section h3 {
  font-size: 1.1rem;
  margin-bottom: 15px;
  color: var(--text-primary);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* Responsive */
@media (max-width: 768px) {
  body {
    overflow: auto;
  }

  .app {
    padding: 10px;
    height: auto;
    min-height: 100vh;
  }

  .main-content {
    overflow: visible;
  }

  .header {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
    margin-bottom: 10px;
    max-height: 200px;
  }

  .header-left {
    flex-wrap: wrap;
    justify-content: center;
  }

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

  .header h1 {
    font-size: 1.2rem;
  }

  /* Hide favorite stars in tracked players on mobile */
  .favorites-card .favorite-star {
    display: none;
  }

  /* Stack favorites and team changes on mobile */
  .favorites-team-row {
    grid-template-columns: 1fr !important;
  }

  .header-nav {
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
  }

  .region-selector {
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }

  .region-pill {
    padding: 5px 12px;
    font-size: 0.8rem;
  }

  .stats-section {
    grid-template-columns: 1fr;
    max-height: none;
  }

  .stats-card {
    min-height: 200px;
  }

  .team-changes-section {
    max-height: none;
  }

  .team-changes-list {
    max-height: none;
  }

  .team-changes-section.collapsed .team-changes-list {
    max-height: 0 !important;
  }

  .leaderboard-section {
    flex: none;
    max-height: 90vh;
  }

  .timeline-hint {
    display: none;
  }

  .timeline-labels {
    display: none;
  }

  .leaderboard-header {
    grid-template-columns: 50px 40px 70px 1fr auto;
    padding: 10px 12px;
    font-size: 0.8rem;
  }

  .leaderboard-row {
    grid-template-columns: 50px 40px 70px 1fr 30px;
    padding: 10px 12px;
  }

  .header-buttons {
    gap: 4px;
    margin-right: 0;
  }

  .filter-bar {
    gap: 8px;
    padding: 8px 12px;
    max-height: none;
  }

  .filter-label {
    font-size: 0.65rem;
  }

  .filter-select {
    font-size: 0.75rem;
    padding: 4px 6px;
  }

  .filter-toggle {
    font-size: 0.75rem;
    padding: 4px 8px;
  }

  .country-picker-input-wrap {
    min-width: 130px;
  }

  .country-picker-input {
    font-size: 0.75rem;
  }

  .country-picker-dropdown {
    width: 220px;
    right: 0;
    left: auto;
  }

  .col-flag,
  .col-arrow,
  .leaderboard-row .flag {
    display: none;
  }
}

/* Mobile landscape - ensure scrolling works */
@media (max-height: 500px) and (orientation: landscape) {
  body {
    overflow: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
  }

  .main-content {
    overflow: visible;
  }

  .leaderboard-section {
    flex: none;
    max-height: none;
  }
}

/* Visually Hidden (for screen readers & SEO) */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* SEO Content Section */
.seo-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 40px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
}

.seo-content-inner {
  max-width: 900px;
  margin: 0 auto;
}

.seo-content h2 {
  color: var(--text-primary);
  font-size: 1.5rem;
  margin-bottom: 16px;
  border-bottom: 2px solid var(--accent);
  padding-bottom: 8px;
}

.seo-content h3 {
  color: var(--text-primary);
  font-size: 1.1rem;
  margin: 24px 0 12px;
}

.seo-content p {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.7;
  margin-bottom: 12px;
}

.seo-content strong {
  color: var(--text-primary);
}

.seo-content ul {
  list-style: none;
  padding-left: 0;
  margin: 12px 0;
}

.seo-content ul li {
  color: var(--text-secondary);
  padding: 6px 0;
  padding-left: 20px;
  position: relative;
}

.seo-content ul li::before {
  content: "→";
  position: absolute;
  left: 0;
  color: var(--accent);
}

/* Footer */
.site-footer {
  background: var(--bg-primary);
  border-top: 1px solid var(--border-color);
  padding: 40px 20px 20px;
  margin-top: auto;
}

.footer-content {
  max-width: 1400px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 30px;
  padding-bottom: 30px;
  border-bottom: 1px solid var(--border-color);
}

.footer-section h4 {
  color: var(--text-primary);
  font-size: 1rem;
  margin-bottom: 12px;
}

.footer-section p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.6;
}

.footer-section ul {
  list-style: none;
}

.footer-section ul li {
  padding: 4px 0;
}

.footer-section ul li a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.85rem;
  transition: color 0.2s;
}

.footer-section ul li a:hover {
  color: var(--accent);
}

.footer-bottom {
  max-width: 1400px;
  margin: 0 auto;
  padding-top: 20px;
  text-align: center;
}

.footer-bottom p {
  color: var(--text-muted);
  font-size: 0.8rem;
}

@media (max-width: 768px) {
  .seo-content {
    padding: 30px 15px;
  }
  
  .footer-content {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}
