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

body {
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    max-width: 800px;
    width: 100%;
}

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

.score-display {
    font-size: 18px;
    font-weight: bold;
    color: #333;
    padding: 5px 10px;
    border: 2px solid red;
    border-radius: 4px;
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 30px;
    font-size: 2.5em;
    font-weight: bold;
}

.addition-container {
    background: #f8f9ff;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    border: 2px solid #e3e8ff;
}

.place-values {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 20px;
    gap: 10px;
    padding-left: 50px; /* 与加号对齐 */
    align-items: center;
}

.place-value {
    width: 60px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: #555;
    font-size: 1.2em;
    flex-shrink: 0; /* 防止字符被压缩 */
    text-align: center; /* 确保文字居中 */
}

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

.addend-placeholder {
    width: 40px; /* 与plus-sign宽度一致 */
}

.plus-sign {
    font-size: 2.5em;
    font-weight: bold;
    color: #333;
    width: 40px;
    text-align: center;
}

.digit-container {
    display: flex;
    gap: 10px;
}

.digit-box {
    position: relative;
    width: 60px;
    height: 60px;
}

.digit-input, .result-input {
    width: 100%;
    height: 100%;
    border: 3px solid #4a90e2;
    border-radius: 10px;
    text-align: center;
    font-size: 1.5em;
    font-weight: bold;
    background: white;
    color: #333;
    transition: all 0.3s ease;
    position: relative;
    z-index: 1;
}

.digit-input:focus, .result-input:focus {
    outline: none;
    border-color: #2c5aa0;
    box-shadow: 0 0 10px rgba(74, 144, 226, 0.3);
}

.result-input {
    background: #fff3cd;
    border-color: #ffc107;
    color: #856404;
}

/* 进位输入框样式 - 位于数字方块右下角，尺寸更大 */
.carry-input {
    position: absolute;
    bottom: -12px;
    right: -12px;
    width: 28px;
    height: 28px;
    border: 2px solid #ff4444;
    border-radius: 4px;
    text-align: center;
    font-size: 1em;
    font-weight: bold;
    background: #ffebee;
    color: #d32f2f;
    z-index: 2;
    padding: 0;
    line-height: 24px;
}

.carry-input:focus {
    outline: none;
    border-color: #f44336;
    box-shadow: 0 0 5px rgba(244, 67, 54, 0.3);
}

.carry-input::placeholder {
    color: #ffb74d;
    font-size: 0.8em;
}

/* 个位数字不需要进位输入框 */
.digit-box:last-child .carry-input {
    display: none;
}

.divider {
    height: 3px;
    background: #333;
    margin: 20px 0;
    border-radius: 2px;
}

.result-row {
    display: flex;
    align-items: center;
    gap: 15px;
}

.result-placeholder {
    width: 40px;
}

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

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

#calculate-btn {
    background: #4caf50;
    color: white;
}

#calculate-btn:hover {
    background: #45a049;
    transform: translateY(-2px);
}

#check-btn {
    background: #2196f3;
    color: white;
}

#check-btn:hover {
    background: #1976d2;
    transform: translateY(-2px);
}

#reset-btn {
    background: #f44336;
    color: white;
}

#reset-btn:hover {
    background: #d32f2f;
    transform: translateY(-2px);
}

#random-btn {
    background: #9c27b0;
    color: white;
}

#random-btn:hover {
    background: #7b1fa2;
    transform: translateY(-2px);
}

.result-display {
    margin-top: 20px;
}

.message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    font-weight: bold;
    text-align: center;
    font-size: 1.1em;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.message.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.calculation-details {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #007bff;
    font-family: 'Courier New', monospace;
    white-space: pre-line;
    line-height: 1.6;
}

/* 烟花效果样式 */
.fireworks-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 9999;
    display: none;
}

.firework {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    animation: explode 1s ease-out forwards;
}

@keyframes explode {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    100% {
        transform: scale(20);
        opacity: 0;
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 20px;
        margin: 10px;
    }
    
    .digit-box {
        width: 50px;
        height: 50px;
    }
    
    .digit-input, .result-input {
        font-size: 1.2em;
    }
    
    .carry-input {
        width: 24px;
        height: 24px;
        font-size: 0.9em;
        bottom: -10px;
        right: -10px;
        line-height: 20px;
    }
    
    .place-value {
        width: 50px;
        font-size: 1em;
    }
    
    .controls {
        flex-direction: column;
        align-items: center;
    }
    
    .btn {
        width: 200px;
    }
}

/* 动画效果 */
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.digit-input:focus, .result-input:focus {
    animation: pulse 0.3s ease-in-out;
}

/* 高亮正确和错误的输入框 */
.correct {
    border-color: #4caf50 !important;
    background: #e8f5e8 !important;
}

.incorrect {
    border-color: #f44336 !important;
    background: #ffebee !important;
}

/* 进位输入框的高亮样式 */
.carry-input.correct {
    border-color: #4caf50 !important;
    background: #e8f5e8 !important;
    color: #2e7d32 !important;
}

.carry-input.incorrect {
    border-color: #f44336 !important;
    background: #ffebee !important;
    color: #c62828 !important;
}

/* 应用题相关样式 */
.mode-selector {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
}

.mode-btn {
    padding: 12px 24px;
    font-size: 16px;
    font-weight: bold;
    border: 2px solid #667eea;
    border-radius: 8px;
    background: white;
    color: #667eea;
    cursor: pointer;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: #667eea;
    color: white;
}

.mode-btn:hover {
    background: #5a6fd8;
    color: white;
    transform: translateY(-2px);
}

.practice-container {
    width: 100%;
}

.word-problem-display {
    background: #f8f9ff;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    border: 2px solid #e3e8ff;
}

.problem-number {
    font-size: 18px;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 20px;
    text-align: center;
}

.problem-section, .calculation-section, .answer-section, .upload-section {
    margin-bottom: 25px;
}

.section-label {
    font-size: 16px;
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
    display: block;
}

.problem-text {
    font-size: 18px;
    line-height: 1.6;
    color: #333;
    text-align: left;
    padding: 20px;
    background: white;
    border-radius: 10px;
    border: 1px solid #e3e8ff;
}

.calculation-input-container {
    width: 100%;
}

.calculation-input {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    border: 2px solid #e3e8ff;
    border-radius: 8px;
    text-align: left;
    transition: border-color 0.3s ease;
}

.calculation-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.answer-section {
    display: block;
    margin-bottom: 25px;
}

.answer-input-container {
    width: 100%;
}

.answer-input {
    width: 100%;
    padding: 15px;
    font-size: 18px;
    border: 2px solid #ffd700;
    border-radius: 8px;
    text-align: center;
    background-color: #fffbf0;
    transition: border-color 0.3s ease;
}

.answer-input:focus {
    outline: none;
    border-color: #ffc107;
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.1);
}

.answer-input.correct {
    border-color: #28a745;
    background-color: #d4edda;
}

.answer-input.incorrect {
    border-color: #dc3545;
    background-color: #f8d7da;
}

.upload-container {
    width: 100%;
}

.upload-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: bold;
    background: #6f42c1;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-bottom: 15px;
    transition: background-color 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.upload-btn:hover {
    background: #5a32a3;
    color: white;
    text-decoration: none;
}

.calculation-process-area {
    width: 100%;
}

.calculation-process-input {
    width: 100%;
    min-height: 120px;
    padding: 15px;
    font-size: 14px;
    border: 2px dashed #6f42c1;
    border-radius: 8px;
    background: white;
    resize: vertical;
    font-family: 'Microsoft YaHei', Arial, sans-serif;
    line-height: 1.5;
}

.calculation-process-input:focus {
    outline: none;
    border-color: #5a32a3;
    box-shadow: 0 0 0 3px rgba(111, 66, 193, 0.1);
}

/* 应用题按钮样式 */
.calculate-btn {
    background: #28a745;
    color: white;
}

.calculate-btn:hover {
    background: #218838;
}

.check-btn {
    background: #007bff;
    color: white;
}

.check-btn:hover {
    background: #0056b3;
}

.reset-btn {
    background: #dc3545;
    color: white;
}

.reset-btn:hover {
    background: #c82333;
}

.random-btn {
    background: #6f42c1;
    color: white;
}

.random-btn:hover {
    background: #5a32a3;
}

.podcast-btn {
    background: #ff6b35;
    color: white;
    text-decoration: none;
    display: inline-block;
}

.podcast-btn:hover {
    background: #e55a2b;
    color: white;
    text-decoration: none;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .mode-selector {
        flex-direction: column;
        gap: 10px;
    }
    
    .mode-btn {
        width: 100%;
    }
    
    .problem-text {
        font-size: 16px;
        padding: 15px;
    }
    
    .calculation-input, .answer-input {
        font-size: 16px;
        padding: 12px;
    }
    
    .calculation-process-input {
        min-height: 100px;
        font-size: 14px;
    }
}