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

body {
    font-family: 'Noto Sans', Arial, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: #2c3e50;
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.1);
}

.level-selector {
    background: white;
    padding: 15px;
    border-radius: 10px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    display: inline-block;
}

.level-selector label {
    font-weight: bold;
    margin-left: 10px;
}

select {
    padding: 8px 12px;
    border: 2px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
    background: white;
}

.game-area {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 8px 16px rgba(0,0,0,0.1);
}

.problem {
    display: none;
}

.equation {
    font-size: 3rem;
    font-weight: bold;
    color: #2c3e50;
    margin-bottom: 20px;
}

.number {
    color: #3498db;
    margin: 0 20px;
}

.operator, .equals {
    color: #e74c3c;
    margin: 0 15px;
}

.question {
    color: #f39c12;
}

.answer-box {
    display: inline-block;
    width: 100px;
    height: 60px;
    border: 2px solid #333;
    border-radius: 8px;
    vertical-align: middle;
    margin: 0 15px;
}

.input-section {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 10px;
    align-items: center;
    justify-content: center;
}

.input-section label {
    font-weight: bold;
}

.text-input {
    display: flex;
    align-items: center;
    gap: 15px;
}

.text-input label {
    font-weight: bold;
    min-width: 80px;
}

#answer {
    padding: 10px 15px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1.2rem;
    text-align: center;
    width: 150px;
    font-family: 'Noto Sans', monospace;
}

#answer:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

.voice-input {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.voice-button {
    background: #27ae60;
    color: white;
    border: none;
    padding: 11px 20px;
    border-radius: 8px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.3s ease;
    height: 48px;
}

.voice-button:hover {
    background: #2ecc71;
    transform: translateY(-2px);
}

.voice-button.listening {
    background: #e74c3c;
    animation: pulse 1s infinite;
}

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

.voice-status-container {
    text-align: center;
    margin-bottom: 20px;
}

.voice-status {
    font-size: 14px;
    color: #666;
    min-height: 20px;
}

.submit-button {
    background: #3498db;
    color: white;
    border: none;
    padding: 11px 25px;
    border-radius: 8px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    height: 48px;
}

.submit-button:hover {
    background: #2980b9;
    transform: translateY(-2px);
}

.feedback {
    margin: 20px 0;
    min-height: 80px;
}

.result {
    text-align: center;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 10px;
}

.result.correct {
    color: #27ae60;
}

.result.incorrect {
    color: #e74c3c;
}

.explanation {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
    line-height: 1.6;
    display: none;
}

.explanation.show {
    display: block;
}

.score-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 20px;
    border-top: 2px solid #eee;
}

.score {
    display: flex;
    gap: 20px;
    font-weight: bold;
    width: 100%;
    justify-content: center;
}

.new-problem-btn {
    background: #f39c12;
    color: white;
    border: none;
    padding: 11px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 16px;
    height: 48px;
}

.new-problem-btn:hover {
    background: #e67e22;
    transform: translateY(-2px);
}

body.incorrect-answer-flash::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 0, 0, 0.3);
    z-index: 1000;
    pointer-events: none; /* Allows interaction with elements underneath */
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background-color: #f00; /* Will be randomized */
    top: -20px;
    opacity: 0;
    animation: fall 4s linear forwards;
}

@keyframes fall {
    0% {
        transform: translateY(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(105vh) rotate(720deg);
        opacity: 0;
    }
}

.drawing-section {
    margin: 0 0 30px 0;
    padding: 0;
    background: transparent;
    border: none;
}

.drawing-section h3 {
    text-align: center;
    color: #2c3e50;
    margin-bottom: 15px;
}

.drawing-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 15px;
    flex-wrap: wrap;
    gap: 15px;
}

.color-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.color-controls label {
    font-weight: bold;
}

.color-btn {
    width: 30px;
    height: 30px;
    border: 2px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    border-color: #333;
    border-width: 3px;
}

.drawing-tools {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-btn {
    background: #6c757d;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s ease;
}

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

.tool-btn.active {
    background: #e74c3c;
}

#brush-size {
    width: 80px;
}

#drawing-canvas {
    width: 100%;
    height: 200px;
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24'%3E%3Cpath d='M3 17.25V21h3.75L17.81 9.94l-3.75-3.75L3 17.25zM20.71 7.04c.39-.39.39-1.02 0-1.41l-2.34-2.34c-.39-.39-1.02-.39-1.41 0l-1.83 1.83 3.75 3.75 1.83-1.83z'/%3E%3C/svg%3E") 0 24, crosshair;
    display: block;
    margin: 0 auto;
}

#drawing-canvas.eraser-mode {
    cursor: grab;
}

@media (max-width: 600px) {
    .container {
        padding: 10px;
    }
    
    .equation {
        font-size: 2rem;
    }
    
    .input-section {
        flex-direction: column;
        align-items: stretch;
    }
    
    .score-section {
        flex-direction: column;
        gap: 15px;
    }
    
    .score {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }
    
    .drawing-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .color-controls, .drawing-tools {
        justify-content: center;
    }
    
    #drawing-canvas {
        width: 100%;
        height: 150px;
    }
}