/* Results Screen Styles */
#results-screen {
    background: linear-gradient(135deg, #1a0033 0%, #330066 50%, #4d0099 100%);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#results-screen.active {
    display: block !important; /* Override parent flex centering only when active */
}

#results-screen.screen.active {
    align-items: unset;
    justify-content: unset;
}

.results-container {
    text-align: center;
    padding: var(--spacing-xl);
    max-width: 800px;
    width: 90%;
    margin: 0 auto;
}

.results-title {
    font-family: var(--font-display);
    font-size: 3rem;
    background: linear-gradient(135deg, var(--primary-accent), var(--secondary-accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: var(--spacing-xl);
    animation: glow 2s ease-in-out infinite;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-xl);
}

.stat-box {
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid var(--primary-accent);
    border-radius: 12px;
    padding: var(--spacing-lg);
    transition: all 0.3s ease;
}

.stat-box:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(255, 0, 255, 0.4);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary-accent);
    margin-bottom: var(--spacing-sm);
}

.stat-label {
    font-size: 1rem;
    color: var(--secondary-accent);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Leaderboard Section */
.leaderboard-section {
    margin-bottom: var(--spacing-xl);
}

.leaderboard-section h2 {
    font-size: 2rem;
    color: var(--secondary-accent);
    margin-bottom: var(--spacing-md);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.leaderboard {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid var(--secondary-accent);
    border-radius: 12px;
    padding: var(--spacing-md);
    max-height: 400px;
    overflow-y: auto;
}

.leaderboard-entry {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    margin-bottom: var(--spacing-sm);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    transition: all 0.2s ease;
}

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

.leaderboard-entry.current-user {
    background: rgba(255, 0, 255, 0.2);
    border: 2px solid var(--primary-accent);
    font-weight: bold;
}

.entry-rank {
    font-size: 1.2rem;
    font-weight: bold;
    min-width: 60px;
    color: var(--secondary-accent);
}

.entry-rank.top3 {
    font-size: 1.5rem;
}

.entry-rank.rank-1 {
    color: #FFD700; /* Gold */
}

.entry-rank.rank-2 {
    color: #C0C0C0; /* Silver */
}

.entry-rank.rank-3 {
    color: #CD7F32; /* Bronze */
}

.entry-username {
    flex: 1;
    text-align: left;
    padding: 0 var(--spacing-md);
    font-size: 1.1rem;
}

.entry-score {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--primary-accent);
    min-width: 80px;
    text-align: right;
    white-space: nowrap;
    text-align: right;
}

/* Prize Info */
.prize-info {
    background: rgba(255, 215, 0, 0.1);
    border: 2px solid #FFD700;
    border-radius: 12px;
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.prize-info p {
    margin: 0.3rem 0;
    font-size: 1.1rem;
}

.prize-info strong {
    color: #FFD700;
}

/* Play Again Button */
#btn-play-again {
    font-size: 1.3rem;
    padding: 1.2rem 2.5rem;
}

/* Scrollbar Styling */
.leaderboard::-webkit-scrollbar {
    width: 8px;
}

.leaderboard::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 4px;
}

.leaderboard::-webkit-scrollbar-thumb {
    background: var(--primary-accent);
    border-radius: 4px;
}

.leaderboard::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-accent);
}

/* Responsive Results */
@media (max-width: 767px) {
    #results-screen {
        padding-top: env(safe-area-inset-top, 20px);
    }

    .results-container {
        padding-top: 2rem;
        padding-bottom: 2rem;
    }

    .results-title {
        font-size: 2rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
        gap: var(--spacing-sm);
    }

    .stat-value {
        font-size: 2rem;
    }

    .stat-label {
        font-size: 0.9rem;
    }

    /* Mobile leaderboard fixes */
    .leaderboard-entry {
        padding: 0.6rem 0.4rem;
        gap: 0.4rem;
        display: flex;
        align-items: center;
        min-height: 45px;
    }

    .entry-rank {
        font-size: 0.85rem;
        min-width: 35px;
        flex-shrink: 0;
    }

    .entry-rank.top3 {
        font-size: 1rem;
    }

    .entry-username {
        font-size: 0.85rem;
        padding: 0 0.3rem;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap; /* Keep username on single line */
        line-height: 1.2;
    }

    .entry-score {
        font-size: 0.85rem;
        min-width: 50px; /* Reduced from 60px to give more space to username */
        flex-shrink: 0;
        text-align: right;
    }

    .leaderboard-section h2 {
        font-size: 1.5rem;
    }

    .prize-info p {
        font-size: 0.9rem;
    }

    #btn-play-again {
        font-size: 1.1rem;
        padding: 1rem 2rem;
    }
}
