/* Leaderboard Page Styles */

/* Game Selector Section with Header */
.game-selector-section {
    background: linear-gradient(135deg, var(--primary-500), var(--secondary-500), var(--primary-600), var(--secondary-600));
    background-size: 400% 400%;
    animation: gradientShift 20s ease-in-out infinite;
    color: var(--white);
    padding: 1rem 0 0.75rem 0;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 64px; /* Position below the navbar (64px height) */
    z-index: 100; /* Ensure it stays above other content */
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    25% {
        background-position: 100% 50%;
    }
    50% {
        background-position: 100% 100%;
    }
    75% {
        background-position: 50% 0%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.header-selector-wrapper {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 0rem;
}

.game-selector-wrapper {
    position: relative;
}

.game-selector-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.game-selector-scroll::-webkit-scrollbar {
    display: none;
}

.game-selector {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0;
    min-width: max-content;
}

.game-selector-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.95);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 140px;
    min-width: 140px;
    max-width: 140px;
    position: relative;
    flex-shrink: 0;
    backdrop-filter: blur(10px);
}

.game-selector-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
    background: var(--white);
}

.game-selector-item.active {
    border-color: var(--primary-600);
    background: linear-gradient(135deg, var(--primary-600), var(--primary-700));
    transform: translateY(-2px);
    backdrop-filter: none;
    border-width: 3px;
}

.game-selector-item.active .game-selector-name {
    color: var(--white);
    font-weight: 700;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.game-selector-item.active .game-selector-icon {
    transform: scale(1.1);
    filter: brightness(1.2);
}

.game-selector-item.coming-soon {
    opacity: 0.6;
    cursor: not-allowed;
}

.game-selector-item.coming-soon:hover {
    transform: none;
    box-shadow: none;
}

.game-selector-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.game-selector-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    text-align: center;
}

.game-selector-badge {
    position: absolute;
    top: -0.5rem;
    right: -0.5rem;
    background: var(--primary-600);
    color: var(--white);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    min-width: 20px;
    text-align: center;
}

.game-selector-badge.coming-soon {
    background: var(--neutral-600);
    font-size: 0.7rem;
}

/* Header Period Selector - Integrated Pills */
.header-period-selector {
    display: flex;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.period-pills {
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-radius: 50px;
    padding: 0.375rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.period-pill {
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.period-pill:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 1);
    transform: translateY(-1px);
}

.period-pill.active {
    background: var(--white);
    color: var(--primary-600);
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Leaderboard Section */
.leaderboard-section {
    padding: 1.5rem 0;
    background: linear-gradient(180deg, 
        rgba(212, 165, 116, 0.05) 0%,
        rgba(139, 108, 78, 0.03) 50%,
        var(--background) 100%
    );
    min-height: 60vh;
}

/* Leaderboard Container */
.leaderboard-container {
    max-width: 1000px;
    margin: 0 auto;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-bottom: 2rem;
}


/* Loading State */
.leaderboard-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--neutral-200);
    border-top: 4px solid var(--primary-600);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Leaderboard Table */
.leaderboard-table-wrapper {
    overflow: hidden;
}

.table-header {
    display: none;
    grid-template-columns: 80px 1fr 120px 100px;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    background: var(--neutral-50);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Nonogram now uses standard 4-column layout like Sudoku */

.header-rank {
    text-align: center;
}

.header-player {
    text-align: left;
}

.header-score,
.header-moves,
.header-games {
    text-align: center;
}

/* Leaderboard Entries */
.leaderboard-entries {
    /* Remove max-height and overflow to let it use full page height */
}

.leaderboard-entry {
    display: grid;
    grid-template-columns: 80px 1fr 120px 100px;
    gap: 1.5rem;
    align-items: center;
    padding: 1.25rem 2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    transition: background 0.2s ease;
    background: transparent;
    position: relative;
}

.leaderboard-entry:hover {
    background: rgba(255, 255, 255, 0.1);
}

.leaderboard-entry.top-3 {
    background: rgba(255, 255, 255, 0.15);
    border-left: 4px solid rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(10px);
}

.leaderboard-entry.top-3:hover {
    background: rgba(255, 255, 255, 0.2);
}

.leaderboard-entry.current-user {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15), rgba(255, 193, 7, 0.1));
    border-left: 4px solid #FFD700;
    backdrop-filter: blur(10px);
}

.leaderboard-entry.current-user:hover {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2), rgba(255, 193, 7, 0.15));
}

.leaderboard-entry.empty-entry {
    background: transparent;
    opacity: 0.4;
}

.entry-rank {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--primary-600);
    text-align: center;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    backdrop-filter: blur(10px);
    transition: background 0.2s ease;
}

.leaderboard-entry:hover .entry-rank {
    background: rgba(255, 255, 255, 0.4);
}

.leaderboard-entry.top-3 .entry-rank {
    font-size: 1.25rem;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.4);
}

.entry-rank.rank-1 {
    color: #FFD700;
    background: rgba(255, 215, 0, 0.2);
}

.entry-rank.rank-2 {
    color: #C0C0C0;
    background: rgba(192, 192, 192, 0.2);
}

.entry-rank.rank-3 {
    color: #CD7F32;
    background: rgba(205, 127, 50, 0.2);
}

.entry-player {
    display: flex;
    align-items: center;
}

.player-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.player-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.player-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.entry-score {
    font-weight: 400;
    color: var(--text-primary);
    text-align: center;
    font-size: 1rem;
}

.entry-moves,
.entry-games {
    color: var(--text-secondary);
    text-align: center;
    font-size: 0.875rem;
    font-weight: 400;
}

.score-number {
    font-weight: 700;
}



/* Floating User Summary */
.floating-user-summary {
    position: fixed;
    left: 50%;
    bottom: 2rem;
    transform: translateX(-50%);
    z-index: 150;
    pointer-events: none;
}

.floating-summary-content {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(212, 165, 116, 0.3);
    border-radius: 50px;
    padding: 0.75rem 1.5rem;
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    pointer-events: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    min-width: 280px;
}

.floating-summary-content:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-2px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.2);
}

.floating-user-summary .summary-label {
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.875rem;
}

.floating-user-summary .summary-rank {
    color: var(--primary-600);
    font-weight: 700;
    font-size: 1rem;
}

.floating-user-summary #user-score {
    color: var(--text-primary);
    font-weight: 400;
    font-size: 1rem;
}

.floating-user-summary #user-score .score-number {
    font-weight: 700;
    color: var(--primary-600);
}

.floating-user-summary .summary-divider {
    width: 2px;
    height: 24px;
    background: linear-gradient(to bottom, var(--primary-400), var(--secondary-400));
    border-radius: 1px;
}

/* User Summary - Legacy (if needed) */
.user-summary {
    background: var(--accent-50);
    border-top: 1px solid var(--accent-200);
    padding: 1.5rem 2rem;
}

/* Default summary content styles - used by header integration */
.summary-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    max-width: 600px;
    margin: 0 auto;
}

.summary-text,
.summary-score {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.summary-label {
    font-size: 0.875rem;
    font-weight: 500;
}

.summary-divider {
    width: 1px;
    height: 20px;
    flex-shrink: 0;
}

.summary-rank {
    font-size: 1rem;
    font-weight: 700;
    color: var(--primary-600);
}

#user-score {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-primary);
}

#user-score .score-number {
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 1024px) {
    
    .table-header,
    .leaderboard-entry {
        grid-template-columns: 60px 1fr 100px 80px;
        gap: 1rem;
        padding: 1rem 1.5rem;
    }
    
    /* Nonogram now uses same layout as other games */
}

@media (max-width: 768px) {
    .game-selector-section {
        padding: 0.75rem 0;
    }
    
    .period-pills {
        gap: 0.25rem;
        padding: 0.25rem;
    }
    
    .period-pill {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }
    
    .game-selector-section .container {
        padding-left: 0;
        padding-right: 0;
        overflow: hidden; /* Prevent page scroll */
    }
    
    .game-selector-wrapper {
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
        /* Remove any position constraints */
    }
    
    .game-selector-wrapper::-webkit-scrollbar {
        display: none;
    }
    
    .game-selector-scroll {
        /* Remove scrolling from this level - move it up to wrapper */
        padding: 0;
        width: 100%;
    }
    
    .game-selector {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 1rem;
        padding: 0.5rem 1rem;
        width: max-content; /* Force wider than container */
        min-width: 100%;
        align-items: center;
    }
    
    .game-selector-item {
        flex: 0 0 auto; /* Don't grow, don't shrink, auto width */
        width: 120px;
        height: 80px;
        padding: 0.5rem;
        /* Remove hover effects on mobile */
        transition: none;
    }
    
    .game-selector-item:hover,
    .game-selector-item:active,
    .game-selector-item:focus {
        box-shadow: none;
        transform: none;
        background: rgba(255, 255, 255, 0.95); /* Keep same as default */
        border-color: rgba(255, 255, 255, 0.3); /* Keep same as default */
    }
    
    /* Keep active items consistent on touch */
    .game-selector-item.active:hover,
    .game-selector-item.active:active,
    .game-selector-item.active:focus {
        background: linear-gradient(135deg, var(--primary-600), var(--primary-700)) !important;
        border-color: var(--primary-600) !important;
        color: var(--white) !important;
    }
    
    .game-selector-item.active .game-selector-name {
        color: var(--white) !important;
    }
    
    /* Disable all touch feedback */
    .game-selector-item {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
    
    .game-selector-icon {
        font-size: 1.5rem;
    }
    
    .game-selector-name {
        font-size: 0.875rem;
    }
    
    .leaderboard-section {
        padding: 1.5rem 0;
    }
    
    .table-header,
    .leaderboard-entry {
        grid-template-columns: 50px 1fr 80px 60px;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
    }
    
    .entry-rank {
        width: 30px;
        height: 30px;
        font-size: 0.9rem;
    }
    
    .leaderboard-entry.top-3 .entry-rank {
        width: 32px;
        height: 32px;
    }
    
    /* Nonogram now uses same layout as other games */
    

    
    .entry-player {
        gap: 0.5rem;
    }
    
    .player-name {
        font-size: 0.875rem;
    }
    
    .player-date {
        font-size: 0.7rem;
    }
    
    .entry-score {
        font-size: 0.875rem;
    }
    
    .entry-moves,
    .entry-games {
        font-size: 0.8rem;
    }
    
    .header-period-selector {
        margin-bottom: 0.5rem;
    }
    
    .header-selector-wrapper {
        gap: 0.5rem;
    }
    
    .floating-user-summary {
        bottom: calc(90px + env(safe-area-inset-bottom)); /* Account for bottom nav */
    }
    
    .floating-summary-content {
        gap: 1rem;
        padding: 0.625rem 1.25rem;
        min-width: 250px;
        margin: 0 1rem;
    }
    
    .floating-user-summary .summary-divider {
        height: 20px;
    }
    
    .floating-user-summary .summary-label {
        display: none;
    }
    
    .user-summary {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .period-pills {
        gap: 0.2rem;
        padding: 0.2rem;
    }
    
    .period-pill {
        padding: 0.4rem 0.6rem;
        font-size: 0.75rem;
    }
    
    .floating-summary-content {
        gap: 0.875rem;
        padding: 0.5rem 1rem;
        min-width: 220px;
        margin: 0 0.75rem;
    }
    
    .floating-user-summary .summary-divider {
        width: 1px;
        height: 18px;
    }
    
    .floating-user-summary .summary-text,
    .floating-user-summary .summary-score {
        font-size: 0.8rem;
    }
    
    .floating-user-summary .summary-label {
        display: none;
    }
    
    .table-header,
    .leaderboard-entry {
        grid-template-columns: 40px 1fr 70px 50px;
        gap: 0.5rem;
        padding: 0.5rem 0.75rem;
    }
    
    /* Nonogram now uses same layout as other games */
    
    .entry-rank {
        font-size: 0.85rem;
        width: 28px;
        height: 28px;
    }
    
    .leaderboard-entry.top-3 .entry-rank {
        width: 30px;
        height: 30px;
    }
    
    .player-name {
        font-size: 0.8rem;
    }
    
    .entry-score {
        font-size: 0.8rem;
    }
    
    .entry-moves,
    .entry-games {
        font-size: 0.75rem;
    }
}

/* Stats Section */
.stats-section {
    padding: 3rem 0;
    background: var(--primary-600);
    color: var(--white);
}

.stats-grid {
    display: grid;
    gap: 2rem;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    text-align: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.stat-label {
    font-size: 0.875rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
