/**
 * Statistics Display Styles
 * Overlay and chart styling for game statistics
 */

/* Stats Overlay Container */
.stats-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease-in-out;
}

.stats-overlay.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Stats Container */
.stats-container {
    background: linear-gradient(135deg, #1e3c72 0%, #2a5298 100%);
    border-radius: 20px;
    padding: 30px;
    max-width: 90%;
    max-height: 90%;
    overflow-y: auto;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Stats Header */
.stats-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.2);
}

.stats-header h2 {
    color: #fff;
    font-size: 28px;
    margin: 0;
    font-weight: 700;
}

.stats-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: #fff;
    font-size: 32px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.stats-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Stats Content */
.stats-content {
    color: #fff;
    min-height: 300px;
}

/* Question Display */
.stats-question {
    background: rgba(255, 255, 255, 0.1);
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.stats-question p {
    margin: 8px 0;
    font-size: 16px;
}

.stats-question strong {
    color: #FFD700;
}

/* Chart Canvas */
#stats-chart {
    max-height: 500px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    padding: 20px;
}

/* Performance Grid */
.performance-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.performance-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.performance-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.performance-card h3 {
    margin: 0 0 15px 0;
    font-size: 20px;
    color: #FFD700;
    text-align: center;
}

.perf-stats {
    margin-bottom: 15px;
}

.perf-stat {
    display: flex;
    justify-content: space-between;
    margin: 8px 0;
    font-size: 14px;
}

.perf-label {
    color: rgba(255, 255, 255, 0.7);
}

.perf-value {
    font-weight: 600;
    color: #fff;
}

.perf-value.correct {
    color: #4CAF50;
}

.perf-value.incorrect {
    color: #F44336;
}

/* Performance Bar */
.perf-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    overflow: hidden;
}

.perf-bar-fill {
    height: 100%;
    transition: width 0.5s ease;
    border-radius: 4px;
}

/* Game Summary */
.game-summary {
    color: #fff;
}

.overall-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    transition: transform 0.3s ease;
}

.stat-box:hover {
    transform: scale(1.05);
}

.stat-value {
    font-size: 36px;
    font-weight: 700;
    color: #FFD700;
    margin-bottom: 8px;
}

.stat-label {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-sublabel {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 5px;
}

/* Leaderboard */
.leaderboard {
    margin-top: 30px;
}

.leaderboard h3 {
    color: #FFD700;
    font-size: 24px;
    margin-bottom: 20px;
    text-align: center;
}

.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    overflow: hidden;
}

.leaderboard-table thead {
    background: rgba(255, 255, 255, 0.15);
}

.leaderboard-table th {
    padding: 15px;
    text-align: left;
    font-weight: 600;
    color: #FFD700;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 1px;
}

.leaderboard-table td {
    padding: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.leaderboard-table tr:hover {
    background: rgba(255, 255, 255, 0.08);
}

.rank-cell {
    font-size: 24px;
    font-weight: 700;
    text-align: center;
}

.leaderboard-table tr.rank-1 {
    background: rgba(255, 215, 0, 0.15);
}

.leaderboard-table tr.rank-2 {
    background: rgba(192, 192, 192, 0.15);
}

.leaderboard-table tr.rank-3 {
    background: rgba(205, 127, 50, 0.15);
}

.player-name {
    font-weight: 600;
    font-size: 16px;
}

.score {
    font-weight: 700;
    font-size: 18px;
    color: #FFD700;
}

.correct {
    color: #4CAF50;
    font-weight: 600;
}

.accuracy {
    font-weight: 600;
}

/* Error Display */
.stats-content .error {
    background: rgba(244, 67, 54, 0.2);
    border: 2px solid #F44336;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-size: 16px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .stats-container {
        padding: 20px;
        max-width: 95%;
    }

    .stats-header h2 {
        font-size: 22px;
    }

    .performance-grid {
        grid-template-columns: 1fr;
    }

    .overall-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .leaderboard-table {
        font-size: 14px;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        padding: 10px 8px;
    }

    .stat-value {
        font-size: 28px;
    }
}

@media (max-width: 480px) {
    .stats-container {
        padding: 15px;
        max-width: 98%;
        max-height: 95%;
    }

    .stats-header h2 {
        font-size: 18px;
    }

    .stats-close-btn {
        width: 35px;
        height: 35px;
        font-size: 28px;
    }

    .overall-stats {
        grid-template-columns: 1fr;
    }

    .leaderboard-table {
        font-size: 12px;
    }

    .player-name {
        font-size: 14px;
    }

    .score {
        font-size: 16px;
    }
}
