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

body {
    font-family: 'Comic Sans MS', cursive, sans-serif;
    background: linear-gradient(135deg, #6a11cb 0%, #2575fc 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    padding: 20px;
}

.screen {
    background: rgba(255, 255, 255, 0.92);
    color: #333;
    border-radius: 25px;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.3);
    padding: 30px;
    text-align: center;
    max-width: 800px;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.screen-title {
    font-size: 2.8rem;
    width: 100%;
    margin-bottom: 25px;
    color: #ff5252;
    text-shadow: 2px 2px 0 #ffd700;
    position: relative;
    display: inline-block;
}

.subtitle {
    font-size: 1.4rem;
    margin: 15px 0 25px;
    color: #1a237e;
    font-weight: bold;
}

.lang-toggle-btn {
    background: linear-gradient(135deg, #2575fc, #6a11cb);
    color: #fff;
    border: none;
    padding: 10px 18px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.lang-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
}
.screen-title::after {
    content: '';
    position: absolute;
    bottom: -5px;
    left: 0;
    width: 100%;
    height: 8px;
    background: linear-gradient(90deg, #ff5252, #ffd700, #4caf50);
    border-radius: 4px;
}

.settings-screen, .summary-screen {
    padding: 40px;
}

.setting-group {
    margin: 25px 0;
    text-align: left;
}

.setting-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 1.3rem;
    font-weight: bold;
    color: #2c3e50;
}

.setting-controls {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-top: 10px;
}

.checkboxes-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    margin-top: 15px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background: #f5f5f5;
    border: 2px solid #4caf50;
    border-radius: 12px;
    cursor: pointer;
    font-weight: bold;
    color: #2c3e50;
    transition: all 0.3s ease;
}

.checkbox-label:hover {
    background: #e8f5e9;
    border-color: #2e7d32;
}

.checkbox-label input[type="checkbox"] {
    cursor: pointer;
    accent-color: #4caf50;
    visibility: hidden;
        width: 0;
}

.checkbox-label input[type="checkbox"]:checked + label,
.checkbox-label input[type="checkbox"]:checked {
    /* This will be handled by the label:has selector or JS */
}

.checkbox-label:has(input[type="checkbox"]:checked) {
    background: #4caf50;
    color: white;
    border-color: #2e7d32;
}

input[type="number"] {
    width: 85px;
    padding: 10px 15px;
    border: 3px solid #4caf50;
    border-radius: 12px;
    font-size: 1.4rem;
    font-weight: bold;
    text-align: center;
    background: #e8f5e9;
    color: #2e7d32;
}

input[type="number"]:focus {
    outline: none;
    border-color: #ff9800;
    box-shadow: 0 0 0 3px rgba(255, 152, 0, 0.3);
}

.range-display {
    font-size: 1.2rem;
    background: #e3f2fd;
    padding: 8px 15px;
    border-radius: 20px;
    min-width: 180px;
    font-weight: bold;
    color: #1565c0;
}

.time-display {
    font-size: 1.8rem;
    background: #fff8e1;
    padding: 10px 20px;
    border-radius: 25px;
    min-width: 100px;
    font-weight: bold;
    color: #e65100;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
}

.start-btn, .restart-btn {
    background: linear-gradient(45deg, #ff5252, #ff1744);
    color: white;
    border: none;
    padding: 18px 60px;
    font-size: 1.8rem;
    border-radius: 50px;
    margin-top: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 6px 0 rgba(200, 0, 0, 0.8);
    font-weight: bold;
    letter-spacing: 2px;
    position: relative;
    overflow: hidden;
}

.start-btn:hover, .restart-btn:hover {
    background: linear-gradient(45deg, #ff1744, #d50000);
    transform: translateY(-2px);
    box-shadow: 0 8px 0 rgba(180, 0, 0, 0.8);
}

.start-btn:active, .restart-btn:active {
    transform: translateY(4px);
    box-shadow: 0 3px 0 rgba(150, 0, 0, 0.8);
}

.start-btn::after, .restart-btn::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 70%);
    transform: scale(0);
    transition: transform 0.5s ease;
    border-radius: 50%;
}

.start-btn:hover::after, .restart-btn:hover::after {
    transform: scale(1);
}

#game-screen {
    display: none;
    padding: 25px;
}

#question-display {
    font-size: 3.5rem;
    margin: 30px 0;
    min-height: 80px;
    font-weight: bold;
    color: #1a237e;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
}

#question-display::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 6px;
    background: linear-gradient(90deg, #ff5252, #ffd700, #4caf50, #2196f3, #9c27b0);
}

#input-display {
    font-size: 3.2rem;
    margin: 20px 0;
    min-height: 70px;
    background: #e3f2fd;
    border-radius: 18px;
    padding: 10px;
    border: 4px solid #2196f3;
    font-weight: bold;
    color: #0d47a1;
    letter-spacing: 3px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

#input-display.wrong {
    animation: shake 0.5s, blink-red 0.7s;
    background: #ffebee;
    border-color: #f44336;
    color: #c62828;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-8px); }
    20%, 40%, 60%, 80% { transform: translateX(8px); }
}

@keyframes blink-red {
    0%, 100% { box-shadow: inset 0 0 15px rgba(244, 67, 54, 0.7), 0 0 15px rgba(244, 67, 54, 0.5); }
    50% { box-shadow: inset 0 0 25px rgba(244, 67, 54, 0.9), 0 0 25px rgba(244, 67, 54, 0.8); }
}

#timer-container {
    margin: 20px 0;
    height: 30px;
    background: #e0e0e0;
    border-radius: 15px;
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.2);
}

#timer-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff5252, #ff9800, #ffd700);
    width: 100%;
    border-radius: 15px;
    transition: width 0.5s linear;
}

#timer-text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    color: #333;
    font-size: 1.3rem;
    text-shadow: 0 1px 1px rgba(255,255,255,0.8);
}

#score-display {
    font-size: 1.8rem;
    margin: 25px 0 15px;
    padding: 12px 25px;
    background: rgba(255, 255, 255, 0.85);
    border-radius: 50px;
    display: inline-block;
    font-weight: bold;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.correct-score {
    color: #2e7d32;
    margin-right: 15px;
}

.wrong-score {
    color: #c62828;
}

#keyboard {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-top: 30px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    padding: 0;
    background: transparent;
    border-radius: 0;
}

.key {
    background: linear-gradient(135deg, #5dade2, #3498db);
    border: none;
    border-radius: 18px;
    height: 75px;
    font-size: 1.8rem;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 12px rgba(52, 152, 219, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    user-select: none;
}

.key:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(52, 152, 219, 0.5), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.key:active {
    transform: translateY(3px);
    box-shadow: 0 3px 6px rgba(52, 152, 219, 0.4), 0 1px 3px rgba(0, 0, 0, 0.1);
}

.key::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, rgba(255,255,255,0) 70%);
    transform: scale(0);
    transition: transform 0.5s ease;
    border-radius: 50%;
}

.key:hover::after {
    transform: scale(1);
}

.key.backspace {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    box-shadow: 0 6px 12px rgba(255, 107, 107, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
}

.key.backspace:hover {
    box-shadow: 0 8px 16px rgba(255, 107, 107, 0.5), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.key.backspace:active {
    box-shadow: 0 3px 6px rgba(255, 107, 107, 0.4), 0 1px 3px rgba(0, 0, 0, 0.1);
}

.key.enter {
    background: linear-gradient(135deg, #51cf66, #37b24d);
    box-shadow: 0 6px 12px rgba(81, 207, 102, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
    font-size: 1.7rem;
}

.key.enter:hover {
    box-shadow: 0 8px 16px rgba(81, 207, 102, 0.5), 0 4px 8px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.key.enter:active {
    box-shadow: 0 3px 6px rgba(81, 207, 102, 0.4), 0 1px 3px rgba(0, 0, 0, 0.1);
    transform: translateY(3px);
}

#keyboard-controls {
    display: flex;
    gap: 20px;
    margin-top: 25px;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
    justify-content: center;
    flex-wrap: wrap;
}

.key-control {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border: none;
    border-radius: 18px;
    padding: 18px 30px;
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 6px 12px rgba(102, 126, 234, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    user-select: none;
    min-width: 160px;
}

.key-control:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(102, 126, 234, 0.5), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.key-control:active {
    transform: translateY(3px);
    box-shadow: 0 3px 6px rgba(102, 126, 234, 0.4), 0 1px 3px rgba(0, 0, 0, 0.1);
}

.key-control.backspace {
    background: linear-gradient(135deg, #ff6b6b, #ee5a52);
    box-shadow: 0 6px 12px rgba(255, 107, 107, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
}

.key-control.backspace:hover {
    box-shadow: 0 8px 16px rgba(255, 107, 107, 0.5), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.key-control.backspace:active {
    box-shadow: 0 3px 6px rgba(255, 107, 107, 0.4), 0 1px 3px rgba(0, 0, 0, 0.1);
}

.key-control.enter {
    background: linear-gradient(135deg, #51cf66, #37b24d);
    box-shadow: 0 6px 12px rgba(81, 207, 102, 0.4), 0 2px 4px rgba(0, 0, 0, 0.1);
}

.key-control.enter:hover {
    box-shadow: 0 8px 16px rgba(81, 207, 102, 0.5), 0 4px 8px rgba(0, 0, 0, 0.15);
}

.key-control.enter:active {
    box-shadow: 0 3px 6px rgba(81, 207, 102, 0.4), 0 1px 3px rgba(0, 0, 0, 0.1);
}

#summary-screen {
    display: none;
    padding: 40px;
    text-align: center;
}

.final-score {
    font-size: 2.5rem;
    margin: 25px 0;
    padding: 20px;
    border-radius: 20px;
    font-weight: bold;
}

.final-correct {
    background: rgba(76, 175, 80, 0.25);
    color: #2e7d32;
    border: 3px dashed #4caf50;
}

.final-wrong {
    background: rgba(244, 67, 54, 0.25);
    color: #c62828;
    border: 3px dashed #f44336;
}

.instructions {
    margin-top: 30px;
    font-size: 1.1rem;
    color: #455a64;
    line-height: 1.5;
}

.congratulations {
    margin-top: 30px;
    font-size: 1.3rem;
    color: #37474f;
    line-height: 1.6;
}

.total-result {
    font-size: 2rem;
    margin: 25px 0;
    font-weight: bold;
    color: #546e7a;
}

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

.confetti {
    position: absolute;
    width: 15px;
    height: 15px;
    background-color: #f00;
    border-radius: 0;
}

@media (max-width: 600px) {
    .screen {
        border-radius: 20px;
        padding: 20px;
        margin: 10px;
    }
    
    .screen-title {
        font-size: 2.2rem;
    }
    
    #question-display {
        font-size: 2.5rem;
        margin: 20px 0;
    }
    
    #input-display {
        font-size: 2.5rem;
    }
    
    .key {
        height: 60px;
        font-size: 1.6rem;
    }
    
    #keyboard {
        gap: 12px;
        max-width: 100%;
    }
    
    #keyboard-controls {
        gap: 12px;
        margin-top: 20px;
    }
    
    .key-control {
        padding: 14px 20px;
        font-size: 1rem;
        min-width: 140px;
        flex: 1;
        min-width: 120px;
    }
    
    .setting-controls {
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .checkboxes-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }
    
    .checkbox-label {
        padding: 10px;
        font-size: 0.9rem;
    }
    
    input[type="number"] {
        width: 100%;
        max-width: 120px;
    }
    
    .range-display, .time-display {
        width: 100%;
        max-width: 250px;
        margin-top: 5px;
    }
}
