:root {
    --bg: #f5f3f0;
    --bg-soft: #efeae4;
    --ink: #1f1a15;
    --muted: #6f675e;
    --accent: #e07a1f;
    --accent-2: #0f766e;
    --accent-3: #c2410c;
    --card: #ffffff;
    --line: rgba(31, 26, 21, 0.12);
    --shadow: 0 12px 24px rgba(17, 12, 7, 0.12);
    --radius-lg: 22px;
    --radius-md: 16px;
    --radius-sm: 10px;
    --glow: 0 0 14px rgba(224, 122, 31, 0.25);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
    color: var(--ink);
    background: radial-gradient(900px 500px at 10% -10%, rgba(224, 122, 31, 0.08) 0%, transparent 60%),
        radial-gradient(700px 420px at 90% 0%, rgba(15, 118, 110, 0.08) 0%, transparent 55%),
        linear-gradient(180deg, #f7f4ef 0%, #efe8df 100%);
    min-height: 100vh;
    position: relative;
    overflow-x: hidden;
    padding-bottom: 0;
    line-height: 1.6;
}

@keyframes rise-fade {
    0% {
        opacity: 0;
        transform: translateY(18px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rune-sweep {
    0% {
        transform: translateX(-120%);
        opacity: 0.2;
    }
    50% {
        opacity: 0.65;
    }
    100% {
        transform: translateX(120%);
        opacity: 0.2;
    }
}

@keyframes ember-pulse {
    0%,
    100% {
        box-shadow: 0 0 0 rgba(224, 122, 31, 0);
    }
    50% {
        box-shadow: 0 0 18px rgba(224, 122, 31, 0.28);
    }
}

h1, h2, h3, h4 {
    font-family: "Source Serif 4", "Georgia", serif;
    margin: 0 0 12px;
    letter-spacing: -0.01em;
}

a {
    color: inherit;
    text-decoration: none;
}

.bg-orb {
    position: absolute;
    width: 360px;
    height: 360px;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.18;
    z-index: 0;
}

.orb-1 {
    background: rgba(224, 122, 31, 0.65);
    top: -140px;
    left: -120px;
}

.orb-2 {
    background: rgba(15, 118, 110, 0.35);
    bottom: -120px;
    right: -80px;
}

.grid-lines {
    position: absolute;
    inset: 0;
    background-image: linear-gradient(rgba(31, 26, 21, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31, 26, 21, 0.04) 1px, transparent 1px);
    background-size: 140px 140px;
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

.site-header {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 24px 6vw 0;
    gap: 20px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 16px;
    background: linear-gradient(135deg, #f2c27a 0%, var(--accent) 100%);
    color: #2a1407;
    font-weight: 700;
    font-size: 20px;
    box-shadow: var(--shadow);
    border: 1px solid rgba(224, 122, 31, 0.3);
}

.brand-title {
    font-weight: 700;
    font-size: 20px;
}

.brand-sub {
    font-size: 13px;
    color: var(--muted);
}

.nav {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    background: transparent;
    padding: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
}

.nav-link {
    font-size: 14px;
    color: var(--muted);
    padding: 6px 2px;
    border-bottom: 2px solid transparent;
    transition: color 0.2s ease, border-color 0.2s ease;
}

.nav-link:hover,
.nav-link.is-active {
    color: var(--ink);
    border-color: var(--accent);
}

.page {
    position: relative;
    z-index: 1;
    padding: 28px 6vw 96px;
    display: flex;
    flex-direction: column;
    gap: 36px;
}

.hero {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    align-items: center;
    padding: 24px;
    background: var(--card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    animation: rise-fade 0.7s ease-out both;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.2em;
    font-size: 12px;
    color: var(--muted);
    margin: 0 0 12px;
}

.lead {
    font-size: 16px;
    color: var(--muted);
    margin: 0 0 24px;
}

.hero-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 18px;
    border-radius: 999px;
    font-weight: 600;
    font-size: 14px;
    border: 1px solid transparent;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn.primary {
    background: var(--accent);
    color: #fffaf3;
    box-shadow: var(--shadow);
    animation: ember-pulse 3s ease-in-out infinite;
}

.btn.ghost {
    border-color: var(--line);
    color: var(--ink);
    background: #faf7f3;
}

.btn:hover {
    transform: translateY(-1px);
}

.hero-panel {
    display: grid;
    gap: 14px;
}

.metric-card {
    padding: 16px 18px;
    border-radius: var(--radius-md);
    background: #fbf9f6;
    border: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.metric-card.accent {
    background: linear-gradient(135deg, rgba(224, 122, 31, 0.12), rgba(255, 251, 243, 0.7));
}

.metric-label {
    font-size: 13px;
    color: var(--muted);
}

.metric-value {
    font-size: 20px;
    font-weight: 700;
}

.section {
    display: flex;
    flex-direction: column;
    gap: 18px;
    animation: rise-fade 0.7s ease-out both;
}

.section:nth-of-type(2) { animation-delay: 0.06s; }
.section:nth-of-type(3) { animation-delay: 0.12s; }
.section:nth-of-type(4) { animation-delay: 0.18s; }
.section:nth-of-type(5) { animation-delay: 0.24s; }

.section-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.section-link {
    font-size: 14px;
    color: var(--accent);
    font-weight: 600;
}

.section-hint {
    font-size: 14px;
    color: var(--muted);
}

.table-card,
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow);
}

.table-card,
.card,
.tournament-card,
.match-card,
.trend-item,
.opponent-card,
.round-card {
    animation: rise-fade 0.6s ease-out both;
    animation-delay: 0.05s;
}

.table-card {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 560px;
}

thead th {
    text-align: left;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    padding: 12px 8px;
    border-bottom: 1px solid var(--line);
}

thead th[data-sort-key] {
    cursor: pointer;
    position: relative;
    padding-right: 20px;
}

thead th[data-sort-key]::after {
    content: "▲";
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%) scale(0.6);
    color: var(--muted);
    opacity: 0.3;
    transition: opacity 0.2s, color 0.2s;
}

thead th.sort-asc,
thead th.sort-desc {
    color: var(--accent);
}

thead th.sort-asc::after,
thead th.sort-desc::after {
    opacity: 1;
    color: var(--accent);
}

thead th.sort-desc::after {
    transform: translateY(-50%) scale(0.6) rotate(180deg);
}


tbody td {
    padding: 12px 8px;
    border-bottom: 1px solid rgba(31, 26, 21, 0.08);
    font-size: 14px;
}

.table-empty {
    text-align: center;
    color: var(--muted);
    padding: 24px 0;
}

.table-compact td,
.table-compact th {
    padding: 8px 6px;
    font-size: 13px;
}

.table-compact {
    overflow-x: auto;
}

.season-rewards {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.season-rewards .reward {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    white-space: nowrap;
    background: rgba(31, 26, 21, 0.08);
    color: var(--muted);
}

.season-rewards .reward.gold {
    background: rgba(224, 122, 31, 0.18);
    color: #9a4a0f;
}

.season-rewards .reward.silver {
    background: rgba(107, 114, 128, 0.18);
    color: #4b5563;
}

.season-rewards .reward.bronze {
    background: rgba(194, 65, 12, 0.18);
    color: #8a2c0a;
}

.match-list {
    display: grid;
    gap: 12px;
}

.match-card {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding: 14px 16px;
    background: #fbf9f6;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
}

.match-players {
    font-weight: 600;
}

.match-meta {
    color: var(--muted);
    font-size: 12px;
    margin-top: 6px;
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(224, 122, 31, 0.15);
    color: var(--accent);
}

.chip.success {
    background: rgba(15, 118, 110, 0.16);
    color: var(--accent-2);
}

.chip.warning {
    background: rgba(194, 65, 12, 0.18);
    color: var(--accent-3);
}

.chip.neutral {
    background: rgba(31, 26, 21, 0.08);
    color: var(--muted);
}

.season-grid,
.profile-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.insight-grid,
.showcase-grid {
    display: grid;
    gap: 18px;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.insight-list {
    display: grid;
    gap: 10px;
    margin-top: 12px;
}

.insight-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: #fbf9f6;
    border: 1px solid var(--line);
    font-size: 14px;
}

.insight-item strong {
    font-weight: 600;
}

.stats-row {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.stats-cell span {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.stats-cell strong {
    font-size: 20px;
    font-weight: 700;
}

.season-meta {
    margin-top: 12px;
    color: var(--muted);
    font-size: 14px;
}

.field-label {
    font-size: 13px;
    text-transform: uppercase;
    color: var(--muted);
    letter-spacing: 0.1em;
}

.field-select,
.field-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    background: #fffdf9;
    color: var(--ink);
    margin-top: 10px;
    font-size: 15px;
    font-family: "Source Sans 3", "Segoe UI", sans-serif;
}

.field-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.search-card {
    display: grid;
    gap: 12px;
}

.search-results {
    display: grid;
    gap: 8px;
}

.search-results button {
    border: 1px solid rgba(242, 231, 215, 0.18);
    background: #fbf9f6;
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    color: var(--ink);
}

.tournament-grid,
.rounds-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.filter-bar {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.filter-group {
    display: grid;
}

.trend-list {
    display: grid;
    gap: 12px;
    margin-top: 12px;
}

.trend-item {
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: #fbf9f6;
    display: grid;
    gap: 8px;
}

.trend-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
}

.trend-metric {
    font-size: 12px;
    color: var(--muted);
}

.sparkline-wrap {
    width: 100%;
    height: clamp(140px, 24vw, 220px);
    min-height: 140px;
    background: linear-gradient(135deg, rgba(224, 122, 31, 0.12), rgba(15, 118, 110, 0.08));
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    padding: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
}

.sparkline-wrap svg {
    width: 100%;
    height: 100%;
}

#player-elo-chart {
    display: block;
}

.sparkline-meta {
    margin-top: 10px;
    font-size: 13px;
    color: var(--muted);
}

.compare-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    align-items: end;
}

.compare-actions {
    display: flex;
    align-items: flex-end;
}

.h2h-summary {
    margin-top: 16px;
    display: grid;
    gap: 12px;
}

.h2h-card {
    padding: 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: #fbf9f6;
    display: grid;
    gap: 6px;
}

.h2h-row {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
}

.bracket {
    display: grid;
    gap: 16px;
    grid-auto-flow: column;
    grid-auto-columns: minmax(220px, 1fr);
    overflow-x: auto;
    padding-bottom: 10px;
}

.bracket-round {
    display: grid;
    gap: 12px;
    min-width: 220px;
}

.bracket-round h4 {
    margin: 0;
    font-size: 15px;
}

.bracket-match {
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: #fbf9f6;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.bracket-player {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
}

.bracket-player.winner {
    font-weight: 700;
    color: var(--accent);
}

.opponent-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.opponent-card {
    padding: 14px;
    border-radius: var(--radius-md);
    background: #fbf9f6;
    border: 1px solid var(--line);
}

.opponent-card h4 {
    margin: 0 0 6px;
}

.opponent-meta {
    font-size: 12px;
    color: var(--muted);
}

.opponent-filter {
    display: grid;
    gap: 8px;
    margin-bottom: 12px;
}

.opponent-filter .field-select {
    margin-top: 0;
}

.opponent-highlight-list {
    display: grid;
    gap: 12px;
}

.opponent-highlight {
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--line);
    background: #fbf9f6;
    display: grid;
    gap: 6px;
}

.opponent-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
}

.opponent-highlight strong {
    font-size: 16px;
}

.opponent-highlight strong a {
    color: var(--ink);
}

.opponent-meta {
    font-size: 12px;
    color: var(--muted);
}

.opponent-empty {
    font-size: 13px;
    color: var(--muted);
}

.tournament-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    padding: 18px;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    display: grid;
    gap: 12px;
}

.tournament-card h3 {
    margin: 0;
}

.tournament-meta {
    font-size: 13px;
    color: var(--muted);
}

.round-card {
    padding: 16px;
    border-radius: var(--radius-md);
    background: #fbf9f6;
    border: 1px solid var(--line);
    display: grid;
    gap: 10px;
}

.podium {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 18px;
}

.podium-card {
    padding: 16px;
    border-radius: var(--radius-md);
    text-align: center;
    background: #fbf9f6;
    border: 1px solid var(--line);
    display: grid;
    gap: 8px;
}

.podium-rank {
    font-size: 18px;
    font-weight: 700;
}

.podium-name {
    font-size: 14px;
    font-weight: 600;
}

.podium-card.gold {
    background: linear-gradient(135deg, rgba(224, 122, 31, 0.18), rgba(255, 251, 243, 0.9));
}

.podium-card.silver {
    background: linear-gradient(135deg, rgba(160, 160, 160, 0.18), rgba(255, 251, 243, 0.9));
}

.podium-card.bronze {
    background: linear-gradient(135deg, rgba(194, 65, 12, 0.18), rgba(255, 251, 243, 0.9));
}

.empty-card {
    padding: 20px;
    border-radius: var(--radius-md);
    background: #faf9f7;
    border: 1px dashed var(--line);
    text-align: center;
    color: var(--muted);
    font-family: "Source Serif 4", "Georgia", serif;
}

.loading-card {
    position: relative;
    overflow: hidden;
    color: transparent;
    text-shadow: none;
}

.loading-card::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg,
        transparent 0%,
        rgba(224, 122, 31, 0.18) 35%,
        rgba(255, 233, 196, 0.35) 50%,
        rgba(224, 122, 31, 0.18) 65%,
        transparent 100%);
    animation: rune-sweep 2.2s infinite;
}

.round-card h4 {
    margin: 0;
}

.site-footer {
    position: relative;
    z-index: 1;
    padding: 24px 6vw 36px;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 720px) {
    .site-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .sparkline-wrap {
        height: clamp(180px, 55vw, 280px);
        padding: 10px;
    }

    .nav {
        position: sticky;
        top: 12px;
        width: 100%;
        display: flex;
        gap: 10px;
        padding: 10px;
        background: #fffaf3;
        border: 1px solid var(--line);
        border-radius: 14px;
        box-shadow: 0 10px 20px rgba(17, 12, 7, 0.12);
        z-index: 5;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .nav-link {
        font-size: 12px;
        font-weight: 600;
        padding: 10px 14px;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        border-radius: 12px;
        border: 1px solid transparent;
        background: transparent;
        white-space: nowrap;
    }

    .nav-link.is-active {
        background: linear-gradient(135deg, rgba(224, 122, 31, 0.18), rgba(255, 251, 243, 0.95));
        border-color: rgba(224, 122, 31, 0.25);
        color: var(--ink);
    }

    body {
        padding-bottom: 24px;
    }

    .hero {
        padding: 20px;
    }

    .stats-row {
        grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    }

    .match-card {
        grid-template-columns: 1fr;
    }

    .podium {
        grid-template-columns: 1fr;
    }
}
