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

body {
    font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
    background: #87CEEB;
    min-height: 100vh;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

/* Language Selector */
.language-selector {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100;
}

.language-flags {
    display: flex;
    gap: 10px;
    background: white;
    padding: 10px 15px;
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.language-flag {
    font-size: 1.5em;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 8px;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.language-flag:hover {
    background: #f0f0f0;
    transform: scale(1.1);
}

.language-flag.active {
    background: #87CEEB;
    border-color: #2563eb;
    transform: scale(1.15);
}

.language-flag-tooltip {
    position: relative;
}

.language-flag-tooltip:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8em;
    white-space: nowrap;
    margin-bottom: 5px;
    z-index: 101;
}

.container {
    background: white;
    border-radius: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 1000px;
    width: 100%;
    padding: 40px;
    animation: slideIn 0.5s ease-out;
}

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

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.header h1 {
    font-size: 3em;
    color: #2563eb;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.subtitle {
    font-size: 1.3em;
    color: #7c3aed;
    font-weight: bold;
}

/* Difficulty Section */
.difficulty-section {
    background: linear-gradient(135deg, #dc2626 0%, #ea580c 100%);
    border-radius: 20px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 10px 25px rgba(220, 38, 38, 0.3);
}

.difficulty-label {
    display: block;
    font-size: 1.3em;
    color: white;
    font-weight: bold;
    margin-bottom: 15px;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

#difficulty-display {
    background: white;
    color: #dc2626;
    padding: 5px 15px;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1.2em;
}

.slider-container {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.difficulty-text {
    color: white;
    font-weight: bold;
    font-size: 0.95em;
    min-width: 50px;
}

.slider {
    flex: 1;
    height: 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.3);
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
}

.slider::-moz-range-thumb {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.slider::-moz-range-thumb:hover {
    transform: scale(1.1);
}

.difficulty-info {
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 15px;
    border-radius: 10px;
    text-align: center;
}

#difficulty-description {
    color: white;
    font-size: 0.95em;
    font-weight: bold;
}

/* Problem Section */
.problem-section {
    background: linear-gradient(135deg, #dbeafe 0%, #e0e7ff 100%);
    border-radius: 20px;
    padding: 40px;
    margin-bottom: 30px;
    min-height: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.2);
}

.problem-display {
    font-size: 2.5em;
    font-weight: bold;
    color: #333;
    text-align: center;
    font-family: 'Courier New', monospace;
    line-height: 1.6;
}

/* Horizontal multiplication (1x1) */
.multiplication-horizontal {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.multiplication-horizontal .number {
    font-size: 2.5em;
}

.multiplication-horizontal .operator {
    font-size: 2.5em;
    color: #f5576c;
    font-weight: bold;
}

/* Vertical multiplication (2+ digits) */
.multiplication-vertical {
    display: inline-block;
    text-align: right;
    font-family: 'Courier New', monospace;
}

.multiplication-vertical .line {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
    margin: 5px 0;
    font-size: 2em;
}

.multiplication-vertical .operator {
    color: #f5576c;
    font-weight: bold;
    margin-right: 10px;
}

.multiplication-vertical .separator {
    width: 100%;
    height: 3px;
    background: #333;
    margin: 10px 0;
}

.digit-input {
    width: 90px;
    height: 90px;
    font-size: 1.4em;
    text-align: center;
    border: 2px solid #2563eb;
    border-radius: 8px;
    padding: 10px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    transition: all 0.2s;
}

.digit-input:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 8px rgba(124, 58, 237, 0.4);
    background-color: #f0f4ff;
}

.digit-input.error {
    border-color: #dc2626;
    background-color: #fee2e2;
}

.digit-input.correct {
    border-color: #16a34a;
    background-color: #dcfce7;
}

/* Answer Section */
.answer-section {
    display: flex;
    gap: 15px;
    margin-bottom: 30px;
}

.answer-input {
    flex: 1;
    padding: 18px;
    font-size: 1.3em;
    border: 3px solid #2563eb;
    border-radius: 15px;
    outline: none;
    transition: all 0.3s;
    font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
    font-weight: bold;
}

.answer-input:focus {
    border-color: #7c3aed;
    box-shadow: 0 0 15px rgba(124, 58, 237, 0.3);
    transform: scale(1.02);
}

.answer-input::placeholder {
    color: #ccc;
}

.submit-btn {
    padding: 18px 30px;
    font-size: 1.2em;
    background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(37, 99, 235, 0.4);
    font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
}

.submit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(37, 99, 235, 0.6);
}

.submit-btn:active {
    transform: translateY(-1px);
}

/* Feedback Section */
.feedback-section {
    min-height: 80px;
    margin-bottom: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.feedback {
    font-size: 1.1em;
    font-weight: bold;
    text-align: center;
    padding: 15px;
    border-radius: 15px;
    min-width: 100%;
    animation: fadeIn 0.5s ease-out;
    word-wrap: break-word;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.feedback.correct {
    background: linear-gradient(135deg, #84fab0 0%, #8fd3f4 100%);
    color: #2d5016;
    box-shadow: 0 5px 15px rgba(132, 250, 176, 0.4);
}

.feedback.incorrect {
    background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
    color: #8b0000;
    box-shadow: 0 5px 15px rgba(250, 112, 154, 0.4);
}

.feedback.empty {
    background: transparent;
    color: transparent;
}

/* Score Section */
.score-section {
    display: flex;
    gap: 20px;
    margin-bottom: 30px;
    justify-content: center;
}

.score-box {
    background: linear-gradient(135deg, #16a34a 0%, #059669 100%);
    padding: 20px 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 5px 15px rgba(22, 163, 74, 0.3);
    min-width: 120px;
    color: white;
}

.score-label {
    font-size: 0.95em;
    color: white;
    font-weight: bold;
    margin-bottom: 8px;
}

.score-value {
    font-size: 2.5em;
    color: white;
    font-weight: bold;
}

/* New Problem Button */
.new-problem-btn {
    width: 100%;
    padding: 18px;
    font-size: 1.3em;
    background: linear-gradient(135deg, #dc2626 0%, #ea580c 100%);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(220, 38, 38, 0.4);
    font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
}

.new-problem-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(220, 38, 38, 0.6);
}

.new-problem-btn:active {
    transform: translateY(-1px);
}

/* Confetti Animation */
@keyframes confetti-fall {
    to {
        transform: translateY(100vh) rotateZ(360deg);
        opacity: 0;
    }
}

.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    pointer-events: none;
    animation: confetti-fall 3s ease-in forwards;
}

/* Modal Popup */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background-color: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalBounce 0.5s ease-out;
    max-width: 500px;
}

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

.modal-content h2 {
    font-size: 2.5em;
    color: #16a34a;
    margin-bottom: 20px;
}

.modal-content p {
    font-size: 1.3em;
    color: #333;
    margin-bottom: 30px;
}

.modal-btn {
    padding: 15px 40px;
    font-size: 1.2em;
    background: linear-gradient(135deg, #16a34a 0%, #059669 100%);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s;
    box-shadow: 0 5px 15px rgba(22, 163, 74, 0.4);
    font-family: 'Segoe UI', 'Roboto', 'Arial', sans-serif;
}

.modal-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.6);
}

.modal-btn:active {
    transform: translateY(-1px);
}

/* Responsive Design */
@media (max-width: 600px) {
    .container {
        padding: 25px;
    }

    .header h1 {
        font-size: 2.2em;
    }

    .problem-section {
        padding: 25px;
        min-height: 120px;
    }

    .problem-display {
        font-size: 1.8em;
    }

    .answer-input,
    .submit-btn {
        font-size: 1.1em;
        padding: 15px;
    }

    .score-box {
        min-width: 100px;
        padding: 15px 20px;
    }

    .score-value {
        font-size: 2em;
    }
}