/* Tailwind palette */
:root {
  --bg: #09090b;            /* zinc-950 */
  --panel: #18181b;         /* zinc-900 */
  --panel-2: #27272a;       /* zinc-800 */
  --border: #27272a;        /* zinc-800 */
  --border-strong: #3f3f46; /* zinc-700 */
  --text: #f4f4f5;          /* zinc-100 */
  --muted: #a1a1aa;         /* zinc-400 */
  --accent: #34d399;        /* emerald-400 */
  --accent-2: #38bdf8;      /* sky-400 */
  --danger: #f87171;        /* red-400 */
  --warning: #fbbf24;       /* amber-400 */
  --shadow: 0 1px 0 rgba(255,255,255,0.03), 0 6px 24px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Helvetica, Arial, sans-serif;
  background:
    radial-gradient(900px 500px at 20% -10%, rgba(56,189,248,0.07), transparent 60%),
    radial-gradient(700px 420px at 110% 10%, rgba(52,211,153,0.06), transparent 60%),
    var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

header {
  max-width: 960px;
  margin: 0 auto;
  padding: 32px 16px 12px;
}
header h1 {
  margin: 0 0 4px;
  font-size: 24px;
  letter-spacing: -0.02em;
  font-weight: 600;
}
.muted { color: var(--muted); margin: 2px 0; font-size: 13px; }

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 12px 16px 56px;
  display: grid;
  gap: 16px;
}

@media (min-width: 640px) {
  header { padding: 48px 24px 16px; }
  header h1 { font-size: 28px; }
  main { padding: 16px 24px 64px; gap: 20px; }
}

/* Tooltip */
.tip {
  position: fixed;
  pointer-events: none;
  z-index: 50;
  background: #0a0a0a;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 12px;
  padding: 6px 8px;
  border-radius: 6px;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: opacity 80ms ease;
  white-space: nowrap;
  max-width: 90vw;
}
.tip.show { opacity: 1; }

/* Leaderboard */
.leaderboard {
  display: grid;
  gap: 8px;
}
.player {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.player summary {
  list-style: none;
  cursor: pointer;
  padding: 12px 14px;
  display: grid;
  gap: 8px;
}
.player summary::-webkit-details-marker { display: none; }
.player summary:hover { background: var(--panel-2); }
.player[open] summary { border-bottom: 1px solid var(--border); }

@media (min-width: 640px) {
  .player summary { padding: 14px 18px; gap: 10px; }
}

/* Row 1: rank + name + chevron */
.player-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.rank {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  flex-shrink: 0;
}
.pname {
  font-weight: 600;
  letter-spacing: -0.01em;
  font-size: 15px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chev {
  color: var(--muted);
  font-size: 14px;
  line-height: 1;
  transition: transform 150ms ease;
  flex-shrink: 0;
}
.player[open] .chev { transform: rotate(90deg); }

/* Row 2: bar + pts */
.player-bar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.bar-track {
  flex: 1;
  position: relative;
  height: 16px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
  flex-direction: row;
  min-width: 0;
}
.bar-seg {
  height: 100%;
  border-right: 1px solid rgba(0,0,0,0.4);
  transition: filter 120ms ease;
}
.bar-seg:last-child { border-right: none; }
.bar-seg:hover { filter: brightness(1.2) saturate(1.1); }
.pscore {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--accent);
  font-size: 13px;
  flex-shrink: 0;
  white-space: nowrap;
}

/* Overall multi-line chart */
.overall-chart {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 14px 12px;
  box-shadow: var(--shadow);
}
@media (min-width: 640px) {
  .overall-chart { padding: 18px 20px 14px; }
}
.overall-chart .chart-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.overall-chart svg {
  width: 100%;
  height: auto;
  display: block;
}
.overall-chart svg .grid { stroke: var(--border-strong); stroke-width: 1; stroke-dasharray: 2 3; }
.overall-chart svg .axis-label {
  fill: var(--muted);
  font-size: 12px;
  font-family: ui-monospace, monospace;
}
.overall-chart svg .pline { fill: none; stroke-width: 2.5; stroke-linejoin: round; stroke-linecap: round; }
.overall-chart svg .pdot { stroke-width: 0; }
.overall-chart .legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
  font-size: 12px;
}
.overall-chart .legend .item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
}
.overall-chart .legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}
.overall-chart .empty {
  color: var(--muted);
  font-size: 13px;
  padding: 14px 0 4px;
}

/* History sparkline (per-player expansion) */
.history {
  padding: 12px 14px 6px;
  border-top: 1px solid var(--border);
}
@media (min-width: 640px) {
  .history { padding: 14px 18px 6px; }
}
.history-header {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.history svg {
  width: 100%;
  height: auto;
  display: block;
}
.history svg .line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.history svg .area { fill: var(--accent); opacity: 0.12; }
.history svg .dot { fill: var(--accent); }
.history-empty { color: var(--muted); font-size: 12px; padding: 4px 0; }

/* Movie list */
.movies { padding: 4px 0; }
.movie {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "title pts"
    "meta meta";
  align-items: center;
  gap: 4px 10px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.movie:first-child { border-top: none; }
.movie .m-title { grid-area: title; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.movie .m-pts { grid-area: pts; }
.movie .m-meta {
  grid-area: meta;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.movie a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px dashed transparent;
}
.movie a:hover { border-bottom-color: var(--muted); }
.rdate {
  color: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.movie .gross {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.movie .pts {
  color: var(--accent-2);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
}

@media (min-width: 640px) {
  .movie {
    grid-template-columns: 1fr auto auto auto;
    grid-template-areas: "title meta gross pts";
    padding: 10px 18px;
    gap: 12px;
  }
  .movie .m-meta { flex-wrap: nowrap; }
  .movie .gross { font-size: 13px; }
}

/* Status pills (issues only) */
.pill {
  display: inline-block;
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
  background: var(--panel-2);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  white-space: nowrap;
}
.pill.unreleased { color: #082f49; background: var(--accent-2); border-color: var(--accent-2); }
.pill.error      { color: #450a0a; background: var(--danger);  border-color: var(--danger);  }
.pill.no_url, .pill.never { color: var(--muted); }

/* Status panel */
.status-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 8px;
}
@media (min-width: 640px) {
  .status-panel { padding: 14px 18px; gap: 10px; }
}
.status-panel:empty { display: none; }
.status-errors {
  display: grid;
  gap: 4px;
  font-size: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-top: 4px;
}
.status-errors .err-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 4px 0;
  border-top: 1px solid var(--border);
}
.status-errors .err-row:first-child { border-top: none; }
.status-errors .err-title { color: var(--text); }
.status-errors .err-msg { color: var(--danger); word-break: break-word; }
@media (min-width: 640px) {
  .status-errors .err-row { grid-template-columns: auto 1fr; gap: 10px; }
}
details.status-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 12px;
  list-style: none;
}
details.status-details summary::-webkit-details-marker { display: none; }
details.status-details summary::before { content: "▸ "; }
details.status-details[open] summary::before { content: "▾ "; }
