:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --border: #0f3460;
  --text: #e0e0e0;
  --text-muted: #8899aa;
  --accent: #e94560;
  --green: #4ecca3;
  --yellow: #f0c040;
  --blue: #5da0d0;
  --orange: #e89040;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

header {
  padding: 20px 32px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: baseline;
  gap: 16px;
  flex-wrap: wrap;
}

header h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.5px; }

nav { display: flex; gap: 12px; }
nav a {
  color: var(--blue);
  text-decoration: none;
  font-size: 13px;
}
nav a:hover { text-decoration: underline; }
nav a.active { color: var(--text); font-weight: 600; }

.header-stats {
  font-size: 13px;
  color: var(--text-muted);
  margin-left: auto;
}
.header-stats .val { color: var(--text); font-weight: 600; }

.controls {
  padding: 16px 32px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  align-items: flex-end;
}

.control-group { display: flex; flex-direction: column; gap: 4px; }

.control-group label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.controls select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 4px;
  font-size: 13px;
  min-width: 140px;
}

.view-toggle {
  display: flex;
  gap: 0;
  margin-left: auto;
}

.view-toggle button {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.view-toggle button:first-child { border-radius: 4px 0 0 4px; }
.view-toggle button:last-child { border-radius: 0 4px 4px 0; border-left: none; }

.view-toggle button.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.content { padding: 24px 32px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 2px solid var(--border);
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

th:hover { color: var(--text); }
th .sort-arrow { font-size: 10px; margin-left: 4px; color: var(--accent); }
th.sorted { color: var(--text); }

td { padding: 8px 12px; border-bottom: 1px solid var(--border); }
tr:hover { background: var(--surface); }

.pct-bar-cell { position: relative; min-width: 120px; }

.pct-bar {
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  border-radius: 3px;
  opacity: 0.2;
}

.pct-bar.strike { background: var(--accent); }
.pct-bar.ball { background: var(--blue); }
.pct-bar.inplay { background: var(--green); }

.pct-text { position: relative; z-index: 1; font-weight: 500; font-size: 12px; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.highlight { color: var(--yellow); font-weight: 600; }

.section-title {
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.section-title:first-child { margin-top: 0; }

.summary-row { background: rgba(233, 69, 96, 0.05); font-weight: 600; }
.summary-row td { border-bottom: 2px solid var(--border); }

.no-data { padding: 40px; text-align: center; color: var(--text-muted); }

/* Loading spinner */
.loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 80px 0;
}

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

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

.clickable-label { color: var(--blue); cursor: pointer; text-decoration: none; }
.clickable-label:hover { text-decoration: underline; }

.back-link {
  color: var(--blue);
  cursor: pointer;
  font-size: 13px;
  margin-bottom: 16px;
  display: inline-block;
}
.back-link:hover { text-decoration: underline; }

.stat-cards { display: flex; gap: 12px; flex-wrap: wrap; }

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px 16px;
  min-width: 110px;
}

.stat-card .card-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}

.stat-card .card-value { font-size: 20px; font-weight: 600; }

.detail-header { margin-bottom: 24px; }

.detail-header h2 { font-size: 20px; font-weight: 600; margin-bottom: 12px; }

.detail-header .subtitle {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 10px;
}

/* Player search */
.player-search {
  position: relative;
  margin-left: auto;
}

.player-search input {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  width: 200px;
}

.player-search input::placeholder { color: var(--text-muted); }

.player-search .results {
  position: absolute;
  top: 100%;
  right: 0;
  width: 260px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-top: 4px;
  z-index: 100;
  display: none;
}

.player-search .results.visible { display: block; }

.player-search .result-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.player-search .result-item:last-child { border-bottom: none; }
.player-search .result-item:hover { background: var(--bg); }

.player-search .result-team {
  color: var(--text-muted);
  font-size: 11px;
  margin-left: 6px;
}
