* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Microsoft YaHei', Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    padding: 15px;
    padding-bottom: 30px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
    overflow: visible;
    min-height: calc(70vh - 30px);
    display: flex;
    flex-direction: column;
}

header {
    background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
    color: white;
    padding: 20px 15px;
    text-align: center;
    position: relative;
}

h1 {
    font-size: 1.6em;
    margin-bottom: 8px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.subtitle {
    opacity: 0.9;
    font-size: 0.9em;
    line-height: 1.4;
    max-width: 90%;
    margin: 0 auto;
}

.content {
    padding: 20px 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.text-section {
    display: flex;
    flex-direction: column;
    margin-bottom: 20px;
}

.text-display {
    font-size: 1em;
    line-height: 1.7;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    flex: 0 0 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    word-break: break-word;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-height: 350px; /* 添加最大高度 */
    min-height: 200px;
}
/* 自定义滚动条样式 */
.text-display::-webkit-scrollbar {
    width: 8px;
}

.text-display::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.text-display::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.text-display::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.english-word {
    cursor: pointer;
    padding: 4px 8px;
    margin: 0 2px;
    border-radius: 6px;
    background-color: #e8f4fc;
    color: #2980b9;
    border: 2px solid #bde0fe;
    font-weight: 600;
    display: inline-block;
    transition: all 0.25s ease;
    touch-action: manipulation;
    min-height: 32px;
    line-height: 1.4;
    vertical-align: middle;
}

.english-word:active {
    background-color: #d1ecf1;
    transform: translateY(1px);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.chinese-word-plain {
    color: #0066cc;
    padding: 4px 8px;
    margin: 0 2px;
    display: inline-block;
    font-weight: 600;
    background-color: #f0f8ff;
    border-radius: 4px;
    border: 1px dashed #bde0fe;
}

.word-correct {
    animation: pop 0.3s ease;
}

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

.controls {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

button {
    background: #3498db;
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 4px 6px rgba(52, 152, 219, 0.2);
    touch-action: manipulation;
    min-height: 48px;
    width: 100%;
    max-width: 280px;
    display: inline-block;
}

button:active {
    background: #2980b9;
    transform: translateY(1px);
    box-shadow: 0 2px 4px rgba(52, 152, 219, 0.3);
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 15px;
}

.modal-content {
    background: white;
    padding: 20px;
    border-radius: 12px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    animation: modalAppear 0.3s ease;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-title {
    color: #2c3e50;
    margin-bottom: 15px;
    font-size: 1.3em;
    text-align: center;
    font-weight: 700;
}

.question-box {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    text-align: center;
}

.chinese-prompt {
    font-size: 1.3em;
    color: #2c3e50;
    margin-bottom: 8px;
    font-weight: 600;
}

.english-example {
    font-size: 0.85em;
    color: #6c757d;
    margin-top: 5px;
}

.answer-input-container {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin: 15px 0;
    flex-wrap: wrap;
}

.letter-input {
    width: 40px;
    height: 50px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1.2em;
    text-align: center;
    font-weight: bold;
    transition: all 0.2s;
    -webkit-appearance: none;
    appearance: none;
    background-color: white;
}

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

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

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

.space-input {
    background-color: #e9ecef;
    border: 2px dashed #adb5bd;
    cursor: default;
    color: #6c757d;
}

.space-input:focus {
    border-color: #adb5bd;
    box-shadow: none;
}

.letter-feedback {
    margin: 10px 0;
    padding: 8px;
    text-align: center;
    font-size: 0.9em;
    min-height: 20px;
    display: none;
}

.letter-feedback.show {
    display: block;
}

.letter-feedback.error {
    color: #dc3545;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

@media (max-width: 480px) {
    .letter-input {
        width: 35px;
        height: 45px;
        font-size: 1.1em;
    }
}

.modal-buttons {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-direction: column;
}

@media (min-width: 480px) {
    .modal-buttons {
        flex-direction: row;
    }
}

.modal-buttons button {
    flex: 1;
    min-width: 120px;
    padding: 12px;
    font-size: 0.95em;
}

.check-btn {
    background: #28a745;
}

.check-btn:active {
    background: #218838;
}

.cancel-btn {
    background: #6c757d;
}

.cancel-btn:active {
    background: #5a6268;
}

.result-message {
    padding: 12px;
    border-radius: 8px;
    margin: 15px 0;
    text-align: center;
    display: none;
    font-size: 0.95em;
}

.result-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.result-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.completion-message {
    text-align: center;
    padding: 20px;
    color: #28a745;
    font-size: 1.1em;
    font-weight: bold;
    display: none;
    margin-top: 20px;
}

.difficulty-indicator {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: bold;
    margin-top: 8px;
}

.difficulty-easy {
    background: #d4edda;
    color: #155724;
}

.difficulty-medium {
    background: #fff3cd;
    color: #856404;
}

.difficulty-hard {
    background: #f8d7da;
    color: #721c24;
}

.progress-indicator {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 10px 15px;
    background: #f8f9fa;
    border-radius: 8px;
    font-size: 0.9em;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    margin: 0 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #3498db;
    border-radius: 4px;
    width: 0%;
    transition: width 0.3s ease;
}

.keyboard-hint {
    text-align: center;
    font-size: 0.8em;
    color: #6c757d;
    margin-top: 5px;
    display: none;
}

.touch-hint {
    text-align: center;
    font-size: 0.8em;
    color: #6c757d;
    margin-top: 5px;
    display: block;
}

/* 移动端优化 */
@media (max-width: 480px) {
    body {
        padding: 10px;
        padding-bottom: 20px;
    }
    
    .container {
        border-radius: 10px;
    }
    
    header {
        padding: 18px 12px;
    }
    
    h1 {
        font-size: 1.4em;
    }
    
    .subtitle {
        font-size: 0.85em;
    }
    
    .content {
        padding: 15px 12px;
    }
    
    .text-display {
        padding: 12px;
        font-size: 0.95em;
        line-height: 1.6;
    }
    
    .english-word, .chinese-word-plain {
        padding: 3px 6px;
        margin: 0 1px;
        font-size: 0.95em;
    }
    
    button {
        padding: 12px 24px;
        font-size: 0.95em;
        min-height: 44px;
    }
    
    .modal-content {
        padding: 18px;
    }
    
    .modal-title {
        font-size: 1.2em;
    }
    
    .chinese-prompt {
        font-size: 1.2em;
    }
    
    .answer-input {
        padding: 12px;
        font-size: 1em;
    }
}

@media (min-width: 768px) {
    .keyboard-hint {
        display: block;
    }
    
    .touch-hint {
        display: none;
    }
}

/* 防止iOS输入框放大 */
@media screen and (max-width: 767px) {
    input, textarea, select {
        font-size: 16px !important;
    }
}