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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 60px 20px 20px 20px;
}

header {
    text-align: center;
    margin-top: 40px;
    margin-bottom: 80px;
    color: white;
}

/* 当显示背单词界面时，调整标题位置 */
body:has(#study-screen.active) header {
    margin-bottom: 60px;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.screen {
    display: none;
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
    min-height: 500px;
    max-height: 500px;
    overflow: hidden;
    margin: 0 auto;
    max-width: 800px;
}

/* 背单词界面居中对齐 */
#study-screen {
    max-width: 800px;
    margin: 0 auto;
}

.screen.active {
    display: block;
}

/* 课程选择界面 */
#lesson-selection h2 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 2rem;
}

/* 上下册切换标签 */
.book-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    background: #f0f0f0;
    border-radius: 25px;
    padding: 4px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.book-tab {
    flex: 1;
    padding: 12px 20px;
    border: none;
    background: transparent;
    border-radius: 20px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.book-tab.active {
    background: #667eea;
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.book-tab:hover:not(.active) {
    color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

/* 课程内容区域 */
.book-content {
    margin-bottom: 30px;
}

.book-section {
    display: none;
}

.book-section.active {
    display: block;
}

.lessons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 15px;
    max-width: 600px;
    margin: 0 auto;
}

/* 操作按钮区域 */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.lesson-btn {
    padding: 15px 10px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: 500;
}

.lesson-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
    transform: translateY(-2px);
}

.lesson-btn.selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.select-all-btn {
    padding: 15px 10px;
    border: 1px solid #e0e0e0;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    font-weight: 500;
    color: #333;
}

.select-all-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
    transform: translateY(-2px);
}

.select-all-btn.all-selected {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.primary-btn {
    display: block;
    margin: 0 auto;
    padding: 15px 40px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.primary-btn:hover:not(:disabled) {
    background: #5a6fd8;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.primary-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* 背单词界面 */
.study-header {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 30px;
}

.back-button-container {
    margin-top: 20px;
    text-align: center;
    display: none;
}

/* 只在背单词界面显示返回按钮 */
body:has(#study-screen.active) .back-button-container {
    display: block;
}

.back-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-size: 1rem;
    transition: all 0.3s ease;
    font-weight: 500;
    color: white;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.progress {
    font-size: 1.2rem;
    font-weight: 600;
    color: #667eea;
}

.word-card {
    text-align: center;
    margin-bottom: 20px;
    min-height: 300px;
    max-height: 300px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #f8f9ff;
    border-radius: 15px;
    padding: 30px 20px;
    overflow: hidden;
}

.chinese-meaning {
    font-size: 2rem;
    color: #333;
    margin-bottom: 20px;
    line-height: 1.4;
}

.japanese-word {
    font-size: 3rem;
    color: #667eea;
    font-weight: bold;
    margin-bottom: 15px;
    line-height: 1.2;
    word-break: break-all;
    overflow-wrap: break-word;
}

/* 长单词字体缩小 */
.japanese-word.long-word {
    font-size: 2.2rem;
}

.japanese-word.very-long-word {
    font-size: 1.8rem;
}

.pronunciation {
    font-size: 1.5rem;
    color: #888;
    font-style: italic;
}

.controls {
    text-align: center;
}

.secondary-btn {
    padding: 12px 30px;
    background: #f5f5f5;
    color: #333;
    border: none;
    border-radius: 20px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 15px;
}

.secondary-btn:hover {
    background: #e0e0e0;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }
    
    .screen {
        padding: 20px;
        border-radius: 15px;
        min-height: auto;
        max-height: none;
    }
    
    #study-screen {
        max-width: 100%;
    }
    
    header {
        margin-bottom: 40px;
    }
    
    body:has(#study-screen.active) header {
        margin-bottom: 40px;
    }
    
    header h1 {
        font-size: 1.8rem;
        margin-bottom: 0;
    }
    
    #lesson-selection h2 {
        font-size: 1.4rem;
        margin-bottom: 20px;
    }
    
    .book-tabs {
        max-width: 280px;
        margin-bottom: 20px;
        padding: 3px;
    }
    
    .book-tab {
        padding: 10px 15px;
        font-size: 0.9rem;
    }
    
    .lessons {
        grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
        gap: 8px;
        max-width: 100%;
    }
    
    .lesson-btn {
        padding: 10px 6px;
        font-size: 0.75rem;
        border-radius: 8px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .action-buttons {
        flex-direction: column;
        align-items: center;
        gap: 12px;
        margin-top: 20px;
    }
    
    .primary-btn, .secondary-btn {
        width: 100%;
        max-width: 200px;
        padding: 12px 20px;
        font-size: 1rem;
        margin: 0;
    }
    
    .chinese-meaning {
        font-size: 1.2rem;
        line-height: 1.4;
        word-break: break-word;
        hyphens: auto;
    }
    
    .japanese-word {
        font-size: 1.8rem;
        line-height: 1.2;
        word-break: break-word;
    }
    
    .pronunciation {
        font-size: 1rem;
        line-height: 1.3;
    }
    
    .study-header {
        justify-content: center;
        margin-bottom: 20px;
    }
    
    .back-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .progress {
        font-size: 1rem;
    }
    
    .word-card {
        padding: 20px 15px;
        min-height: 200px;
        max-height: 200px;
        margin-bottom: 15px;
    }
    
    .back-button-container {
        margin-top: 15px;
    }
    
    .controls {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 12px;
    }
    
    .controls .primary-btn,
    .controls .secondary-btn {
        width: 100%;
        max-width: 180px;
    }
}

/* 编辑按钮样式 - 采用下一个按钮的样式 */
.edit-btn {
    padding: 15px 40px;
    background: #f5f5f5;
    color: #333;
    border: none;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-left: 15px;
}

.edit-btn:hover {
    background: #e0e0e0;
}

/* 弹窗样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e0e0e0;
}

.modal-header h3 {
    margin: 0;
    color: #333;
    font-size: 1.3rem;
}

.close-btn {
    font-size: 28px;
    color: #999;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 25px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #333;
    font-weight: 500;
    font-size: 0.95rem;
}

.form-input {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

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

.modal-footer {
    display: flex;
    justify-content: center;
    gap: 30px;
    padding: 20px 25px;
    border-top: 1px solid #e0e0e0;
}

.modal-footer .primary-btn,
.modal-footer .secondary-btn {
    padding: 10px 25px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 0;
    flex-shrink: 0;
}

.modal-footer .secondary-btn {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.modal-footer .secondary-btn:hover {
    background: #e9ecef;
    color: #495057;
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    .container {
        padding: 8px;
    }
    
    .screen {
        padding: 15px;
    }
    
    header {
        margin-bottom: 30px;
    }
    
    body:has(#study-screen.active) header {
        margin-bottom: 30px;
    }
    
    header h1 {
        font-size: 1.4rem;
    }
    
    .lessons {
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
        gap: 6px;
    }
    
    .lesson-btn {
        padding: 8px 4px;
        font-size: 0.8rem;
        min-height: 40px;
        color: #333;
    }
    
    .select-all-btn {
        font-size: 0.8rem;
        min-height: 40px;
        padding: 8px 4px;
    }
    
    .select-all-btn:hover {
        transform: none;
    }
    
    .book-tab {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    
    .chinese-meaning {
        font-size: 1rem;
        line-height: 1.3;
    }
    
    .japanese-word {
        font-size: 1.5rem;
        line-height: 1.1;
    }
    
    .pronunciation {
        font-size: 0.9rem;
    }
    
    .word-card {
        padding: 15px 10px;
        min-height: 180px;
        max-height: 180px;
    }
    
    .back-button-container {
        margin-top: 10px;
    }
    
    .edit-btn {
        width: 100%;
        max-width: 180px;
        padding: 12px 20px;
        font-size: 1rem;
        margin: 0;
        white-space: nowrap;
        border-radius: 25px;
        font-weight: 500;
    }
    
    .edit-btn:hover {
        background: #e0e0e0;
        transform: none;
    }
    
    .controls {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 12px;
        margin-top: 20px;
    }
    
    .controls .primary-btn,
    .controls .secondary-btn,
    .controls .edit-btn {
        width: 100%;
        max-width: 180px;
        padding: 12px 20px;
        font-size: 1rem;
        margin: 0;
        white-space: nowrap;
    }
    
    .modal-footer {
        padding: 15px 20px;
        gap: 20px;
    }
    
    .modal-footer .primary-btn,
    .modal-footer .secondary-btn {
        padding: 8px 20px;
        font-size: 0.9rem;
        min-width: 80px;
        max-width: 120px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .modal-body {
        padding: 20px;
    }
}