/* 移动端优化和触摸设备样式 */

/* 触摸反馈效果 */
.touch-active {
    opacity: 0.7;
    transform: scale(0.98);
    transition: all 0.1s ease;
}

/* 游戏棋盘触摸高亮 */
.cell-hover {
    background-color: rgba(74, 144, 226, 0.2) !important;
    box-shadow: inset 0 0 0 2px var(--primary-color);
}

/* 移动端通用优化 */
@media (max-width: 768px) {
    /* 增大触摸目标尺寸 */
    .game-btn, .btn, .game-button {
        min-height: 44px;
        padding: 12px 16px;
        font-size: 16px;
    }
    
    /* 游戏棋盘单元格最小触摸尺寸 */
    .chess-cell, .sudoku-cell, .tiaoqi-grid {
        min-width: 30px;
        min-height: 30px;
    }
    
    /* 侧边栏优化 */
    .game-sidebar {
        width: 100%;
        padding: 10px;
        margin-top: 20px;
    }
    
    /* 游戏容器改为垂直布局 */
    .game-container {
        flex-direction: column;
        padding: 10px;
    }
    
    /* 游戏控制按钮网格布局 */
    .game-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    /* 游戏信息卡片 */
    .game-info {
        margin-bottom: 15px;
        border-radius: 8px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    }
    
    /* 输入框优化 */
    input[type="text"], input[type="number"] {
        font-size: 16px; /* 防止iOS缩放 */
        padding: 12px;
        border-radius: 8px;
        border: 1px solid var(--border-color);
    }
    
    /* 导航菜单优化 */
    .nav {
        padding: 8px 12px;
    }
    
    .nav-menu {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }
    
    .nav-menu::-webkit-scrollbar {
        display: none; /* Safari, Chrome */
    }
    
    .nav-item {
        white-space: nowrap;
    }
    
    .nav-link {
        padding: 10px 12px;
    }
    
    /* 游戏卡片网格 */
    .game-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        padding: 15px;
    }
    
    /* 游戏卡片 */
    .game-card {
        margin-bottom: 0;
    }
    
    .game-card-image {
        height: 120px;
    }
    
    .game-card-body {
        padding: 12px;
    }
    
    /* 模态框优化 */
    .modal-content, .game-modal-content {
        width: 95%;
        max-width: none;
        margin: 20px auto;
    }
    
    /* 排行榜样式 */
    .ranking-item {
        padding: 12px;
    }
    
    /* 首页英雄区域 */
    .hero {
        padding: 40px 15px;
    }
    
    .hero-content {
        text-align: center;
    }
    
    .hero-title {
        font-size: 28px;
        margin-bottom: 15px;
    }
    
    .hero-description {
        font-size: 16px;
    }
}

/* 超小屏幕优化 */
@media (max-width: 480px) {
    /* 游戏棋盘尺寸调整 */
    .chess-board {
        width: 280px;
        height: 280px;
    }
    
    .sudoku-board {
        width: 280px;
        height: 280px;
    }
    
    .tiaoqi-board {
        width: 280px;
        height: 280px;
    }
    
    .sudoku-cell {
        width: 31px;
        height: 31px;
        font-size: 14px;
    }
    
    .chess-cell {
        width: 18.67px;
        height: 18.67px;
    }
    
    .chess-piece {
        width: 16px;
        height: 16px;
    }
    
    /* 游戏网格单列显示 */
    .game-grid {
        grid-template-columns: 1fr;
        padding: 10px;
        gap: 15px;
    }
    
    /* 游戏卡片 */
    .game-card-image {
        height: 150px;
    }
    
    /* 导航菜单 */
    .logo {
        font-size: 18px;
    }
    
    .nav-link {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    /* 页面标题 */
    h1 {
        font-size: 24px;
    }
    
    /* 游戏控制按钮 */
    .game-controls {
        grid-template-columns: 1fr;
    }
    
    /* 用户输入框 */
    .username-input {
        width: 100%;
    }
    
    /* 分页按钮 */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    .page-btn {
        margin: 3px;
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .game-container {
        flex-direction: row;
        padding: 10px;
    }
    
    .game-sidebar {
        width: 300px;
        flex-shrink: 0;
        margin-top: 0;
    }
    
    .hero {
        padding: 20px 15px;
    }
    
    .hero-title {
        font-size: 24px;
    }
}

/* 添加PWA安装按钮样式 */
.pwa-install {
    margin-top: 10px;
    text-align: center;
}

#install-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s;
}

#install-btn:hover {
    background-color: var(--primary-hover);
}

/* 全屏按钮样式已添加在pwa-touch.js中 */

/* 键盘弹出时的优化 */
@media (max-height: 500px) and (orientation: landscape) {
    .game-sidebar {
        display: none;
    }
    
    .game-container {
        justify-content: center;
    }
    
    .game-board-container {
        height: 80vh;
    }
}