/* ============================================
   移动端体验增强 - 现代化优化
   设计理念: 触感反馈 + 流畅动画 + 大触摸热区
   ============================================ */

/* 移动端专用样式 - 仅在768px以下生效 */
@media (max-width: 768px) {

    /* ========== 全局优化 ========== */

    /* 平滑滚动 + 防止过度滚动 */
    html {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
        overscroll-behavior-y: contain;
    }

    /* 优化字体渲染 */
    body {
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        text-rendering: optimizeLegibility;
        font-size: 16px; /* 防止iOS自动缩放 */
    }

    /* 禁用长按选择和放大 */
    img, video {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
        pointer-events: none;
    }

    /* ========== 触摸热区优化 ========== */

    /* 确保所有可点击元素至少44x44px */
    button,
    .btn,
    a.btn,
    .nav-item,
    .category-tab,
    .tag-item,
    .page-btn,
    .share-button {
        min-height: 44px;
        min-width: 44px;
        -webkit-tap-highlight-color: rgba(102, 126, 234, 0.15);
        tap-highlight-color: rgba(102, 126, 234, 0.15);
    }

    /* 扩大小按钮的触摸区域 */
    .page-btn,
    .carousel-nav button {
        position: relative;
    }

    .page-btn::before,
    .carousel-nav button::before {
        content: '';
        position: absolute;
        top: -10px;
        left: -10px;
        right: -10px;
        bottom: -10px;
    }

    /* ========== 卡片触摸反馈 ========== */

    /* 游戏/新闻/抽奖卡片统一触摸反馈 */
    .game-card,
    .news-card,
    .lottery-card,
    .resource-card {
        position: relative;
        transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1),
                    box-shadow 0.15s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform;
        transform: translateZ(0);
    }

    /* 按下反馈 - 快速缩小 */
    .game-card:active,
    .news-card:active,
    .lottery-card:active,
    .resource-card:active {
        transform: scale(0.97) translateZ(0);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
        transition-duration: 0.08s;
    }

    /* 悬停状态保持（触摸设备不触发） */
    @media (hover: hover) and (pointer: fine) {
        .game-card:hover,
        .news-card:hover,
        .lottery-card:hover,
        .resource-card:hover {
            transform: translateY(-4px) translateZ(0);
            box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
        }
    }

    /* ========== 按钮触摸反馈 ========== */

    /* 主要按钮 */
    .btn-primary,
    .primary-btn,
    .submit-btn,
    .btn-primary-elegant {
        position: relative;
        overflow: hidden;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        will-change: transform, box-shadow;
    }

    .btn-primary:active,
    .primary-btn:active,
    .submit-btn:active,
    .btn-primary-elegant:active {
        transform: scale(0.96);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    }

    /* 次要按钮 */
    .btn-secondary,
    .secondary-btn,
    .btn-secondary-elegant {
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .btn-secondary:active,
    .secondary-btn:active,
    .btn-secondary-elegant:active {
        transform: scale(0.94);
        opacity: 0.7;
    }

    /* ========== 导航菜单增强 ========== */

    /* 汉堡菜单按钮增大触摸区域 */
    .nav-toggle {
        min-width: 48px;
        min-height: 48px;
        padding: 12px;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .nav-toggle:active {
        transform: scale(0.9);
        background: rgba(255, 255, 255, 0.95);
    }

    /* 菜单项触摸反馈优化 */
    .nav-item {
        position: relative;
        user-select: none;
        -webkit-user-select: none;
    }

    /* 移除hover效果，只保留active */
    @media (hover: none) and (pointer: coarse) {
        .nav-item:hover {
            transform: none;
            background: rgba(255, 255, 255, 0.8);
        }

        .nav-item:active {
            transform: scale(0.97);
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: #ffffff;
        }
    }

    /* ========== 输入框优化 ========== */

    /* 防止iOS自动缩放 */
    input,
    textarea,
    select {
        font-size: 16px !important;
        -webkit-appearance: none;
        appearance: none;
        border-radius: 12px;
    }

    /* 输入框聚焦效果 */
    input:focus,
    textarea:focus,
    select:focus {
        outline: none;
        border-color: #667eea;
        box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
        transform: scale(1.01);
        transition: all 0.2s ease;
    }

    /* ========== 轮播图触摸优化 ========== */

    /* 轮播图容器触摸优化 */
    .carousel-container {
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x mandatory;
        scroll-behavior: smooth;
    }

    .carousel-main {
        touch-action: pan-x;
        user-select: none;
        -webkit-user-select: none;
    }

    /* 轮播图导航按钮触摸优化 */
    .page-btn {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        backdrop-filter: blur(10px);
        background: rgba(255, 255, 255, 0.9);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        transition: all 0.2s ease;
    }

    .page-btn:active {
        transform: scale(0.85);
        background: rgba(255, 255, 255, 1);
    }

    /* ========== 模态框优化 ========== */

    /* 通用模态框移动端优化 */
    .modal {
        padding: 20px;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .modal-content {
        margin: auto;
        max-width: 95vw;
        max-height: 90vh;
        overflow-y: auto;
        border-radius: 20px;
        -webkit-overflow-scrolling: touch;
    }

    /* 模态框关闭按钮增大 */
    .modal-close,
    .close-button,
    .modal-close-elegant {
        min-width: 44px;
        min-height: 44px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 24px;
    }

    .modal-close:active,
    .close-button:active,
    .modal-close-elegant:active {
        transform: scale(0.9) rotate(90deg);
    }

    /* ========== 评论区优化 ========== */

    /* 评论输入框 */
    .comment-input,
    #comment-input,
    textarea[name="comment"] {
        font-size: 16px;
        padding: 16px;
        border-radius: 12px;
        min-height: 100px;
        resize: vertical;
    }

    /* 评论提交按钮 */
    .comment-submit-btn,
    #submit-comment {
        min-height: 48px;
        font-size: 16px;
        border-radius: 12px;
        font-weight: 600;
    }

    /* ========== 标签页/分类优化 ========== */

    /* 分类标签触摸优化 */
    .category-tab,
    .tag-item,
    .filter-tag {
        padding: 10px 20px;
        min-height: 44px;
        border-radius: 22px;
        font-size: 15px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        white-space: nowrap;
        transition: all 0.2s ease;
    }

    .category-tab:active,
    .tag-item:active,
    .filter-tag:active {
        transform: scale(0.92);
    }

    /* 横向滚动容器优化 */
    .category-tabs,
    .hot-tags,
    .tag-container {
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        scroll-behavior: smooth;
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }

    .category-tabs::-webkit-scrollbar,
    .hot-tags::-webkit-scrollbar,
    .tag-container::-webkit-scrollbar {
        display: none;
    }

    /* ========== 加载状态优化 ========== */

    /* 骨架屏/加载中状态 */
    .loading,
    .skeleton-loader {
        animation: pulse 1.5s ease-in-out infinite;
    }

    @keyframes pulse {
        0%, 100% {
            opacity: 1;
        }
        50% {
            opacity: 0.5;
        }
    }

    /* ========== 下拉刷新提示 ========== */

    /* 下拉刷新指示器（如果有） */
    .pull-to-refresh {
        position: absolute;
        top: -60px;
        left: 0;
        right: 0;
        height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #667eea;
        font-size: 14px;
        transition: transform 0.3s ease;
    }

    /* ========== 浮动操作按钮 ========== */

    /* 返回顶部按钮 */
    .back-to-top,
    .scroll-to-top {
        position: fixed;
        bottom: 24px;
        right: 24px;
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 8px 24px rgba(102, 126, 234, 0.4);
        z-index: 1000;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .back-to-top:active,
    .scroll-to-top:active {
        transform: scale(0.88);
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    }

    /* ========== 文字选择优化 ========== */

    /* 标题和按钮不可选择 */
    h1, h2, h3, h4, h5, h6,
    button, .btn,
    .nav-item, .category-tab {
        user-select: none;
        -webkit-user-select: none;
    }

    /* 正文可选择 */
    p, article, .article-content,
    .game-content, .news-content {
        user-select: text;
        -webkit-user-select: text;
    }

    /* ========== 性能优化 ========== */

    /* 使用硬件加速 */
    .game-card,
    .news-card,
    .lottery-card,
    .banner-img,
    .modal-content,
    .nav-item {
        will-change: transform;
        transform: translateZ(0);
        -webkit-transform: translateZ(0);
    }

    /* 减少重绘 */
    .game-card img,
    .news-card img,
    .banner-img {
        will-change: opacity;
        backface-visibility: hidden;
        -webkit-backface-visibility: hidden;
    }

    /* ========== 暗色模式支持 ========== */

    @media (prefers-color-scheme: dark) {
        /* 如果需要支持暗色模式，在这里添加样式 */
        /* 目前网站使用浅色主题，暂不实现 */
    }

    /* ========== 减少动画（如果用户启用） ========== */

    @media (prefers-reduced-motion: reduce) {
        * {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }

    /* ========== 游戏详情页特殊优化 ========== */

    /* 详情页图片查看器 */
    .game-content img,
    .article-content img,
    .news-content img {
        cursor: pointer;
        transition: transform 0.2s ease;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    }

    .game-content img:active,
    .article-content img:active,
    .news-content img:active {
        transform: scale(0.98);
    }

    /* 分享按钮优化 */
    .share-button,
    #share-button {
        min-height: 44px;
        padding: 12px 24px;
        border-radius: 12px;
        font-size: 15px;
        font-weight: 600;
        display: flex;
        align-items: center;
        gap: 8px;
        transition: all 0.2s ease;
    }

    .share-button:active,
    #share-button:active {
        transform: scale(0.94);
    }

    /* ========== 表单增强 ========== */

    /* 表单标签 */
    label {
        font-size: 15px;
        font-weight: 600;
        color: #2d3748;
        margin-bottom: 8px;
        display: block;
    }

    /* 表单错误提示 */
    .error-message,
    .form-error {
        font-size: 14px;
        color: #dc2626;
        margin-top: 6px;
        padding: 8px 12px;
        background: rgba(220, 38, 38, 0.1);
        border-radius: 8px;
        border-left: 3px solid #dc2626;
    }

    /* 表单成功提示 */
    .success-message,
    .form-success {
        font-size: 14px;
        color: #059669;
        margin-top: 6px;
        padding: 8px 12px;
        background: rgba(5, 150, 105, 0.1);
        border-radius: 8px;
        border-left: 3px solid #059669;
    }

    /* ========== 抽奖页面特殊优化 ========== */

    /* 抽奖按钮 */
    .lottery-participate-btn,
    .participate-btn {
        min-height: 52px;
        font-size: 17px;
        font-weight: 700;
        border-radius: 14px;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        color: white;
        box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .lottery-participate-btn:active,
    .participate-btn:active {
        transform: scale(0.96);
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
    }

    /* ========== Toast/通知优化 ========== */

    /* Toast通知 */
    .toast,
    .notification {
        position: fixed;
        bottom: 80px;
        left: 50%;
        transform: translateX(-50%);
        min-width: 280px;
        max-width: 90vw;
        padding: 16px 24px;
        background: rgba(0, 0, 0, 0.9);
        color: white;
        border-radius: 12px;
        font-size: 15px;
        text-align: center;
        z-index: 10000;
        animation: slideUpFade 0.3s ease-out;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    }

    @keyframes slideUpFade {
        from {
            opacity: 0;
            transform: translateX(-50%) translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateX(-50%) translateY(0);
        }
    }
}

/* ========== 小屏手机额外优化 (≤480px) ========== */
@media (max-width: 480px) {

    /* 字体微调 */
    body {
        font-size: 15px;
    }

    h1 { font-size: 24px; }
    h2 { font-size: 20px; }
    h3 { font-size: 18px; }
    h4 { font-size: 16px; }

    /* 间距调整 */
    .page-container {
        padding: 16px 12px;
    }

    /* 按钮稍小 */
    .btn-primary,
    .btn-secondary {
        min-height: 42px;
        padding: 10px 20px;
        font-size: 15px;
    }

    /* 卡片间距 */
    .game-card,
    .news-card,
    .lottery-card {
        margin-bottom: 12px;
    }

    /* 浮动按钮位置调整 */
    .back-to-top,
    .scroll-to-top {
        width: 48px;
        height: 48px;
        bottom: 20px;
        right: 20px;
    }
}

/* ========== 横屏优化 ========== */
@media (max-width: 768px) and (orientation: landscape) {

    /* 轮播图高度调整 */
    .carousel-main {
        height: 240px;
    }

    /* 模态框最大高度 */
    .modal-content {
        max-height: 85vh;
    }

    /* 减少垂直间距 */
    .page-container {
        padding: 16px 20px;
    }
}
