/* === RESET & VARIABLES === */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg: #0c0f14;
  --bg-card: #141820;
  --bg-card-hover: #1a1f2a;
  --bg-surface: #111520;
  --border: #1e2432;
  --border-hover: #2a3244;
  --text: #e8ecf4;
  --text-dim: #7a8494;
  --text-muted: #4a5468;
  --green: #22c55e;
  --green-dim: rgba(34, 197, 94, 0.12);
  --green-glow: rgba(34, 197, 94, 0.25);
  --red: #ef4444;
  --red-dim: rgba(239, 68, 68, 0.12);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.12);
  --blue: #3b82f6;
  --blue-dim: rgba(59, 130, 246, 0.12);
  --purple: #a855f7;
  --purple-dim: rgba(168, 85, 247, 0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'SF Mono', monospace;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* === NAV === */
nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(12, 15, 20, 0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-icon {
  font-size: 20px;
  filter: hue-rotate(90deg) brightness(1.5);
}

.logo-text {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 2.5px;
  color: var(--green);
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.refresh-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-dim);
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  animation: pulse 2s infinite;
}

.status-dot.refreshing {
  background: var(--amber);
  animation: pulse 0.5s infinite;
}

.status-dot.error {
  background: var(--red);
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.btn-refresh {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}

.btn-refresh:hover {
  background: var(--bg-card-hover);
  color: var(--text);
  border-color: var(--border-hover);
}

.btn-refresh.spinning svg {
  animation: spin 1s linear infinite;
}

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

/* === TAB BAR === */
.tab-bar {
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 53px;
  z-index: 99;
}

.tab-bar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  gap: 0;
}

.tab {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--text-dim);
  background: none;
  border: none;
  padding: 14px 20px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

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

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

.tab-icon { font-size: 16px; }

/* === MAIN CONTENT === */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
  min-height: calc(100vh - 200px);
}

.section { display: none; }
.section.active { display: block; }

.section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
  flex-wrap: wrap;
}

.section-header h2 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.section-sub {
  font-size: 14px;
  color: var(--text-dim);
  margin-top: 4px;
  max-width: 600px;
}

.controls-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* === TOGGLE BUTTONS === */
.type-toggle, .window-toggle {
  display: flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.toggle-btn {
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  background: none;
  border: none;
  padding: 8px 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.toggle-btn:hover { color: var(--text); background: var(--bg-card-hover); }

.toggle-btn.active {
  color: var(--green);
  background: var(--green-dim);
}

/* === PLAYER LIST / CARDS === */
.player-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Loading state */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  color: var(--text-dim);
  gap: 16px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-dim);
}

.empty-state h3 { font-size: 18px; margin-bottom: 8px; color: var(--text); }
.empty-state p { font-size: 14px; max-width: 400px; margin: 0 auto; }

/* === PLAYER CARD (BREAKOUT) === */
.player-card {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.player-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.player-rank {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
  width: 40px;
}

.player-rank.top3 { color: var(--green); }

.player-info {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.player-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  overflow: hidden;
  flex-shrink: 0;
}

.player-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.player-details {
  min-width: 0;
}

.player-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-meta {
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.player-team {
  font-weight: 600;
  color: var(--text-muted);
}

.player-stats-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 48px;
}

.stat-value {
  font-family: var(--mono);
  font-size: 15px;
  font-weight: 600;
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Score badge */
.score-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  height: 40px;
  border-radius: var(--radius-sm);
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
}

.score-badge.score-hot {
  background: var(--green-dim);
  color: var(--green);
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.score-badge.score-warm {
  background: var(--amber-dim);
  color: var(--amber);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.score-badge.score-cool {
  background: var(--blue-dim);
  color: var(--blue);
  border: 1px solid rgba(59, 130, 246, 0.2);
}

/* Factor tags */
.factor-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.factor-tag {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  color: var(--text-dim);
}

.factor-tag.positive { color: var(--green); border-color: rgba(34, 197, 94, 0.2); }
.factor-tag.negative { color: var(--red); border-color: rgba(239, 68, 68, 0.2); }
.factor-tag.neutral { color: var(--amber); border-color: rgba(245, 158, 11, 0.2); }

/* === MATCHUP CARD === */
.matchup-card {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  gap: 14px;
  align-items: center;
  padding: 16px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.2s;
}

.matchup-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-hover);
  transform: translateY(-1px);
}

.matchup-vs {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
}

.matchup-vs .vs-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
}

.matchup-vs .pitcher-name {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 500;
  white-space: nowrap;
}

.matchup-context {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.ctx-chip {
  font-size: 11px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-dim);
}

.ctx-chip .icon { font-size: 12px; }

/* === GAMES BAR === */
.games-bar {
  display: flex;
  gap: 8px;
  padding: 12px 0;
  overflow-x: auto;
  margin-bottom: 16px;
  scrollbar-width: none;
}

.games-bar::-webkit-scrollbar { display: none; }

.game-chip {
  flex-shrink: 0;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.game-chip .game-teams { font-weight: 600; color: var(--text); }

.game-chip .game-time {
  font-size: 11px;
  color: var(--text-muted);
}

.game-chip .game-weather {
  font-size: 11px;
  color: var(--text-dim);
}

/* === PREMIUM GATE === */
.premium-gate {
  position: relative;
  margin-top: -60px;
  padding-top: 60px;
  background: linear-gradient(to bottom, transparent, var(--bg) 30%);
}

.gate-content {
  text-align: center;
  padding: 40px 20px;
}

.gate-icon { font-size: 36px; margin-bottom: 12px; }

.gate-content h3 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 8px;
}

.gate-content p {
  font-size: 14px;
  color: var(--text-dim);
  max-width: 400px;
  margin: 0 auto;
}

.btn-primary {
  margin-top: 16px;
  padding: 12px 32px;
  background: var(--green);
  color: #000;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  background: #16a34a;
  transform: translateY(-1px);
}

.gate-note {
  margin-top: 10px;
  font-size: 12px;
  color: var(--text-muted) !important;
}

/* === MODAL === */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 600px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
  padding: 32px;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
}

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

.modal-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
}

.modal-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  overflow: hidden;
}

.modal-avatar img { width: 100%; height: 100%; object-fit: cover; }

.modal-player-name {
  font-size: 22px;
  font-weight: 700;
}

.modal-player-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 2px;
}

.modal-section {
  margin-bottom: 20px;
}

.modal-section h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 8px;
}

.stat-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  text-align: center;
}

.stat-box .val {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 600;
}

.stat-box .lbl {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Game log mini-table */
.game-log-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.game-log-table th {
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 10px;
}

.game-log-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(30, 36, 50, 0.5);
  font-family: var(--mono);
  font-size: 12px;
}

.game-log-table tr:hover td { background: var(--bg-card-hover); }

.highlight-cell {
  color: var(--green);
  font-weight: 600;
}

/* === FOOTER === */
footer {
  border-top: 1px solid var(--border);
  margin-top: 60px;
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-muted);
}

.footer-divider {
  margin: 0 8px;
  color: var(--border);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
  .nav-inner { padding: 12px 16px; }

  .tab-bar-inner { padding: 0 12px; }
  .tab { padding: 12px 14px; font-size: 13px; }
  .tab-icon { display: none; }

  main { padding: 16px; }

  .section-header { flex-direction: column; }

  .player-card {
    grid-template-columns: 32px 1fr;
    gap: 10px;
    padding: 14px 16px;
  }

  .player-stats-row {
    grid-column: 1 / -1;
    justify-content: space-around;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    margin-top: 4px;
  }

  .matchup-card {
    grid-template-columns: 32px 1fr;
    gap: 10px;
    padding: 14px 16px;
  }

  .matchup-vs {
    grid-column: 1 / -1;
    flex-direction: row;
    padding-top: 8px;
    border-top: 1px solid var(--border);
  }

  .player-avatar { width: 38px; height: 38px; }

  .stat-pill { min-width: 40px; }
  .stat-value { font-size: 13px; }

  .footer-inner { flex-direction: column; gap: 8px; text-align: center; }

  .modal { padding: 24px 16px; }
}

@media (max-width: 480px) {
  .logo-text { font-size: 14px; letter-spacing: 2px; }
  .refresh-status .status-text { display: none; }
  .section-header h2 { font-size: 20px; }
  .controls-row { flex-direction: column; }
}

/* === MATCHUP CATEGORY FILTER === */
#matchupCategoryToggle .toggle-btn {
  padding: 8px 12px;
}

@media (max-width: 480px) {
  #matchupCategoryToggle .toggle-btn {
    padding: 7px 9px;
    font-size: 12px;
  }
}

/* Blurred premium rows */
.player-card.blurred,
.matchup-card.blurred {
  filter: blur(6px);
  pointer-events: none;
  user-select: none;
}

/* ==============================
   HOT MATCHUPS + UNDER THE RADAR
   ============================== */

.matchups-section {
  margin-bottom: 32px;
}

.section-header-inline {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}

.section-header-icon {
  font-size: 22px;
  flex-shrink: 0;
  margin-top: 1px;
}

.section-header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 0.3px;
}

.section-header-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.radar-section .section-header-title {
  color: var(--green);
}

/* ==============================
   EXPECTED STATS MINI (on card)
   ============================== */

.expected-mini {
  font-size: 12px;
  color: var(--text-dim);
  margin: 2px 0 4px;
}

.expected-mini strong {
  color: var(--green);
}

.radar-chip {
  color: var(--green) !important;
  border-color: rgba(52, 211, 153, 0.25) !important;
  background: rgba(52, 211, 153, 0.06) !important;
}

/* 2025 stats fallback badge */
.stats-badge-2025 {
  display: inline-block;
  font-size: 9px;
  font-weight: 700;
  background: rgba(251, 191, 36, 0.15);
  color: var(--amber);
  border: 1px solid rgba(251, 191, 36, 0.3);
  border-radius: 4px;
  padding: 0 4px;
  vertical-align: middle;
  letter-spacing: 0.5px;
  margin-left: 4px;
}

/* ==============================
   PLAYER MODAL — EXPECTED STATS
   ============================== */

.matchup-header-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.value-score-badge {
  font-size: 13px;
  color: var(--text-dim);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px 10px;
}

.exp-stats-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.expected-stats-grid {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.exp-stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
  min-width: 90px;
  text-align: center;
}

.exp-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 5px;
}

.exp-val {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
}

.exp-val.exp-up { color: var(--green); }
.exp-val.exp-down { color: var(--red); }

.exp-delta {
  font-size: 11px;
  font-weight: 600;
  opacity: 0.85;
  margin-left: 2px;
}

.exp-baseline {
  font-size: 10px;
  color: var(--text-dim);
  margin-top: 5px;
}

/* Key matchup drivers */
.matchup-drivers {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.driver-bullet {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  padding: 6px 10px;
  background: var(--bg-card);
  border-radius: 8px;
  border-left: 3px solid var(--green);
}

/* === SHARE BUTTON === */
.card-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.share-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 5px 10px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  min-width: 56px;
  letter-spacing: 0.3px;
}

.share-btn:hover {
  background: rgba(29, 161, 242, 0.1);
  border-color: rgba(29, 161, 242, 0.4);
  color: #1da1f2;
}

.share-btn svg {
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .share-btn span {
    display: none;
  }
  .share-btn {
    padding: 5px 7px;
    min-width: auto;
  }
}
