/* ==========================================
   移动端导航菜单样式
   ========================================== */

/* 只在移动设备上显示导航菜单 */
.mobile-navigation {
    display: none;
}

@media screen and (max-width: 768px) {

    /* 移动端导航容器 */
    .mobile-navigation {
        display: block;
        position: fixed;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: min(400px, 95vw);
        height: 70px;
        background: #fff;
        border-radius: 10px 10px 0 0;
        z-index: 10000;
        /* 提高到最高层级，确保不被遮挡 */
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    }

    .mobile-navigation ul {
        display: flex;
        width: 100%;
        height: 100%;
        justify-content: space-around;
        align-items: center;
        padding: 0;
        margin: 0;
        list-style: none;
        position: relative;
    }

    .mobile-navigation ul li {
        position: relative;
        flex: 1;
        max-width: 80px;
        height: 70px;
        z-index: 1;
    }

    .mobile-navigation ul li a {
        position: relative;
        display: flex;
        justify-content: center;
        align-items: center;
        flex-direction: column;
        width: 100%;
        height: 100%;
        text-align: center;
        font-weight: 500;
        text-decoration: none;
    }

    .mobile-navigation ul li a .icon {
        position: relative;
        display: block;
        line-height: 75px;
        font-size: 1.5em;
        text-align: center;
        transition: 0.5s;
        color: #222327;
    }

    .mobile-navigation ul li.active a .icon {
        transform: translateY(-32px);
    }

    .mobile-navigation ul li a .text {
        position: absolute;
        color: #222327;
        font-weight: 400;
        font-size: 0.75em;
        letter-spacing: 0.05em;
        transition: 0.5s;
        opacity: 0;
        transform: translateY(20px);
    }

    .mobile-navigation ul li.active a .text {
        opacity: 1;
        transform: translateY(10px);
    }

    .mobile-navigation .indicator {
        position: absolute;
        top: -55%;
        width: 60px;
        height: 60px;
        background: #29fd53;
        border-radius: 50%;
        border: 6px solid #000033;
        transition: 0.5s;
        z-index: 0;
    }


    /* 指示器位置 - 将通过 JavaScript 动态计算 */
    .mobile-navigation .indicator {
        left: 0;
    }

    /* 移动端页面容器 */
    .mobile-page-container {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: calc(100vh - 70px);
        /* 为底部导航栏留出空间 */
        background: #000033;
        z-index: 2000;
        overflow-y: hidden;
        overflow-x: hidden;
        padding: 0;
        /* 移除padding，让子元素自己控制间距 */
        box-sizing: border-box;
    }

    .mobile-page-container.active {
        display: flex;
        /* 移除!important，让JavaScript可以控制显示/隐藏 */
        flex-direction: column;
        align-items: center;
        justify-content: center;
        /* 居中对齐 */
        z-index: 2001;
        /* 激活的页面z-index更高 */
    }

    /* 游戏开始页面样式 */
    .mobile-start-page {
        width: 100%;
        max-width: 500px;
        flex: 1;
        display: flex !important;
        flex-direction: column;
        justify-content: flex-start;
        align-items: center;
        padding: 10px 20px 10px 20px;
        box-sizing: border-box;
        overflow: hidden !important;
        gap: 0;
        min-height: 0;
    }

    /* 教程提示 - 顶部 */
    .mobile-start-page .tutorial-hint {
        display: flex !important;
        align-items: center !important;
        gap: 12px !important;
        background: #1a1a4e !important;
        padding: 12px 16px !important;
        border-radius: 12px !important;
        width: 100% !important;
        max-width: 500px !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        flex-shrink: 0 !important;
        margin: 0 !important;
    }

    .mobile-start-page .tutorial-hint:active {
        background: rgba(255, 255, 255, 0.15);
        transform: scale(0.98);
    }

    .mobile-start-page .tutorial-icon {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        background: linear-gradient(135deg, #6a11cb, #2575fc);
        color: white;
        font-size: 20px;
        font-weight: bold;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

    .mobile-start-page .tutorial-text {
        color: white;
        font-size: 14px;
        line-height: 1.5;
    }

    /* Logo容器 */
    .mobile-start-page .logo-container {
        text-align: center;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        margin: 0 !important;
        order: unset !important;
        padding-top: 2vh !important;
        padding-bottom: 1vh !important;
    }

    .mobile-start-page .logo {
        max-width: 200px !important;
        width: 50vw !important;
        filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.6)) !important;
    }

    /* 开始按钮区域 - 底部，避开导航栏 */
    .mobile-start-page .start-actions {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        width: 100% !important;
        flex-shrink: 0 !important;
        padding-bottom: 0 !important;
        margin: 0 !important;
        gap: 10px !important;
    }

    /* 统一按钮样式 */
    .mobile-start-page .start-button,
    .mobile-start-page .learning-mode-btn {
        color: #fff !important;
        border: none !important;
        height: 50px !important;
        padding: 0 20px !important;
        font-size: 18px !important;
        font-weight: bold !important;
        border-radius: 25px !important;
        cursor: pointer !important;
        transition: all 0.3s ease !important;
        width: 85% !important;
        max-width: 280px !important;
        text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3) !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        line-height: 1 !important;
    }

    .mobile-start-page .start-button {
        background: linear-gradient(135deg, #e0af00, #ffcc00) !important;
        box-shadow: 0 4px 15px rgba(224, 175, 0, 0.4) !important;
    }

    .mobile-start-page .learning-mode-btn {
        background: linear-gradient(135deg, #4CAF50, #8BC34A) !important;
        box-shadow: 0 4px 15px rgba(76, 175, 80, 0.4) !important;
    }

    .mobile-start-page .start-button:active,
    .mobile-start-page .learning-mode-btn:active {
        transform: scale(0.95);
    }

    .mobile-start-page .start-button:active {
        box-shadow: 0 2px 10px rgba(224, 175, 0, 0.5) !important;
    }

    .mobile-start-page .learning-mode-btn:active {
        box-shadow: 0 2px 10px rgba(76, 175, 80, 0.5) !important;
    }

    /* 开始页面模式切换开关 */
    .mobile-start-mode-toggles {
        display: flex;
        flex-direction: row;
        justify-content: center;
        gap: 20px;
        margin-top: 8px;
        order: 3;
    }

    .mobile-start-toggle-item {
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .mobile-start-toggle-label {
        color: #ddd;
        font-size: 13px;
    }

    /* 隐藏桌面端的开始屏幕 */
    .start-screen {
        display: none !important;
    }

    /* 词库管理页面样式 */
    .mobile-dictionary-page {
        display: flex;
        flex-direction: column;
    }

    .mobile-page-header {
        padding: 20px;
        background: #0a0a2e;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    /* 确保开始页面不显示 header */
    .mobile-start-page .mobile-page-header {
        display: none !important;
    }

    .mobile-page-header h2 {
        color: #eeffee;
        margin: 0;
        font-size: 24px;
        font-weight: 600;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
        letter-spacing: 1px;
    }

    .mobile-page-content {
        flex: 1;
        padding: 15px;
        padding-bottom: 80px;
        /* 减少外边距，让错字项目更宽 */
        overflow-y: auto;
        width: 100%;
        /* 确保占满宽度 */
        box-sizing: border-box;
    }

    .dictionary-intro {
        background: #0d0d35;
        padding: 15px;
        border-radius: 10px;
        margin-bottom: 20px;
        border-left: 4px solid #33cc33;
    }

    .dictionary-intro p {
        color: rgba(255, 255, 255, 0.8);
        margin: 0;
        font-size: 14px;
        line-height: 1.6;
    }

    .mobile-dictionary-btn {
        width: 100%;
        padding: 18px 20px;
        background: linear-gradient(135deg, #33cc33, #28a428);
        color: white;
        border: none;
        border-radius: 12px;
        font-size: 18px;
        font-weight: bold;
        cursor: pointer;
        transition: all 0.3s ease;
        box-shadow: 0 4px 15px rgba(51, 204, 51, 0.3);
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 25px;
    }

    .mobile-dictionary-btn:active {
        transform: translateY(2px);
        box-shadow: 0 2px 10px rgba(51, 204, 51, 0.5);
    }

    .dictionary-tips {
        background: #0a0a2e;
        padding: 20px;
        border-radius: 10px;
        border: 1px solid rgba(255, 255, 255, 0.08);
    }

    .dictionary-tips h3 {
        color: #33cc33;
        margin: 0 0 15px 0;
        font-size: 16px;
        font-weight: 600;
    }

    .dictionary-tips ul {
        margin: 0;
        padding-left: 20px;
        color: rgba(255, 255, 255, 0.7);
    }

    .dictionary-tips li {
        margin-bottom: 10px;
        line-height: 1.6;
        font-size: 14px;
    }

    .dictionary-tips li:last-child {
        margin-bottom: 0;
    }

    /* 移动端词库管理器样式优化 */
    .word-library-manager {
        top: 0 !important;
        transform: translate(-50%, 0) !important;
        max-height: calc(100vh - 70px) !important;
        /* 减去导航栏高度 */
        height: calc(100vh - 70px) !important;
        width: 100% !important;
        max-width: 100% !important;
        border-radius: 0 !important;
    }

    .word-library-manager.show {
        transform: translate(-50%, 0) !important;
    }

    .word-library-manager .library-manager-header h2 {
        font-size: 18px !important;
    }

    /* 移动端隐藏词库顶栏，释放显示空间 */
    .word-library-manager .library-manager-header {
        display: none;
    }

    /* 移动端"添加词库"按钮内嵌帮助按钮 */
    .add-library-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
    }

    .library-inline-help {
        background: rgba(255, 255, 255, 0.15);
        border: 1px solid rgba(255, 255, 255, 0.25);
        border-radius: 50%;
        width: 26px;
        height: 26px;
        color: rgba(255, 255, 255, 0.8);
        font-size: 14px;
        font-weight: 700;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0;
        line-height: 1;
    }

    .library-inline-help:active {
        background: rgba(255, 255, 255, 0.25);
    }

    .word-library-manager .library-manager-content {
        padding-bottom: 80px;
    }

    /* 移动端错词本页面样式 */
    .mobile-wronglog-page {
        display: flex;
        flex-direction: column;
        overflow: hidden;
        /* 防止横向滚动 */
        width: 100%;
        /* 确保不超出 */
        max-width: 100vw;
        /* 限制最大宽度 */
    }

    .mobile-wronglog-page .mobile-page-content {
        flex: 1;
        padding: 15px;
        padding-bottom: 80px;
        overflow-y: auto;
        overflow-x: hidden;
        /* 防止横向滚动 */
        width: 100%;
        max-width: 100%;
        /* 限制最大宽度 */
        box-sizing: border-box;
    }

    .mobile-wrong-char-list-container {
        width: 100%;
        max-width: 100%;
        /* 确保不超出父容器 */
    }

    .mobile-wrong-char-empty-msg {
        text-align: center;
        color: rgba(255, 255, 255, 0.5);
        font-size: 16px;
        padding: 40px 20px;
        line-height: 1.6;
    }

    .mobile-wrong-char-items-ul {
        list-style: none;
        padding: 0;
        margin: 0;
        display: flex;
        flex-direction: column;
        gap: 12px;
        width: 100%;
        /* 确保不超出 */
        box-sizing: border-box;
    }

    .mobile-wrong-char-item {
        background: #0d0d35;
        border: 1px solid rgba(255, 255, 255, 0.1);
        border-radius: 12px;
        padding: 16px 12px;
        /* 减少左右padding以防止超出 */
        display: flex;
        justify-content: space-between;
        align-items: center;
        transition: all 0.2s ease;
        width: 100%;
        max-width: 100%;
        /* 限制最大宽度 */
        box-sizing: border-box;
        /* 确保padding和border不会增加宽度 */
    }


    .mobile-wrong-char-item-text {
        color: #eeffee;
        font-size: 18px;
        font-weight: 500;
        flex: 1;
    }

    .mobile-wrong-char-buttons {
        display: flex;
        gap: 8px;
        flex-shrink: 0;
    }

    .mobile-wrong-char-search-btn,
    .mobile-wrong-char-remove-btn {
        width: 44px;
        height: 44px;
        border: none;
        border-radius: 10px;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: all 0.2s ease;
        font-size: 22px;
    }

    .mobile-wrong-char-search-btn {
        background: linear-gradient(135deg, #3F51B5, #303F9F);
        color: white;
    }

    .mobile-wrong-char-search-btn:active {
        background: linear-gradient(135deg, #5C6BC0, #3949AB);
        transform: scale(0.95);
    }

    .mobile-wrong-char-remove-btn {
        background: linear-gradient(135deg, #f44336, #d32f2f);
        color: white;
    }

    .mobile-wrong-char-remove-btn:active {
        background: linear-gradient(135deg, #e57373, #ef5350);
        transform: scale(0.95);
    }

    /* 移动端排行榜页面样式 */
    .mobile-leaderboard-page {
        display: flex;
        flex-direction: column;
        overflow: hidden;
        width: 100%;
        max-width: 100vw;
    }

    .mobile-leaderboard-page .mobile-page-content {
        flex: 1;
        padding: 15px;
        padding-bottom: 80px;
        overflow-y: auto;
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* 排行榜选项卡 */
    .mobile-leaderboard-tabs {
        display: flex;
        margin-bottom: 20px;
        border-bottom: 2px solid rgba(51, 204, 51, 0.2);
        gap: 0;
    }

    .mobile-leaderboard-tab {
        flex: 1;
        padding: 12px 8px;
        background: transparent;
        border: none;
        border-bottom: 3px solid transparent;
        color: rgba(238, 238, 238, 0.7);
        font-size: 15px;
        font-weight: 500;
        cursor: pointer;
        transition: all 0.2s ease;
        text-align: center;
        margin-bottom: -2px;
    }

    .mobile-leaderboard-tab:active {
        background-color: rgba(51, 204, 51, 0.1);
    }

    .mobile-leaderboard-tab.active {
        color: #eeffee;
        font-weight: 600;
        border-bottom: 3px solid #33cc33;
        background-color: rgba(51, 204, 51, 0.05);
    }

    /* 排行榜列表 */
    .mobile-leaderboard-list {
        width: 100%;
        box-sizing: border-box;
    }

    .mobile-leaderboard-empty {
        text-align: center;
        color: rgba(255, 255, 255, 0.5);
        font-size: 16px;
        padding: 60px 20px;
        line-height: 1.6;
        font-style: italic;
    }

    .mobile-leaderboard-items {
        list-style: none;
        padding: 0;
        margin: 0;
        counter-reset: none;
    }

    .mobile-leaderboard-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px 12px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.08);
        background: #0a0a2e;
        transition: background 0.2s ease;
    }

    .mobile-leaderboard-item:nth-child(odd) {
        background: #0d0d35;
    }

    .mobile-leaderboard-item:last-child {
        border-bottom: none;
    }

    .mobile-leaderboard-rank {
        flex: 0 0 50px;
        font-weight: bold;
        color: #a0a0a0;
        font-size: 16px;
    }

    .mobile-leaderboard-name {
        flex: 1;
        color: #eeffee;
        font-size: 16px;
        padding: 0 10px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .mobile-leaderboard-score {
        flex: 0 0 80px;
        text-align: right;
        font-weight: bold;
        color: #ffdd00;
        font-size: 18px;
    }

    /* 移动端设置页面样式 */
    .mobile-settings-page {
        display: flex;
        flex-direction: column;
        overflow: hidden;
        width: 100%;
        max-width: 100vw;
    }

    .mobile-settings-page .mobile-page-content {
        flex: 1;
        padding: 15px;
        padding-bottom: 80px;
        overflow-y: auto;
        overflow-x: hidden;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    /* 设置分组 */
    .mobile-settings-section {
        margin-bottom: 25px;
    }

    .mobile-settings-section h3 {
        color: #eeffee;
        font-size: 16px;
        font-weight: 600;
        margin: 0 0 15px 0;
        padding-bottom: 8px;
        border-bottom: 1px solid rgba(51, 204, 51, 0.3);
    }

    /* 设置项目 */
    .mobile-settings-item {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 14px 12px;
        background: #0d0d35;
        border-radius: 10px;
        margin-bottom: 12px;
    }

    .mobile-settings-label {
        color: #eeffee;
        font-size: 15px;
        flex: 1;
    }

    /* 移动端开关样式 */
    .mobile-toggle-switch {
        position: relative;
        width: 50px;
        height: 28px;
        flex-shrink: 0;
    }

    .mobile-toggle-switch input {
        opacity: 0;
        width: 0;
        height: 0;
    }

    .mobile-slider {
        position: absolute;
        cursor: pointer;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(255, 255, 255, 0.2);
        transition: 0.3s;
        border-radius: 28px;
    }

    .mobile-slider:before {
        position: absolute;
        content: "";
        height: 22px;
        width: 22px;
        left: 3px;
        bottom: 3px;
        background-color: white;
        transition: 0.3s;
        border-radius: 50%;
    }

    .mobile-toggle-switch input:checked+.mobile-slider {
        background: linear-gradient(135deg, #33cc33, #28a428);
    }

    .mobile-toggle-switch input:checked+.mobile-slider:before {
        transform: translateX(22px);
    }

    .mobile-toggle-switch input:disabled+.mobile-slider {
        opacity: 0.5;
        cursor: not-allowed;
    }

    /* 音量控制 */
    .mobile-volume-item {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .mobile-volume-control {
        display: flex;
        align-items: center;
        gap: 10px;
        width: 100%;
    }

    #mobileVolumeSlider {
        flex: 1;
        height: 6px;
        border-radius: 3px;
        background: rgba(255, 255, 255, 0.2);
        outline: none;
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
    }

    #mobileVolumeSlider::-webkit-slider-thumb {
        -webkit-appearance: none;
        -moz-appearance: none;
        appearance: none;
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: linear-gradient(135deg, #33cc33, #28a428);
        cursor: pointer;
    }

    #mobileVolumeSlider::-moz-range-thumb {
        width: 18px;
        height: 18px;
        border-radius: 50%;
        background: linear-gradient(135deg, #33cc33, #28a428);
        cursor: pointer;
        border: none;
    }

    #mobileVolumeSlider:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

    .mobile-volume-value {
        color: #eeffee;
        font-size: 14px;
        min-width: 45px;
        text-align: right;
    }

    /* 语言选择器 */
    .mobile-language-select {
        background: rgba(255, 255, 255, 0.1);
        border: 1px solid rgba(255, 255, 255, 0.2);
        border-radius: 8px;
        color: #eeffee;
        padding: 8px 12px;
        font-size: 15px;
        min-width: 120px;
        cursor: pointer;
    }

    .mobile-language-select:focus {
        outline: none;
        border-color: #33cc33;
        box-shadow: 0 0 8px rgba(51, 204, 51, 0.3);
    }

    .mobile-language-select option {
        background-color: #1a1a3e;
        color: white;
    }

    /* 更新日志按钮 */
    .mobile-changelog-btn {
        width: 100%;
        padding: 14px 16px;
        background: linear-gradient(135deg, #6c757d, #5a6268);
        border: none;
        border-radius: 10px;
        color: white;
        font-size: 15px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .mobile-changelog-btn:active {
        background: linear-gradient(135deg, #5a6268, #495057);
        transform: scale(0.98);
    }

    .mobile-changelog-btn ion-icon {
        font-size: 20px;
    }

    .mobile-clear-cache-btn {
        width: 100%;
        padding: 14px 16px;
        margin-top: 10px;
        background: linear-gradient(135deg, #e74c3c, #c0392b);
        border: none;
        border-radius: 10px;
        color: white;
        font-size: 15px;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 10px;
        cursor: pointer;
        transition: all 0.3s ease;
    }

    .mobile-clear-cache-btn:active {
        background: linear-gradient(135deg, #c0392b, #a93226);
        transform: scale(0.98);
    }

    .mobile-clear-cache-btn ion-icon {
        font-size: 20px;
    }
}

/* 小屏幕设备优化 */
@media screen and (max-width: 480px) {
    .mobile-navigation {
        width: 100%;
        border-radius: 0;
    }

    .mobile-start-page .logo {
        max-width: 180px;
        width: 50vw;
    }

    .mobile-start-page .start-button {
        padding: 0 20px;
        font-size: 18px;
        width: 90%;
    }

    .mobile-start-page .tutorial-hint {
        padding: 12px 15px;
    }

    .mobile-start-page .tutorial-icon {
        width: 35px;
        height: 35px;
        font-size: 20px;
    }

    .mobile-start-page .tutorial-text {
        font-size: 13px;
    }
}

/* 横屏模式优化 */
@media screen and (max-height: 500px) and (orientation: landscape) {
    .mobile-page-container {
        height: calc(100vh - 60px);
    }

    .mobile-navigation {
        height: 60px;
    }

    .mobile-navigation ul li {
        height: 60px;
    }

    .mobile-start-page .logo {
        max-width: 180px;
    }

    .mobile-start-page .start-button {
        padding: 12px 35px;
        font-size: 20px;
    }
}