:root {
  --bg: #fafaf9;
  --bg-card: #ffffff;
  --border: #e7e5e4;
  --text: #1c1917;
  --text-muted: #78716c;
  --accent: #ea580c;        /* Raver orange */
  --accent-dark: #c2410c;
  --accent-light: #fed7aa;
  --good: #16a34a;
  --bad: #dc2626;
  --raver-row: #fff7ed;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

.container { max-width: 1200px; margin: 0 auto; padding: 16px 24px; }

header.site {
  background: var(--text);
  color: white;
  padding: 16px 24px;
}
header.site .container {
  display: flex; align-items: center; gap: 16px;
  padding: 0;
}
header.site h1 {
  font-size: 18px; font-weight: 700; margin: 0;
  display: flex; align-items: center; gap: 12px;
}
header.site h1 .logo {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  background: var(--accent); color: white;
  border-radius: 50%; font-weight: 800;
  letter-spacing: -1px;
}
header.site h1 a { color: white; }
header.site nav { display: flex; gap: 16px; margin-left: auto; }
header.site nav a { color: #d6d3d1; }
header.site nav a:hover { color: white; text-decoration: none; }

h2 { font-size: 22px; margin: 24px 0 12px; font-weight: 700; }
h3 { font-size: 16px; margin: 20px 0 8px; font-weight: 600; }
h4 { font-size: 14px; margin: 16px 0 4px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

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

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

/* Crumbs */
.crumbs { font-size: 12px; color: var(--text-muted); margin: 12px 0; }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--text); }

/* Categories grid (landing) */
.cat-grid {
  display: grid; gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.cat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px; padding: 16px;
  display: block; color: inherit;
  transition: border-color 120ms, transform 120ms;
}
.cat-card:hover {
  border-color: var(--accent); text-decoration: none;
  transform: translateY(-1px);
}
.cat-card .cat-name { font-weight: 700; font-size: 15px; margin-bottom: 4px; }
.cat-card .comp { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }
.cat-card .deleg { color: var(--text-muted); font-size: 11px; margin-bottom: 8px; }
.cat-card .stats { display: flex; gap: 12px; align-items: baseline; }
.cat-card .stat-num { font-size: 22px; font-weight: 700; color: var(--accent); }
.cat-card .stat-detail { font-size: 11px; color: var(--text-muted); }
.cat-card .pos { background: var(--accent-light); color: var(--accent-dark);
                  border-radius: 4px; padding: 2px 6px; font-weight: 600; font-size: 11px; }

/* Tables */
table {
  width: 100%; border-collapse: collapse; font-size: 13px;
  background: var(--bg-card);
}
th, td {
  text-align: left; padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
th { background: #f5f5f4; font-weight: 600; font-size: 11px;
     text-transform: uppercase; letter-spacing: 0.3px; color: var(--text-muted);
     position: sticky; top: 0; z-index: 1; }
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--accent-dark); background: #fafaf9; }
th.sorted { color: var(--accent-dark); }
th.sorted::after { content: " ▾"; }
th.sorted.asc::after { content: " ▴"; }

tr.raver { background: var(--raver-row); }
tr.raver td { font-weight: 600; }
tr:hover { background: #f5f5f4; }
tr.raver:hover { background: #fde9d4; }

td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
td.player-cell { display: flex; align-items: center; gap: 8px; }

.escudo {
  width: 24px; height: 24px; border-radius: 4px;
  object-fit: contain; background: #fafaf9;
  flex-shrink: 0;
}
.escudo.placeholder {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--border); color: var(--text-muted);
  font-size: 9px; font-weight: 700; letter-spacing: 0;
  border-radius: 4px;
}
.escudo-large {
  width: 56px; height: 56px; border-radius: 8px;
  object-fit: contain; background: white; padding: 4px;
  border: 1px solid var(--border);
}
.escudo-large.placeholder {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--border); color: var(--text-muted);
  font-size: 18px; font-weight: 700;
}

.foto {
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; background: #fafaf9;
  flex-shrink: 0;
}
.foto.placeholder {
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent-light); color: var(--accent-dark);
  font-size: 11px; font-weight: 700;
  border-radius: 50%;
}

/* Game list */
.game {
  display: grid;
  grid-template-columns: 60px 1fr auto 1fr 80px;
  align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.game:hover { background: #f5f5f4; }
.game.future { opacity: 0.85; }
.game .jornada { color: var(--text-muted); font-size: 11px; text-align: center; }
.game .team { display: flex; align-items: center; gap: 8px; min-width: 0; }
.game .team.home { justify-content: flex-end; }
.game .team .name { overflow: hidden; text-overflow: ellipsis; }
.game .score {
  font-weight: 700; font-variant-numeric: tabular-nums;
  font-size: 16px; min-width: 64px; text-align: center;
}
.game .score.future { color: var(--text-muted); font-size: 12px; font-weight: 500; }
.game .score .vs { color: var(--text-muted); padding: 0 4px; font-weight: 400; }
.game .score .winning { color: var(--good); }
.game .date { color: var(--text-muted); font-size: 11px; text-align: right; }

/* Filter / select */
.filter-row {
  display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
select, input.text {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: white; font: inherit;
}

/* Court / shot chart */
.court-wrap { display: flex; gap: 16px; flex-wrap: wrap; }
.court-block { flex: 1; min-width: 280px; }
.court-block h4 { margin-top: 0; }
svg.court { width: 100%; max-width: 320px; height: auto; display: block;
             background: #fff7ed; border-radius: 8px; }
.court-bg { fill: transparent; }
.court-line { stroke: var(--accent-dark); stroke-width: 1; fill: none; }
.court-paint { fill: rgba(234, 88, 12, 0.06); }
.court-rim { stroke: #b45309; stroke-width: 2; }
.court-backboard { stroke: #1c1917; stroke-width: 2; }
.shot { stroke-width: 0.5; }
.shot.made { fill: var(--good); stroke: #14532d; }
.shot.missed { fill: var(--bad); stroke: #7f1d1d; opacity: 0.7; }

.zone { transition: fill 200ms; }
.zone-text { font-size: 9px; font-weight: 700; fill: white;
              paint-order: stroke; stroke: rgba(0,0,0,0.55); stroke-width: 2px; }
.zone-pct { font-size: 8px; font-weight: 600; fill: white;
             paint-order: stroke; stroke: rgba(0,0,0,0.55); stroke-width: 2px; }

.legend { display: flex; gap: 12px; font-size: 11px; margin-top: 8px; flex-wrap: wrap; }
.legend .key { display: inline-flex; align-items: center; gap: 4px; }
.legend .dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.legend .dot.made { background: var(--good); }
.legend .dot.missed { background: var(--bad); }

/* Header section for team/player pages */
.detail-header {
  display: flex; gap: 16px; align-items: center;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px; padding: 16px; margin-bottom: 16px;
}
.detail-header .name { font-size: 22px; font-weight: 700; margin-bottom: 4px; }
.detail-header .sub { color: var(--text-muted); font-size: 13px; }
.detail-header .pill {
  display: inline-block;
  background: var(--accent-light); color: var(--accent-dark);
  padding: 2px 8px; border-radius: 4px; font-weight: 600; font-size: 11px;
  margin-right: 4px;
}
.summary-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px; margin-left: auto; padding-left: 16px;
}
.summary-grid .stat { text-align: center; }
.summary-grid .stat .num { font-size: 22px; font-weight: 700; color: var(--accent); }
.summary-grid .stat .lbl { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 12px; }
.tabs button {
  background: none; border: 0; padding: 10px 16px; cursor: pointer;
  font: inherit; color: var(--text-muted);
  border-bottom: 2px solid transparent;
}
.tabs button.active { color: var(--accent-dark); border-bottom-color: var(--accent); font-weight: 600; }
.tabs button:hover { color: var(--text); }

/* Loading + errors */
.loading { padding: 40px; text-align: center; color: var(--text-muted); }
.error { padding: 16px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px;
          color: var(--bad); }

/* Make tables scrollable horizontally on small screens */
.table-wrap { overflow-x: auto; border-radius: 8px; border: 1px solid var(--border); }
.table-wrap table { border: 0; }
.table-wrap th { border-top: 0; }
.table-wrap td:first-child, .table-wrap th:first-child { padding-left: 16px; }
.table-wrap td:last-child, .table-wrap th:last-child { padding-right: 16px; }

footer.site {
  background: var(--text);
  color: #a8a29e;
  padding: 16px 24px;
  margin-top: 32px;
  font-size: 11px;
}
footer.site .container {
  display: flex; gap: 16px; align-items: center; flex-wrap: wrap;
  padding: 0;
}
footer.site .container > * { line-height: 1.5; }
footer.site a { color: #d6d3d1; }
footer.site .freshness { margin-left: auto; }
footer.site .freshness .stale { color: #fbbf24; }

@media (max-width: 700px) {
  .detail-header { flex-wrap: wrap; }
  .summary-grid { width: 100%; padding-left: 0; }
  .game { grid-template-columns: 1fr 80px 1fr; gap: 4px; padding: 8px; }
  .game .jornada, .game .date { display: none; }
}
