* {
    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;
    padding: 20px;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

header h2 {
    font-size: 1.3em;
    font-weight: 300;
    opacity: 0.9;
    margin-bottom: 20px;
}

.mode-switcher {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 20px;
}

.mode-btn {
    padding: 12px 25px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border-radius: 25px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.mode-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.mode-btn.active {
    background: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.stats {
    display: flex;
    justify-content: space-around;
    padding: 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.stat-item {
    text-align: center;
    padding: 10px 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    min-width: 120px;
}

.stat-label {
    display: block;
    font-size: 0.9em;
    color: #6c757d;
    margin-bottom: 5px;
}

.stat-item span:last-child {
    font-size: 1.5em;
    font-weight: bold;
    color: #495057;
}

.exercise-container {
    padding: 40px;
}

.exercise {
    text-align: center;
    margin-bottom: 30px;
}

.numbers {
    font-size: 3em;
    font-weight: bold;
    color: #495057;
    margin-bottom: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
}

.numbers span {
    padding: 10px 20px;
    background: #f8f9fa;
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

#operator {
    color: #007bff;
    font-size: 1.2em;
}

.answer-input {
    display: flex;
    justify-content: center;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
}

#answer {
    font-size: 1.5em;
    padding: 15px 20px;
    border: 3px solid #e9ecef;
    border-radius: 15px;
    width: 200px;
    text-align: center;
    transition: all 0.3s ease;
}

#answer:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

#check-btn {
    font-size: 1.2em;
    padding: 15px 30px;
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: bold;
}

#check-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(40, 167, 69, 0.3);
}

.result {
    text-align: center;
    font-size: 1.3em;
    font-weight: bold;
    padding: 20px;
    border-radius: 15px;
    margin: 20px 0;
    opacity: 0;
    transition: all 0.3s ease;
}

.result.correct {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
    opacity: 1;
}

.result.incorrect {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
    opacity: 1;
}

.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 20px 40px;
    background: #f8f9fa;
}

.controls button {
    padding: 12px 25px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s ease;
}

#new-exercise-btn {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
}

#new-exercise-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.3);
}

#reset-btn {
    background: linear-gradient(135deg, #6c757d, #495057);
    color: white;
}

#reset-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(108, 117, 125, 0.3);
}

#show-solution-btn {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
}

#show-solution-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(23, 162, 184, 0.3);
}

.help-wrapper {
    max-width: 800px;
    margin: 30px auto 0 auto;
    padding: 0 0 30px 0;
}

.help {
    background: white;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    border: 1.5px solid #e9ecef;
    padding: 30px 40px;
    margin: 0;
}

.help h3 {
    color: #1976d2;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.help-content p {
    margin-bottom: 10px;
    line-height: 1.6;
    color: #424242;
}

.help-content strong {
    color: #1976d2;
}

/* Стили для пошагового решения */
.step-by-step {
    margin-top: 30px;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 15px;
    border: 2px solid #e9ecef;
}

.step-by-step h3 {
    color: #495057;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.4em;
}

.solution-steps {
    min-height: 200px;
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
    position: relative;
}

.step-content {
    display: none;
    animation: fadeIn 0.5s ease-in;
}

.step-content.active {
    display: block;
}

.step-content h4 {
    color: #007bff;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.calculation-grid {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 10px;
    align-items: center;
    margin: 15px 0;
    font-family: 'Courier New', monospace;
    font-size: 1.3em;
    font-weight: bold;
}

.calculation-grid .number {
    text-align: right;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 2px solid #e9ecef;
}

.calculation-grid .operator {
    text-align: center;
    font-size: 1.5em;
    color: #007bff;
    padding: 10px;
}

.calculation-grid .result {
    text-align: left;
    padding: 10px;
    background: #d4edda;
    border-radius: 8px;
    border: 2px solid #c3e6cb;
    color: #155724;
}

.carry-over {
    position: absolute;
    font-size: 0.8em;
    color: #dc3545;
    font-weight: bold;
    animation: bounce 0.6s ease-in-out;
}

.carry-over.top {
    top: -5px;
    right: 10px;
}

.carry-over.bottom {
    bottom: -5px;
    right: 10px;
}

.explanation {
    background: #e3f2fd;
    border-left: 4px solid #2196f3;
    padding: 15px;
    margin: 15px 0;
    border-radius: 0 8px 8px 0;
    line-height: 1.6;
}

.explanation strong {
    color: #1976d2;
}

.step-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
}

.step-controls button {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    background: #6c757d;
    color: white;
}

.step-controls button:enabled {
    background: #007bff;
}

.step-controls button:enabled:hover {
    background: #0056b3;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

.step-controls button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

#step-counter {
    font-weight: bold;
    color: #495057;
    background: white;
    padding: 8px 15px;
    border-radius: 20px;
    border: 2px solid #e9ecef;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* Стили для визуализации разрядов */
.digit-placeholder {
    display: inline-block;
    width: 30px;
    height: 40px;
    border: 2px solid #dee2e6;
    border-radius: 5px;
    text-align: center;
    line-height: 36px;
    margin: 0 2px;
    background: white;
    font-weight: bold;
}

.digit-placeholder.highlighted {
    background: #fff3cd;
    border-color: #ffc107;
    animation: pulse 1s infinite;
}

.digit-placeholder.carry {
    background: #f8d7da;
    border-color: #dc3545;
    color: #721c24;
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(255, 193, 7, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(255, 193, 7, 0);
    }
}

/* Стили для результатов тестирования */
.test-results {
    margin-top: 30px;
    padding: 25px;
    background: #f8f9fa;
    border-radius: 15px;
    border: 2px solid #e9ecef;
}

.test-results h3 {
    color: #495057;
    margin-bottom: 20px;
    text-align: center;
    font-size: 1.4em;
}

.test-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.test-stat {
    background: white;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border: 2px solid #e9ecef;
}

.test-label {
    display: block;
    font-size: 0.9em;
    color: #6c757d;
    margin-bottom: 8px;
}

.test-stat span:last-child {
    font-size: 1.8em;
    font-weight: bold;
    color: #495057;
}

.test-details {
    background: white;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid #dee2e6;
}

.test-question {
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    border-left: 4px solid #e9ecef;
}

.test-question.correct {
    background: #d4edda;
    border-left-color: #28a745;
}

.test-question.incorrect {
    background: #f8d7da;
    border-left-color: #dc3545;
}

.test-question-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.test-question-text {
    font-weight: bold;
    color: #495057;
}

.test-question-result {
    font-weight: bold;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.9em;
}

.test-question-result.correct {
    background: #28a745;
    color: white;
}

.test-question-result.incorrect {
    background: #dc3545;
    color: white;
}

.test-question-details {
    font-size: 0.9em;
    color: #6c757d;
}

.test-actions {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.test-actions button {
    padding: 12px 25px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    font-size: 1em;
}

#retake-test {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
}

#retake-test:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 123, 255, 0.3);
}

#download-results {
    background: linear-gradient(135deg, #28a745, #20c997);
    color: white;
}

#download-results:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(40, 167, 69, 0.3);
}

.controls-wrapper {
    max-width: 800px;
    margin: 30px auto 0 auto;
    padding: 0 0 30px 0;
}

.controls {
    background: white;
    border-radius: 20px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    border: 1.5px solid #e9ecef;
    display: flex;
    justify-content: center;
    gap: 20px;
    padding: 20px 40px;
    margin: 0;
}

@media (max-width: 900px) {
    .help-wrapper {
        max-width: 98vw;
        padding: 0 2vw 30px 2vw;
    }
    .help {
        padding: 20px 10px;
        border-radius: 15px;
    }
    .controls-wrapper {
        max-width: 98vw;
        padding: 0 2vw 30px 2vw;
    }
    .controls {
        padding: 15px 5px;
        border-radius: 15px;
    }
}

@media (max-width: 768px) {
    .container {
        margin: 10px;
        border-radius: 15px;
    }
    
    header {
        padding: 20px;
    }
    
    header h1 {
        font-size: 2em;
    }
    
    .numbers {
        font-size: 2em;
        flex-direction: column;
        gap: 10px;
    }
    
    .answer-input {
        flex-direction: column;
    }
    
    #answer {
        width: 100%;
        max-width: 300px;
    }
    
    .stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .controls {
        flex-direction: column;
    }
} 