/*
 * 移动端 UI v3 - 完全重写
 * 简洁、清晰、多行布局
 * 2025-12-05
 */

@media (max-width: 768px) {
    /* ===== 强制隐藏所有旧元素 ===== */
    .desktop-layout,
    .header-left,
    .header-right,
    .app-sidebar,
    .library-header,
    .app-header .header-left,
    .app-header .header-right,
    .app-container .header-left,
    .app-container .header-right,
    body .quick-access-buttons,
    body .quick-access-btn,
    body.mobile-device .quick-access-buttons,
    body.mobile-device .quick-access-btn,
    .app-header .quick-access-buttons,
    .app-header .quick-access-btn,
    .header-left .quick-access-buttons,
    button.save-center-btn,
    .app-header .mobile-header-single-row,
    .app-header .mobile-categories-section,
    .app-header .mobile-save-section {
        display: none !important;
        visibility: hidden !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
        position: absolute !important;
        left: -9999px !important;
    }
    
    /* ===== 显示移动端 ===== */
    .mobile-layout {
        display: block !important;
    }
    
    /* ===== 防止溢出 ===== */
    html, body {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
    
    /* ===== 容器 ===== */
    .app-container {
        display: flex;
        flex-direction: column;
        height: 100vh;
        height: 100dvh;
        overflow: hidden;
        width: 100%;
        max-width: 100vw;
    }
    
    /* ===== 顶部区域 ===== */
    .app-header {
        flex-shrink: 0;
        background: #0d1117;
        padding: 0;
    }
    
    .mobile-ui {
        display: flex;
        flex-direction: column;
    }
    
    /* ===== 通用行 ===== */
    .m-row {
        padding: 0 12px;
    }
    
    /* ===== 第一行：Logo + 登录 ===== */
    .m-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px;
        background: #161b22;
    }
    
    .m-logo {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .m-logo-icon {
        font-size: 24px;
    }
    
    .m-logo-text {
        font-size: 18px;
        font-weight: 700;
        color: #fff;
    }
    
    .m-user {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    #m-login-btn {
        padding: 8px 16px;
        font-size: 14px;
        font-weight: 600;
        background: linear-gradient(135deg, #7c5dff, #a78bfa);
        border: none;
        border-radius: 20px;
        color: #fff;
        cursor: pointer;
    }
    
    #m-user-name {
        font-size: 13px;
        color: #8b949e;
        max-width: 80px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    
    #m-logout-btn {
        padding: 6px 12px;
        font-size: 12px;
        background: rgba(231, 76, 60, 0.2);
        border: 1px solid rgba(231, 76, 60, 0.4);
        border-radius: 16px;
        color: #e74c3c;
        cursor: pointer;
    }
    
    /* ===== 第二行：搜索框 ===== */
    .m-search {
        padding: 8px 12px;
    }
    
    #m-search-input {
        width: 100%;
        padding: 12px 16px;
        font-size: 15px;
        background: #21262d;
        border: 1px solid #30363d;
        border-radius: 10px;
        color: #fff;
        outline: none;
    }
    
    #m-search-input::placeholder {
        color: #6e7681;
    }
    
    #m-search-input:focus {
        border-color: #7c5dff;
        box-shadow: 0 0 0 3px rgba(124, 93, 255, 0.15);
    }
    
    /* ===== 第三行：快捷按钮（缩小版） ===== */
    .m-buttons {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 6px;
        padding: 6px 12px;
    }
    
    .m-btn {
        padding: 8px 6px;
        font-size: 12px;
        font-weight: 500;
        background: #21262d;
        border: 1px solid #30363d;
        border-radius: 8px;
        color: #c9d1d9;
        cursor: pointer;
        transition: all 0.15s;
    }
    
    .m-btn:active {
        transform: scale(0.96);
    }
    
    .m-btn-fav {
        background: rgba(255, 107, 157, 0.1);
        border-color: rgba(255, 107, 157, 0.3);
    }
    
    .m-btn-recent {
        background: rgba(0, 212, 170, 0.1);
        border-color: rgba(0, 212, 170, 0.3);
    }
    
    .m-btn-save {
        background: rgba(124, 93, 255, 0.1);
        border-color: rgba(124, 93, 255, 0.3);
    }
    
    /* ===== 第四行：游戏分类（横向滚动） ===== */
    .m-tabs {
        padding: 6px 12px 10px;
        overflow-x: auto;
        overflow-y: hidden;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        width: 100%;
        box-sizing: border-box;
    }
    
    .m-tabs::-webkit-scrollbar {
        display: none;
    }
    
    .m-tabs-scroll {
        display: flex;
        gap: 6px;
        width: max-content;
    }
    
    .m-tab {
        flex-shrink: 0;
        padding: 6px 12px;
        font-size: 12px;
        background: #21262d;
        border: 1px solid #30363d;
        border-radius: 14px;
        color: #8b949e;
        cursor: pointer;
        white-space: nowrap;
        transition: all 0.15s;
    }
    
    .m-tab.active {
        background: linear-gradient(135deg, rgba(124, 93, 255, 0.3), rgba(167, 139, 250, 0.2));
        border-color: #7c5dff;
        color: #fff;
    }
    
    .m-tab:active {
        transform: scale(0.96);
    }
    
    /* ===== 滚动时收缩 ===== */
    .app-header.scrolled .m-header {
        padding: 8px 12px;
    }
    
    .app-header.scrolled .m-logo-text {
        font-size: 16px;
    }
    
    .app-header.scrolled .m-search,
    .app-header.scrolled .m-buttons {
        display: none;
    }
    
    .app-header.scrolled .m-tabs {
        padding: 4px 12px 8px;
    }
    
    .app-header.scrolled .m-tab {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    /* ===== 主内容区 ===== */
    .app-main {
        flex: 1;
        overflow: hidden;
        min-height: 0;
    }
    
    .app-content {
        height: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* ===== 游戏网格 ===== */
    .game-library {
        padding: 0;
    }
    
    .game-grid {
        padding: 10px;
        overflow: visible;
    }
    
    .game-grid-inner {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    /* ===== 游戏卡片 ===== */
    .game-card {
        background: #161b22;
        border: 1px solid #21262d;
        border-radius: 12px;
        overflow: hidden;
    }
    
    .game-card:active {
        transform: scale(0.98);
    }
    
    .game-cover {
        position: relative;
        aspect-ratio: 3/4;
        background: #0d1117;
    }
    
    .game-cover img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }
    
    .favorite-btn {
        position: absolute;
        top: 6px;
        right: 6px;
        width: 32px;
        height: 32px;
        background: rgba(0, 0, 0, 0.6);
        border: none;
        border-radius: 50%;
        font-size: 16px;
        color: rgba(255, 255, 255, 0.6);
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .favorite-btn.active {
        color: #ff6b9d;
    }
    
    .game-info {
        padding: 10px;
    }
    
    .game-title {
        font-size: 13px;
        font-weight: 600;
        color: #c9d1d9;
        line-height: 1.3;
        margin-bottom: 4px;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    
    .game-meta {
        font-size: 11px;
        color: #6e7681;
    }
    
    /* ===== Toast 提示框（移动端紧凑版） ===== */
    .toast {
        top: 12px !important;
        bottom: auto !important;
        right: 12px !important;
        left: auto !important;
        max-width: 180px !important;
        padding: 6px 10px !important;
        font-size: 12px !important;
        border-radius: 6px !important;
        height: auto !important;
        min-height: auto !important;
    }
}

/* ===== 平板 =====
@media (min-width: 481px) and (max-width: 768px) {
    .game-grid-inner {
        grid-template-columns: repeat(3, 1fr);
    }
}
