/* ---------- Themes: every color comes from these tokens. Switch with <html data-theme="..."> ---------- */

[data-theme="midnight"] {
    color-scheme: dark;
    --bg: #0b0f17;
    --bg-glow: radial-gradient(1200px 500px at 15% -10%, rgba(244, 63, 94, .10), transparent 60%),
               radial-gradient(900px 400px at 100% 0%, rgba(99, 102, 241, .10), transparent 60%);
    --surface: #121826;
    --surface-2: #182033;
    --line: #232c3f;
    --text: #e6e9f0;
    --muted: #8b95a9;
    --accent: #fb7185;
    --accent-soft: rgba(251, 113, 133, .14);
    --header-bg: rgba(11, 15, 23, .72);
    --header-text: #e6e9f0;
    --header-line: #1c2434;
    --th-bg: #161d2d;
    --th-text: #8b95a9;
    --row-hover: #172036;
    --me-bg: rgba(204, 255, 51, .12);
    --me-text: #e9ffad;
    --me-bar: #ccff33;
    --gold: #fbbf24;
    --silver: #cbd5e1;
    --bronze: #f59e6b;
    --chart-1: #fb7185;
    --chart-2: #818cf8;
    --chart-3: #34d399;
    --chart-4: #fbbf24;
    --chart-grid: rgba(139, 149, 169, .15);
    --radius: 12px;
    --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 8px 24px rgba(0, 0, 0, .25);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[data-theme="felt"] {
    color-scheme: dark;
    --bg: #07190f;
    --bg-glow: radial-gradient(1000px 600px at 50% -20%, rgba(46, 160, 90, .22), transparent 65%);
    --surface: #0d2618;
    --surface-2: #11301f;
    --line: #1c4229;
    --text: #eef5ea;
    --muted: #93b39c;
    --accent: #e3b341;
    --accent-soft: rgba(227, 179, 65, .14);
    --header-bg: rgba(7, 25, 15, .78);
    --header-text: #eef5ea;
    --header-line: #163a24;
    --th-bg: #0f2c1c;
    --th-text: #c9a94a;
    --row-hover: #12331f;
    --me-bg: rgba(204, 255, 51, .13);
    --me-text: #eaffb0;
    --me-bar: #ccff33;
    --gold: #e3b341;
    --silver: #d6dccf;
    --bronze: #d08a52;
    --chart-1: #e3b341;
    --chart-2: #f2f2ee;
    --chart-3: #e05a47;
    --chart-4: #5fb3e6;
    --chart-grid: rgba(147, 179, 156, .15);
    --radius: 14px;
    --shadow: 0 10px 30px rgba(0, 0, 0, .35);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

[data-theme="slate"] {
    color-scheme: light;
    --bg: #f5f7fb;
    --bg-glow: none;
    --surface: #ffffff;
    --surface-2: #f1f4f9;
    --line: #e3e8f0;
    --text: #0f172a;
    --muted: #64748b;
    --accent: #e11d48;
    --accent-soft: rgba(225, 29, 72, .08);
    --header-bg: rgba(255, 255, 255, .8);
    --header-text: #0f172a;
    --header-line: #e3e8f0;
    --th-bg: #f8fafc;
    --th-text: #64748b;
    --row-hover: #f8fafc;
    --me-bg: #ccff33;
    --me-text: #1a2e05;
    --me-bar: #84cc16;
    --gold: #d97706;
    --silver: #64748b;
    --bronze: #b45309;
    --chart-1: #e11d48;
    --chart-2: #4f46e5;
    --chart-3: #059669;
    --chart-4: #d97706;
    --chart-grid: rgba(100, 116, 139, .15);
    --radius: 12px;
    --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .04);
    --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

:root,
[data-theme="classic"] {
    color-scheme: light;
    --bg: #f6f6f4;
    --bg-glow: none;
    --surface: #ffffff;
    --surface-2: #fafaf6;
    --line: #e4e4e0;
    --text: #222222;
    --muted: #666666;
    --accent: #8b0000;
    --accent-soft: rgba(139, 0, 0, .07);
    --header-bg: #8b0000;
    --header-text: #ffffff;
    --header-line: #8b0000;
    --th-bg: #8b0000;
    --th-text: #ffffff;
    --row-hover: #fafaf6;
    --me-bg: #ccff33;
    --me-text: #222222;
    --me-bar: #ccff33;
    --gold: #8b0000;
    --silver: #8b0000;
    --bronze: #8b0000;
    --chart-1: #8b0000;
    --chart-2: #1f6fb2;
    --chart-3: #2e8b57;
    --chart-4: #b8860b;
    --chart-grid: rgba(0, 0, 0, .08);
    --radius: 6px;
    --shadow: none;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---------- Layout ---------- */

* { box-sizing: border-box; }

body {
    margin: 0;
    font: 15px/1.5 var(--font);
    font-feature-settings: "cv11", "ss01";
    background: var(--bg-glow), var(--bg);
    background-attachment: fixed;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.wrap { max-width: 1040px; margin: 0 auto; padding: 0 16px; }

.site-header {
    position: sticky; top: 0; z-index: 10;
    background: var(--header-bg);
    color: var(--header-text);
    border-bottom: 1px solid var(--header-line);
    backdrop-filter: saturate(160%) blur(12px);
    -webkit-backdrop-filter: saturate(160%) blur(12px);
}
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 60px; flex-wrap: wrap; }
.brand { color: var(--header-text); font-weight: 700; text-decoration: none; font-size: 17px; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.brand .logo { width: 26px; height: 26px; }
.header-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.site-header nav { display: flex; gap: 2px; }
.site-header nav a { color: var(--header-text); text-decoration: none; padding: 6px 12px; border-radius: 999px; opacity: .72; font-weight: 500; font-size: 14px; }
.site-header nav a:hover { opacity: 1; }
.site-header nav a.active { opacity: 1; background: var(--accent-soft); color: var(--accent); }
[data-theme="classic"] .site-header nav a.active,
[data-theme="classic"] .site-header nav a:hover { background: rgba(0, 0, 0, .2); color: #fff; }

.theme-picker { font: inherit; font-size: 13px; color: var(--header-text); background: transparent; border: 1px solid var(--header-line); border-radius: 999px; padding: 4px 10px; cursor: pointer; }
[data-theme="classic"] .theme-picker { border-color: rgba(255, 255, 255, .4); }
.theme-picker option { color: #000; background: #fff; }

main.wrap { padding: 32px 16px 48px; }
h1 { margin: 0 0 4px; font-size: 30px; letter-spacing: -.02em; line-height: 1.2; }
h2 { margin: 36px 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.sub { margin: 0 0 22px; color: var(--muted); }
.empty { color: var(--muted); }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 4px; }

/* ---------- Filters ---------- */

.filters { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 20px; }
.filters label { display: flex; flex-direction: column; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.filters select {
    margin-top: 6px; font: inherit; font-size: 14px; text-transform: none; letter-spacing: 0; font-weight: 400;
    color: var(--text); padding: 9px 12px; border: 1px solid var(--line); border-radius: calc(var(--radius) - 4px);
    background: var(--surface); min-width: 190px; max-width: 100%; cursor: pointer;
}
.filters select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }

/* ---------- Tables ---------- */

.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table { width: 100%; border-collapse: collapse; text-align: center; font-variant-numeric: tabular-nums; }
th { background: var(--th-bg); color: var(--th-text); font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .07em; padding: 12px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-top: 1px solid var(--line); }
tbody tr:first-child td { border-top: 0; }
.left { text-align: left; }
.strong { font-weight: 700; }
td a { color: var(--text); text-decoration: none; font-weight: 500; }
td a:hover { color: var(--accent); }
tbody tr { transition: background-color .12s; }
tbody tr:hover { background: var(--row-hover); }

tr.me, tr.me:hover { background: var(--me-bg); color: var(--me-text); box-shadow: inset 3px 0 0 var(--me-bar); }
tr.me td a { color: var(--me-text); font-weight: 700; }
tr.win td.strong { color: var(--accent); }

/* Top three: medal-coloured rank */
.rank { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 999px; font-weight: 600; }
.podium-1 .rank { background: color-mix(in srgb, var(--gold) 18%, transparent); color: var(--gold); }
.podium-2 .rank { background: color-mix(in srgb, var(--silver) 18%, transparent); color: var(--silver); }
.podium-3 .rank { background: color-mix(in srgb, var(--bronze) 18%, transparent); color: var(--bronze); }
[data-theme="classic"] .rank { background: none !important; color: inherit !important; font-weight: 400; }

/* ---------- Player page ---------- */

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin: 12px 0 8px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 16px; box-shadow: var(--shadow); }
.stat .num { display: block; font-size: 30px; font-weight: 700; letter-spacing: -.02em; color: var(--text); font-variant-numeric: tabular-nums; }
.stat .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .07em; font-weight: 600; }
.stat:first-child .num { color: var(--accent); }
[data-theme="classic"] .stat { text-align: center; }
[data-theme="classic"] .stat .num { color: var(--accent); }

.chart { position: relative; height: 320px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }

.site-footer { color: var(--muted); font-size: 13px; padding: 24px 0 36px; border-top: 1px solid var(--line); }
.site-footer a { color: var(--muted); }

@media (max-width: 640px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .filters select { min-width: 0; width: 100%; }
    .filters label { flex: 1 1 100%; }
    h1 { font-size: 24px; }
    .site-header .wrap { padding-top: 8px; padding-bottom: 8px; }
}

/* ---------- Classic: restores the original design exactly (only the theme picker is new) ---------- */

[data-theme="classic"] body { font-feature-settings: normal; -webkit-font-smoothing: auto; }
[data-theme="classic"] .wrap { max-width: 1000px; }

[data-theme="classic"] .site-header { position: static; border-bottom: 0; backdrop-filter: none; -webkit-backdrop-filter: none; }
[data-theme="classic"] .site-header .wrap { gap: 16px; min-height: 56px; }
[data-theme="classic"] .brand { font-size: 18px; letter-spacing: normal; }
[data-theme="classic"] .brand .logo { display: none; }
[data-theme="classic"] .site-header nav { display: block; }
[data-theme="classic"] .site-header nav a { padding: 6px 10px; border-radius: 4px; opacity: .85; font-weight: normal; font-size: inherit; }
[data-theme="classic"] .site-header nav a:hover,
[data-theme="classic"] .site-header nav a.active { background: #6a0000; color: #fff; opacity: 1; }

[data-theme="classic"] main.wrap { padding: 0 16px; }
[data-theme="classic"] h1 { margin: 0 0 2px; font-size: 26px; letter-spacing: normal; line-height: inherit; }
[data-theme="classic"] h2 { margin: 32px 0 10px; font-size: 18px; text-transform: none; letter-spacing: normal; color: inherit; font-weight: bold; }
[data-theme="classic"] .sub { margin: 0 0 18px; }

[data-theme="classic"] .filters { margin-bottom: 18px; }
[data-theme="classic"] .filters label { font-size: 12px; letter-spacing: .03em; font-weight: normal; }
[data-theme="classic"] .filters select { margin-top: 4px; padding: 7px 10px; border-radius: 4px; min-width: 180px; font-size: inherit; }
[data-theme="classic"] .filters select:focus { outline: revert; border-color: var(--line); }

[data-theme="classic"] table { font-variant-numeric: normal; }
[data-theme="classic"] th { font-size: 12px; font-weight: bold; letter-spacing: .04em; padding: 10px 8px; border-bottom: 0; white-space: normal; }
[data-theme="classic"] td { padding: 8px; }
[data-theme="classic"] tbody tr:first-child td { border-top: 1px solid var(--line); }
[data-theme="classic"] tbody tr { transition: none; }
[data-theme="classic"] td a { color: var(--accent); font-weight: normal; }
[data-theme="classic"] td a:hover { color: var(--accent); text-decoration: underline; }
[data-theme="classic"] tr.me { color: inherit; box-shadow: none; }
[data-theme="classic"] tr.me td a { color: var(--accent); font-weight: normal; }
[data-theme="classic"] .rank { display: inline; min-width: 0; height: auto; border-radius: 0; font-weight: normal; }

[data-theme="classic"] .stats { margin: 8px 0; }
[data-theme="classic"] .stat { padding: 14px; text-align: center; }
[data-theme="classic"] .stat .num { font-size: 26px; letter-spacing: normal; font-variant-numeric: normal; color: var(--accent); }
[data-theme="classic"] .stat .lbl { font-size: 12px; letter-spacing: .04em; font-weight: normal; }

[data-theme="classic"] .chart { height: 300px; padding: 12px; }

[data-theme="classic"] .site-footer { padding: 20px 0 32px; }
[data-theme="classic"] .site-footer a { color: var(--accent); }
