@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Mono:wght@400;500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --bg:        #0d0f0e;
    --surface:   #141714;
    --surface2:  #1a1d1a;
    --border:    rgba(255,255,255,0.06);
    --gold:      #c9aa71;
    --gold-dim:  #8a7249;
    --green:     #00c853;
    --red:       #ff1744;
    --text:      #e8e8e2;
    --muted:     #6b7068;
    --accent:    #1a3a20;
    --font:      'Syne', sans-serif;
    --mono:      'DM Mono', monospace;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    min-height: 100vh;
    display: flex;
}

.rank-name a {
    color: inherit;
    text-decoration: none;
}

.rank-name a:hover {
    color: var(--gold);
}



/* ── SIDEBAR ── */
.sidebar {
    width: 240px;
    min-height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 28px 0;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    justify-content: space-between;
    transition: transform 0.3s ease;
}

.sidebar.hidden {
    transform: translateX(-240px);
}

.sidebar-logo {
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.18em;
    color: var(--gold);
    padding: 0 24px 32px;
    border-bottom: 1px solid var(--border);
}

.sidebar-toggle {
    position: fixed;
    top: 50%;
    left: 240px;
    transform: translateY(-50%);
    z-index: 51;
    background: var(--surface);
    border: 1px solid var(--gold-dim);
    border-left: none;
    border-radius: 0 8px 8px 0;
    color: var(--gold);
    font-size: 14px;
    padding: 12px 8px;
    cursor: pointer;
    transition: left 0.3s ease, border-color 0.15s;
    line-height: 1;
}

.sidebar-toggle.shifted {
    left: 0;
}

.sidebar-toggle:hover {
    border-color: var(--gold);
}

.sidebar-nav {
    padding: 20px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--muted);
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    transition: background 0.15s, color 0.15s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
    background: var(--surface2);
    color: var(--text);
}

.sidebar-nav a.active { color: var(--gold); }

.nav-icon { font-size: 15px; }

/* ── SIDEBAR USER BLOCK ── */
.sidebar-user {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: auto;
}

.sidebar-profile-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    border-radius: 10px;
    text-decoration: none;
    transition: background 0.15s;
    overflow: hidden;
}

.sidebar-profile-link:hover {
    background: var(--surface2);
}

.sidebar-avatar {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: var(--surface2);
    border: 2px solid var(--gold);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--gold);
    flex-shrink: 0;
}

.sidebar-profile-text {
    display: flex;
    flex-direction: column;
    min-width: 0
}

.sidebar-profile-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-profile-sub {
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.06em;
    margin-top: 2px;
}

.btn-logout {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--red);
    text-decoration: none;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    transition: background 0.15s;
    width: 100%;
    border: 1px solid rgba(255, 23, 68, 0.2);
}

.btn-logout:hover {
    background: rgba(255, 23, 68, 0.08);
    border-color: var(--red);
}

/* ── MAIN ── */
.main {
    margin-left: 240px;
    flex: 1;
    padding: 48px 56px;
    width: calc(100% - 240px);
    transition: margin-left 0.3s ease, width 0.3s ease;
}

.main.expanded {
    margin-left: 0 !important;
    width: 100% !important;
}

.equity-value, .equity-sub, .stat-value, .portfolio-value, .rank-value {
    font-family: var(--mono);
}

.buy-animation {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: rgba(20, 22, 20, 0.9);
    border-radius: 20px;
    padding: 40px;
    min-width: 200px;
}

.spinner {
    width: 120px;
    height: 120px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top: 4px solid #c9aa71;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.treasure-overlay {
    position: fixed;
    inset: 0;
    background: rgba(13, 15, 14, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.treasure-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.buy-character-img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border: 2px solid #c9aa71;
    border-radius: 12px;
    transition: opacity 0.4s ease;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}


/* ── FOOTER ── */
.footer {
    text-align: center;
    padding: 24px;
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 0.08em;
    border-top: 1px solid var(--border);
    margin-top: 48px;
    width: 100%;
}

/* ── BOTTOM NAV (hidden on desktop) ── */
.bottom-nav { display: none; }

/* ── SHARED BADGES ── */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    font-family: var(--mono);
}

.badge-green { background: rgba(0,200,83,0.12);  color: var(--green); }
.badge-red   { background: rgba(255,23,68,0.12); color: var(--red); }

/* ── SHARED BUTTONS ── */
.btn-gold {
    padding: 10px 24px;
    background: var(--gold);
    color: #0d0f0e;
    border-radius: 8px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-decoration: none;
    transition: opacity 0.15s;
    border: none;
    cursor: pointer;
}
.btn-gold:hover { opacity: 0.85; }

.btn-outline {
    padding: 10px 24px;
    background: transparent;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-decoration: none;
    transition: border-color 0.15s, color 0.15s;
    cursor: pointer;
}
.btn-outline:hover { border-color: var(--gold-dim); color: var(--gold); }

/* ── PAGE TITLE ── */
.page-title {
    font-size: 28px;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 8px;
}

.page-sub {
    font-size: 13px;
    color: var(--muted);
    margin-bottom: 32px;
    letter-spacing: 0.06em;
}

.section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--gold);
}

/* ── TOAST ── */
.toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface);
    border: 1px solid var(--gold);
    border-radius: 12px;
    padding: 14px 24px;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    white-space: nowrap;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    border-color: var(--red);
    color: var(--red);
}

.btn-spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(0,200,83,0.3);
    border-top-color: var(--green);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ══════════════════════════════════════
   MOBILE
══════════════════════════════════════ */
@media (max-width: 900px) {
    body {
        display: block;
        padding-bottom: 64px;
    }

    .sidebar { display: none; }

    .main {
        margin-left: 0;
        padding: 20px 16px 80px;
        width: 100%;
    }

    .sidebar-toggle { display: none; }

    .page-title { font-size: 22px; }

    .bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0; left: 0; right: 0;
        height: calc(64px + env(safe-area-inset-bottom));
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--surface);
        border-top: 1px solid var(--border);
        z-index: 999;
        justify-content: space-around;
        align-items: center;
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
        will-change: transform;
    }

    .bottom-nav a {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 4px;
        text-decoration: none;
        color: var(--muted);
        font-size: 10px;
        font-weight: 600;
        letter-spacing: 0.06em;
        font-family: var(--font);
        flex: 1;
        height: 64px;
        padding: 0;
        transition: color 0.15s;
    }

    .bottom-nav a.active { color: var(--gold); }
    .bottom-nav a span {font-size: 20px;line-height: 1;}
}
