/* Math Challenge Game Styles V2 */

/* Main game area layout */
.math-game-area {
    display: none; /* Hidden by default, shown by JS */
    flex-direction: column;
    height: calc(100vh - 220px); /* Adjust based on header height */
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    padding: 10px;
    box-sizing: border-box;
    background-color: #f0f4f8;
}

.math-question-area {
    flex: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.math-question {
    background: linear-gradient(135deg, #4ECDC4 0%, #44A08D 100%);
    color: white;
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    width: 100%;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.1);
}

.question-display {
    font-size: 2.5em;
    font-weight: bold;
    font-family: 'Arial', 'Microsoft YaHei', monospace;
}

.math-answer-display-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px 0;
}

.math-answer-display {
    font-size: 2em;
    font-weight: bold;
    color: #333;
    min-height: 50px;
    padding: 10px 20px;
    border-radius: 10px;
    background-color: #fff;
    border: 2px solid #ddd;
    width: 80%;
    text-align: center;
}

.math-feedback {
    min-height: 24px;
    font-size: 1em;
    font-weight: bold;
    margin-top: 10px;
    transition: all 0.3s ease;
}

.math-feedback.correct {
    color: #4CAF50;
}

.math-feedback.incorrect {
    color: #f44336;
}

.math-keyboard-area {
    padding: 10px 0;
}

.custom-math-keyboard {
    width: 100%;
    padding: 10px;
    background: #ffffff;
    border-radius: 15px;
    box-shadow: 0 -5px 15px rgba(0, 0, 0, 0.05);
}

.keyboard-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.keyboard-actions {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 10px;
    margin-top: 10px;
}

.key-btn {
    padding: 15px;
    border: none;
    border-radius: 12px;
    font-size: 1.5em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    background-color: #f5f5f5;
    color: #333;
}

.key-btn:active {
    transform: scale(0.95);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.key-btn.number {
    background-color: #fff;
}

.key-btn.special {
    background-color: #ffc107;
    color: white;
}

.key-btn.action {
    font-size: 1.2em;
}

.key-btn.clear {
    background-color: #ff6b6b;
    color: white;
}

.key-btn.submit {
    background-color: #4ECDC4;
    color: white;
}

/* Hide original elements that are no longer needed */
.math-history {
    display: none;
}
.answer-input {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .math-game-area {
        height: calc(100vh - 180px); /* Adjust for smaller header on mobile */
    }
    .question-display {
        font-size: 2em;
    }
    .math-answer-display {
        font-size: 1.8em;
    }
    .key-btn {
        font-size: 1.2em;
        min-height: 50px;
        padding: 10px;
    }
}

@media (max-height: 700px) {
    .key-btn {
        padding: 10px;
        font-size: 1.2em;
    }
    .question-display {
        font-size: 2em;
    }
    .math-game-area {
        height: calc(100vh - 180px);
    }
}

/* Challenge History Modal Styles */
.challenge-history-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.challenge-history-modal.active {
    opacity: 1;
    visibility: visible;
}

.challenge-history-content {
    background: white;
    border-radius: 15px;
    max-width: 90vw;
    max-height: 90vh;
    width: 600px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.challenge-history-modal.active .challenge-history-content {
    transform: scale(1);
}

.challenge-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(45deg, #4ECDC4, #44A08D);
    color: white;
    border-radius: 15px 15px 0 0;
}

.challenge-history-header h3 {
    margin: 0;
    font-size: 1.4em;
}

.close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
}

.close-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

.challenge-stats {
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
}

.stat-item {
    text-align: center;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.stat-value {
    font-size: 1.5em;
    font-weight: bold;
    color: #4ECDC4;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9em;
    color: #666;
}

.challenge-history-tabs {
    display: flex;
    background: #f0f0f0;
}

.tab-btn {
    flex: 1;
    padding: 15px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.tab-btn.active {
    background: white;
    border-bottom-color: #4ECDC4;
    color: #4ECDC4;
    font-weight: bold;
}

.challenge-history-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    max-height: 400px;
}

.history-session {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 15px;
    transition: box-shadow 0.2s ease;
}

.history-session:hover {
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
}

.session-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.session-date {
    font-weight: bold;
    color: #333;
}

.session-difficulty {
    background: linear-gradient(45deg, #4ECDC4, #44A08D);
    color: white;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8em;
}

.session-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
}

.summary-item {
    text-align: center;
    padding: 8px;
    background: #f8f9fa;
    border-radius: 6px;
}

.summary-value {
    font-weight: bold;
    color: #4ECDC4;
    font-size: 1.1em;
}

.summary-label {
    font-size: 0.8em;
    color: #666;
    margin-top: 2px;
}

.session-details {
    display: none;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.session-details.expanded {
    display: block;
}

.expand-btn {
    background: none;
    border: 1px solid #4ECDC4;
    color: #4ECDC4;
    padding: 5px 10px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.2s ease;
}

.expand-btn:hover {
    background: #4ECDC4;
    color: white;
}

.question-list {
    max-height: 200px;
    overflow-y: auto;
}

.question-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    margin-bottom: 5px;
    border-radius: 5px;
    font-size: 0.9em;
}

.question-item.correct {
    background: #e8f5e8;
    border-left: 4px solid #4CAF50;
}

.question-item.incorrect {
    background: #ffebee;
    border-left: 4px solid #f44336;
}

.question-text {
    font-weight: bold;
}

.question-answer {
    color: #666;
}

.question-result {
    font-weight: bold;
}

.question-result.correct {
    color: #4CAF50;
}

.question-result.incorrect {
    color: #f44336;
}

.challenge-history-footer {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
    border-radius: 0 0 15px 15px;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.empty-history {
    text-align: center;
    padding: 40px;
    color: #666;
}

.empty-history-icon {
    font-size: 3em;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* Mobile responsive */
@media (max-width: 600px) {
    .challenge-history-content {
        width: 95vw;
        max-height: 95vh;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .session-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .challenge-history-footer {
        flex-direction: column;
        gap: 10px;
    }
    
    .challenge-history-footer .btn {
        width: 100%;
    }
}

.math-control-section {
    flex-direction: column;
    gap: 15px;
}
