:root {
    --primary: #8b5cf6; 
    --bg: #121212;      
    --surface: #1e1e1e; 
    --surface-2: #2d2d2d; 
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --team-a: #fbbf24; 
    --team-b: #3b82f6; 
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    
    /* Nav Variables */
    --nav-width: 260px;
    --nav-width-collapsed: 80px;
}

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

html, body {
    height: 100%; 
}

body {
    background-color: var(--bg);
    color: var(--text);
    font-family: var(--font);
    overscroll-behavior: none;
    display: flex;
    flex-direction: column;
    transition: padding-left 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
    
    /* Removed padding-bottom from here; moved to .container */
}

/* Add scrolling lock class */
body.no-scroll {
    overflow: hidden;
}

/* --- Animations --- */
@keyframes pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.95); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeInUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.animate-slide-in { animation: slideInLeft 0.5s cubic-bezier(0.215, 0.610, 0.355, 1.000) forwards; }
.animate-fade-up { animation: fadeInUp 0.6s cubic-bezier(0.215, 0.610, 0.355, 1.000) forwards; }
.delay-1 { animation-delay: 0.1s; opacity: 0; animation-fill-mode: forwards; }
.delay-2 { animation-delay: 0.2s; opacity: 0; animation-fill-mode: forwards; }
.delay-3 { animation-delay: 0.3s; opacity: 0; animation-fill-mode: forwards; }

/* --- Layout --- */
.container { 
    padding: 20px; 
    max-width: 600px; 
    margin: 0 auto; 
    width: 100%;
    flex: 1;
    
    /* MOBILE DEFAULT: Add clearance for the nav/footer if needed */
    padding-bottom: 20px; 
}
.hidden { display: none !important; }

/* --- Typography --- */
h1, h2, h3 { font-weight: 700; letter-spacing: -0.5px; }
.text-muted { color: var(--text-muted); font-size: 0.9em; }

.section-title-large {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    margin: 50px 0 25px 0;
    letter-spacing: -0.5px;
}

/* --- Mobile Header --- */
#mobile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--surface-2);
    position: sticky;
    top: 0;
    z-index: 90;
}
.mobile-app-title {
    font-size: 18px;
    font-weight: 800;
    margin: 0;
}
.mobile-toggle {
    display: flex;
    align-items: center;
    cursor: pointer;
    color: var(--text);
}

/* --- Buttons & Inputs --- */
.btn {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--surface-2);
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
    width: 100%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); border: none; color: white; }
.btn-google { background: white; color: #333; border: none; }
.btn-danger { background: var(--danger); border: none; }
.btn-success { background: var(--success); border: none; color: white; }
.btn-sm { padding: 8px 12px; font-size: 13px; width: auto; }
.btn-xs { padding: 4px 8px; font-size: 11px; width: auto; border-radius: 6px;}

/* --- Close Button Icons --- */
.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
    border-radius: 50%;
}
.btn-close:hover { color: var(--text); background: rgba(255,255,255,0.1); }
.icon-close { width: 24px; height: 24px; stroke: currentColor; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }


input[type="text"], input[type="number"], input[type="datetime-local"], select {
    width: 100%;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid var(--surface-2);
    background: var(--surface);
    color: white;
    font-size: 16px;
    margin-bottom: 10px;
}

.card {
    background: var(--surface);
    border-radius: 16px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    border: 1px solid var(--surface-2);
}

/* --- Event & Notification Cards --- */
.event-card {
    background: var(--surface);
    border: 1px solid var(--surface-2);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}
.event-date-badge {
    background: var(--surface-2);
    padding: 5px 10px;
    border-radius: 8px;
    text-align: center;
    font-size: 11px;
    font-weight: bold;
    min-width: 50px;
    margin-right: 15px;
}
.notification-item {
    background: var(--surface-2);
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    border-left: 3px solid var(--primary);
}

/* --- Draft Chips & Team Builder --- */
.team-draft-box {
    background: var(--surface-2);
    border-radius: 8px;
    padding: 8px;
    min-height: 40px;
}
.draft-badge {
    display: inline-flex;
    align-items: center;
    background: rgba(255,255,255,0.1);
    border-radius: 12px;
    padding: 4px 8px;
    font-size: 11px;
    cursor: pointer;
    border: 1px solid rgba(255,255,255,0.1);
    transition: background 0.2s;
}
.draft-badge:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.3);
}

/* --- Dashboard Header --- */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.user-controls { display: flex; align-items: center; gap: 10px; }
.user-info-display { display: flex; align-items: center; gap: 8px; text-align: right; }
.user-pic { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--surface-2); object-fit: cover; }
.user-name { font-size: 12px; color: var(--text-muted); font-weight: 600; }
@media (max-width: 350px) { .user-name { display: none; } }

/* --- Views --- */
#auth-view {
    height: 100vh; display: flex; flex-direction: column;
    justify-content: center; align-items: center; text-align: center; padding: 40px;
}

/* Dashboard Stats */
.overview-stats { display: flex; gap: 10px; margin-bottom: 15px; }
.stat-box { background: var(--surface); border: 1px solid var(--surface-2); border-radius: 12px; padding: 12px; flex: 1; text-align: center; }
.stat-value { font-size: 20px; font-weight: bold; display: block; }
.stat-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; }

/* Sport Grid */
.breakdown-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 20px; }
.breakdown-item { background: rgba(255,255,255,0.03); border-radius: 8px; padding: 8px; display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.sport-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.sport-card { background: var(--surface); border-radius: 16px; padding: 20px; display: flex; flex-direction: column; justify-content: center; align-items: center; cursor: pointer; border: 1px solid var(--surface-2); transition: all 0.2s; min-height: 130px; }
.sport-card:active { background: var(--surface-2); }
.sport-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.sport-emoji { font-size: 40px; margin-bottom: 8px; }
.sport-name { font-weight: 700; font-size: 16px; }

.app-header { display: flex; align-items: center; margin-bottom: 20px; }

/* --- Team Builder (Main Game) --- */
.team-box { background: var(--surface-2); border-radius: 12px; padding: 12px; margin-bottom: 10px; min-height: 50px; }
.team-box h4 { margin-bottom: 8px; font-size: 0.8em; text-transform: uppercase; letter-spacing: 1px; }
.team-a-box { border-left: 4px solid var(--team-a); }
.team-b-box { border-left: 4px solid var(--team-b); }
.active-pool-list { display: grid; gap: 6px; }
.pool-player-row { display: flex; justify-content: space-between; align-items: center; background: var(--surface); padding: 8px 12px; border-radius: 10px; border: 1px solid var(--surface-2); }
.pool-actions { display: flex; gap: 6px; }
.btn-add-a { background: rgba(251, 191, 36, 0.15); color: var(--team-a); border: 1px solid var(--team-a); }
.btn-add-b { background: rgba(59, 130, 246, 0.15); color: var(--team-b); border: 1px solid var(--team-b); }
.selected-player-chip { display: inline-flex; align-items: center; background: rgba(255,255,255,0.1); padding: 4px 8px; border-radius: 20px; font-size: 12px; margin-right: 4px; margin-bottom: 4px; }
.remove-chip { margin-left: 6px; font-weight: bold; color: var(--text-muted); cursor: pointer; }

/* --- Score Screen --- */
.score-input-container { display: flex; justify-content: space-around; align-items: center; margin: 20px 0; }
.score-box { text-align: center; width: 45%; }
.score-input { font-size: 40px; text-align: center; font-weight: bold; }

/* --- Modals --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); z-index: 200; display: flex; justify-content: center; align-items: center; padding: 20px; }
.modal-content { background: var(--surface); padding: 20px; border-radius: 16px; width: 100%; max-width: 500px; max-height: 90vh; overflow-y: auto; border: 1px solid var(--surface-2); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.edit-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; padding: 10px; background: var(--surface-2); border-radius: 8px; }

/* --- Profile Stats --- */
.profile-avatar-large { width: 90px; height: 90px; border-radius: 50%; margin-bottom: 10px; border: 3px solid var(--surface-2); object-fit: cover; }
.profile-total-stat { font-size: 28px; font-weight: 800; margin-bottom: 2px; }
.profile-sport-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.profile-stat-card { background: var(--surface-2); padding: 10px; border-radius: 10px; display: flex; flex-direction: column; align-items: center; text-align: center; }

/* --- Filters --- */
.leaderboard-filters { display: flex; gap: 10px; margin-bottom: 15px; overflow-x: auto; padding-bottom: 5px; }
.filter-btn { background: var(--surface); border: 1px solid var(--surface-2); padding: 8px 16px; border-radius: 20px; color: var(--text-muted); font-size: 13px; font-weight: 600; cursor: pointer; white-space: nowrap; transition: all 0.2s; }
.filter-btn:hover { background: var(--surface-2); }
.filter-btn.active { background: var(--primary); color: white; border-color: var(--primary); }

/* --- NAVIGATION & OVERLAY --- */
.nav-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 99;
}

.nav-bar {
    position: fixed; top: 0; left: 0; height: 100vh;
    width: 260px;
    background: #181818;
    border-right: 1px solid var(--surface-2);
    z-index: 100;
    display: flex; flex-direction: column; justify-content: space-between;
    transition: transform 0.3s ease;
    transform: translateX(-100%); /* Hidden by default on mobile */
}

/* Mobile: Show nav when class is added */
.nav-bar.mobile-open { transform: translateX(0); }

/* Navigation Items */
.nav-links { flex: 1; padding-top: 10px; overflow-y: auto; }
.nav-item {
    display: flex; align-items: center; gap: 16px;
    padding: 14px 24px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 15px;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { color: var(--primary); background: rgba(139, 92, 246, 0.1); border-right: 3px solid var(--primary); }
.nav-icon-svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.hidden-nav-item { display: none !important; }

/* Toggle & Brand inside Nav */
.nav-header-container {
    display: flex; align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--surface-2);
    height: 80px;
    flex-shrink: 0;
}
.nav-toggle-btn { cursor: pointer; color: var(--text-muted); margin-right: 15px; }
.nav-toggle-btn:hover { color: var(--text); }
.nav-brand { font-size: 18px; font-weight: 800; color: white; white-space: nowrap; overflow: hidden; }

/* Accordion Styles */
.nav-section-title {
    padding: 20px 24px 10px 24px;
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}
.accordion-trigger {
    justify-content: space-between;
}
.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: rgba(255,255,255,0.03);
}
.nav-accordion.open .accordion-content {
    max-height: 200px; /* Arbitrary large height */
}
.nav-accordion.open .chevron-icon {
    transform: rotate(180deg);
}
.chevron-icon {
    width: 16px; height: 16px; fill:none; stroke:currentColor; stroke-width:2;
    transition: transform 0.3s;
}
.nav-sub-item {
    display: block;
    padding: 10px 24px 10px 50px;
    font-size: 14px;
    color: var(--text-muted);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}
.nav-sub-item:hover { color: var(--text); }

/* Active state for sub items - matching main nav style */
.nav-sub-item.active {
    color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
    border-right: 3px solid var(--primary);
}

/* --- Mobile Close Button in Nav --- */
.nav-close-btn {
    display: none; /* Hidden on desktop */
}

/* MOBILE STYLES */
@media (max-width: 767px) {
    /* Show mobile close button */
    .nav-close-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background: rgba(255,255,255,0.1);
        color: var(--text);
        cursor: pointer;
        position: absolute;
        bottom: 20px;
        right: 20px;
        transition: background 0.2s;
    }
    .nav-close-btn:active {
        background: rgba(255,255,255,0.2);
    }

    /* Reduce vertical padding to fit more items */
    .nav-item {
        padding: 10px 20px;
        font-size: 14px;
    }
    .nav-section-title {
        padding: 15px 20px 5px 20px;
    }
    .nav-sub-item {
        padding: 8px 20px 8px 45px;
    }
    .nav-header-container {
        height: 60px;
        padding: 10px 20px;
    }
}


/* DESKTOP STYLES - Wrapped in :not(.simulate-mobile) to allow toggling */
@media (min-width: 768px) {
    /* Hide Mobile Headers & FAB on Desktop (unless simulated) */
    body:not(.simulate-mobile) #mobile-header { display: none; }
    
    /* Body padding logic for desktop nav */
    body.desktop-nav-expanded:not(.simulate-mobile) { padding-left: var(--nav-width); }
    body.desktop-nav-collapsed:not(.simulate-mobile) { padding-left: var(--nav-width-collapsed); }

    /* RESET CONTAINER PADDING FOR DESKTOP (remove mobile clearance) */
    body:not(.simulate-mobile) .container {
        padding-bottom: 20px; 
    }

    /* Nav bar is always visible on desktop (unless logged out or simulated) */
    body:not(.simulate-mobile) .nav-bar { 
        transform: translateX(0); 
        width: var(--nav-width); 
    }
    
    /* Collapsed state */
    body:not(.simulate-mobile) .nav-bar.collapsed { width: var(--nav-width-collapsed); }
    body:not(.simulate-mobile) .nav-bar.collapsed .nav-brand { display: none; }
    body:not(.simulate-mobile) .nav-bar.collapsed .nav-text { display: none; }
    body:not(.simulate-mobile) .nav-bar.collapsed .nav-header-container { justify-content: center; padding: 20px 0; }
    body:not(.simulate-mobile) .nav-bar.collapsed .nav-toggle-btn { margin: 0; }
    body:not(.simulate-mobile) .nav-bar.collapsed .toggle-icon-svg { transform: rotate(180deg); }
    body:not(.simulate-mobile) .nav-bar.collapsed .nav-item { justify-content: center; padding: 20px 0; }
    body:not(.simulate-mobile) .nav-bar.collapsed .nav-footer .nav-item { justify-content: center; }
    
    body:not(.simulate-mobile) .nav-bar.collapsed .nav-section-title { display: none; }
    body:not(.simulate-mobile) .nav-bar.collapsed .chevron-icon { display: none; }
    body:not(.simulate-mobile) .nav-bar.collapsed .accordion-content { display: none; } /* Hide submenus when side nav collapsed */

    /* Hide overlay on desktop */
    body:not(.simulate-mobile) .nav-overlay { display: none !important; }
}