/* Mobile Responsive Optimization for Fruit Hole */
/* 专门针对手机端显示和排版的优化 */

/* ===== 基础手机端优化 ===== */
@media screen and (max-width: 768px) {
    /* 手机端两列布局优化 */
    .grid.grid-cols-2 {
        gap: 0.75rem !important; /* 12px */
    }
    
    /* 等级卡片手机端优化 */
    .level-card {
        border-radius: 0.5rem !important; /* 8px */
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
    }
    
    .level-card:hover {
        transform: translateY(-2px) !important;
        box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15) !important;
    }
    
    /* 等级卡片内容区域优化 */
    .level-text-content {
        padding: 0.75rem !important; /* 12px */
    }
    
    .level-title {
        font-size: 0.875rem !important; /* 14px */
        line-height: 1.3 !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* 等级徽章优化 */
    .absolute.top-3.right-3 {
        top: 0.5rem !important;
        right: 0.5rem !important;
        padding: 0.25rem 0.5rem !important;
        font-size: 0.625rem !important; /* 10px */
        border-radius: 0.75rem !important;
    }
    /* 全局字体大小优化 */
    html {
        font-size: 14px; /* 减小基础字体大小 */
    }
    
    body {
        font-size: 14px;
        line-height: 1.5; /* 优化行高 */
        letter-spacing: 0.01em; /* 轻微增加字母间距 */
    }
    
    /* 标题字体大小优化 */
    h1 {
        font-size: 1.75rem !important; /* 28px */
        line-height: 1.3 !important;
        margin-bottom: 0.75rem !important;
    }
    
    h2 {
        font-size: 1.5rem !important; /* 24px */
        line-height: 1.3 !important;
        margin-bottom: 0.75rem !important;
    }
    
    h3 {
        font-size: 1.25rem !important; /* 20px */
        line-height: 1.3 !important;
        margin-bottom: 0.5rem !important;
    }
    
    h4 {
        font-size: 1.125rem !important; /* 18px */
        line-height: 1.3 !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* 段落文字优化 */
    p {
        font-size: 0.875rem !important; /* 14px */
        line-height: 1.6 !important;
        margin-bottom: 0.75rem !important;
    }
    
    /* 小字体优化 */
    .text-sm {
        font-size: 0.75rem !important; /* 12px */
        line-height: 1.4 !important;
    }
    
    .text-xs {
        font-size: 0.6875rem !important; /* 11px */
        line-height: 1.3 !important;
    }
}

/* ===== 超小屏幕优化 (iPhone SE等) ===== */
@media screen and (max-width: 480px) {
    html {
        font-size: 13px; /* 进一步减小基础字体 */
    }
    
    body {
        font-size: 13px;
        line-height: 1.4;
    }
    
    h1 {
        font-size: 1.5rem !important; /* 24px */
        line-height: 1.2 !important;
    }
    
    h2 {
        font-size: 1.375rem !important; /* 22px */
        line-height: 1.2 !important;
    }
    
    h3 {
        font-size: 1.125rem !important; /* 18px */
        line-height: 1.2 !important;
    }
    
    p {
        font-size: 0.8125rem !important; /* 13px */
        line-height: 1.5 !important;
    }
}

/* ===== 导航栏手机端优化 ===== */
@media screen and (max-width: 768px) {
    /* 导航栏高度优化 */
    nav {
        min-height: 56px !important; /* 减小导航栏高度 */
    }
    
    .max-w-7xl {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* Logo和标题优化 */
    .text-xl {
        font-size: 1.125rem !important; /* 18px */
    }
    
    /* 移动端菜单优化 */
    .mobile-menu {
        padding: 0.5rem !important;
    }
    
    .mobile-menu a {
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem !important;
        line-height: 1.4 !important;
    }
    
    /* 搜索输入框优化 */
    input[type="number"] {
        font-size: 0.875rem !important;
        padding: 0.5rem 0.75rem !important;
    }
    
    button {
        font-size: 0.875rem !important;
        padding: 0.5rem 0.75rem !important;
    }
}

/* ===== 首页Hero区域优化 ===== */
@media screen and (max-width: 768px) {
    /* Hero区域间距优化 */
    .py-16 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .py-12 {
        padding-top: 1.5rem !important;
        padding-bottom: 1.5rem !important;
    }
    
    /* Hero标题优化 */
    .text-4xl {
        font-size: 1.75rem !important; /* 28px */
        line-height: 1.2 !important;
    }
    
    .text-5xl {
        font-size: 2rem !important; /* 32px */
        line-height: 1.2 !important;
    }
    
    .text-6xl {
        font-size: 2.25rem !important; /* 36px */
        line-height: 1.2 !important;
    }
    
    /* Hero描述文字优化 */
    .text-xl {
        font-size: 1rem !important; /* 16px */
        line-height: 1.4 !important;
    }
    
    .text-2xl {
        font-size: 1.125rem !important; /* 18px */
        line-height: 1.4 !important;
    }
    
    /* 统计信息优化 */
    .text-3xl {
        font-size: 1.5rem !important; /* 24px */
    }
    
    /* 按钮优化 */
    .px-6 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    .py-3 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    .py-4 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
}

/* ===== 等级卡片优化 ===== */
@media screen and (max-width: 768px) {
    /* 等级卡片间距优化 */
    .gap-6 {
        gap: 1rem !important;
    }
    
    .gap-8 {
        gap: 1.25rem !important;
    }
    
    .gap-12 {
        gap: 1.5rem !important;
    }
    
    /* 等级卡片内容优化 */
    .level-card {
        margin-bottom: 0.75rem !important;
    }
    
    .level-text-content {
        padding: 0.75rem !important;
    }
    
    .level-title {
        font-size: 0.875rem !important; /* 14px */
        line-height: 1.3 !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* 等级徽章优化 */
    .level-badge {
        font-size: 0.75rem !important; /* 12px */
        padding: 0.25rem 0.5rem !important;
        top: 0.5rem !important;
        right: 0.5rem !important;
    }
    
    /* 等级图片高度优化 */
    .level-card .bg-gray-100 {
        height: 140px !important; /* 减小图片高度 */
    }
    
    /* 等级卡片网格布局优化 - 只针对等级卡片容器 */
    #featured-levels,
    #levels-grid,
    .levels-container {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.75rem !important;
    }
    
    /* 其他网格布局保持原有逻辑 */
    .grid-cols-1:not(#featured-levels):not(#levels-grid):not(.levels-container) {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
    
    .sm\\:grid-cols-2:not(#featured-levels):not(#levels-grid):not(.levels-container) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    
    .lg\\:grid-cols-3:not(#featured-levels):not(#levels-grid):not(.levels-container) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    
    .xl\\:grid-cols-4:not(#featured-levels):not(#levels-grid):not(.levels-container) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
    
    .2xl\\:grid-cols-5:not(#featured-levels):not(#levels-grid):not(.levels-container) {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }
}

/* ===== 超小屏幕等级卡片优化 ===== */
@media screen and (max-width: 480px) {
    .level-card .bg-gray-100 {
        height: 120px !important; /* 进一步减小图片高度 */
    }
    
    .level-text-content {
        padding: 0.5rem !important;
    }
    
    .level-title {
        font-size: 0.8125rem !important; /* 13px */
        line-height: 1.2 !important;
    }
    
    .level-badge {
        font-size: 0.6875rem !important; /* 11px */
        padding: 0.1875rem 0.375rem !important;
    }
    
    /* 等级卡片在超小屏幕仍然保持两列布局 */
    #featured-levels,
    #levels-grid,
    .levels-container {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 0.5rem !important;
    }
    
    /* 其他网格布局在超小屏幕改为单列 */
    .sm\\:grid-cols-2:not(#featured-levels):not(#levels-grid):not(.levels-container),
    .lg\\:grid-cols-3:not(#featured-levels):not(#levels-grid):not(.levels-container),
    .xl\\:grid-cols-4:not(#featured-levels):not(#levels-grid):not(.levels-container),
    .2xl\\:grid-cols-5:not(#featured-levels):not(#levels-grid):not(.levels-container) {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
}

/* ===== 搜索框优化 ===== */
@media screen and (max-width: 768px) {
    /* 搜索框尺寸优化 */
    .hero-search-container {
        max-width: 100% !important;
        padding: 0 1rem !important;
    }
    
    .hero-search-box {
        border-radius: 1rem !important;
        padding: 0.5rem !important;
    }
    
    .hero-search-input {
        font-size: 1rem !important; /* 16px */
        padding: 0.75rem 0.5rem !important;
    }
    
    .hero-search-btn {
        width: 48px !important;
        height: 48px !important;
        font-size: 1rem !important;
    }
    
    /* 搜索提示文字优化 */
    .hero-search-hint {
        font-size: 0.875rem !important; /* 14px */
        margin-top: 1rem !important;
    }
}

/* ===== 标签页优化 ===== */
@media screen and (max-width: 768px) {
    /* 标签按钮优化 */
    .level-tab-btn {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important; /* 12px */
        margin-bottom: 0.5rem !important;
    }
    
    /* 标签容器优化 */
    .flex.flex-wrap {
        gap: 0.5rem !important;
        margin-bottom: 1rem !important;
    }
}

/* ===== 内容区域优化 ===== */
@media screen and (max-width: 768px) {
    /* 内容容器优化 */
    .max-w-6xl,
    .max-w-4xl,
    .max-w-7xl {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }
    
    /* 内容间距优化 */
    .mb-8 {
        margin-bottom: 1.5rem !important;
    }
    
    .mb-12 {
        margin-bottom: 2rem !important;
    }
    
    .mb-6 {
        margin-bottom: 1rem !important;
    }
    
    /* 卡片内容优化 */
    .p-6 {
        padding: 1rem !important;
    }
    
    .p-8 {
        padding: 1.25rem !important;
    }
    
    /* 列表项优化 */
    .space-y-4 > * + * {
        margin-top: 0.75rem !important;
    }
    
    .space-y-6 > * + * {
        margin-top: 1rem !important;
    }
}

/* ===== 游戏页面优化 ===== */
@media screen and (max-width: 768px) {
    /* 游戏容器优化 */
    .game-container {
        margin-bottom: 1rem !important;
    }
    
    /* 游戏描述优化 */
    .prose {
        font-size: 0.875rem !important;
        line-height: 1.6 !important;
    }
    
    .prose h3 {
        font-size: 1.125rem !important; /* 18px */
        margin-bottom: 0.75rem !important;
    }
    
    .prose h4 {
        font-size: 1rem !important; /* 16px */
        margin-bottom: 0.5rem !important;
    }
    
    .prose p {
        font-size: 0.875rem !important; /* 14px */
        margin-bottom: 0.75rem !important;
    }
    
    .prose li {
        font-size: 0.875rem !important; /* 14px */
        margin-bottom: 0.5rem !important;
    }
    
    /* 游戏信息卡片优化 */
    .app-info-card {
        padding: 1rem !important;
    }
    
    .info-row {
        padding-bottom: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .info-label {
        font-size: 0.875rem !important;
    }
    
    .info-value {
        font-size: 0.875rem !important;
    }
}

/* ===== 详情页优化 ===== */
@media screen and (max-width: 768px) {
    /* 详情页布局优化 */
    .lg\\:col-span-7 {
        grid-column: span 1 !important;
    }
    
    .lg\\:col-span-3 {
        grid-column: span 1 !important;
        margin-top: 1.5rem !important;
    }
    
    /* 视频容器优化 */
    .aspect-video {
        aspect-ratio: 16/9 !important;
        height: auto !important;
    }
    
    /* 视频容器屏幕模式优化 */
    .video-container {
        position: relative !important;
        width: 100% !important;
        border-radius: 0.5rem !important;
    }
    
    /* 手机端竖屏模式 */
    .video-container[data-mobile-mode="2"] {
        aspect-ratio: 9/16 !important;
        max-width: 100% !important;
        max-height: 70vh !important;
    }
    
    /* 手机端横屏模式 */
    .video-container[data-mobile-mode="1"] {
        aspect-ratio: 16/9 !important;
        max-height: 50vh !important;
    }
    
    /* 屏幕模式指示器移动端优化 */
    .screen-mode-indicator {
        font-size: 10px !important;
        padding: 2px 6px !important;
        top: 4px !important;
        left: 4px !important;
    }
    
    /* 详情页内容优化 */
    .video-info-header {
        padding: 0.75rem !important;
        margin-bottom: 0.75rem !important;
    }
    
    .video-info-header h3 {
        font-size: 1rem !important; /* 16px */
    }
    
    .video-duration-display {
        font-size: 0.75rem !important; /* 12px */
        padding: 0.25rem 0.5rem !important;
    }
    
    /* 分享按钮优化 */
    .flex.flex-wrap.gap-3 {
        gap: 0.5rem !important;
    }
    
    .flex.flex-wrap.gap-3 a,
    .flex.flex-wrap.gap-3 button {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
    }
}

/* ===== 分页优化 ===== */
@media screen and (max-width: 768px) {
    /* 分页按钮优化 */
    nav.flex.items-center.space-x-1 {
        gap: 0.25rem !important;
    }
    
    nav.flex.items-center.space-x-1 a,
    nav.flex.items-center.space-x-1 span {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
        min-width: 2rem !important;
        text-align: center !important;
    }
    
    /* 分页信息优化 */
    .text-center.text-sm {
        font-size: 0.75rem !important;
        margin-top: 0.75rem !important;
    }
}

/* ===== 页脚优化 ===== */
@media screen and (max-width: 768px) {
    /* 页脚布局优化 */
    .md\\:grid-cols-4 {
        grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
    }
    
    .md\\:col-span-2 {
        grid-column: span 1 !important;
    }
    
    /* 页脚内容优化 */
    .py-12 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
    
    .gap-8 {
        gap: 1.5rem !important;
    }
    
    /* 页脚文字优化 */
    .text-xl {
        font-size: 1.125rem !important; /* 18px */
    }
    
    .text-lg {
        font-size: 1rem !important; /* 16px */
    }
    
    /* 页脚链接优化 */
    .space-y-2 > * + * {
        margin-top: 0.5rem !important;
    }
    
    .space-y-2 a {
        font-size: 0.875rem !important; /* 14px */
        line-height: 1.4 !important;
    }
}

/* ===== 特殊元素优化 ===== */
@media screen and (max-width: 768px) {
    /* 3D立方体隐藏（手机端性能考虑） */
    .cube-scene {
        display: none !important;
    }
    
    /* 加载动画优化 */
    .loading-spinner {
        width: 16px !important;
        height: 16px !important;
    }
    
    /* 返回顶部按钮优化 */
    #back-to-top {
        bottom: 1rem !important;
        right: 1rem !important;
        padding: 0.75rem !important;
        font-size: 1rem !important;
    }
    
    /* 工具提示优化 */
    .tooltip {
        font-size: 0.75rem !important;
        padding: 0.5rem 0.75rem !important;
    }
}

/* ===== 触摸优化 ===== */
@media screen and (max-width: 768px) {
    /* 触摸目标最小尺寸 */
    button,
    a,
    input,
    select,
    textarea {
        min-height: 44px !important;
        min-width: 44px !important;
    }
    
    /* 触摸反馈 */
    button:active,
    a:active {
        transform: scale(0.95) !important;
        transition: transform 0.1s ease !important;
    }
    
    /* 输入框优化 */
    input,
    textarea {
        font-size: 16px !important; /* 防止iOS缩放 */
    }
}

/* ===== 性能优化 ===== */
@media screen and (max-width: 768px) {
    /* 减少动画复杂度 */
    * {
        animation-duration: 0.2s !important;
        transition-duration: 0.2s !important;
    }
    
    /* 减少阴影效果 */
    .shadow-lg,
    .shadow-xl,
    .shadow-2xl {
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1) !important;
    }
    
    /* 减少模糊效果 */
    .backdrop-blur-md,
    .backdrop-blur-lg {
        backdrop-filter: blur(4px) !important;
    }
}

/* ===== 横屏优化 ===== */
@media screen and (orientation: landscape) and (max-height: 500px) {
    /* 横屏时进一步压缩垂直空间 */
    .py-16 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }
    
    .py-12 {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }
    
    .py-8 {
        padding-top: 0.5rem !important;
        padding-bottom: 0.5rem !important;
    }
    
    /* 横屏时隐藏非关键元素 */
    .hero-search-hint {
        display: none !important;
    }
    
    /* 横屏时优化网格布局 */
    .grid-cols-1 {
        grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    }
}

/* ===== 高DPI屏幕优化 ===== */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* 高DPI屏幕下的字体渲染优化 */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
    }
    
    /* 高DPI屏幕下的边框优化 */
    .border {
        border-width: 0.5px !important;
    }
}

/* ===== 深色模式优化 ===== */
@media (prefers-color-scheme: dark) {
    @media screen and (max-width: 768px) {
        /* 深色模式下的手机端优化 */
        .level-card {
            background: rgba(31, 41, 55, 0.95) !important;
            border: 1px solid rgba(75, 85, 99, 0.3) !important;
        }
        
        .level-title {
            color: #f9fafb !important;
        }
        
        .level-badge {
            background: linear-gradient(135deg, #f59e0b, #d97706) !important;
        }
    }
}

/* ===== 减少动画偏好优化 ===== */
@media (prefers-reduced-motion: reduce) {
    @media screen and (max-width: 768px) {
        /* 减少动画时的手机端优化 */
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
        
        .level-card:hover {
            transform: none !important;
        }
    }
}
