* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent; /* 禁用移动端点击高亮 */
}

body {
    font-family: 'Arial Rounded MT Bold', 'Arial', sans-serif;
    line-height: 1.6;
    background: linear-gradient(135deg, #6ecbf5 0%, #c2e9fb 100%);
    color: #333;
    min-height: 100vh;
    padding: 20px;
    -webkit-user-select: none; /* 禁用文本选择 */
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation; /* 优化触摸操作 */
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 30px;
    background-color: rgba(255, 255, 255, 0.9);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    border-radius: 20px;
    margin-top: 30px;
    position: relative;
    overflow: hidden;
}

.container::before {
    content: "";
    position: absolute;
    top: -50px;
    right: -50px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, #ffd166 0%, transparent 70%);
    opacity: 0.3;
    border-radius: 50%;
}

.container::after {
    content: "";
    position: absolute;
    bottom: -80px;
    left: -30px;
    width: 250px;
    height: 250px;
    background: radial-gradient(circle, #06d6a0 0%, transparent 70%);
    opacity: 0.3;
    border-radius: 50%;
}

h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #118ab2;
    font-size: 2.8rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
}

h1::after {
    content: "🧮";
    position: absolute;
    right: -60px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2.5rem;
}

h2 {
    color: #118ab2;
    margin-bottom: 20px;
    text-align: center;
    font-size: 2rem;
}

.settings {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    padding: 25px;
    background: linear-gradient(135deg, #ff9a8b 0%, #ff6a88 50%, #ff99ac 100%);
    border-radius: 15px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.setting-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.setting-group label {
    font-weight: bold;
    color: white;
    font-size: 1.2rem;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
}

select, button, input {
    padding: 12px 18px;
    border: 3px solid #118ab2;
    border-radius: 50px;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.3s ease;
    outline: none; /* 移除默认轮廓 */
}

select {
    background-color: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    min-width: 150px;
    appearance: none; /* 移除默认箭头 */
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23118ab2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
}

select:focus {
    border-color: #ffd166;
    box-shadow: 0 0 0 3px rgba(255, 209, 102, 0.3);
}

button {
    background: linear-gradient(135deg, #06d6a0 0%, #118ab2 100%);
    color: white;
    border: none;
    cursor: pointer;
    font-weight: bold;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    min-width: 120px;
    padding: 12px 20px;
    touch-action: manipulation;
}

button:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

button:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

#start-btn {
    background: linear-gradient(135deg, #ffd166 0%, #ffb700 100%);
    color: #333;
    font-size: 1.2rem;
}

#wrong-questions-btn {
    background: linear-gradient(135deg, #ef476f 0%, #d90429 100%);
}

#scores-btn {
    background: linear-gradient(135deg, #118ab2 0%, #073b4c 100%);
}

.hidden {
    display: none;
}

.question-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    font-size: 3.5rem;
    margin: 40px 0;
    padding: 30px;
    background: linear-gradient(135deg, #90e0ef 0%, #48cae4 100%);
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    animation: pulse 2s infinite;
    flex-wrap: wrap;
}

@keyframes pulse {
    0% { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15); }
    50% { box-shadow: 0 8px 25px rgba(0, 0, 0, 0.25); }
    100% { box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15); }
}

#question-content {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.question-number, .question-operator {
    display: inline-block;
    padding: 10px 15px;
    background-color: rgba(255, 255, 255, 0.3);
    border-radius: 10px;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.1);
}

#answer-input {
    width: 120px;
    text-align: center;
    font-size: 3rem;
    border: 4px solid #118ab2;
    border-radius: 15px;
    padding: 10px;
    background-color: white;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1);
}

#answer-input:focus {
    border-color: #ffd166;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.1), 0 0 0 3px rgba(255, 209, 102, 0.3);
}

.progress {
    text-align: right;
    margin-bottom: 15px;
    font-weight: bold;
    font-size: 1.3rem;
    color: #118ab2;
}

.progress::before {
    content: "📊 ";
}

#training-area {
    text-align: center;
}

/* 自定义数值键盘样式 */
.keyboard {
    margin: 20px auto;
    max-width: 400px;
    background: linear-gradient(135deg, #ffafcc 0%, #ffc8dd 100%);
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 15px;
}

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

.key-btn {
    width: 80px;
    height: 80px;
    font-size: 2rem;
    font-weight: bold;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
    color: #333;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    touch-action: manipulation;
}

.key-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.3);
    background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
}

.key-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    background: linear-gradient(135deg, #e0e0e0 0%, #d0d0d0 100%);
}

#clear-btn, #backspace-btn {
    background: linear-gradient(135deg, #a9d6e5 0%, #89c2d9 100%);
    font-size: 1.1rem;
}

#submit-btn {
    background: linear-gradient(135deg, #06d6a0 0%, #118ab2 100%);
    font-size: 1.3rem;
    padding: 15px 30px;
    margin: 20px 0;
}

#result-feedback {
    margin: 25px auto;
    padding: 25px;
    border-radius: 20px;
    max-width: 600px;
    animation: fadeIn 0.5s ease;
    font-size: 1.4rem;
    font-weight: bold;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

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

#result-feedback.correct {
    background: linear-gradient(135deg, #d4edda 0%, #a2d9a8 100%);
    color: #155724;
    border: 3px solid #28a745;
}

#result-feedback.incorrect {
    background: linear-gradient(135deg, #f8d7da 0%, #f1aeb5 100%);
    color: #721c24;
    border: 3px solid #dc3545;
}

#result-feedback.correct::before {
    content: "✅ 正确！太棒了！";
    display: block;
    font-size: 2rem;
    margin-bottom: 15px;
}

#result-feedback.incorrect::before {
    content: "❌ 不对哦，再试试看！";
    display: block;
    font-size: 2rem;
    margin-bottom: 15px;
}

#score-display, #wrong-questions-display, #scores-display {
    text-align: center;
    padding: 20px;
}

#score-display {
    background: linear-gradient(135deg, #ffd166 0%, #ffb700 100%);
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

#score-display h2::before {
    content: "🏆 ";
}

#correct-count, #score {
    font-weight: bold;
    font-size: 1.5rem;
    color: #073b4c;
}

#restart-btn {
    background: linear-gradient(135deg, #06d6a0 0%, #118ab2 100%);
    font-size: 1.2rem;
    padding: 15px 25px;
    margin: 10px;
}

#back-btn {
    background: linear-gradient(135deg, #9d4edd 0%, #7b2cbf 100%);
    font-size: 1.2rem;
    padding: 15px 25px;
    margin: 10px;
}

#wrong-questions-display, #scores-display {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 20px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
}

#wrong-questions-list, #scores-list {
    margin: 30px 0;
    text-align: left;
    max-height: 400px;
    overflow-y: auto;
    padding: 15px;
    background-color: rgba(240, 248, 255, 0.7);
    border-radius: 15px;
}

.wrong-question-item, .score-item {
    padding: 15px;
    margin-bottom: 15px;
    background: linear-gradient(135deg, #caf0f8 0%, #ade8f4 100%);
    border-radius: 15px;
    border-left: 5px solid #118ab2;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
}

.wrong-question-item {
    background: linear-gradient(135deg, #ffafcc 0%, #ffc8dd 100%);
    border-left: 5px solid #ef476f;
}

.practice-btn {
    background: linear-gradient(135deg, #27ae60 0%, #219653 100%);
    padding: 10px 20px;
    font-size: 1rem;
}

.practice-btn:hover {
    background: linear-gradient(135deg, #219653 0%, #1e7a46 100%);
}

#wrong-questions-back-btn, #scores-back-btn {
    background: linear-gradient(135deg, #9d4edd 0%, #7b2cbf 100%);
    padding: 15px 25px;
    font-size: 1.1rem;
    margin: 20px 0;
}

#next-btn {
    background: linear-gradient(135deg, #ffd166 0%, #ffb700 100%);
    color: #333;
    padding: 15px 25px;
    font-size: 1.2rem;
    margin-top: 15px;
}

/* 平板优化 */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        padding: 25px;
        margin-top: 20px;
    }
    
    .settings {
        gap: 15px;
        padding: 20px;
    }
    
    .setting-group label {
        font-size: 1.1rem;
    }
    
    select, button {
        padding: 12px 16px;
        font-size: 17px;
        min-width: 130px;
    }
    
    .question-display {
        font-size: 3rem;
        padding: 25px;
        gap: 18px;
    }
    
    #answer-input {
        width: 110px;
        font-size: 2.8rem;
    }
    
    .keyboard {
        max-width: 350px;
        padding: 18px;
    }
    
    .keyboard-row {
        gap: 12px;
    }
    
    .key-btn {
        width: 75px;
        height: 75px;
        font-size: 1.8rem;
    }
    
    #clear-btn, #backspace-btn {
        font-size: 1rem;
    }
}

/* 手机优化 */
@media (max-width: 767px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 20px 15px;
        margin-top: 15px;
    }
    
    h1 {
        font-size: 2.2rem;
    }
    
    h1::after {
        right: -40px;
        font-size: 2rem;
    }
    
    .settings {
        flex-direction: column;
        align-items: center;
        padding: 20px;
        gap: 15px;
    }
    
    .setting-group label {
        font-size: 1.1rem;
    }
    
    select, button {
        padding: 12px 16px;
        font-size: 16px;
        min-width: 140px;
    }
    
    .question-display {
        font-size: 2.5rem;
        padding: 20px;
        gap: 15px;
    }
    
    #answer-input {
        width: 100px;
        font-size: 2.5rem;
    }
    
    .keyboard {
        max-width: 300px;
        padding: 15px;
    }
    
    .keyboard-row {
        gap: 10px;
    }
    
    .key-btn {
        width: 65px;
        height: 65px;
        font-size: 1.6rem;
    }
    
    #clear-btn, #backspace-btn {
        font-size: 0.9rem;
    }
    
    #result-feedback {
        font-size: 1.2rem;
        padding: 20px;
    }
    
    #result-feedback.correct::before,
    #result-feedback.incorrect::before {
        font-size: 1.7rem;
    }
}

/* 小屏幕手机优化 */
@media (max-width: 480px) {
    body {
        padding: 5px;
    }
    
    .container {
        padding: 15px 10px;
    }
    
    h1 {
        font-size: 1.8rem;
    }
    
    h1::after {
        display: none;
    }
    
    .question-display {
        font-size: 2rem;
        gap: 10px;
        padding: 15px;
    }
    
    #answer-input {
        width: 80px;
        font-size: 2rem;
    }
    
    .keyboard {
        max-width: 250px;
        padding: 12px;
    }
    
    .keyboard-row {
        gap: 8px;
    }
    
    .key-btn {
        width: 55px;
        height: 55px;
        font-size: 1.4rem;
    }
    
    #clear-btn, #backspace-btn {
        font-size: 0.8rem;
    }
    
    select, button {
        padding: 10px 15px;
        font-size: 15px;
        min-width: 120px;
    }
    
    #submit-btn, #next-btn, .practice-btn, #restart-btn, #back-btn {
        padding: 12px 20px;
        font-size: 1rem;
        min-width: 100px;
    }
}