:root {
    --bg-dark: #121212;
    --window-bg: #e8dbc3;
    --sidebar-bg: #dccaa5;
    --border-color: #4a3b2a;
    --gold-accent: #b89548;
    --ink: #2b2018;
    --ink-muted: #665243;
    --tab-bg: #3d2f24;
    --tab-text: #a89582;
    --tab-hover: #4f3d2f;
    --r-common: #a0a0a0;
    --r-uncommon: #3bd26f;
    --r-rare: #0070dd;
    --r-epic: #a335ee;
    --r-legendary: #ff8000;
    --font-title: "Cinzel", serif;
    --font-body: "Lato", sans-serif;
}

body {
    margin: 0;
    background-color: var(--bg-dark);
    background-image: radial-gradient(circle at center, #1f1f1f 0%, #050505 100%);
    color: var(--ink);
    font-family: var(--font-body);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow: hidden;
}

.layout-anchor {
    position: relative;
    width: 1200px;
    height: calc(94vh - 73px);
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 16px auto 0;
}

.main-window {
    width: 100%;
    height: 100%;
    background: var(--window-bg);
    border: 6px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 0 0 2px #2a2118, 0 30px 80px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 20;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="200" height="200"><filter id="n"><feTurbulence type="fractalNoise" baseFrequency="0.7" numOctaves="3" stitchTiles="stitch"/></filter><rect width="200" height="200" filter="url(%23n)" opacity="0.04"/></svg>');
}

/* Nav bar */
.nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 40px;
    background: var(--tab-bg);
    border-bottom: 3px solid #2a2118;
    background-image: linear-gradient(to bottom, rgba(255,255,255,0.05), rgba(0,0,0,0.2));
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    box-sizing: border-box;
}
.nav-bar a {
    color: var(--tab-text);
    text-decoration: none;
    font-family: var(--font-title);
    font-size: 0.95rem;
    padding: 6px 16px;
    border-radius: 4px;
    transition: all 0.2s;
}
.nav-bar a:hover { background: var(--tab-hover); color: #dccaa5; }
.nav-bar a.active { color: var(--gold-accent); font-weight: 700; }
.nav-title {
    color: var(--gold-accent);
    font-family: var(--font-title);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 1px;
}
.nav-bar a.nav-title { color: var(--gold-accent); font-size: 1.1rem; font-weight: 700; letter-spacing: 1px; padding: 0; background: none; }
.nav-bar a.nav-title:hover { background: none; color: #dccaa5; }

/* Header */
.content-header {
    padding: 30px 50px 20px 50px;
    border-bottom: 2px solid rgba(74, 59, 42, 0.1);
    background: rgba(255,255,255,0.1);
    text-align: center;
}
.content-header h1 {
    font-family: var(--font-title);
    margin: 0;
    font-size: 2.4rem;
    color: #2b1b00;
    text-shadow: 0 1px 0 rgba(255,255,255,0.5);
}
.content-header .subtitle {
    color: var(--ink-muted);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* Scroll area */
.scroll-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px 50px;
}
.scroll-container::-webkit-scrollbar { width: 10px; }
.scroll-container::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); }
.scroll-container::-webkit-scrollbar-thumb {
    background: #c4b08b;
    border: 2px solid var(--window-bg);
    border-radius: 6px;
}

/* Podium */
.podium {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 20px;
    margin-bottom: 40px;
    padding: 20px 0;
}
.podium-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.3s;
}
.podium-slot:hover { transform: translateY(-4px); }

.podium-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    background: #000;
    margin-bottom: 10px;
}
.podium-slot.rank-1 .podium-avatar {
    width: 100px; height: 100px;
    border: 4px solid var(--gold-accent);
    box-shadow: 0 0 20px rgba(184, 149, 72, 0.5);
}
.podium-slot.rank-2 .podium-avatar {
    width: 85px; height: 85px;
    border: 3px solid #c0c0c0;
    box-shadow: 0 0 12px rgba(192, 192, 192, 0.3);
}
.podium-slot.rank-3 .podium-avatar {
    width: 75px; height: 75px;
    border: 3px solid #cd7f32;
    box-shadow: 0 0 10px rgba(205, 127, 50, 0.3);
}

.podium-name {
    font-family: var(--font-title);
    font-size: 1.1rem;
    color: var(--ink);
    font-weight: 700;
    margin-bottom: 4px;
}
.podium-points {
    font-family: var(--font-title);
    font-size: 1.6rem;
    font-weight: 900;
}
.rank-1 .podium-points { color: var(--gold-accent); }
.rank-2 .podium-points { color: #a0a0a0; }
.rank-3 .podium-points { color: #cd7f32; }

.podium-pedestal {
    width: 140px;
    border-radius: 6px 6px 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
    font-family: var(--font-title);
    font-size: 1.8rem;
    font-weight: 900;
    color: rgba(255,255,255,0.4);
}
.rank-1 .podium-pedestal {
    background: linear-gradient(180deg, #b89548 0%, #7a5f28 100%);
    height: 120px;
}
.rank-2 .podium-pedestal {
    background: linear-gradient(180deg, #a0a0a0 0%, #686868 100%);
    height: 90px;
}
.rank-3 .podium-pedestal {
    background: linear-gradient(180deg, #cd7f32 0%, #8a5520 100%);
    height: 65px;
}

.podium-badge {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

/* Stats table */
.stats-section {
    margin-top: 10px;
}
.stats-section h2 {
    font-family: var(--font-title);
    font-size: 1.4rem;
    color: #2b1b00;
    border-bottom: 2px solid rgba(74, 59, 42, 0.15);
    padding-bottom: 8px;
    margin-bottom: 16px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
}
.stats-table th {
    font-family: var(--font-title);
    font-size: 0.85rem;
    color: var(--ink-muted);
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid rgba(74, 59, 42, 0.15);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.stats-table td {
    padding: 12px;
    border-bottom: 1px solid rgba(74, 59, 42, 0.08);
    vertical-align: middle;
}
.stats-table tr:hover td {
    background: rgba(255,255,255,0.3);
}

.rank-cell {
    font-family: var(--font-title);
    font-weight: 900;
    font-size: 1.3rem;
    width: 50px;
    text-align: center;
}
.rank-cell.gold { color: var(--gold-accent); }
.rank-cell.silver { color: #a0a0a0; }
.rank-cell.bronze { color: #cd7f32; }

.user-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}
.table-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    border: 2px solid var(--gold-accent);
    object-fit: cover;
    background: #000;
}
.table-username {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 1rem;
}

.stat-value {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--ink);
}
.stat-sub {
    font-size: 0.8rem;
    color: var(--ink-muted);
}

/* Achievement breakdown bar */
.rarity-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    width: 200px;
    background: rgba(0,0,0,0.1);
}
.rarity-bar .seg {
    height: 100%;
    transition: width 0.5s;
}

.recent-ach {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255,255,255,0.4);
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 4px;
    padding: 4px 10px;
    margin: 3px;
    font-size: 0.82rem;
}
.recent-ach-icon {
    width: 22px; height: 22px;
    border-radius: 2px;
    background: #2a2118;
}

.loader {
    text-align: center;
    padding: 60px;
    color: var(--ink-muted);
    font-style: italic;
}

/* Level badge */
.lvl-badge {
    display: inline-block;
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 0.95rem;
    padding: 3px 10px;
    border-radius: 4px;
    background: rgba(0,0,0,0.08);
    color: var(--ink);
    border: 1px solid rgba(0,0,0,0.15);
}
.lvl-badge.lvl-initiate { background: rgba(59, 210, 111, 0.12); color: #2a8f4a; border-color: rgba(59, 210, 111, 0.3); }
.lvl-badge.lvl-veteran   { background: rgba(0, 112, 221, 0.12); color: #0055aa; border-color: rgba(0, 112, 221, 0.3); }
.lvl-badge.lvl-elite     { background: rgba(163, 53, 238, 0.12); color: #7a22bb; border-color: rgba(163, 53, 238, 0.3); }
.lvl-badge.lvl-apex      { background: rgba(255, 128, 0, 0.12); color: #c06000; border-color: rgba(255, 128, 0, 0.3); }

/* Podium CP sub-label */
.podium-cp {
    font-family: var(--font-body);
    font-size: 0.82rem;
    color: var(--ink-muted);
    margin-top: 2px;
    margin-bottom: 6px;
}
/* Tooltip */
.tt {
    position: fixed;
    pointer-events: none;
    background: #1a1612;
    color: #eee;
    border: 1px solid #635034;
    border-radius: 4px;
    padding: 8px 12px;
    font-size: 0.82rem;
    max-width: 280px;
    z-index: 9999;
    display: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
}
.tt-name { color: #f7d16d; font-family: var(--font-title); font-weight: 700; font-size: 0.9rem; }
.tt-flavor { color: #aaa; font-style: italic; margin-top: 3px; }
.tt-pts { color: #cd7f32; margin-top: 4px; }

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 768px) {
    body {
        overflow: auto;
        align-items: flex-start;
    }
    .layout-anchor {
        width: 100%;
        height: auto;
        min-height: 100vh;
    }
    .main-window {
        border: none;
        border-radius: 0;
        box-shadow: none;
        height: auto;
        min-height: 100vh;
    }

    /* Nav bar */
    .nav-bar {
        padding: 10px 15px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .nav-title { font-size: 0.9rem; }
    .nav-bar a { font-size: 0.8rem; padding: 4px 10px; }

    /* Header */
    .content-header {
        padding: 15px;
    }
    .content-header h1 { font-size: 1.5rem; }
    .subtitle { font-size: 0.8rem; }

    /* Scroll area */
    .scroll-container {
        padding: 15px 12px;
    }

    /* Podium mobile */
    .podium {
        gap: 8px;
        margin-bottom: 25px;
        padding: 10px 0;
    }
    .podium-avatar {
        width: 50px !important;
        height: 50px !important;
    }
    .podium-slot.rank-1 .podium-avatar {
        width: 60px !important;
        height: 60px !important;
        border-width: 3px;
    }
    .podium-slot.rank-2 .podium-avatar {
        width: 52px !important;
        height: 52px !important;
        border-width: 2px;
    }
    .podium-slot.rank-3 .podium-avatar {
        width: 46px !important;
        height: 46px !important;
        border-width: 2px;
    }
    .podium-name { font-size: 0.8rem; }
    .podium-points { font-size: 1.1rem; }
    .podium-badge { font-size: 1rem; }
    .podium-pedestal {
        width: 90px;
        font-size: 1.3rem;
    }
    .rank-1 .podium-pedestal { height: 80px; }
    .rank-2 .podium-pedestal { height: 60px; }
    .rank-3 .podium-pedestal { height: 45px; }

    /* Stats table → card layout on mobile */
    .stats-table thead { display: none; }
    .stats-table, .stats-table tbody, .stats-table tr, .stats-table td {
        display: block;
        width: 100%;
    }
    .stats-table tr {
        background: rgba(255,255,255,0.35);
        border: 1px solid rgba(0,0,0,0.08);
        border-radius: 6px;
        padding: 12px;
        margin-bottom: 12px;
    }
    .stats-table td {
        padding: 4px 0;
        border-bottom: none;
    }
    .stats-table tr:hover td {
        background: none;
    }

    /* Rank cell */
    .rank-cell {
        position: absolute;
        right: 12px;
        top: 12px;
        width: auto;
        font-size: 1.5rem;
    }
    .stats-table tr {
        position: relative;
    }

    /* User cell */
    .user-cell {
        margin-bottom: 6px;
    }
    .table-avatar { width: 36px; height: 36px; }
    .table-username { font-size: 0.95rem; }

    /* Stats inline */
    .stat-value { font-size: 0.95rem; }
    .stats-table td[style*="text-align:center"] {
        display: inline-block;
        width: auto;
        padding: 2px 8px;
        text-align: left !important;
    }
    .stats-table td[style*="text-align:center"]::before {
        font-size: 0.7rem;
        color: var(--ink-muted);
        margin-right: 4px;
    }

    /* Rarity bar */
    .rarity-bar { width: 100%; margin: 6px 0; }

    /* Recent achievements */
    .stats-table td[style*="max-width"] {
        max-width: 100% !important;
    }
    .recent-ach {
        font-size: 0.75rem;
        padding: 3px 8px;
    }
    .recent-ach-icon { width: 18px; height: 18px; }

    /* Tooltip mobile */
    .tt {
        position: fixed;
        top: auto !important;
        bottom: 20px !important;
        left: 50% !important;
        transform: translateX(-50%);
        max-width: 280px;
    }
}
