/* Match System Styles */

/* Match Mode Card */
.test-mode-card[data-mode="match"] .mode-icon {
    background: linear-gradient(135deg, #ff6b6b, #ff8787);
}

/* Match Selection Screen */
.match-selection-screen {
    padding: 20px;
    animation: fadeIn 0.3s ease-in;
}

.match-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.match-header h2 {
    flex: 1;
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    color: var(--text-primary);
}

.match-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
}

.match-option-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}

.match-option-card:active {
    transform: scale(0.95);
}

.match-option-card .match-option-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 12px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.match-option-card .match-option-icon i {
    width: 30px;
    height: 30px;
}

.match-option-card h3 {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.match-option-card p {
    font-size: 13px;
    color: var(--text-secondary);
}

.match-option-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 136, 255, 0.2);
}

/* Waiting Screen */
.waiting-screen {
    padding: 40px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.waiting-content {
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.waiting-animation {
    margin-bottom: 30px;
}

.spinner-large {
    width: 80px;
    height: 80px;
    margin: 0 auto;
    border: 6px solid var(--border-color);
    border-top: 6px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

#waiting-title {
    font-size: 22px;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--text-primary);
}

#waiting-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.waiting-info {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 20px;
}

.waiting-info h3 {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.room-code {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}

#room-code-text {
    font-size: 42px;
    font-weight: bold;
    letter-spacing: 8px;
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
    background: var(--bg-color);
    padding: 12px 20px;
    border-radius: 12px;
}

.btn-share {
    width: 100%;
    background: linear-gradient(135deg, #0088cc, #0099dd);
    color: white;
    border: none;
    padding: 14px;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    margin-bottom: 16px;
}

.btn-share:active {
    transform: scale(0.98);
}

.btn-share i {
    width: 20px;
    height: 20px;
}

.code-expires {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.players-list {
    text-align: right;
}

.players-list h4 {
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.players-list ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.players-list li {
    padding: 8px;
    background: var(--bg-color);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 14px;
}

/* Match Screen */
.match-screen {
    padding: 16px;
    padding-top: 2vh;
}

.match-scores {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}

.player-score {
    flex: 1;
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow);
}

.player-score.opponent {
    flex-direction: row-reverse;
}

.player-avatar {
    width: 40px;
    height: 40px;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.player-info {
    flex: 1;
}

.player-score.opponent .player-info {
    text-align: left;
}

.player-name {
    font-size: 13px;
    font-weight: bold;
    color: var(--text-primary);
    margin: 0;
}

.player-points {
    font-size: 16px;
    font-weight: bold;
    color: var(--primary-color);
    margin: 0;
}

.vs-badge {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: bold;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 136, 255, 0.3);
}

.match-progress {
    text-align: center;
    margin-bottom: 16px;
}

.match-question-num {
    font-size: 15px;
    font-weight: bold;
    color: var(--primary-color);
}

.match-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}

.match-actions .btn {
    flex: 1;
}

/* Match Results Screen */
.match-results-screen {
    padding: 30px 20px;
    text-align: center;
}

.match-results-header {
    margin-bottom: 30px;
}

.winner-badge {
    display: inline-block;
    animation: bounceIn 0.6s ease-out;
}

.winner-badge i {
    width: 80px;
    height: 80px;
    color: #ffd700;
    filter: drop-shadow(0 4px 12px rgba(255, 215, 0, 0.5));
}

#match-result-title {
    font-size: 28px;
    font-weight: bold;
    margin-top: 16px;
    color: var(--text-primary);
}

.match-final-scores {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 30px;
}

.final-score-card {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.final-score-card.winner {
    border: 2px solid #ffd700;
    box-shadow: 0 4px 20px rgba(255, 215, 0, 0.3);
}

.final-avatar {
    font-size: 48px;
    margin-bottom: 12px;
}

.final-score-card h3 {
    font-size: 16px;
    font-weight: bold;
    margin-bottom: 16px;
    color: var(--text-primary);
}

.final-stats {
    display: flex;
    gap: 16px;
    justify-content: center;
}

.final-stats .stat {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 24px;
    font-weight: bold;
    color: var(--primary-color);
}

.stat-label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.match-results-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 300px;
    margin: 0 auto;
}

@keyframes bounceIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Join Room Modal */
.join-room-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.join-room-modal .modal-content {
    background: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 24px;
    max-width: 320px;
    width: 90%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    position: relative;
    z-index: 2001;
}

.join-room-modal h3 {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.join-room-modal p {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.code-input {
    width: 100%;
    padding: 20px;
    font-size: 38px;
    font-weight: bold;
    text-align: center;
    letter-spacing: 10px;
    border: 3px solid var(--primary-color);
    border-radius: 12px;
    background: var(--bg-color);
    color: var(--primary-color);
    font-family: 'Courier New', monospace;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(0, 136, 255, 0.2);
}

.code-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 4px 20px rgba(0, 136, 255, 0.4);
}

.code-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.5;
}

.modal-actions {
    display: flex;
    gap: 10px;
}

.modal-actions .btn {
    flex: 1;
}

/* Animation for code input */
@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
    }
}

.code-input.typing {
    animation: pulse 0.3s ease-in-out;
}

/* Responsive */
@media (max-width: 480px) {
    .match-options {
        grid-template-columns: 1fr;
    }
    
    #room-code-text {
        font-size: 32px;
        letter-spacing: 6px;
    }
    
    .code-input {
        font-size: 32px;
        letter-spacing: 8px;
    }
    
    /* إبقاء VS أفقياً على الجوال */
    .match-scores {
        flex-direction: row;
        gap: 8px;
    }
    
    .vs-badge {
        transform: none;
    }
}
