/* ========================
   GAME STATISTICS MODAL
   ======================== */

#stats-screen {
    z-index: 1000;
}

#stats-screen .modal-content {
    max-width: 900px;
    width: 95vw;
    height: 95vh;
    max-height: 95vh;
    background: linear-gradient(145deg, rgba(44, 62, 80, 0.95), rgba(52, 73, 94, 0.95));
    border: 2px solid var(--gold-color);
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    overflow: hidden;
    padding: 15px;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

#stats-screen .modal-content h2 {
    color: var(--gold-color);
    text-align: center;
    font-size: 1.8rem;
    font-weight: bold;
    margin: 0 0 15px 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
    border-bottom: 2px solid rgba(240, 195, 60, 0.3);
    padding-bottom: 10px;
    flex-shrink: 0;
}

/* Stats Tabs */
.stats-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 15px;
    gap: 10px;
    flex-shrink: 0;
}

.stats-tab {
    background: rgba(0, 0, 0, 0.3);
    color: rgba(255, 255, 255, 0.7);
    border: 2px solid rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.stats-tab.active,
.stats-tab:hover {
    background: var(--treasure-gradient);
    color: var(--dark-color);
    border-color: var(--gold-color);
}

/* Stats Data Container */
.stats-data {
    text-align: left;
    max-height: 422px;
    overflow-y: auto;
    margin-bottom: var(--spacing-lg);
    padding: var(--spacing-md);
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: var(--border-radius);
    color: #ffffff;
    line-height: 1.6;
}

/* Stats Sections */
.stats-section {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 15px;
    border-left: 4px solid var(--gold-color);
    border: 1px solid rgba(240, 195, 60, 0.2);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.stats-section h3 {
    color: var(--gold-color);
    font-size: 1.3rem;
    font-weight: bold;
    margin-bottom: 15px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.8);
    text-align: center;
    border-bottom: 1px solid rgba(240, 195, 60, 0.3);
    padding-bottom: 8px;
}

/* Stat Rows */
.stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: background-color 0.2s ease;
}

.stat-row:hover {
    background: rgba(255, 255, 255, 0.08);
}

.stat-name {
    font-weight: 500;
    color: rgba(255, 255, 255, 0.9);
    flex: 1;
}

.stat-value {
    font-weight: bold;
    color: var(--gold-color);
    font-size: 1.1rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    min-width: 80px;
    text-align: right;
}

/* Special Cards Grid */
.special-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.special-card-stat {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    transition: all 0.2s ease;
}

.special-card-stat:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateY(-2px);
}

.special-card-name {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 5px;
}

.special-card-count {
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--gold-color);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
}

/* Recent Scores Table */
.recent-scores {
    overflow-x: auto;
}

.scores-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

.scores-table thead {
    background: rgba(240, 195, 60, 0.2);
}

.scores-table th {
    padding: 12px;
    color: var(--gold-color);
    font-weight: bold;
    text-align: left;
    border-bottom: 2px solid rgba(240, 195, 60, 0.3);
}

.scores-table td {
    padding: 10px 12px;
    color: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.scores-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.05);
}

.scores-table tbody tr:last-child td {
    border-bottom: none;
}

.no-scores {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    padding: 20px;
}

/* Modal Buttons */
.modal-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 2px solid rgba(240, 195, 60, 0.4);
    flex-shrink: 0;
}

.modal-buttons button {
    padding: 14px 28px;
    font-size: 1.1rem;
    font-weight: bold;
    border-radius: 10px;
    transition: all 0.3s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 140px;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

#close-stats-button,
.primary-button {
    background: var(--treasure-gradient);
    color: var(--dark-color);
    border: 2px solid var(--gold-color) !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

#close-stats-button:hover,
.primary-button:hover {
    background: linear-gradient(135deg, #f1c40f, #f39c12);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
    border-color: #fff !important;
}

#reset-stats-button,
.danger-button {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
    border: 2px solid #e74c3c !important;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.5);
    font-weight: bold;
}

#reset-stats-button:hover,
.danger-button:hover {
    background: linear-gradient(135deg, #c0392b, #a93226);
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(231, 76, 60, 0.5);
    border-color: #ff6b6b !important;
}

.modal-buttons button:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

/* ========================
   MOBILE OPTIMIZATION
   ======================== */

@media (max-width: 768px) {
    #stats-screen .modal-content {
        width: 98vw;
        max-height: 90vh;
        padding: 15px;
        margin: 10px auto;
    }

    #stats-screen .modal-content h2 {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }

    .stats-section {
        padding: 15px;
        margin-bottom: 15px;
    }

    .stats-section h3 {
        font-size: 1.2rem;
        margin-bottom: 12px;
    }

    .stat-row {
        padding: 10px 12px;
        margin-bottom: 6px;
    }

    .stat-name {
        font-size: 0.95rem;
    }

    .stat-value {
        font-size: 1rem;
        min-width: 60px;
    }

    .special-cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 8px;
    }

    .special-card-stat {
        padding: 10px;
    }

    .special-card-name {
        font-size: 0.8rem;
    }

    .special-card-count {
        font-size: 1.1rem;
    }

    .scores-table th,
    .scores-table td {
        padding: 8px;
        font-size: 0.9rem;
    }

    .modal-buttons {
        flex-direction: column;
        gap: 10px;
    }

    .modal-buttons button {
        width: 100%;
        padding: 12px;
    }
}

@media (max-width: 480px) {
    #stats-screen .modal-content {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        margin: 0;
        padding: 10px;
    }

    #stats-screen .modal-content h2 {
        font-size: 1.3rem;
        margin-bottom: 12px;
    }

    .stats-section {
        padding: 12px;
        margin-bottom: 12px;
    }

    .stat-row {
        padding: 8px 10px;
        margin-bottom: 4px;
    }

    .stat-name {
        font-size: 0.9rem;
    }

    .stat-value {
        font-size: 0.95rem;
        min-width: 50px;
    }

    .special-cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
        gap: 6px;
    }

    .special-card-stat {
        padding: 8px;
    }

    .scores-table th,
    .scores-table td {
        padding: 6px;
        font-size: 0.8rem;
    }
}

/* ========================
   SCROLLBAR STYLING
   ======================== */

#stats-screen .modal-content::-webkit-scrollbar {
    width: 8px;
}

#stats-screen .modal-content::-webkit-scrollbar-track {
    background: rgba(44, 62, 80, 0.3);
    border-radius: 4px;
}

#stats-screen .modal-content::-webkit-scrollbar-thumb {
    background: var(--gold-color);
    border-radius: 4px;
    opacity: 0.7;
}

#stats-screen .modal-content::-webkit-scrollbar-thumb:hover {
    opacity: 1;
}

.recent-scores::-webkit-scrollbar {
    height: 6px;
}

.recent-scores::-webkit-scrollbar-track {
    background: rgba(44, 62, 80, 0.3);
    border-radius: 3px;
}

.recent-scores::-webkit-scrollbar-thumb {
    background: var(--gold-color);
    border-radius: 3px;
    opacity: 0.7;
}

.recent-scores::-webkit-scrollbar-thumb:hover {
    opacity: 1;
}
