
    :root {
        --uk-blue: #0033A0;
        --uk-white: #FFFFFF;
        --uk-silver: #808080;
    }

    .players-header {
        background: var(--uk-blue);
        color: white;
        padding: 2rem 0;
        border-bottom: 5px solid var(--uk-silver);
    }

    .stats-table {
        border-collapse: separate;
        border-spacing: 0;
        transition: all 0.3s ease;
        width: 100%;
    }

    .stats-table.show-advanced {
        min-width: 1200px;
    }

    .stats-table thead th {
        background: var(--uk-blue);
        color: white;
        position: sticky;
        top: 0;
        z-index: 10;
        cursor: pointer;
    }

    .stats-table tbody tr {
        transition: all 0.3s ease;
        cursor: pointer;
    }

    .stats-table tbody tr:hover {
        background-color: rgba(0, 51, 160, 0.05);
        transform: translateX(5px);
    }

    .player-photo {
        width: 50px;
        height: 50px;
        border-radius: 50%;
        object-fit: cover;
        margin-right: 10px;
        border: 2px solid var(--uk-blue);
    }

    .player-photo-lg {
        width: 120px;
        height: 120px;
        border-radius: 50%;
        object-fit: cover;
        border: 4px solid var(--uk-blue);
        margin-bottom: 15px;
    }

    .season-selector {
        max-width: 200px;
        margin-left: 1rem;
    }

    .bg-uk-blue {
        background-color: #0033A0; 
    }

    .stat-card {
        border-radius: 10px;
        box-shadow: 0 4px 8px rgba(0,0,0,0.1);
        transition: all 0.3s ease;
        border-top: 4px solid var(--uk-blue);
    }

    .stat-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    }

    .rating-cell {
        font-weight: bold;
        display: inline-block;
        width: 40px;
        text-align: center;
        border-radius: 4px;
    }

    .rating-10 { background-color: #03ee3a; color: white; }
    .rating-9 { background-color: #28a745; color: white; }
    .rating-8 { background-color: #5cb85c; color: white; }
    .rating-7 { background-color: #7bbd7b; color: white; }
    .rating-6 { background-color: #eeff00; }
    .rating-5 { background-color: #ff9900; }
    .rating-4 { background-color: #ffc107; }
    .rating-3 { background-color: #fd7e14; color: white; }
    .rating-2 { background-color: #dc3545; color: white; }
    .rating-1 { background-color: #bd2130; color: white; }
    .rating-0 { background-color: #721c24; color: white; }
    .rating-na { background-color: #6c757d; color: white; }

    .player-detail-header {
        position: relative;
        background: linear-gradient(135deg, var(--uk-blue) 0%, #0056b3 100%);
        color: white;
        padding: 2rem 0;
        margin-bottom: 2rem;
        border-radius: 0 0 10px 10px;
    }

    .back-button {
        position: absolute;
        left: 20px;
        top: 20px;
        z-index: 1;
    }

    .stat-pill {
        display: inline-block;
        padding: 5px 10px;
        margin: 2px;
        border-radius: 20px;
        background-color: #f8f9fa;
        font-size: 0.9rem;
    }

    .stat-highlight {
        background-color: rgba(0, 123, 255, 0.1);
        font-weight: bold;
    }

    .game-log-row {
        transition: all 0.2s ease;
    }

    .game-log-row:hover {
        background-color: rgba(0, 51, 160, 0.05);
    }

    #playerListSection {
        transition: all 0.3s ease;
    }

    #playerDetailSection {
        display: none;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sort-arrow {
        display: inline-block;
        width: 15px;
        margin-left: 5px;
    }

    .sort-arrow::after {
        content: "↕";
        color: var(--uk-silver);
    }

    .active-sort .sort-arrow::after {
        color: var(--uk-white);
    }

    .asc .sort-arrow::after {
        content: "↓";
    }

    .desc .sort-arrow::after {
        content: "↑";
    }

    .bbn-title {
        color: var(--uk-blue);
        font-family: 'Arial Black', sans-serif;
        font-size: 2.5rem;
        letter-spacing: 1.5px;
    }
    
    /* Grid View Styles */
    .player-card {
        cursor: pointer;
        transition: all 0.3s ease;
        border: 1px solid rgba(0, 0, 0, 0.125);
        border-radius: 10px;
        overflow: hidden;
        height: 100%;
        position: relative;
        margin-bottom: 1.5rem;
    }
    
    .player-card:hover {
        transform: translateY(-5px);
        box-shadow: 0 10px 20px rgba(0,0,0,0.1);
    }
    
    .player-card-header {
        background-color: var(--uk-blue);
        height: 120px;
        position: relative;
        overflow: hidden;
        display: flex;
        justify-content: center;
        align-items: center;
    }
    
    .player-card-img {
        width: 100px;
        height: 100px;
        border-radius: 50%;
        object-fit: cover;
        border: 4px solid white;
        z-index: 2;
        position: relative;
    }
    
    .card-backdrop {
        position: absolute;
        width: 100%;
        height: 100%;
        background-color: var(--uk-blue);
        z-index: 1;
    }
    
    .player-card .card-body {
        padding: 1.25rem;
        text-align: center;
    }
    
    .player-card .card-title {
        font-size: 1.1rem;
        margin-bottom: 0.75rem;
        font-weight: bold;
    }
    
    .player-card .card-text {
        font-size: 0.9rem;
        color: #666;
    }
    
    .player-card .player-stats {
        display: flex;
        justify-content: space-around;
        margin-top: 10px;
    }
    
    .player-card .player-stat {
        display: flex;
        flex-direction: column;
        align-items: center;
    }
    
    .player-card .stat-label {
        font-size: 0.8rem;
        color: #777;
    }
    
    .player-card .stat-value {
        font-weight: bold;
        font-size: 1rem;
    }
    
    #playersGridView {
        display: none;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 1.5rem;
        margin-top: 1rem;
    }
    
    .player-bio {
        font-size: 0.85rem;
        line-height: 1.4;
        height: 60px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 3;
        line-clamp: 3;
        -webkit-box-orient: vertical;
    }

    .advanced-stat {
        display: none;
    }

    .stats-table.show-advanced .advanced-stat {
        display: table-cell;
    }

    .table-responsive {
        transition: all 0.3s ease;
        overflow-x: auto;
    }

    .social-media {
        display: flex;
        justify-content: center;
        margin-bottom: 0.5rem;
        margin-top: 0.5rem;
    }

    .social-links {
        display: flex;
        gap: 5px;
    }

    .social-link {
        display: flex;
        align-items: center;
        gap: 5px;
        padding: 8px 15px;
        background-color: #f0f0f0;
        border-radius: 5px;
        text-decoration: none;
        color: #333;
        transition: background-color 0.3s ease;
    }

    .social-link:hover {
        background-color: #e0e0e0;
    }

    .social-link i {
        font-size: 1.2em;
    }

    .past-seasons-table {
        font-size: 0.85rem;
    }

    /* Mobile Responsive Styles */
    @media (max-width: 768px) {
        .stats-table {
            font-size: 0.8rem;
        }
        
        .player-photo {
            width: 30px;
            height: 30px;
        }

        .player-photo-lg {
            width: 80px;
            height: 80px;
        }
        
        .back-button {
            left: 10px;
            top: 10px;
            padding: 0.375rem 0.75rem;
            font-size: 0.875rem;
        }
        
        .player-card-img {
            width: 80px;
            height: 80px;
        }
        
        .player-card-header {
            height: 100px;
        }
        
        .navbar {
            padding: 0.5rem 0;
        }
        
        .bbn-title {
            font-size: 1.8rem;
            margin: 0 10px;
        }
        
        .dropdown-toggle {
            padding: 0.25rem 0.5rem;
            font-size: 0.9rem;
        }
        
        .players-header h1 {
            font-size: 2rem;
            margin-bottom: 0.5rem !important;
        }
        
        /* Center season selector on mobile */
        .season-selector-container {
            display: flex;
            justify-content: center;
            width: 100%;
            margin: 0.5rem 0;
        }
        
        .season-selector {
            margin: 0 auto !important;
            max-width: 200px;
        }
        
        .players-header .d-flex {
            flex-direction: column;
            align-items: center;
        }
        
        .players-header .me-3 {
            margin-right: 0 !important;
        }
        
        .player-bio {
            height: 40px;
            font-size: 0.8rem;
        }
        
        .table th, .table td {
            font-size: 0.8rem;
            padding: 4px 6px;
        }
        
        /* Mobile table improvements */
        .mobile-player-cell {
            min-width: 180px !important;
            padding: 8px 6px !important;
        }
        
        .mobile-stats {
            font-size: 0.8rem;
            line-height: 1.2;
        }
        
        .mobile-stats div {
            margin: 0;
        }
        
        .mobile-stats strong {
            font-size: 0.9rem;
            color: var(--uk-blue);
        }
        
        .mobile-stats small {
            font-size: 0.7rem;
            color: #666;
            text-transform: uppercase;
            font-weight: 500;
        }
        
        .stats-table {
            font-size: 0.75rem;
            min-width: auto !important;
        }
        
        .stats-table th, 
        .stats-table td {
            padding: 6px 4px;
            white-space: nowrap;
            vertical-align: middle;
        }
        
        .player-photo {
            width: 35px;
            height: 35px;
            margin-right: 8px;
        }
        
        .rating-cell {
            font-size: 0.75rem !important;
            width: 35px;
            padding: 4px 6px;
        }
        
        .table-responsive {
            overflow-x: auto;
            -webkit-overflow-scrolling: touch;
        }
        
        #playersGridView {
            grid-template-columns: 1fr;
            gap: 1rem;
            padding: 0 10px;
        }
        
        .player-card {
            margin-bottom: 1rem;
        }
        
        .player-card-header {
            height: 80px;
        }
        
        .player-card-img {
            width: 60px;
            height: 60px;
            border-width: 2px;
        }
        
        .player-bio {
            height: 40px;
            font-size: 0.75rem;
            line-height: 1.3;
        }
        
        .players-header {
            padding: 1rem 0;
        }
        
        .players-header h1 {
            font-size: 1.8rem;
            margin-bottom: 1rem;
        }
        
        .players-header .d-flex {
            flex-direction: column;
            gap: 1rem;
        }
        
        .players-header .form-check {
            margin: 0;
        }
        
        .bbn-title {
            font-size: 1.5rem;
            letter-spacing: 1px;
        }
        
        .dropdown-toggle {
            font-size: 0.85rem;
            padding: 0.375rem 0.75rem;
        }
        
        /* Default mobile view - show PPG, RPG, APG and Rating */
        .stats-table:not(.show-advanced) {
            width: 100% !important;
        }
        
        .stats-table:not(.show-advanced) th:nth-child(1),
        .stats-table:not(.show-advanced) td:nth-child(1) {
            width: 40% !important; /* Reduced from 30% */
        }
        
        .stats-table:not(.show-advanced) th:nth-child(2),
        .stats-table:not(.show-advanced) td:nth-child(2),
        .stats-table:not(.show-advanced) th:nth-child(3),
        .stats-table:not(.show-advanced) td:nth-child(3),
        .stats-table:not(.show-advanced) th:nth-child(4),
        .stats-table:not(.show-advanced) td:nth-child(4),
        .stats-table:not(.show-advanced) th:nth-child(5),
        .stats-table:not(.show-advanced) td:nth-child(5) {
            width: 20% !important; /* Adjusted for new total */
            text-align: center;
        }
        
        /* When advanced stats is shown on mobile, show all columns */
        .stats-table.show-advanced th,
        .stats-table.show-advanced td {
            display: table-cell !important;
        }
        
        /* Make sure advanced stats table is scrollable on mobile */
        .stats-table.show-advanced {
            min-width: 1200px;
        }
        
        /* Format MPG, PPG, RPG, APG columns in advanced stats view */
        .stats-table.show-advanced th:nth-child(6), /* MPG */
        .stats-table.show-advanced td:nth-child(6),
        .stats-table.show-advanced th:nth-child(7), /* PPG */
        .stats-table.show-advanced td:nth-child(7),
        .stats-table.show-advanced th:nth-child(8), /* RPG */
        .stats-table.show-advanced td:nth-child(8),
        .stats-table.show-advanced th:nth-child(9), /* APG */
        .stats-table.show-advanced td:nth-child(9) {
            text-align: center;
            min-width: 60px;
            padding: 8px 4px;
        }
        
        /* Ensure all stat columns have consistent alignment */
        .stats-table.show-advanced th:nth-child(n+6):nth-child(-n+11),
        .stats-table.show-advanced td:nth-child(n+6):nth-child(-n+11) {
            text-align: center;
        }
        
        /* Make table responsive for advanced stats */
        .table-responsive:has(.stats-table.show-advanced) {
            overflow-x: auto;
        }
        
        /* Hide advanced stats columns when not in advanced mode */
        .stats-table:not(.show-advanced) .advanced-stat {
            display: none !important;
        }
        
        /* Past seasons table adjustments */
        .past-seasons-table th:nth-child(4), /* GP */
        .past-seasons-table th:nth-child(11), /* FG% */
        .past-seasons-table th:nth-child(12), /* 3P% */
        .past-seasons-table th:nth-child(13), /* FT% */
        .past-seasons-table td:nth-child(4),
        .past-seasons-table td:nth-child(11),
        .past-seasons-table td:nth-child(12),
        .past-seasons-table td:nth-child(13) {
            display: none;
        }
        
        /* NEW: Mobile Advanced Stats Alignment Fix */
        .stats-table.show-advanced th,
        .stats-table.show-advanced td {
            text-align: center;
            padding: 8px 4px;
        }

        .stats-table.show-advanced td:first-child {
            text-align: center;
        }

        .stats-table.show-advanced td:first-child .player-photo {
            margin: 0 auto;
            display: block;
        }

        .stats-table.show-advanced td:first-child strong {
            display: block;
            text-align: center;
            margin-top: 4px;
        }

        .stats-table.show-advanced .advanced-stat {
            font-size: 0.7rem;
        }
        
        /* First initial + last name for mobile non-advanced view */
        .mobile-player-name {
            display: flex;
            flex-direction: column;
            line-height: 1.2;
        }
        
        .mobile-player-name .full-name {
            display: none;
        }
        
        .mobile-player-name .short-name {
            display: block;
            font-weight: bold;
            line-height: 0.5;
        }
        
        /* NEW: Make normal player list thinner for mobile */
        .stats-table:not(.show-advanced) {
            font-size: 0.65rem; /* Reduced from 0.7rem */
        }
        
        .stats-table:not(.show-advanced) th, 
        .stats-table:not(.show-advanced) td {
            padding: 3px 1px; /* Reduced from 4px 2px */
        }
        
        .stats-table:not(.show-advanced) th:nth-child(1),
        .stats-table:not(.show-advanced) td:nth-child(1) {
            width: 22% !important; /* Reduced from 30% */
        }
        
        .stats-table:not(.show-advanced) th:nth-child(2),
        .stats-table:not(.show-advanced) td:nth-child(2),
        .stats-table:not(.show-advanced) th:nth-child(3),
        .stats-table:not(.show-advanced) td:nth-child(3),
        .stats-table:not(.show-advanced) th:nth-child(4),
        .stats-table:not(.show-advanced) td:nth-child(4),
        .stats-table:not(.show-advanced) th:nth-child(5),
        .stats-table:not(.show-advanced) td:nth-child(5) {
            width: 18.75% !important; /* Adjusted for new total */
        }
        
        .player-photo {
            width: 24px; /* Reduced from 28px */
            height: 24px;
            margin-right: 4px;
        }
        
        .mobile-stats {
            font-size: 0.65rem; /* Reduced from 0.7rem */
            line-height: 1.1;
        }
        
        .mobile-stats strong {
            font-size: 0.7rem; /* Reduced from 0.75rem */
        }
        
        .mobile-stats small {
            font-size: 0.55rem; /* Reduced from 0.6rem */
        }
        
        .rating-cell {
            width: 24px !important; /* Reduced from 28px */
            font-size: 0.6rem !important; /* Reduced from 0.65rem */
            padding: 2px 3px !important;
        }
        
        .mobile-player-cell {
            min-width: 100px !important; /* Reduced from 120px */
            padding: 4px 2px !important;
        }
    }

    /* Tablet adjustments (768px - 991px) */
    @media (min-width: 769px) and (max-width: 991px) {
        .stats-table {
            font-size: 0.85rem;
        }
        
        .stats-table th, 
        .stats-table td {
            padding: 6px 8px;
        }
        
        .player-photo {
            width: 40px;
            height: 40px;
        }
        
        #playersGridView {
            grid-template-columns: repeat(2, 1fr);
            gap: 8px;
        }
    }

    /* Large mobile/small tablet (576px - 768px) */
    @media (min-width: 576px) and (max-width: 768px) {
        .mobile-player-cell {
            min-width: 200px !important;
        }
        
        #playersGridView {
            grid-template-columns: repeat(2, 1fr);
        }
    }

    /* Very small mobile (< 576px) */
    @media (max-width: 575px) {
        .mobile-player-cell {
            min-width: 160px !important;
            padding: 6px 4px !important;
        }
        
        .player-photo {
            width: 30px;
            height: 30px;
            margin-right: 6px;
        }
        
        .mobile-stats {
            font-size: 0.75rem;
        }
        
        .mobile-stats strong {
            font-size: 0.8rem;
        }
        
        .mobile-stats small {
            font-size: 0.65rem;
        }
        
        .rating-cell {
            width: 30px !important;
            font-size: 0.7rem !important;
            padding: 3px 4px !important;
        }
        
        .bbn-title {
            font-size: 1.3rem;
        }
        
        .players-header h1 {
            font-size: 1.5rem;
        }
        
        .season-selector {
            max-width: 150px;
            font-size: 0.85rem;
        }
        
        .form-check-label {
            font-size: 0.85rem;
        }
        
        /* NEW: Even smaller player column for very small screens */
        .stats-table:not(.show-advanced) th:nth-child(1),
        .stats-table:not(.show-advanced) td:nth-child(1) {
            width: 22% !important; /* Reduced from 30% */
        }
        
        .stats-table:not(.show-advanced) th:nth-child(2),
        .stats-table:not(.show-advanced) td:nth-child(2),
        .stats-table:not(.show-advanced) th:nth-child(3),
        .stats-table:not(.show-advanced) td:nth-child(3),
        .stats-table:not(.show-advanced) th:nth-child(4),
        .stats-table:not(.show-advanced) td:nth-child(4),
        .stats-table:not(.show-advanced) th:nth-child(5),
        .stats-table:not(.show-advanced) td:nth-child(5) {
            width: 19.5% !important; /* Adjusted for new total */
        }
    }

    /* Landscape orientation on mobile */
    @media (max-width: 768px) and (orientation: landscape) {
        .players-header {
            padding: 0.75rem 0;
        }
        
        .players-header h1 {
            font-size: 1.5rem;
            margin-bottom: 0.5rem;
        }
        
        .players-header .d-flex {
            flex-direction: row;
            flex-wrap: wrap;
            justify-content: center;
            gap: 0.5rem;
        }
    }

    /* Ensure grid view preference is maintained */
    .view-preference-grid #playerListSection {
        display: none !important;
    }

    .view-preference-grid #playersGridView {
        display: grid !important;
    }

    .view-preference-table #playerListSection {
        display: block !important;
    }

    .view-preference-table #playersGridView {
        display: none !important;
    }

    /* Desktop-specific styles - Updated to handle advanced stats properly */
    @media (min-width: 992px) {
        /* Remove the problematic full-width rule that was causing overflow */
        .table-responsive:has(.stats-table.show-advanced) {
            overflow-x: auto;
            /* Removed the problematic full-width styling */
        }

        /* Better column management for advanced stats on desktop */
        .stats-table.show-advanced {
            width: 100%;
            table-layout: fixed;
            min-width: auto; /* Override the mobile min-width */
        }

        /* Optimize column widths for desktop advanced view */
        .stats-table.show-advanced th,
        .stats-table.show-advanced td {
            padding: 6px 8px; /* Reduced padding */
            font-size: 0.85rem; /* Slightly smaller font */
            white-space: nowrap;
            text-align: center;
            overflow: hidden;
            text-overflow: ellipsis;
        }

        /* Player name column - wider since it contains the most info */
        .stats-table.show-advanced th:first-child,
        .stats-table.show-advanced td:first-child {
            width: 200px;
            text-align: left;
            min-width: 200px;
        }

        /* Basic info columns */
        .stats-table.show-advanced th:nth-child(2), /* Grade */
        .stats-table.show-advanced td:nth-child(2),
        .stats-table.show-advanced th:nth-child(3), /* POS */
        .stats-table.show-advanced td:nth-child(3) {
            width: 65px;
        }

        .stats-table.show-advanced th:nth-child(4), /* HT */
        .stats-table.show-advanced td:nth-child(4),
        .stats-table.show-advanced th:nth-child(5), /* WT */
        .stats-table.show-advanced td:nth-child(5) {
            width: 75px;
        }

        /* Stats columns - wider for better readability */
        .stats-table.show-advanced th:nth-child(n+6):nth-child(-n+21), /* All stat columns */
        .stats-table.show-advanced td:nth-child(n+6):nth-child(-n+21) {
            width: 70px;
            min-width: 65px;
        }

        /* Rating column - wider for visibility */
        .stats-table.show-advanced th:last-child, /* Rating */
        .stats-table.show-advanced td:last-child {
            width: 80px;
        }

        /* Ensure the table container doesn't exceed viewport */
        .stats-table.show-advanced {
            max-width: calc(100vw - 80px); /* Account for container padding */
        }

        /* Make sure the container respects the max-width */
        .container:has(.stats-table.show-advanced) {
            max-width: none;
            padding: 0 20px;
        }
    }

    /* Large desktop optimization (1400px+) */
    @media (min-width: 1400px) {
        .stats-table.show-advanced th,
        .stats-table.show-advanced td {
            padding: 8px 10px; /* Slightly more padding on large screens */
            font-size: 0.9rem;
        }

        .stats-table.show-advanced th:first-child,
        .stats-table.show-advanced td:first-child {
            width: 200px;
            min-width: 200px;
        }

        .stats-table.show-advanced th:nth-child(n+6):nth-child(-n+21),
        .stats-table.show-advanced td:nth-child(n+6):nth-child(-n+21) {
            width: 60px;
            min-width: 55px;
        }
    }

    /* Show full name on desktop and tablet */
    @media (min-width: 769px) {
        .mobile-player-name .full-name {
            display: block;
        }
        
        .mobile-player-name .short-name {
            display: none;
        }
    }
