@import url("https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap");

:root {
    --bg-primary: #0b0f17;
    --bg-surface: #121827;
    --bg-surface-strong: #171f30;
    --stroke-subtle: rgba(255, 255, 255, 0.08);
    --stroke-strong: rgba(255, 255, 255, 0.14);
    --text-primary: #f2f6ff;
    --text-muted: #b3bdd3;
    --accent: #2aa3ff;
    --accent-strong: #00d4ff;
    --header-height: 85px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family:
        "Manrope",
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        Roboto,
        "Helvetica Neue",
        Arial,
        sans-serif;
    background:
        radial-gradient(
            circle at top,
            rgba(42, 163, 255, 0.18),
            transparent 55%
        ),
        var(--bg-primary);
    color: var(--text-primary);
    overflow-x: hidden;
    padding-top: 40px;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    background:
        radial-gradient(
            circle at top,
            rgba(42, 163, 255, 0.18),
            transparent 55%
        ),
        var(--bg-primary);
    padding: 0;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--stroke-subtle);
    box-shadow: 0 12px 30px rgba(6, 12, 22, 0.45);
    backdrop-filter: blur(12px);
    height: var(--header-height);
}

nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    padding: 0 30px;
}

.nav-drawer {
    display: flex;
    align-items: center;
    gap: 24px;
    flex: 1;
    justify-content: center;
}

.nav-toggle {
    display: none;
    width: 44px;
    height: 44px;
    border-radius: 10px;
    border: 1px solid var(--stroke-subtle);
    background: rgba(18, 24, 39, 0.6);
    color: #fff;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    margin-left: 0; /* Was auto, now handled by stats container or flex */
}

.nav-toggle span {
    width: 20px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    display: block;
}

.logo {
    font-size: 28px;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    padding: 0;
    margin-left: 10px;
}

.nav-logo {
    width: auto;
    max-width: 260px;
    height: 130px;
    max-height: 130px;
    margin: 5px 0 -20px 0;
    display: block;
    object-fit: contain;
    position: relative;
    z-index: 1001;
}

.logo-icon {
    font-size: 32px;
}

.nav-links {
    display: flex;
    gap: 30px;
    list-style: none;
    align-items: center;
    flex: 1;
    justify-content: center;
    margin-top: 0;
}

.nav-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s;
    font-size: 15px;
}

.nav-links a:hover {
    color: #fff;
}

.nav-links a.active {
    color: #fff;
    font-weight: 600;
}

.nav-auth-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-shrink: 0;
    margin-left: 20px;
}

.nav-login-indicator {
    display: none !important; /* Hidden permanently */
}

/* Mobile Stats in Header */
/* Mobile Stats in Header */
.nav-mobile-stats {
    display: none; /* Hidden on desktop */
    flex-direction: column; /* Stack vertically */
    align-items: flex-end; /* Align to right */
    justify-content: center;
    gap: 2px; /* Small gap between rows */
    margin-left: auto; /* Push to right */
    margin-right: 15px; /* Space between stats and toggle */
    flex-shrink: 0; /* Don't shrink */
    pointer-events: none;
}

@media (max-width: 900px) {
    .nav-mobile-stats {
        display: flex;
    }
}

.nav-mobile-stats .nav-currency-mobile,
.nav-mobile-stats .nav-rank-mobile,
.nav-mobile-stats .nav-level-mobile {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    font-size: 11px; /* Smaller font */
    font-weight: 700;
    line-height: 1.2;
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-mobile-stats .nav-currency-mobile {
    color: #2aa3ff;
    gap: 4px;
}

.nav-mobile-stats .nav-rank-mobile {
    color: #b3bdd3;
    font-weight: 600;
}

.nav-mobile-stats #nav-rank-name-mobile {
    color: #fff;
}

.nav-login-indicator__text {
    display: none !important;
}

.nav-login-indicator__dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #ef4444;
    border: 2px solid rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.2);
    flex-shrink: 0;
}

.nav-login-indicator.is-online .nav-login-indicator__dot {
    background: #22c55e;
    box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.2);
}

@media (max-width: 900px) {
    header .container {
        padding-left: 10px; /* Minimal padding */
    }
    nav {
        padding-left: 0;
        padding-right: 20px;
    }
    
    .logo {
        margin-left: 0;
    }

    .nav-logo {
        max-width: 140px;
        height: 70px;
        max-height: 70px;
        margin: 5px 0 0 0;
    }

    .nav-drawer {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: auto;
        width: 50vw;
        height: calc(100vh - var(--header-height));
        background:
            radial-gradient(
                circle at top,
                rgba(42, 163, 255, 0.18),
                transparent 55%
            ),
            var(--bg-primary);
        border-bottom: 1px solid var(--stroke-subtle);
        box-shadow: 0 20px 40px rgba(6, 12, 22, 0.45);
        padding: 16px 20px 24px;
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        transform: translateX(-100%);
        opacity: 0;
        pointer-events: none;
        transition:
            opacity 0.2s ease,
            transform 0.2s ease;
        z-index: 1001;
    }

    body.nav-open .nav-drawer {
        opacity: 1;
        transform: translateX(0);
        pointer-events: auto;
    }

    .nav-drawer .nav-links {
        display: flex;
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
        margin-top: 0;
    }

    .nav-auth-buttons {
        margin-left: 0;
        justify-content: flex-start;
        flex-wrap: wrap;
        width: 100%;
        gap: 12px;
    }

    .nav-auth-buttons .nav-btn {
        width: 100%;
        text-align: center;
        justify-content: center;
        display: flex;
    }

    /* Hide redundant desktop stats in mobile drawer */
    .nav-auth-buttons #nav-currency,
    .nav-auth-buttons #nav-rank {
        display: none !important;
    }

    .nav-toggle {
        display: flex !important; /* Force visibility */
        margin-left: 10px;
        z-index: 2000; /* Ensure on top */
        position: relative;
        flex-shrink: 0; /* DATA-LOSS PREVENTION: User, this ensures it doesn't get squashed */
        min-width: 44px; /* Force minimum width */
    }

    .nav-login-indicator {
        display: inline-flex;
        margin-left: auto;
    }
}

/* PWA Install Prompt */
.pwa-install-prompt {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    width: 90%;
    max-width: 400px;
    background: var(--bg-surface-strong);
    border: 1px solid var(--stroke-strong);
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 10000; /* High z-index */
    display: none;
    flex-direction: column;
    gap: 16px;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.27);
    opacity: 0;
}

.pwa-install-prompt.visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.pwa-prompt-content {
    display: flex;
    align-items: center;
    gap: 16px;
}

.pwa-prompt-icon img {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    object-fit: cover;
}

.pwa-prompt-text h3 {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    margin-bottom: 4px;
}

.pwa-prompt-text p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.4;
}

.pwa-prompt-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.pwa-btn {
    border: none;
    cursor: pointer;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.pwa-btn-primary {
    background: var(--accent);
    color: #fff;
    padding: 10px 20px;
    flex: 1;
}

.pwa-btn-primary:hover {
    background: #108ff4;
}

.pwa-btn-close {
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    padding: 8px;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
}

.pwa-btn-close:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    border-color: var(--stroke-subtle);
}

.nav-btn {
    padding: 10px 24px;
    background: var(--accent);
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s;
}

.nav-btn:hover {
    background: #108ff4;
    transform: translateY(-1px);
}

.nav-auth-buttons .nav-btn {
    border: 1px solid transparent;
    text-transform: uppercase;
}

.nav-auth-buttons #nav-admin-link {
    background: #1d2230;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 14px rgba(13, 16, 28, 0.55);
}

.nav-auth-buttons #nav-admin-link:hover {
    background: #242a3a;
    border-color: rgba(255, 255, 255, 0.25);
}

.nav-auth-buttons #global-logout-button {
    background: #b53737;
    border-color: #7c2525;
    box-shadow: 0 4px 20px rgba(179, 55, 55, 0.45);
}

.nav-auth-buttons #global-logout-button:hover {
    background: #cc4343;
    box-shadow: 0 6px 22px rgba(204, 67, 67, 0.55);
}

footer {
    background: var(--bg-surface);
    border-top: 1px solid var(--stroke-subtle);
    padding: 60px 0 40px;
    margin-top: 5px;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

.footer-section h3 {
    color: #fff;
    font-size: 18px;
    margin-bottom: 20px;
}

.footer-links {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 14px;
    transition: all 0.3s;
}

.footer-links a:hover {
    color: #fff;
}

.footer-bottom {
    text-align: center;
    padding-top: 40px;
    border-top: 1px solid var(--stroke-subtle);
    color: var(--text-muted);
    font-size: 14px;
}
