:root {
  --bg: #f7f7f5;
  --card-bg: #ffffff;
  --text: #1a1a1a;
  --text-muted: #6b6b6b;
  --border: #e3e2de;
  --accent: #b45309;

  --orange: #f97316;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --empty: #d9d9d4;

  --court-line: #3a3a3a;
  --court-wood: #f1e4c7;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16161a;
    --card-bg: #1f1f24;
    --text: #eaeaea;
    --text-muted: #9a9a9a;
    --border: #2e2e34;
    --court-line: #cfcfcf;
    --court-wood: #2a2620;
    --empty: #3a3a3f;
  }
}

:root[data-theme="dark"] {
  --bg: #16161a;
  --card-bg: #1f1f24;
  --text: #eaeaea;
  --text-muted: #9a9a9a;
  --border: #2e2e34;
  --court-line: #cfcfcf;
  --court-wood: #2a2620;
  --empty: #3a3a3f;
}

* { box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}

.topbar h1 { margin: 0; font-size: 1.3rem; }

.topbar-controls { display: flex; align-items: center; gap: 8px; }

select {
  font-size: 1rem;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card-bg);
  color: var(--text);
}

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

.card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.card-header h2 { margin: 0; font-size: 1.05rem; }

.subtle { color: var(--text-muted); font-weight: normal; font-size: 0.85rem; }

.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 0.8rem; color: var(--text-muted); }

.legend-item { display: inline-flex; align-items: center; gap: 4px; }

.swatch { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.swatch.orange { background: var(--orange); }
.swatch.green { background: var(--green); }
.swatch.yellow { background: var(--yellow); }
.swatch.red { background: var(--red); }

#court-wrap { max-width: 460px; margin: 0 auto; }

.court-svg { width: 100%; height: auto; background: var(--court-wood); border-radius: 8px; }

.court-lines rect,
.court-lines circle,
.court-lines path,
.court-lines line {
  stroke: var(--court-line);
  stroke-width: 2;
  fill: none;
}

.spot-circle { stroke: var(--court-line); stroke-width: 1.5; }
.spot-empty { fill: var(--empty); opacity: 0.6; }
.spot-orange { fill: var(--orange); }
.spot-green { fill: var(--green); }
.spot-yellow { fill: var(--yellow); }
.spot-red { fill: var(--red); }

.spot-name {
  font-size: 10px;
  fill: var(--text);
  font-weight: 600;
  paint-order: stroke;
  stroke: var(--card-bg);
  stroke-width: 3px;
}

.spot-pct {
  font-size: 12px;
  font-weight: 700;
  fill: var(--text);
  paint-order: stroke;
  stroke: var(--card-bg);
  stroke-width: 3px;
}

.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 0.95rem; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); }
th { color: var(--text-muted); font-weight: 600; font-size: 0.85rem; }

.pct-cell { font-weight: 700; border-radius: 6px; padding: 4px 8px; display: inline-block; color: #1a1a1a; }
.pct-orange { background: var(--orange); }
.pct-green { background: var(--green); }
.pct-yellow { background: var(--yellow); }
.pct-red { background: var(--red); color: #fff; }

.stat-cards { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-card { flex: 1; min-width: 180px; text-align: center; }
.stat-label { color: var(--text-muted); font-size: 0.85rem; margin-bottom: 6px; }
.stat-value { font-size: 1.8rem; font-weight: 700; }
.stat-pct { font-size: 1.1rem; margin-top: 4px; }

.updated-line { text-align: center; color: var(--text-muted); font-size: 0.8rem; }

.error-banner {
  background: var(--red);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
}
