:root {
    --bg: #0c1224;
    --bg-panel: #11182e;
    --card: #0f172a;
    --border: rgba(255, 255, 255, 0.08);
    --text: #e8edf7;
    --muted: #9fb3d1;
    --accent: #6dd3a6;
    --accent-strong: #4cd28a;
    --warn: #f4c363;
    --danger: #ff6b6b;
    --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
    --radius: 16px;
    --radius-sm: 10px;
    --gutter: 1.25rem;
    --max-width: 1320px;
}

* {
    box-sizing: border-box;
}

body {
    font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
    background: radial-gradient(circle at 10% 20%, rgba(77, 210, 138, 0.08), transparent 20%),
        radial-gradient(circle at 80% 10%, rgba(100, 181, 246, 0.15), transparent 22%),
        radial-gradient(circle at 30% 80%, rgba(244, 195, 99, 0.08), transparent 18%),
        var(--bg);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
}

.site-nav {
    position: sticky;
    top: 0;
    z-index: 3;
    backdrop-filter: blur(8px);
    background: rgba(12, 18, 36, 0.9);
    border-bottom: 1px solid var(--border);
}

.site-nav__inner {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 0.85rem var(--gutter);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.nav-logo {
    font-weight: 800;
    color: #f7f9ff;
    text-decoration: none;
    letter-spacing: 0.01em;
}

.site-nav__links {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.site-nav__links a {
    color: var(--muted);
    text-decoration: none;
    font-weight: 700;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    transition: color 0.12s ease, background 0.12s ease, border 0.12s ease;
    border: 1px solid transparent;
}

.site-nav__links a:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border);
}

.site-nav__links .active {
    color: #0b1525;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    border: none;
}

main {
    max-width: var(--max-width);
    margin: 1.5rem auto 3rem;
    padding: 0 var(--gutter);
    position: relative;
    z-index: 1;
}

h1,
h2,
h3,
h4 {
    margin: 0;
    color: #f7f9ff;
}

p {
    margin: 0 0 0.35rem;
    color: var(--muted);
}

header.hero {
    position: relative;
    overflow: hidden;
    background: #060a17;
    border-bottom: 1px solid var(--border);
}

.banner-image {
    display: block;
    width: 100%;
    height: auto;
    object-fit: contain;
    max-height: 420px;
    filter: saturate(1.05);
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.12em;
    font-weight: 700;
    font-size: 0.8rem;
    color: var(--accent);
    margin: 0;
}

.btn {
    border: 1px solid var(--border);
    color: var(--text);
    padding: 0.85rem 1.2rem;
    border-radius: 999px;
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease, background 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
}

.btn.primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #08121f;
    border: none;
    box-shadow: var(--shadow);
}

.btn.primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 18px 40px rgba(108, 211, 166, 0.35);
}

.btn.ghost {
    background: rgba(255, 255, 255, 0.04);
}

.btn.ghost:hover {
    border-color: rgba(255, 255, 255, 0.25);
}

.panel {
    background: linear-gradient(180deg, rgba(16, 25, 48, 0.85), rgba(11, 17, 34, 0.92));
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
    backdrop-filter: blur(10px);
}

.panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.panel-grid {
    display: grid;
    grid-template-columns: 5fr 6fr;
    gap: 1.25rem;
    margin-top: 1.5rem;
}

.panel-grid.two-up {
    grid-template-columns: 1fr 1fr;
}

.quick-links {
    margin-top: 0.5rem;
}

.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
}

.link-card {
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.link-card:hover {
    border-color: rgba(109, 211, 166, 0.5);
    transform: translateY(-2px);
    background: rgba(109, 211, 166, 0.06);
}

.help-copy h3 {
    margin-top: 1.25rem;
}

.help-copy pre {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    overflow: auto;
}

.help-copy code {
    color: #b6d6ff;
}

.help-copy ul {
    margin: 0.5rem 0 0.75rem;
    padding-left: 1.25rem;
    color: var(--muted);
}

.help-copy ul li {
    margin: 0.4rem 0;
}

@media (max-width: 900px) {
    main {
        margin-top: 1rem;
    }
    .panel-grid,
    .panel-grid.two-up {
        grid-template-columns: 1fr;
    }
}

.card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

@media (max-width: 700px) {
    .actions {
        grid-template-columns: 1fr;
    }
}

label {
    display: block;
    font-size: 0.9rem;
    color: var(--muted);
    margin-top: 0.5rem;
}

input,
select,
button {
    width: 100%;
    padding: 0.8rem;
    margin-top: 0.35rem;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
    color: var(--text);
    font-size: 1rem;
}

select {
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

input:focus,
select:focus {
    outline: 2px solid rgba(109, 211, 166, 0.6);
}

button {
    border: none;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #08121f;
    font-weight: 800;
    letter-spacing: 0.01em;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(109, 211, 166, 0.2);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 30px rgba(109, 211, 166, 0.3);
}

.btn-danger,
button.btn-danger {
    background: linear-gradient(135deg, #ff8f8f, var(--danger));
    color: #2a0b0b;
    box-shadow: 0 12px 30px rgba(255, 107, 107, 0.25);
}

small,
.help-text {
    color: var(--muted);
    display: block;
    margin-top: 0.35rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-stack {
    display: grid;
    grid-template-columns: 2fr auto;
    gap: 0.6rem;
}

@media (max-width: 640px) {
    .input-stack {
        grid-template-columns: 1fr;
    }
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.75rem;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

table thead {
    background: rgba(255, 255, 255, 0.03);
}

table th,
table td {
    padding: 0.6rem 0.65rem;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

table tbody tr:hover {
    background: rgba(109, 211, 166, 0.06);
}

.details-row td {
    background: rgba(255, 255, 255, 0.02);
}

.player-details p {
    margin: 0.2rem 0;
}

.player-row {
    cursor: pointer;
}

.details-row {
    transition: opacity 0.2s ease;
}

#games-results-view table,
#games-live-view table,
#history-list table {
    margin-top: 0;
}

#games-results-view tbody tr:nth-child(odd),
#games-live-view tbody tr:nth-child(odd),
#history-list tbody tr:nth-child(odd) {
    background: rgba(255, 255, 255, 0.02);
}

.status-win {
    color: var(--accent);
    font-weight: 800;
}

.status-loss {
    color: #f28b82;
}

.status-draw {
    color: var(--warn);
    font-weight: 700;
}

.status-warn {
    color: var(--warn);
    font-weight: 800;
    margin-left: 0.35rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 700;
    border: 1px solid var(--border);
}

.chip--success {
    background: rgba(109, 211, 166, 0.2);
    color: var(--accent);
    border-color: rgba(109, 211, 166, 0.45);
}

.chip--info {
    background: rgba(100, 181, 246, 0.2);
    color: #b6d6ff;
    border-color: rgba(100, 181, 246, 0.35);
}

.chip--accent {
    background: rgba(109, 211, 166, 0.18);
    color: var(--accent);
    border-color: rgba(109, 211, 166, 0.35);
}

.chip--danger {
    background: rgba(255, 107, 107, 0.16);
    color: #ff9b9b;
    border-color: rgba(255, 107, 107, 0.35);
}

details {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
}

details summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: var(--text);
    font-weight: 700;
}

details summary::-webkit-details-marker {
    display: none;
}

.summary-pill {
    background: rgba(255, 255, 255, 0.06);
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    color: var(--muted);
    font-size: 0.85rem;
}

#history-list {
    margin-top: 0.75rem;
}

#history-list table td,
#games-results-view table td,
#games-live-view table td {
    font-weight: 600;
}

#history-list table td a,
#games-results-view table td a,
#games-live-view table td a {
    color: var(--accent);
    font-weight: 700;
}

.inline-note {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    color: var(--muted);
    font-size: 0.9rem;
}

/* --- Segmented Control --- */

.seg-control {
    display: inline-flex;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}

.seg-control__btn {
    all: unset;
    padding: 0.4rem 1rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--muted);
    cursor: pointer;
    transition: color 0.12s ease, background 0.12s ease;
    width: auto;
    box-shadow: none;
}

.seg-control__btn:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.06);
    transform: none;
    box-shadow: none;
}

.seg-control__btn.active {
    color: #0b1525;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    box-shadow: none;
    transform: none;
}

/* --- Rank Change Indicators --- */

.rank-up {
    color: var(--accent);
    font-weight: 700;
}

.rank-down {
    color: var(--danger);
    font-weight: 700;
}

.rank-same {
    color: var(--muted);
}

.rank-new {
    color: var(--warn);
    font-weight: 700;
    font-size: 0.8rem;
}

/* --- Streak Indicators --- */

.streak-win {
    color: var(--accent);
    font-weight: 700;
}

.streak-loss {
    color: var(--danger);
    font-weight: 700;
}

.streak-none {
    color: var(--muted);
}

/* --- ELO Change Inline --- */

.elo-change {
    font-size: 0.75rem;
    font-weight: 600;
}

.elo-change--pos {
    color: var(--accent);
}

.elo-change--neg {
    color: var(--danger);
}

/* --- Pagination --- */

.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    padding: 0.5rem 0;
}

.pagination__btn {
    all: unset;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--accent);
    cursor: pointer;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    transition: background 0.12s ease, border-color 0.12s ease;
    width: auto;
    box-shadow: none;
}

.pagination__btn:hover:not(:disabled) {
    background: rgba(109, 211, 166, 0.1);
    border-color: rgba(109, 211, 166, 0.4);
    transform: none;
    box-shadow: none;
}

.pagination__btn:disabled {
    opacity: 0.35;
    cursor: default;
    transform: none;
    box-shadow: none;
}

.pagination__info {
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
}

/* --- Template Grid & Cards --- */

.template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
}

.template-card {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.25rem 1rem;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-weight: 700;
    transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
    cursor: pointer;
}

.template-card:hover {
    border-color: rgba(109, 211, 166, 0.5);
    transform: translateY(-2px);
    background: rgba(109, 211, 166, 0.06);
}

/* --- Expandable nested rows (template detail) --- */

.nested-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    background: transparent;
    border: none;
}

.nested-table thead {
    background: rgba(255, 255, 255, 0.02);
}

.nested-table th,
.nested-table td {
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.nested-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* --- Link chip (View on Warzone) --- */

.link-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.7rem;
    border-radius: 999px;
    background: rgba(109, 211, 166, 0.15);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    border: 1px solid rgba(109, 211, 166, 0.3);
    transition: background 0.12s ease;
    margin-left: 0.5rem;
}

.link-chip:hover {
    background: rgba(109, 211, 166, 0.25);
}

/* --- Live chip for active games in combined lists --- */

.chip--live {
    background: rgba(109, 211, 166, 0.2);
    color: var(--accent);
    border-color: rgba(109, 211, 166, 0.45);
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
}

/* --- Matchup Columns (P1 | vs | P2) --- */

td.mu-p1,
td.mu-p2 {
    white-space: nowrap;
}

td.mu-p1 .name-text,
td.mu-p2 .name-text {
    color: var(--text);
    font-weight: 700;
}

td.mu-vs {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 600;
    text-align: center;
    padding-left: 0.15rem !important;
    padding-right: 0.15rem !important;
    width: 1.5rem;
}

.vs-link {
    color: var(--accent);
    text-decoration: underline;
    font-weight: 700;
    font-size: 0.7rem;
}

.vs-link:hover {
    opacity: 0.8;
}

/* --- Win/Loss Cell Backgrounds --- */

td.cell-win {
    background: rgba(109, 211, 166, 0.10);
}

td.cell-loss {
    background: rgba(255, 107, 107, 0.10);
}

td.cell-draw {
    background: rgba(244, 195, 99, 0.08);
}

/* --- Compact Leaderboard --- */

#leaderboard-section table th,
#leaderboard-section table td {
    padding: 0.35rem 0.25rem;
    font-size: 0.82rem;
}

#leaderboard-section table th:nth-child(1),
#leaderboard-section table td:nth-child(1),
#leaderboard-section table th:nth-child(2),
#leaderboard-section table td:nth-child(2) {
    padding-left: 0.2rem;
    padding-right: 0.15rem;
    white-space: nowrap;
}

/* --- Column header subtitle --- */

.th-subtitle {
    display: block;
    font-size: 0.65rem;
    font-weight: 500;
    color: var(--muted);
    text-transform: none;
    letter-spacing: 0;
}

/* --- Last updated chip --- */

.last-updated {
    font-size: 0.75rem;
    color: var(--muted);
    font-weight: 600;
}

/* --- Back link --- */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 700;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    transition: opacity 0.12s ease;
}

.back-link:hover {
    opacity: 0.8;
}

/* --- Medal Ranks (Gold/Silver/Bronze) --- */

.rank-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    font-weight: 700;
    font-size: 0.85rem;
}

.rank-medal {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    font-weight: 900;
    font-size: 0.75rem;
    line-height: 1;
    border: 2px solid;
}

.rank-gold {
    background: linear-gradient(135deg, #ffd700, #f0c030);
    color: #4a3800;
    border-color: #e6be00;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.rank-silver {
    background: linear-gradient(135deg, #d8d8d8, #a8a8a8);
    color: #333;
    border-color: #b0b0b0;
    box-shadow: 0 0 8px rgba(192, 192, 192, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.rank-bronze {
    background: linear-gradient(135deg, #cd7f32, #a0622a);
    color: #2a1a08;
    border-color: #b06a28;
    box-shadow: 0 0 8px rgba(205, 127, 50, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

/* --- Hot Streak Row Theming (fire/ember glow) --- */

tr.streak-hot-1 {
    background: rgba(255, 140, 50, 0.04) !important;
    box-shadow: inset 0 0 20px rgba(255, 120, 30, 0.05);
}

tr.streak-hot-2 {
    background: rgba(255, 120, 30, 0.07) !important;
    box-shadow: inset 0 0 30px rgba(255, 100, 20, 0.08);
}

tr.streak-hot-3 {
    background: rgba(255, 90, 10, 0.10) !important;
    box-shadow: inset 0 0 40px rgba(255, 80, 10, 0.12);
}

tr.streak-hot-4 {
    background: rgba(255, 70, 0, 0.13) !important;
    box-shadow: inset 0 0 50px rgba(255, 60, 0, 0.15);
}

tr.streak-hot-5 {
    background: rgba(255, 50, 0, 0.16) !important;
    box-shadow: inset 0 0 60px rgba(255, 40, 0, 0.18);
}

/* --- Cold Streak Row Theming (ice/frost glow) --- */

tr.streak-cold-1 {
    background: rgba(100, 180, 255, 0.04) !important;
    box-shadow: inset 0 0 20px rgba(80, 160, 255, 0.05);
}

tr.streak-cold-2 {
    background: rgba(80, 160, 255, 0.07) !important;
    box-shadow: inset 0 0 30px rgba(60, 140, 255, 0.08);
}

tr.streak-cold-3 {
    background: rgba(60, 140, 255, 0.10) !important;
    box-shadow: inset 0 0 40px rgba(40, 120, 255, 0.12);
}

tr.streak-cold-4 {
    background: rgba(40, 120, 255, 0.13) !important;
    box-shadow: inset 0 0 50px rgba(20, 100, 255, 0.15);
}

tr.streak-cold-5 {
    background: rgba(20, 100, 255, 0.16) !important;
    box-shadow: inset 0 0 60px rgba(0, 80, 255, 0.18);
}

/* --- Games table compact --- */

#games-results-view table th,
#games-results-view table td,
#games-live-view table th,
#games-live-view table td,
#template-games table th,
#template-games table td {
    padding: 0.45rem 0.5rem;
    font-size: 0.82rem;
}
