/* 全局样式重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* 容器样式 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: white;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* 标题样式 */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
    border-bottom: 2px solid #e0e0e0;
}

.header h1 {
    font-size: 2.5rem;
    color: #2c3e50;
    margin-bottom: 10px;
    animation: fadeInDown 0.8s ease-out;
}

.subtitle {
    font-size: 1.2rem;
    color: #7f8c8d;
    animation: fadeInUp 0.8s ease-out;
}

/* 进度显示样式 */
.progress {
    text-align: center;
    margin-bottom: 30px;
    padding: 15px;
    background-color: #ecf0f1;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    color: #34495e;
    animation: fadeIn 1s ease-out;
}

.progress-text {
    display: inline-block;
}

/* 题目容器样式 */
.questions-container {
    flex: 1;
    margin-bottom: 30px;
}

.question {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 20px;
    margin-bottom: 15px;
    background-color: #fafafa;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    transition: all 0.3s ease;
    animation: slideIn 0.5s ease-out;
}

.question:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.question.correct {
    border-color: #27ae60;
    background-color: #e8f5e8;
    animation: correctAnswer 0.5s ease-in-out;
}

.question.incorrect {
    border-color: #e74c3c;
    background-color: #ffebee;
    animation: incorrectAnswer 0.5s ease-in-out;
}

.question-number {
    font-weight: bold;
    color: #3498db;
    min-width: auto;
    width: 25px;
    text-align: right;
    flex-shrink: 0;
}

.question-text {
    font-size: 1.5rem;
    font-weight: bold;
    white-space: nowrap;
    flex-shrink: 0;
    text-align: center;
}

.question-input {
    width: 80px;
    height: 50px;
    padding: 10px;
    font-size: 1.5rem;
    text-align: center;
    border: 2px solid #bdc3c7;
    border-radius: 8px;
    transition: all 0.3s ease;
    min-width: 80px;
    touch-action: manipulation;
    /* 隐藏数字输入框的上下箭头 */
    -moz-appearance: textfield;
    appearance: textfield;
}

/* Chrome, Safari, Edge, Opera */
.question-input::-webkit-outer-spin-button,
.question-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.question-input:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
    transform: scale(1.05);
}

.question-input.correct {
    border-color: #27ae60;
    background-color: #e8f5e8;
}

.question-input.incorrect {
    border-color: #e74c3c;
    background-color: #ffebee;
}

/* 按钮容器样式 */
.controls {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

/* 按钮样式 */
.btn {
    padding: 15px 30px;
    font-size: 1.1rem;
    font-weight: bold;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
    height: 50px;
    touch-action: manipulation;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-primary {
    background-color: #3498db;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background-color: #2980b9;
}

.btn-success {
    background-color: #27ae60;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background-color: #219a52;
}

.btn-secondary {
    background-color: #95a5a6;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background-color: #7f8c8d;
}

/* 结果显示样式 */
.results {
    text-align: center;
    padding: 30px;
    background-color: #f8f9fa;
    border-radius: 10px;
    border: 2px solid #e0e0e0;
    animation: fadeInUp 0.8s ease-out;
}

.results h2 {
    color: #2c3e50;
    margin-bottom: 20px;
    font-size: 2rem;
}

.score {
    font-size: 1.8rem;
    margin-bottom: 30px;
    padding: 20px;
    background-color: white;
    border-radius: 8px;
    display: inline-block;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.score-label {
    font-weight: bold;
    color: #34495e;
}

.score-value {
    font-weight: bold;
    color: #e67e22;
    margin: 0 10px;
}

.score-total {
    color: #7f8c8d;
}

.answer-key {
    margin-top: 30px;
    text-align: left;
}

.answer-key h3 {
    color: #34495e;
    margin-bottom: 15px;
    text-align: center;
    font-size: 1.5rem;
}

.answer-item {
    display: flex;
    justify-content: space-between;
    padding: 10px;
    margin-bottom: 8px;
    background-color: white;
    border-radius: 6px;
    border-left: 4px solid #3498db;
    animation: fadeIn 0.5s ease-out;
}

.answer-item:nth-child(even) {
    background-color: #f0f8ff;
}

/* 动画效果 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-30px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

@keyframes incorrectAnswer {
    0% {
        transform: translateX(0);
    }
    25% {
        transform: translateX(-10px);
    }
    50% {
        transform: translateX(10px);
    }
    75% {
        transform: translateX(-10px);
    }
    100% {
        transform: translateX(0);
    }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    .header h1 {
        font-size: 2rem;
    }

    .subtitle {
        font-size: 1rem;
    }

    .progress {
        font-size: 1rem;
        padding: 12px;
    }

    .question {
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 10px;
    }

    .question-number {
        margin-right: 0;
        margin-bottom: 0;
    }

    .question-text {
        font-size: 1.3rem;
        margin-bottom: 0;
        min-width: auto;
        flex: none;
    }

    .question-input {
        width: 70px;
        height: 45px;
        font-size: 1.3rem;
        margin: 0;
    }

    .controls {
        flex-direction: column;
        align-items: center;
    }

    .btn {
        width: 100%;
        max-width: 300px;
    }

    .score {
        font-size: 1.5rem;
    }

    .answer-key {
        overflow-x: auto;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.8rem;
    }

    .question-text {
        font-size: 1.2rem;
    }

    .question-input {
        font-size: 1.3rem;
        height: 45px;
    }

    .btn {
        padding: 12px 24px;
        font-size: 1rem;
    }

    .score {
        font-size: 1.3rem;
    }
}

/* 打印样式 */
@media print {
    .controls {
        display: none;
    }

    .question-input {
        border: none;
        background-color: transparent;
    }

    .container {
        box-shadow: none;
    }
}