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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    padding-top: env(safe-area-inset-top, 20px);
    padding-bottom: env(safe-area-inset-bottom, 20px);
}

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

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.tagline {
    font-size: 1.1rem;
    opacity: 0.9;
}

.game-area {
    padding: 40px;
    min-height: 400px;
}

.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

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

/* Level Selection Screen */
#level-screen h2 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2rem;
}

.level-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.level-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 15px;
    padding: 30px 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 1rem;
}

.level-btn:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(102, 126, 234, 0.4);
}

.level-title {
    font-size: 1.5rem;
    font-weight: bold;
}

.level-desc {
    font-size: 0.9rem;
    opacity: 0.9;
}

/* Game Screen */
.stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 40px;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
}

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

.stat-label {
    display: block;
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 1.8rem;
    font-weight: bold;
    color: #667eea;
}

.question-container {
    text-align: center;
    margin: 40px 0;
}

.question {
    font-size: 4rem;
    font-weight: bold;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 40px;
}

.operator, .equals {
    color: #667eea;
}

.answer-placeholder {
    color: #764ba2;
}

.answer-area {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-bottom: 20px;
}

#answer-input {
    font-size: 1.5rem;
    padding: 15px 25px;
    border: 3px solid #667eea;
    border-radius: 10px;
    width: 200px;
    text-align: center;
    transition: all 0.3s ease;
}

#answer-input:focus {
    outline: none;
    border-color: #764ba2;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 10px;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #f8f9fa;
    color: #666;
    border: 2px solid #ddd;
    padding: 12px 30px;
    border-radius: 10px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #e9ecef;
    border-color: #adb5bd;
}

.feedback {
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    min-height: 40px;
    margin: 20px 0;
}

.feedback.correct {
    color: #28a745;
    animation: bounce 0.5s ease;
}

.feedback.incorrect {
    color: #dc3545;
    animation: shake 0.5s ease;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

.game-controls {
    text-align: center;
    margin-top: 30px;
}

/* Results Screen */
#results-screen h2 {
    text-align: center;
    color: #333;
    font-size: 2.5rem;
    margin-bottom: 30px;
}

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

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid #dee2e6;
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    font-size: 1.2rem;
    color: #666;
}

.result-value {
    font-size: 1.3rem;
    font-weight: bold;
    color: #667eea;
}

.results-buttons {
    display: flex;
    gap: 15px;
    justify-content: center;
}

footer {
    background: #f8f9fa;
    text-align: center;
    padding: 20px;
    color: #666;
}

/* Responsive Design */
@media (max-width: 600px) {
    header h1 {
        font-size: 1.8rem;
    }
    
    .question {
        font-size: 2.5rem;
        gap: 10px;
    }
    
    .level-buttons {
        grid-template-columns: 1fr;
    }
    
    .answer-area {
        flex-direction: column;
    }
    
    #answer-input {
        width: 100%;
    }
    
    .results-buttons {
        flex-direction: column;
    }
    
    .stats {
        flex-direction: column;
        gap: 15px;
    }
}
