/* ========================================
   移动端响应式样式 (Mobile Responsive Styles)
   适用于屏幕宽度 ≤ 768px 的设备
   ======================================== */

/* CSS变量定义 */
:root {
    /* 移动端断点 */
    --breakpoint-mobile: 768px;
    --breakpoint-tablet: 1024px;
    
    /* 移动端间距 */
    --spacing-mobile-xs: 0.5rem;
    --spacing-mobile-sm: 1rem;
    --spacing-mobile-md: 1.5rem;
    --spacing-mobile-lg: 2rem;
    
    /* 触摸目标尺寸 */
    --touch-target-min: 44px;
    --touch-target-comfortable: 48px;
    --touch-target-large: 56px;
    
    /* 移动端字体 */
    --font-size-mobile-h1: 1.8rem;
    --font-size-mobile-h2: 1.5rem;
    --font-size-mobile-body: 1rem;
    --font-size-mobile-small: 0.85rem;
}

/* 移动端媒体查询 (max-width: 768px) */
@media (max-width: 768px) {
    /* ========================================
       导航栏适配 (Navigation Bar)
       ======================================== */
    
    .header-main {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }
    
    .logo-area {
        text-align: center;
        margin-bottom: 0;
    }
    
    .logo-area h1 {
        font-size: 1.5rem;
        letter-spacing: -0.5px;
        margin-bottom: 0.25rem;
    }
    
    .subtitle {
        font-size: 0.7rem;
        opacity: 0.7;
        margin-top: 0;
        line-height: 1.2;
    }
    
    .header-actions {
        justify-content: center;
        width: 100%;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .header-actions .glass-btn {
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }
    
    .nav-wrapper {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .tabs-container {
        justify-content: center;
        width: 100%;
        gap: 0.5rem;
    }
    
    .tab-btn {
        padding: 0.6rem 1.2rem;
        font-size: 0.95rem;
    }
    
    .search-wrapper {
        width: 100%;
        margin: 0;
    }
    
    #search-input {
        width: 100%;
        padding: 0.6rem 2.5rem 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    /* ========================================
       单词卡片网格适配 (Word Card Grid)
       ======================================== */
    
    .grid {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }
    
    .card-container {
        height: auto;
        min-height: 350px;
    }
    
    .card-face {
        padding: var(--spacing-mobile-md);
    }
    
    .word-title {
        font-size: 1.6rem;
    }
    
    .meaning {
        font-size: 1.1rem;
        line-height: 1.5;
    }
    
    .example {
        font-size: 0.9rem;
        line-height: 1.6;
    }
    
    .example-cn {
        font-size: 0.8rem;
    }
    
    /* ========================================
       模态弹窗适配 (Modal Dialogs)
       ======================================== */
    
    .modal-content.panel {
        width: 95%;
        max-width: 500px;
        max-height: 85vh;
        padding: 1.25rem;
        overflow-y: auto;
        margin: 1rem;
    }
    
    .modal-content h3 {
        font-size: 1.3rem;
        margin-bottom: 1rem;
    }
    
    .modal-content h4 {
        font-size: 1.1rem;
        margin-top: 1.25rem;
        margin-bottom: 0.75rem;
    }
    
    .modal-content p {
        font-size: 0.9rem;
        line-height: 1.6;
    }
    
    .modal-actions {
        flex-direction: column;
        gap: 0.75rem;
        margin-top: 1.5rem;
    }
    
    .modal-actions button {
        width: 100%;
    }
    
    .modal-close {
        width: var(--touch-target-comfortable);
        height: var(--touch-target-comfortable);
        top: 0.75rem;
        right: 0.75rem;
    }
    
    /* 表单组样式 */
    .form-group {
        margin-bottom: 1rem;
    }
    
    .form-group label {
        display: block;
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
        color: var(--text-main);
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
        font-size: 16px;
        padding: 0.75rem;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 0.5rem;
        color: var(--text-main);
        box-sizing: border-box;
    }
    
    .form-group textarea {
        min-height: 100px;
        resize: vertical;
        line-height: 1.5;
    }
    
    .form-group input:focus,
    .form-group select:focus,
    .form-group textarea:focus {
        outline: none;
        border-color: var(--primary);
        background: rgba(255, 255, 255, 0.08);
    }
    
    /* 设置面板特殊样式 */
    .settings-section {
        margin-bottom: 1.5rem;
    }
    
    .settings-section h4 {
        font-size: 1rem;
        margin-bottom: 0.75rem;
    }
    
    /* 自定义单词管理器样式 */
    .custom-word-modal .modal-content {
        max-height: 90vh;
    }
    
    /* 按钮组样式 */
    .button-group {
        display: flex;
        gap: 0.75rem;
        flex-direction: column;
    }
    
    .button-group button {
        width: 100%;
        min-height: var(--touch-target-comfortable);
    }
    
    /* ========================================
       触摸目标尺寸优化 (Touch Target Optimization)
       ======================================== */
    
    .glass-btn {
        min-height: var(--touch-target-comfortable);
        padding: 0.75rem 1.5rem;
    }
    
    .icon-btn {
        width: var(--touch-target-comfortable);
        height: var(--touch-target-comfortable);
        min-width: var(--touch-target-comfortable);
        min-height: var(--touch-target-comfortable);
    }
    
    .tab-btn {
        min-height: var(--touch-target-comfortable);
        padding: 0.75rem 1.5rem;
    }
    
    .learned-toggle {
        min-height: var(--touch-target-min);
        min-width: var(--touch-target-min);
        padding: 0.5rem 1rem;
    }
    
    .play-btn {
        min-height: var(--touch-target-min);
        padding: 0.75rem 1.25rem;
    }
    
    /* 确保相邻触摸目标间距 */
    .header-actions {
        gap: 0.75rem;
    }
    
    .tabs-container {
        gap: 0.5rem;
    }
    
    /* ========================================
       触摸反馈效果 (Touch Feedback)
       ======================================== */
    
    /* 禁用文本选择 */
    * {
        -webkit-user-select: none;
        user-select: none;
        -webkit-tap-highlight-color: rgba(99, 102, 241, 0.2);
    }
    
    /* 允许输入框选择 */
    input,
    textarea,
    [contenteditable] {
        -webkit-user-select: text;
        user-select: text;
    }
    
    /* 禁用双击缩放 */
    button,
    a,
    .card {
        touch-action: manipulation;
    }
    
    /* ========================================
       表单输入优化 (Form Input Optimization)
       ======================================== */
    
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input[type="url"],
    select,
    textarea {
        font-size: 16px; /* 防止iOS自动缩放 */
        min-height: var(--touch-target-comfortable);
        padding: 0.75rem 1rem;
    }
    
    /* 输入框获得焦点时滚动到视图 */
    input:focus,
    textarea:focus,
    select:focus {
        scroll-margin-top: 100px;
    }
    
    /* ========================================
       影院模式适配 (Cinema Mode)
       ======================================== */
    
    .cinema-container {
        padding: 1rem;
        padding-bottom: 6rem;
        overflow-y: auto;
        max-height: 100vh;
    }
    
    .cinema-card-stage {
        flex-direction: column;
        width: 100%;
        height: auto;
        gap: 1.5rem;
        align-items: center;
    }
    
    .cinema-card-stage .card-container {
        width: 100%;
        max-width: 400px;
        height: auto;
        min-height: 280px;
    }
    
    .cinema-card-stage .card {
        height: 100%;
    }
    
    .cinema-card-stage .card-face {
        padding: 2rem 1.5rem;
    }
    
    .cinema-card-stage .pictogram-container {
        max-height: 180px;
        margin-bottom: 1rem;
    }
    
    .cinema-card-stage .visual-label {
        font-size: 1.5rem;
        margin-top: 1rem;
    }
    
    /* 移动端显示信息面板 */
    .cinema-info-overlay {
        display: flex !important;
        flex-direction: column;
        width: 100%;
        max-width: 400px;
        background: rgba(15, 23, 42, 0.8);
        backdrop-filter: blur(10px);
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 1rem;
        padding: 1.5rem;
        gap: 0.75rem;
    }
    
    .cinema-info-overlay .word-title {
        font-size: 1.8rem;
        color: var(--primary-light);
        margin-bottom: 0.5rem;
    }
    
    .cinema-info-overlay .meaning {
        font-size: 1.1rem;
        color: var(--text-main);
        margin-bottom: 0.5rem;
    }
    
    .cinema-info-overlay .example {
        font-size: 0.95rem;
        color: var(--text-muted);
        font-style: italic;
        line-height: 1.6;
        margin-bottom: 0.25rem;
    }
    
    .cinema-info-overlay .example-cn {
        font-size: 0.9rem;
        color: var(--text-muted);
        opacity: 0.8;
        line-height: 1.5;
        margin-bottom: 1rem;
    }
    
    /* 影院模式音频控制 */
    .cinema-info-overlay .audio-controls {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.5rem;
    }
    
    .cinema-info-overlay .play-btn {
        flex: 1;
        min-height: 40px;
        font-size: 0.85rem;
        padding: 0.5rem 1rem;
        background: rgba(99, 102, 241, 0.2);
        border: 1px solid rgba(99, 102, 241, 0.3);
        border-radius: 0.5rem;
        color: var(--text-main);
        cursor: pointer;
        transition: all 0.2s;
    }
    
    .cinema-info-overlay .play-btn:active {
        transform: scale(0.95);
        background: rgba(99, 102, 241, 0.3);
    }
    
    .cinema-controls {
        position: fixed;
        bottom: 1rem;
        left: 50%;
        transform: translateX(-50%);
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
        background: rgba(15, 23, 42, 0.95);
        backdrop-filter: blur(10px);
        border-radius: 2rem;
        border: 1px solid rgba(255, 255, 255, 0.1);
        display: flex;
        align-items: center;
        z-index: 1000;
    }
    
    .glass-btn.circle {
        width: var(--touch-target-comfortable);
        height: var(--touch-target-comfortable);
        font-size: 1rem;
        padding: 0;
    }
    
    .cinema-controls .glass-btn:not(.circle) {
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
        height: var(--touch-target-comfortable);
    }
    
    .cinema-progress {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 3px;
        background: rgba(255, 255, 255, 0.1);
        z-index: 999;
    }
    
    .cinema-progress .progress-fill {
        height: 100%;
        background: var(--primary);
    }
    
    /* ========================================
       连连看游戏适配 (Connect Game)
       ======================================== */
    
    .connect-stage {
        flex-direction: column;
        height: auto;
        gap: 1rem;
    }
    
    .connect-column {
        width: 100%;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .connect-item {
        flex: 1 1 calc(50% - 0.375rem);
        min-height: var(--touch-target-large);
        font-size: 0.95rem;
    }
    
    #connect-canvas {
        position: relative;
        height: 100px;
        order: 2; /* Canvas放在中间 */
    }
    
    /* ========================================
       挑战模式适配 (Challenge Mode)
       ======================================== */
    
    /* 游戏模态窗口 */
    .modal.game-view {
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* 游戏容器 */
    .game-container {
        padding: 1rem;
        max-width: 100%;
        overflow-y: auto;
        max-height: 100vh;
    }
    
    .game-view .grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
        padding: 0;
        margin-bottom: 2rem;
    }
    
    .game-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
        padding: 0;
        margin-bottom: 1rem;
        position: sticky;
        top: 0;
        background: rgba(2, 6, 23, 0.95);
        backdrop-filter: blur(10px);
        z-index: 10;
        padding: 1rem;
        margin: -1rem -1rem 1rem -1rem;
    }
    
    .game-title-area h2 {
        font-size: 1.3rem;
        margin-bottom: 0.25rem;
    }
    
    .game-title-area p {
        font-size: 0.85rem;
        opacity: 0.8;
    }
    
    .game-stats {
        font-size: 0.9rem;
    }
    
    .game-view .card-container {
        height: auto;
        min-height: 350px;
        max-height: none;
    }
    
    .game-view .card-face {
        padding: 1.5rem;
    }
    
    .game-view .word-title {
        font-size: 1.8rem;
    }
    
    .game-view .meaning {
        font-size: 1rem;
    }
    
    .game-view .example {
        font-size: 0.85rem;
    }
    
    .game-view .example-cn {
        font-size: 0.8rem;
        margin-top: 0.5rem;
    }
    
    .game-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .game-actions button {
        width: 100%;
        min-height: var(--touch-target-comfortable);
    }
    
    /* 评估控制按钮 */
    .assessment-controls {
        display: flex;
        gap: 0.75rem;
        margin-top: 1rem;
        padding: 0 1rem 1rem;
    }
    
    .assessment-controls button {
        flex: 1;
        min-height: var(--touch-target-comfortable);
        font-size: 0.9rem;
        padding: 0.75rem;
    }
    
    /* 音频控制按钮 */
    .audio-controls {
        display: flex;
        gap: 0.5rem;
        margin-top: 1rem;
        flex-wrap: wrap;
    }
    
    .audio-controls .play-btn {
        flex: 1;
        min-width: 120px;
        min-height: 40px;
        font-size: 0.85rem;
    }
    
    /* 标签容器 */
    .tags-container {
        display: flex;
        gap: 0.5rem;
        margin-top: 0.75rem;
        flex-wrap: wrap;
    }
    
    .tag-badge {
        font-size: 0.75rem;
        padding: 0.25rem 0.5rem;
    }
    
    /* 结果覆盖层 */
    .result-overlay {
        padding: 1rem;
    }
    
    .result-box {
        padding: 2rem 1.5rem;
        max-width: 90%;
    }
    
    .result-box h3 {
        font-size: 1.5rem;
    }
    
    .final-score {
        font-size: 2.5rem;
    }
    
    .result-actions {
        flex-direction: column;
        gap: 0.75rem;
        width: 100%;
    }
    
    .result-actions button {
        width: 100%;
    }
    
    /* ========================================
       字体和文本优化 (Typography Optimization)
       ======================================== */
    
    /* 确保基础行高 */
    body {
        line-height: 1.6;
    }
    
    /* ========================================
       页面边距和间距 (Spacing)
       ======================================== */
    
    .container {
        padding: 0.75rem;
        padding-bottom: 0.5rem;
    }
    
    .app-header {
        margin-bottom: 1rem;
        padding-bottom: 0.5rem;
    }
    
    .pagination-container {
        margin-top: 1.25rem;
    }
    
    /* ========================================
       分页导航优化 (Pagination)
       ======================================== */
    
    .pagination-container {
        margin-top: 1.25rem;
        margin-bottom: 0.75rem;
        gap: 0.4rem;
        padding: 0 0.25rem;
    }
    
    .pagination-container button {
        width: 36px;
        height: 36px;
        min-width: 36px;
        min-height: 36px;
        font-size: 0.85rem;
        padding: 0;
    }
    
    #pagination-numbers {
        gap: 0.35rem;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0.2rem 0;
        margin: 0 0.25rem;
    }
    
    #pagination-numbers button {
        width: 36px;
        height: 36px;
        min-width: 36px;
        flex-shrink: 0;
        font-size: 0.85rem;
        padding: 0;
    }
    
    /* 省略号样式优化 */
    #pagination-numbers .dots {
        width: 28px;
        min-width: 28px;
        display: flex;
        align-items: center;
        justify-content: center;
        opacity: 0.6;
    }
    
    /* 隐藏滚动条但保持滚动功能 */
    #pagination-numbers::-webkit-scrollbar {
        display: none;
    }
    
    #pagination-numbers {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }
    
    /* ========================================
       难度筛选器适配 (Difficulty Filter)
       ======================================== */
    
    .filter-container {
        margin-bottom: 0.75rem;
    }
    
    .filter-wrapper {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
        flex-wrap: wrap;
    }
    
    .filter-label {
        text-align: left;
        font-size: 0.8rem;
        white-space: nowrap;
    }
    
    .filter-icon {
        font-size: 0.85rem;
    }
    
    .difficulty-select {
        flex: 1;
        min-width: 150px;
        min-height: 40px;
        font-size: 14px;
        padding: 0.5rem;
    }
    
    .filter-result-count {
        font-size: 0.8rem;
        text-align: center;
        width: 100%;
        margin-top: 0.25rem;
        opacity: 0.8;
    }
    
    /* ========================================
       页脚适配 (Footer)
       ======================================== */
    
    .app-footer {
        padding: 0.75rem 1rem;
        margin-top: 1rem;
        border-top-width: 1px;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
        gap: 0.4rem;
        font-size: 0.75rem;
    }
    
    .github-link {
        font-size: 0.75rem;
        padding: 0.35rem 0.7rem;
        gap: 0.4rem;
    }
    
    .github-link svg {
        width: 14px;
        height: 14px;
    }
    
    .footer-divider {
        font-size: 0.7rem;
        opacity: 0.5;
    }
    
    .footer-text {
        font-size: 0.7rem;
        opacity: 0.7;
    }
    
    /* ========================================
       性能优化 (Performance Optimization)
       ======================================== */
    
    /* 减少模糊效果强度 */
    .card-face,
    .panel,
    .glass-btn {
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
    }
    
    /* GPU加速 */
    .modal.active {
        transform: translateZ(0);
        will-change: transform;
    }
    
    .card-container {
        transform: translateZ(0);
    }
    
    /* ========================================
       可访问性增强 (Accessibility)
       ======================================== */
    
    /* 焦点指示器优化 */
    *:focus {
        outline: 3px solid rgba(99, 102, 241, 0.6);
        outline-offset: 2px;
    }
    
    button:focus,
    a:focus,
    input:focus,
    select:focus,
    textarea:focus {
        outline: 3px solid rgba(99, 102, 241, 0.8);
        outline-offset: 2px;
    }
    
    /* 确保焦点指示器在所有背景上可见 */
    .glass-btn:focus,
    .icon-btn:focus,
    .tab-btn:focus {
        outline-color: rgba(99, 102, 241, 0.9);
        box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.3);
    }
}



/* 触摸设备特定样式 */
@media (hover: none) and (pointer: coarse) {
    .glass-btn:active {
        transform: scale(0.95);
        opacity: 0.8;
    }
    
    .card:active {
        transform: scale(0.98);
    }
    
    .icon-btn:active {
        transform: scale(0.9);
    }
    
    .tab-btn:active {
        transform: scale(0.98);
    }
}

/* 减少动画效果 (Reduced Motion) */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
