/* 全局重置 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    color: #333;
    min-height: 100vh;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
}

/* 禁止选中文本（移动端优化） */
button, .level-card, .option-btn {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* 应用容器 */
.app-container {
    min-height: 100vh;
    position: relative;
    width: 100%;
}

/* 首页背景 - 图片背景 */
.home-page {
    position: relative;
    min-height: 100vh;
    padding: 60px 20px 80px;
    background: var(--bg-image);
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    background-repeat: no-repeat;
}

.home-header {
    text-align: center;
    padding-top: 40px;
    width: 100%;
}

.home-title {
    font-size: 36px;
    font-weight: 800;
    color: #fff;
    margin-bottom: 16px;
    background: rgba(0, 0, 0, 0.4);
    padding: 12px 32px;
    border-radius: 12px;
    display: block;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    margin-left: auto;
    margin-right: auto;
    width: fit-content;
}

/* 首页统计区域 */
.study-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 30px;
    background: rgba(0, 0, 0, 0.4);
    padding: 10px 20px;
    border-radius: 10px;
    margin-left: auto;
    margin-right: auto;
    width: fit-content;
}

.stats-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 65px;
}

.stats-num {
    font-size: 22px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
}

.stats-label {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.8);
    margin-top: 2px;
}

.stats-divider {
    color: rgba(255, 255, 255, 0.4);
    font-size: 18px;
}

.home-subtitle {
    font-size: 16px;
    color: #fff;
    background: rgba(0, 0, 0, 0.4);
    padding: 8px 16px;
    border-radius: 8px;
    display: block;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    margin: 20px auto 0;
    width: fit-content;
}

/* 等级卡片容器 */
.level-cards {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    max-width: 700px;
    margin: 0 auto;
    width: 100%;
}

/* 首页底部 */
.home-footer {
    position: absolute;
    bottom: 30px;
    left: 0;
    right: 0;
    text-align: center;
    width: 100%;
}

/* 等级卡片容器 */
.level-cards {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 16px;
    max-width: 700px;
    margin: 0 auto;
}

/* 等级卡片 */
.level-card {
    background: rgba(255, 255, 255, 0.7);
    border-radius: 16px;
    padding: 24px 20px;
    width: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.level-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25);
    background: rgba(255, 255, 255, 0.8);
}

/* 移动端点击反馈 */
.level-card:active {
    transform: scale(0.95);
    background: rgba(255, 255, 255, 0.9);
}

.card-icon {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #fff5f0 0%, #ffe4d6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
}

.card-label {
    font-size: 12px;
    color: #999;
    letter-spacing: 1px;
}

.card-level {
    font-size: 24px;
    font-weight: 700;
    color: #ff7f50;
}

.card-desc {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

/* 首页操作按钮 */
.home-actions {
    display: flex;
    justify-content: center;
    margin-top: 40px;
}

.home-wrong-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    background: rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    color: #fff;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    margin: 0 auto;
}

.home-wrong-btn:hover {
    background: rgba(255, 255, 255, 0.95);
    transform: translateY(-2px);
}

.wrong-badge {
    background: #ff7f50;
    color: #fff;
    font-size: 12px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.wrong-badge:empty,
.wrong-badge[data-count="0"] {
    display: none;
}

/* 学习页面 */
.study-page {
    min-height: 100vh;
    background: linear-gradient(180deg, #f0f4f8 0%, #e2e8f0 100%);
}

/* 顶部导航 */
.header {
    background: rgba(255, 255, 255, 0.95);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.back-btn {
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: #333;
    border-radius: 8px;
    transition: background 0.2s;
}

.back-btn:hover {
    background: #f0f0f0;
}

.back-btn:active {
    transform: scale(0.95);
}

.current-level-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mode-switch {
    display: flex;
    background: #f0f0f0;
    border-radius: 20px;
    padding: 4px;
}

.mode-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 16px;
    font-size: 14px;
    cursor: pointer;
    background: transparent;
    color: #666;
    transition: all 0.3s ease;
}

.mode-btn.active {
    background: #ff7f50;
    color: #fff;
    font-weight: 500;
}

.mode-btn:hover:not(.active) {
    color: #333;
}

.mode-btn:active:not(.active) {
    transform: scale(0.95);
}

/* 主内容区 */
.main-content {
    flex: 1;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 600px;
    margin: 0 auto;
}

/* 单词卡片 */
.word-card {
    background: rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    padding: 32px 24px;
    text-align: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    backdrop-filter: blur(10px);
}

.word-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.mastery-stars {
    font-size: 16px;
    letter-spacing: 2px;
}

.star {
    color: #ff7f50;
}

.star.empty {
    opacity: 0.3;
}

.audio-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #fff5f0 0%, #ffe4d6 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.audio-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(255, 127, 80, 0.3);
}

.audio-btn.playing {
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.audio-icon {
    font-size: 20px;
}

.word-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-bottom: 12px;
}

.japanese-word {
    font-size: 42px;
    font-weight: 700;
    color: #1a1a2e;
    letter-spacing: 2px;
}

.reading-text {
    font-size: 20px;
    color: #666;
    margin-bottom: 16px;
    font-family: 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
}

.meaning-text {
    font-size: 24px;
    font-weight: 600;
    color: #ff7f50;
    padding: 12px;
    background: linear-gradient(135deg, #fff5f0 0%, #ffe4d6 100%);
    border-radius: 8px;
}

/* 选择题区域 */
.quiz-area {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border: 2px solid #e5e5e5;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.option-btn:hover {
    border-color: #ff7f50;
    background: #fff;
    transform: translateX(4px);
}

.option-btn:active {
    transform: scale(0.98);
}

.option-btn.correct {
    border-color: #4CAF50;
    background: #E8F5E9;
}

.option-btn.wrong {
    border-color: #F44336;
    background: #FFEBEE;
}

.option-btn.disabled {
    pointer-events: none;
    opacity: 0.7;
}

.option-label {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.option-btn.correct .option-label {
    background: #4CAF50;
    color: #fff;
}

.option-btn.wrong .option-label {
    background: #F44336;
    color: #fff;
}

.option-text {
    font-size: 16px;
    color: #333;
}

/* 反馈区域 */
.feedback-area {
    padding: 16px;
    border-radius: 12px;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

.feedback-area.correct {
    background: #E8F5E9;
    border: 1px solid #4CAF50;
}

.feedback-area.wrong {
    background: #FFEBEE;
    border: 1px solid #F44336;
}

.feedback-text {
    font-size: 16px;
    font-weight: 500;
}

.feedback-area.correct .feedback-text {
    color: #2E7D32;
}

.feedback-area.wrong .feedback-text {
    color: #C62828;
}

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

/* 背诵模式区域 */
.memorize-area {
    padding: 20px;
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.08);
}

.memorize-hint {
    color: #666;
    font-size: 14px;
}

/* 导航区域 */
.navigation-area {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.nav-btn {
    flex: 1;
    padding: 14px 20px;
    border: none;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
}

.nav-btn:hover:not(:disabled) {
    background: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.nav-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.nav-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.nav-btn.primary {
    background: linear-gradient(135deg, #ff7f50 0%, #ff6347 100%);
    color: #fff;
}

.nav-btn.primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #ff6347 0%, #ff4500 100%);
}

/* 进度区域 */
.progress-area {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    color: #666;
}

.progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #ff7f50, #ff6347);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* 隐藏类 */
.hidden {
    display: none !important;
}

/* 弹窗样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

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

.modal-header h2 {
    font-size: 20px;
    color: #333;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    line-height: 1;
}

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

.modal-body {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* 按钮样式 */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #ff7f50 0%, #ff6347 100%);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(255, 127, 80, 0.4);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: #f0f0f0;
    color: #333;
}

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

.btn-secondary:active {
    transform: scale(0.98);
}

/* 错题集样式 */
.wrong-book-stats {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f5f7fa;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}

.wrong-book-stats strong {
    color: #ff7f50;
    font-size: 18px;
}

.wrong-word-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.wrong-word-item {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    padding: 16px;
    background: #f9f9f9;
    border-radius: 8px;
    border-left: 4px solid #ff7f50;
    gap: 8px;
}

.wrong-word-info {
    flex: 1;
}

.wrong-word-jp {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.wrong-word-meaning {
    font-size: 14px;
    color: #666;
    margin-top: 4px;
}

.wrong-word-errors {
    font-size: 12px;
    color: #ff7f50;
    display: flex;
    align-items: center;
}

.wrong-word-stars {
    font-size: 12px;
    margin-left: 8px;
    display: flex;
    align-items: center;
}

/* 错题消除进度条 */
.wrong-word-progress {
    display: flex;
    align-items: center;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #eee;
}

.progress-bar-container {
    flex: 1;
    height: 6px;
    background: #e0e0e0;
    border-radius: 3px;
    overflow: hidden;
    margin-right: 8px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #4caf50, #8bc34a);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.progress-text {
    font-size: 11px;
    color: #4caf50;
    white-space: nowrap;
}

.empty-wrong-list {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.empty-wrong-list .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

/* 错题小测样式 */
.review-progress {
    text-align: center;
    padding: 12px;
    background: #f5f7fa;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
}

.review-progress strong {
    color: #ff7f50;
    font-size: 18px;
}

.review-question {
    text-align: center;
    margin-bottom: 20px;
}

.review-word {
    font-size: 28px;
    font-weight: 700;
    color: #333;
    margin-bottom: 8px;
}

.review-reading {
    font-size: 16px;
    color: #666;
}

/* 完成弹窗 */
.complete-body {
    text-align: center;
    padding: 40px 20px;
}

.complete-icon {
    font-size: 64px;
    margin-bottom: 20px;
}

.complete-body p {
    font-size: 18px;
    color: #333;
    margin-bottom: 8px;
}

.complete-stats {
    font-size: 14px;
    color: #666;
    margin-top: 16px;
}

/* 奖励弹窗 */
.reward-body {
    text-align: center;
    padding: 40px 20px;
}

.reward-icon {
    font-size: 64px;
    margin-bottom: 20px;
    animation: bounce 0.6s ease infinite alternate;
}

@keyframes bounce {
    from { transform: translateY(0); }
    to { transform: translateY(-10px); }
}

.reward-message {
    font-size: 20px;
    font-weight: 600;
    color: #ff7f50;
    margin-bottom: 12px;
}

.reward-encourage {
    font-size: 18px;
    color: #333;
    margin-bottom: 16px;
}

.reward-progress {
    font-size: 14px;
    color: #666;
    margin-top: 8px;
}

/* 响应式 - 手机端适配 */
@media (max-width: 480px) {
    /* 首页响应式 */
    .home-header {
        padding-top: 30px;
    }

    .home-title {
        font-size: 24px;
        padding: 10px 20px;
    }

    .study-stats {
        padding: 8px 16px;
        gap: 10px;
    }

    .stats-num {
        font-size: 18px;
    }

    .stats-label {
        font-size: 10px;
    }

    .stats-item {
        min-width: 50px;
    }

    .stats-divider {
        font-size: 14px;
    }

    .home-subtitle {
        font-size: 14px;
        padding: 6px 12px;
    }

    /* 等级卡片响应式 */
    .level-cards {
        gap: 10px;
    }

    .level-card {
        width: 90px;
        padding: 15px 10px;
        min-height: 120px;
    }

    .card-icon {
        width: 40px;
        height: 40px;
        margin-bottom: 8px;
    }

    .card-icon svg {
        width: 20px;
        height: 20px;
    }

    .card-level {
        font-size: 18px;
    }

    .card-desc {
        font-size: 10px;
    }

    .card-label {
        font-size: 10px;
    }

    /* 首页底部 */
    .home-footer {
        bottom: 20px;
    }

    .home-wrong-btn {
        padding: 10px 20px;
        font-size: 13px;
    }

    /* 学习页面响应式 */
    .header {
        padding: 12px 16px;
    }

    .current-level-title {
        font-size: 16px;
    }

    .mode-btn {
        padding: 6px 12px;
        font-size: 12px;
    }

    .word-card {
        padding: 20px 16px;
        margin: 16px;
    }

    .japanese-word {
        font-size: 28px;
    }

    .reading-text {
        font-size: 16px;
    }

    .meaning-text {
        font-size: 18px;
        padding: 12px;
    }

    .mastery-stars {
        font-size: 18px;
    }

    /* 选择题响应式 */
    .options-container {
        padding: 0 16px;
        gap: 10px;
    }

    .option-btn {
        padding: 12px 14px;
        flex-direction: column;
        gap: 6px;
    }

    .option-label {
        width: 24px;
        height: 24px;
        font-size: 12px;
    }

    .option-text {
        font-size: 14px;
        text-align: center;
    }

    /* 导航按钮 */
    .navigation-area {
        padding: 16px;
        gap: 12px;
    }

    .nav-btn {
        padding: 10px 14px;
        font-size: 13px;
    }

    .nav-btn svg {
        width: 16px;
        height: 16px;
    }

    /* 进度显示 */
    .progress-area {
        padding: 0 16px 16px;
    }

    .progress-info {
        font-size: 12px;
    }

    /* 弹窗响应式 */
    .modal-content {
        margin: 16px;
        max-height: 90vh;
        padding: 0;
    }

    .modal-header {
        padding: 16px;
    }

    .modal-header h2 {
        font-size: 18px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        flex-direction: column;
        padding: 16px;
        gap: 10px;
    }

    .btn {
        width: 100%;
        padding: 12px 16px;
        font-size: 14px;
    }

    /* 背诵模式 */
    .memorize-area {
        padding: 20px;
    }

    .memorize-hint p {
        font-size: 16px;
    }

    /* 音频按钮 */
    .audio-btn {
        width: 40px;
        height: 40px;
    }

    .audio-icon {
        font-size: 18px;
    }

    /* 反馈区域 */
    .feedback-area {
        padding: 12px;
        margin: 0 16px;
    }

    .feedback-text {
        font-size: 14px;
    }

    /* 错题列表 */
    .wrong-word-item {
        padding: 12px;
    }

    .wrong-word-jp {
        font-size: 16px;
    }

    .wrong-word-meaning {
        font-size: 13px;
    }

    /* 奖励弹窗 */
    .reward-body {
        padding: 20px 16px;
    }

    .reward-icon {
        font-size: 48px;
    }

    .reward-message {
        font-size: 16px;
    }

    .reward-encourage {
        font-size: 14px;
    }
}

/* 更小屏幕 */
@media (max-width: 360px) {
    .level-card {
        width: 80px;
        padding: 12px 8px;
        min-height: 100px;
    }

    .card-level {
        font-size: 16px;
    }

    .stats-item {
        min-width: 45px;
    }

    .stats-num {
        font-size: 16px;
    }

    .japanese-word {
        font-size: 24px;
    }
}

/* 横屏手机 */
@media (max-height: 500px) and (orientation: landscape) {
    .home-header {
        padding-top: 10px;
        margin-bottom: 10px;
    }

    .home-title {
        font-size: 20px;
        margin-bottom: 8px;
    }

    .study-stats {
        margin-bottom: 10px;
        padding: 6px 12px;
    }

    .level-card {
        padding: 10px 8px;
        min-height: auto;
    }

    .word-card {
        padding: 12px;
        margin: 10px;
    }

    .japanese-word {
        font-size: 22px;
    }

    .options-container {
        gap: 8px;
    }

    .option-btn {
        padding: 10px 12px;
    }
}
