* {
    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, .minus-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;
}

/* 借位点样式 - 位于数字方块正上方，小圆点 */
.borrow-dot {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #4caf50;
    border: 2px solid #2e7d32;
    z-index: 2;
    cursor: pointer;
    transition: all 0.3s ease;
}

.borrow-dot:hover {
    transform: translateX(-50%) scale(1.2);
}

.borrow-dot.active {
    background: #f44336;
    border-color: #d32f2f;
}

/* 个位数字不需要借位点 */
.digit-box:last-child .borrow-dot {
    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);
}

#podcast-btn {
    background: #ff9800;
    color: white;
}

#podcast-btn:hover {
    background: #f57c00;
    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;
    }
}

/* 模式切换样式 */
.mode-switch {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    gap: 10px;
}

.mode-btn {
    padding: 10px 20px;
    border: 2px solid #4a90e2;
    background: white;
    color: #4a90e2;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: #4a90e2;
    color: white;
}

.mode-btn:hover {
    transform: translateY(-2px);
}

/* 模式内容样式 */
.mode-content {
    display: none;
}

.mode-content.active {
    display: block;
}

/* 应用题容器样式 */
.word-problem-container {
    background: #f8f9ff;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    border: 2px solid #e3e8ff;
}

/* 题目显示样式 */
.problem-display {
    margin-bottom: 25px;
}

.problem-display h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.problem-text {
    background: white;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #e3e8ff;
    font-size: 1.1em;
    line-height: 1.6;
    color: #333;
    min-height: 80px;
}

/* 列式计算区域样式 */
.calculation-area {
    margin-bottom: 25px;
}

.calculation-area h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.calculation-inputs {
    background: white;
    padding: 20px;
    border-radius: 10px;
    border: 2px solid #e3e8ff;
}

.calc-row {
    margin-bottom: 10px;
}

.calc-row:last-child {
    margin-bottom: 0;
}

.calc-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #4a90e2;
    border-radius: 8px;
    font-size: 1.1em;
    font-family: 'Courier New', monospace;
    background: #f8f9ff;
    color: #333;
    transition: all 0.3s ease;
}

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

/* 答案输入样式 */
.answer-area {
    margin-bottom: 25px;
}

.answer-area h3 {
    color: #333;
    margin-bottom: 10px;
    font-size: 1.2em;
}

.answer-input {
    width: 100%;
    padding: 15px;
    border: 3px solid #ffc107;
    border-radius: 10px;
    font-size: 1.3em;
    font-weight: bold;
    text-align: center;
    background: #fff3cd;
    color: #856404;
    transition: all 0.3s ease;
}

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

/* 拍照上传区域样式 */
.upload-area {
    margin-bottom: 25px;
}

.upload-area h3 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.2em;
}

.upload-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.upload-controls .btn {
    flex: 1;
    padding: 12px 20px;
    background: #9c27b0;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.upload-controls .btn:hover {
    background: #7b1fa2;
    transform: translateY(-2px);
    color: white;
    text-decoration: none;
}

.photo-preview {
    background: white;
    border: 2px dashed #ccc;
    border-radius: 10px;
    padding: 20px;
    text-align: center;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
}

.photo-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
}

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

    .mode-switch {
        flex-direction: column;
        align-items: center;
    }
    
    .mode-btn {
        width: 200px;
    }
    
    .upload-controls {
        flex-direction: column;
    }
    
    .upload-controls .btn {
        width: 100%;
    }
    
    .problem-text {
        font-size: 1em;
    }
    
    .calc-input {
        font-size: 1em;
    }
    
    .answer-input {
        font-size: 1.2em;
    }
}

/* 动画效果 */
@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;
}

/* 借位点的高亮样式 */
.borrow-dot.correct {
    background: #4caf50 !important;
    border-color: #2e7d32 !important;
}

.borrow-dot.incorrect {
    background: #f44336 !important;
    border-color: #d32f2f !important;
}