* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', 'Helvetica', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    direction: rtl;
}

.container {
    max-width: 800px;
    width: 100%;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    padding: 40px;
}

h1 {
    text-align: center;
    color: #667eea;
    font-size: 2.5em;
    margin-bottom: 10px;
}

.subtitle {
    text-align: center;
    color: #666;
    font-size: 1.2em;
    margin-bottom: 30px;
}

.mode-selector {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 30px;
}

.mode-btn {
    padding: 12px 24px;
    font-size: 1em;
    font-weight: bold;
    border: 2px solid #667eea;
    border-radius: 25px;
    background: white;
    color: #667eea;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
}

.mode-btn.active {
    background: #667eea;
    color: white;
}

.game-area {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 20px;
}

.puzzle-display {
    text-align: center;
    margin-bottom: 40px;
}

.puzzle-equation {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    font-size: 3em;
    font-weight: bold;
    color: #333;
    padding: 30px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    direction: ltr !important;
}

.number, .operator, .equals, .question-mark {
    font-family: 'Arial', 'Helvetica', 'Roboto', 'Segoe UI', sans-serif !important;
    direction: ltr !important;
    unicode-bidi: isolate;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.number {
    color: #667eea;
    min-width: 80px;
    text-align: center;
}

.operator {
    color: #764ba2;
    font-size: 1.2em;
}

.equals {
    color: #28a745;
}

.question-mark {
    color: #dc3545;
    animation: pulse 1.5s ease-in-out infinite;
}

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

.input-area {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

#answerInput {
    flex: 1;
    padding: 20px;
    font-size: 1.5em;
    font-family: 'Arial', 'Helvetica', 'Roboto', 'Segoe UI', sans-serif !important;
    border: 3px solid #667eea;
    border-radius: 10px;
    outline: none;
    transition: all 0.3s ease;
    direction: ltr !important;
    text-align: center;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

#answerInput:focus {
    border-color: #764ba2;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.4);
}

.btn {
    padding: 20px 40px;
    font-size: 1.2em;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-check {
    background: #28a745;
    color: white;
}

.btn-check:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(40, 167, 69, 0.3);
}

.btn-new {
    width: 100%;
    background: #667eea;
    color: white;
}

.btn-new:hover {
    background: #764ba2;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.feedback {
    text-align: center;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 1.3em;
    font-weight: bold;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback.correct {
    background: #d4edda;
    color: #155724;
    border: 3px solid #28a745;
    animation: celebrate 0.5s ease;
}

.feedback.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 3px solid #dc3545;
    animation: shake 0.5s ease;
}

@keyframes celebrate {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.stats {
    display: flex;
    justify-content: space-around;
    background: #e9ecef;
    border-radius: 10px;
    padding: 20px;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    color: #666;
    font-size: 1em;
    margin-bottom: 8px;
    font-weight: bold;
}

.stat-value {
    display: block;
    font-size: 2.5em;
    font-weight: bold;
}

.correct-stat {
    color: #28a745;
}

.incorrect-stat {
    color: #dc3545;
}

#accuracy {
    color: #667eea;
}

@media (max-width: 600px) {
    .container {
        padding: 20px;
    }
    
    h1 {
        font-size: 2em;
    }
    
    .puzzle-equation {
        font-size: 2em;
        gap: 10px;
        padding: 20px;
    }
    
    .number {
        min-width: 50px;
    }
    
    #answerInput {
        font-size: 1.2em;
        padding: 15px;
    }
    
    .btn {
        padding: 15px 25px;
        font-size: 1em;
    }
    
    .mode-selector {
        gap: 5px;
    }
    
    .mode-btn {
        padding: 10px 15px;
        font-size: 0.9em;
    }
    
    .stat-value {
        font-size: 2em;
    }
}
