/* Modern Leaderboard Modal - 2025 Design */
.leaderboard-modal {
    z-index: 10000;
}

.leaderboard-modal .modal-content {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    background: linear-gradient(145deg, rgba(10, 25, 47, 0.3), rgba(0, 15, 30, 0.3));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 212, 255, 0.5);
    border-radius: 20px;
    box-shadow: 
        0 8px 32px rgba(0, 212, 255, 0.4),
        0 2px 20px rgba(0, 0, 0, 0.8),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    margin: 5% auto;
    max-width: 900px;
    padding: 0;
    overflow: hidden;
}

/* Fallback for browsers without backdrop-filter support */
@supports not (backdrop-filter: blur(20px)) {
    .leaderboard-modal .modal-content {
        background: linear-gradient(145deg, rgba(10, 25, 47, 0.9), rgba(0, 15, 30, 0.9));
    }
}

/* Modern Header Section */
.leaderboard-modal .modal-header-section {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1) 0%, rgba(0, 150, 200, 0.05) 100%);
    border-bottom: 1px solid rgba(0, 212, 255, 0.2);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    gap: 20px;
    flex-shrink: 0;
    border-radius: 20px 20px 0 0;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    font-size: 24px;
    opacity: 0.9;
}

.header-text {
    color: #00d4ff;
    font-weight: 700;
    font-size: 24px;
    margin: 0;
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.5);
    letter-spacing: 0.5px;
}

.close-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    transform: rotate(90deg) scale(1.1);
}

/* Header Dropdown (for landscape mode) */
.header-dropdown {
    flex: 0 0 auto;
}

.header-dropdown .custom-dropdown {
    width: 200px;
}

.header-dropdown .dropdown-selected {
    padding: 8px 12px;
    font-size: 14px;
    gap: 8px;
}

.header-dropdown .dropdown-arrow {
    font-size: 10px;
}

.header-dropdown .dropdown-options {
    top: calc(100% + 6px);
}

.header-dropdown .dropdown-option {
    padding: 8px 12px;
    font-size: 14px;
    gap: 8px;
}

/* Modern Category Dropdown Section */
.leaderboard-category-section {
    display: flex;
    justify-content: center;
    padding: 16px 24px 20px;
    position: relative;
}

.custom-dropdown {
    position: relative;
    width: 280px;
    user-select: none;
}

.dropdown-selected {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.95);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.dropdown-selected:hover {
    background: rgba(0, 212, 255, 0.1);
    border-color: rgba(0, 212, 255, 0.5);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.3),
                inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.dropdown-icon {
    font-size: 18px;
    opacity: 0.8;
}

.dropdown-text {
    flex: 1;
    text-align: left;
}

.dropdown-arrow {
    font-size: 12px;
    transition: transform 0.2s ease;
    opacity: 0.6;
}

.custom-dropdown.open .dropdown-arrow {
    transform: rotate(180deg);
}

.dropdown-options {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: rgba(10, 14, 25, 0.95);
    border: 2px solid rgba(0, 212, 255, 0.3);
    border-radius: 12px;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(20px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5),
                0 0 40px rgba(0, 212, 255, 0.2);
    z-index: 100;
}

.custom-dropdown.open .dropdown-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.dropdown-option:hover {
    background: rgba(0, 212, 255, 0.05);
    color: #fff;
    padding-left: 25px;
}

.dropdown-option.active {
    background: rgba(0, 212, 255, 0.1);
    color: #00d4ff;
}

.option-icon {
    font-size: 18px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.dropdown-option:hover .option-icon,
.dropdown-option.active .option-icon {
    opacity: 1;
    filter: drop-shadow(0 0 8px #00d4ff);
}

/* Modern Tabs Section */
.leaderboard-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 20px 24px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
}

.tab-button {
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 20px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.tab-button:hover {
    background: rgba(0, 212, 255, 0.1);
    color: rgba(255, 255, 255, 0.9);
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 212, 255, 0.3);
}

.tab-button.active {
    background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
    border-color: #00d4ff;
    color: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.5),
                inset 0 0 15px rgba(255, 255, 255, 0.2);
}

/* Scrollable Content Wrapper */
.leaderboard-scrollable-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Modern Content Section */
.leaderboard-content {
    flex: 0 0 auto;
    padding: 0 24px;
    position: relative;
}

/* Modern Scrollbar Styling - Apply to scrollable wrapper */
.leaderboard-scrollable-content::-webkit-scrollbar {
    width: 8px;
}

.leaderboard-scrollable-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

.leaderboard-scrollable-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

.leaderboard-scrollable-content::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Modern Leaderboard List */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 24px 0;
}

/* Modern Leaderboard Entry Cards */
.leaderboard-entry {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}

.leaderboard-entry:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(5px);
    border-color: rgba(0, 212, 255, 0.4);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.2);
}

/* Modern Special Ranks */
.leaderboard-entry.rank-gold {
    background: rgba(255, 215, 0, 0.12);
    border-color: rgba(255, 215, 0, 0.3);
    border-left: 3px solid rgba(255, 215, 0, 0.8);
}

.leaderboard-entry.rank-silver {
    background: rgba(192, 192, 192, 0.12);
    border-color: rgba(192, 192, 192, 0.3);
    border-left: 3px solid rgba(192, 192, 192, 0.8);
}

.leaderboard-entry.rank-bronze {
    background: rgba(205, 127, 50, 0.12);
    border-color: rgba(205, 127, 50, 0.3);
    border-left: 3px solid rgba(205, 127, 50, 0.8);
}

/* Modern Current User Highlight */
.leaderboard-entry.current-user {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.2) 0%, rgba(0, 150, 255, 0.15) 100%);
    border-color: rgba(0, 212, 255, 0.6);
    box-shadow: 0 0 30px rgba(0, 212, 255, 0.3),
                inset 0 0 20px rgba(0, 212, 255, 0.1);
    position: relative;
}

.leaderboard-entry.current-user::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: linear-gradient(to bottom, #00d4ff, #0099cc);
    box-shadow: 0 0 10px rgba(0, 212, 255, 0.8);
}

/* Modern Rank Badge */
.rank-badge {
    min-width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* Modern User Avatar */
.user-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Modern User Info */
.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 16px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.user-username {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 500;
}

/* Modern Score Section */
.score-section {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.score-value {
    font-size: 24px;
    font-weight: bold;
    color: #00d4ff;
    text-shadow: 0 0 15px rgba(0, 212, 255, 0.8);
    margin-bottom: 2px;
}

.score-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.5);
    text-transform: uppercase;
    font-weight: 500;
    letter-spacing: 0.5px;
}

/* Modern Current User Section */
.current-user-section {
    padding: 0 24px 24px;
    position: relative;
    flex-shrink: 0;
}

.separator-line {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 20px 0;
}

.current-user-highlight {
    /* Removed pulsing animation for cleaner design */
}

/* Modern Last Updated */
.last-updated-inline {
    text-align: center;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.4);
    font-weight: 500;
    margin-top: 24px;
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* Modern Loading State */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 0;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(0, 212, 255, 0.2);
    border-top-color: #00d4ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.loading-spinner p {
    margin-top: 16px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 15px;
    font-weight: 500;
}

/* Modern Error State */
.error-message {
    text-align: center;
    padding: 80px 0;
}

.error-icon {
    font-size: 40px;
    display: block;
    margin-bottom: 16px;
    opacity: 0.6;
}

.error-message p {
    color: rgba(255, 255, 255, 0.6);
    margin-bottom: 24px;
    font-size: 15px;
    font-weight: 500;
}

.retry-button {
    padding: 10px 30px;
    background: rgba(0, 212, 255, 0.2);
    border: 2px solid rgba(0, 212, 255, 0.5);
    border-radius: 25px;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.retry-button:hover {
    background: rgba(0, 212, 255, 0.3);
    transform: translateY(-2px);
}

/* Modern Empty State */
.empty-leaderboard {
    text-align: center;
    padding: 80px 0;
}

.empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-leaderboard p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 16px;
    font-weight: 500;
}

/* Landscape Mode - Move dropdown to header */
@media (orientation: landscape) and (min-width: 769px) {
    /* Hide portrait dropdown, show header dropdown */
    .leaderboard-category-section {
        display: none;
    }
    
    .header-dropdown {
        display: block !important;
    }
    
    /* Adjust header layout for three elements with centered dropdown */
    .leaderboard-modal .modal-header-section {
        display: flex;
        justify-content: center;
        align-items: center;
        position: relative;
    }
    
    /* Title on left */
    .header-title {
        position: absolute;
        left: 20px;
        flex: 0 0 auto;
    }
    
    /* Dropdown in center */
    .header-dropdown {
        flex: 0 0 auto;
        margin: 0 auto;
    }
    
    /* Close button on right */
    .close-btn {
        position: absolute;
        right: 20px;
        flex: 0 0 auto;
    }
}

/* Tablet landscape specific adjustments */
@media (orientation: landscape) and (min-width: 769px) and (max-width: 1024px) {
    .header-dropdown .custom-dropdown {
        width: 180px;
    }
    
    .leaderboard-modal .modal-header-section {
        padding: 16px 20px;
    }
    
    .header-text {
        font-size: 16px;
    }
}

/* Modern Mobile Responsive Design */
@media (max-width: 768px) {
    .leaderboard-modal .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
        margin: 0;
        /* More transparent background for better blur visibility on mobile */
        background: linear-gradient(145deg, rgba(10, 25, 47, 0.25), rgba(0, 15, 30, 0.25));
        backdrop-filter: blur(25px);
        -webkit-backdrop-filter: blur(25px);
        /* Remove cyan glow on mobile, keep only subtle shadow */
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
        border: none;
        /* Add safe area padding */
        padding-top: env(safe-area-inset-top, 0px);
        padding-bottom: env(safe-area-inset-bottom, 0px);
        padding-left: env(safe-area-inset-left, 0px);
        padding-right: env(safe-area-inset-right, 0px);
    }
    
    /* Fallback for browsers without backdrop-filter support */
    @supports not (backdrop-filter: blur(25px)) {
        .leaderboard-modal .modal-content {
            background: linear-gradient(145deg, rgba(10, 25, 47, 0.95), rgba(0, 15, 30, 0.95));
        }
    }
    
    .leaderboard-modal {
        padding: 0;
    }
    
    /* Header adjustments for mobile */
    .leaderboard-modal .modal-header-section {
        padding: 16px 20px;
    }
    
    .header-text {
        font-size: 16px;
    }
    
    /* Modern mobile dropdown */
    .leaderboard-category-section {
        padding: 12px 20px 16px;
    }
    
    .custom-dropdown {
        width: 100%;
        max-width: 100%;
    }
    
    .dropdown-selected {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    .dropdown-option {
        padding: 10px 16px;
        font-size: 14px;
    }
    
    /* Modern mobile tabs */
    .leaderboard-tabs {
        padding: 16px 20px;
        gap: 6px;
    }
    
    .tab-button {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    /* Mobile content adjustments */
    .leaderboard-content {
        padding: 0 20px;
    }
    
    /* Hide header dropdown on mobile */
    .header-dropdown {
        display: none !important;
    }
    
    .leaderboard-list {
        gap: 10px;
    }
    
    .leaderboard-entry {
        padding: 14px 16px;
        gap: 12px;
    }
    
    .rank-badge {
        min-width: 40px;
        height: 40px;
        font-size: 16px;
    }
    
    .user-avatar {
        width: 40px;
        height: 40px;
    }
    
    .user-name {
        font-size: 15px;
    }
    
    .user-username {
        font-size: 12px;
    }
    
    .score-value {
        font-size: 18px;
    }
    
    .score-label {
        font-size: 10px;
    }
    
    /* Mobile section adjustments */
    .current-user-section {
        padding: 0 20px 20px;
    }
}

/* Modern Entrance Animation */
.leaderboard-modal.show .modal-content {
    animation: modal-enter 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modal-enter {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}