/* Tablet */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .comparison-panel {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: auto;
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
        max-height: 60vh;
        overflow-y: auto;
        transform: translateY(calc(100% - 60px));
        transition: transform var(--transition-slow);
        z-index: var(--z-dropdown);
    }

    .comparison-panel.expanded {
        transform: translateY(0);
    }

    .panel-header {
        cursor: pointer;
    }

    .comparison-grid.players-3 {
        grid-template-columns: 1fr;
    }
}

/* Mobile */
@media (max-width: 768px) {
    .header-content {
        display: grid;
        grid-template-columns: 1fr auto;
        gap: 12px;
        padding-bottom: 10px;
        /* Add space for search box */
    }

    .logo {
        grid-column: 1;
        grid-row: 1;
    }

    .header-controls {
        grid-column: 2;
        grid-row: 1;
        display: flex;
        align-items: center;
        gap: 12px;
    }

    /* Make search visible and full width on row 2 */
    .search-box {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
        display: block !important;
        /* Force show */
        margin: 0;
    }

    .search-input {
        width: 100%;
        /* Ensure input takes full width */
    }

    .filters-container {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        flex-wrap: wrap;
        justify-content: center;
    }

    /* Mobile Navigation */
    .nav-toggle {
        display: flex;
        /* Show hamburger */
        font-size: 1.5rem;
        background: var(--bg-tertiary);
        width: 40px;
        height: 40px;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        color: var(--text-primary);
        z-index: 102;
        border: none;
        cursor: pointer;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        width: 90%;
        left: 5%;
        background: var(--bg-card);
        /* Solid background for readability */
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 10px;
        position: absolute;
        top: 70px;
        z-index: 101;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    }

    .nav-link {
        justify-content: flex-start;
        /* Align text left */
        width: 100%;
        padding: 12px 20px;
        font-size: 1rem;
    }

    .nav-links.open {
        display: flex;
        animation: scaleIn 0.2s ease-out;
    }

    @keyframes scaleIn {
        from {
            opacity: 0;
            transform: scale(0.95) translateY(-10px);
        }

        to {
            opacity: 1;
            transform: scale(1) translateY(0);
        }
    }

    .nav-link {
        width: 100%;
        padding: 12px 20px;
        border-radius: var(--radius-lg);
    }

    .nav-link:hover {
        background: var(--bg-tertiary);
    }

    /* Adjust Header Layout */
    .header-content {
        position: relative;
        padding-right: 50px;
        /* Space for toggle */
    }
}

.header-controls {
    width: 100%;
    justify-content: flex-end;
}

/* Quick Jump Slider Mobile */
.quick-jump-slider {
    position: sticky;
    top: 0;
    z-index: 90;
    margin: 0 -20px 20px -20px;
    /* Bleed to edge */
    padding: 10px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}


.players-grid {
    grid-template-columns: 1fr;
}

.comparison-grid.players-2 {
    grid-template-columns: 1fr;
}

.modal {
    max-height: 95vh;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal-body {
    max-height: calc(95vh - 70px);
}

.chart-container {
    height: 300px;
}
}

/* Small Mobile */
@media (max-width: 480px) {
    :root {
        --font-size-3xl: 1.75rem;
        --font-size-4xl: 2rem;
    }

    .container {
        padding: 0 var(--space-4);
    }

    .player-stats {
        grid-template-columns: 1fr;
    }

    .modal-header {
        padding: var(--space-4);
    }

    .modal-body {
        padding: var(--space-4);
    }
}

/* Filters Drawer Mobile */
@media (max-width: 900px) {
    .filters-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 300px;
        background: var(--bg-card);
        z-index: 1000;
        padding: 24px;
        border-right: 1px solid var(--border-color);
        box-shadow: 4px 0 12px rgba(0, 0, 0, 0.1);
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
        overflow-y: auto;
    }

    .filters-sidebar.open {
        transform: translateX(0);
    }

    .filters-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        display: none;
        backdrop-filter: blur(2px);
    }

    .filters-overlay.open {
        display: block;
    }

    .filter-toggle-btn {
        display: flex !important;
        align-items: center;
        gap: 8px;
        padding: 10px 16px;
        background: var(--bg-secondary);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        color: var(--text-primary);
        font-weight: 600;
        cursor: pointer;
        margin-bottom: 20px;
        width: 100%;
        justify-content: center;
    }

    .close-filters-btn {
        display: block !important;
        position: absolute;
        top: 15px;
        right: 15px;
        background: none;
        border: none;
        font-size: 1.5rem;
        color: var(--text-secondary);
        cursor: pointer;
        z-index: 1001;
    }
}