/* ============================================
   移动端专业UI设计 - Mobile Pro Design
   ============================================ */

/* ========== 基础移动端适配 ========== */
@media (max-width: 768px) {
  /* 底部导航栏 */
  .header {
    position: fixed;
    bottom: 0;
    top: auto;
    height: 56px;
    padding: 0 8px;
    background: rgba(15, 10, 30, 0.98);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    border-bottom: none;
    z-index: 1000;
  }

  .header-left .logo-small {
    display: none;
  }

  .header-center {
    flex: 1;
  }

  .main-nav {
    display: flex;
    justify-content: space-around;
    gap: 0;
    width: 100%;
  }

  .nav-link {
    padding: 6px 4px;
    font-size: 0.65rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
  }

  .nav-link::before {
    content: '';
    font-size: 1.1rem;
  }

  .nav-link[data-page="home"]::before { content: '🏠'; }
  .nav-link[data-page="games"]::before { content: '🎮'; }
  .nav-link[data-page="sports"]::before { content: '⚽'; }
  .nav-link[data-page="leaderboard"]::before { content: '🏆'; }

  .header-right {
    gap: 4px;
  }

  .user-points {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .user-menu {
    display: none;
  }

  /* 页面内容区域 */
  .section {
    padding: 10px;
    padding-bottom: 66px;
  }

  /* 登录页面 - 全屏显示，隐藏导航 */
  #login-page {
    position: fixed !important;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom);
  }

  #login-page ~ .header,
  #login-page + .header {
    display: none !important;
  }

  body.login-active .header {
    display: none !important;
  }

  body.login-active {
    overflow: hidden;
  }

  .login-container {
    padding: 16px 14px;
    margin: 12px;
    max-width: none;
    width: calc(100% - 24px);
    min-height: calc(100vh - 80px);
  }

  .logo h1 {
    font-size: 1.3rem;
  }

  .logo p {
    font-size: 0.7rem;
  }

  .login-tabs {
    gap: 4px;
  }

  .tab-btn {
    padding: 9px 6px;
    font-size: 0.75rem;
    flex: 1;
    min-width: 65px;
  }

  .tab-content {
    padding: 10px 0;
  }

  .form-group {
    margin-bottom: 10px;
  }

  .form-group label {
    font-size: 0.8rem;
    margin-bottom: 3px;
  }

  .form-group input {
    padding: 10px 12px;
    font-size: 16px;
    border-radius: 8px;
  }

  .btn-large {
    padding: 12px 18px;
    font-size: 0.9rem;
    width: 100%;
  }

  .login-footer {
    margin-top: 12px;
    font-size: 0.65rem;
  }

  /* 用户统计栏 - 超紧凑 */
  .user-stats-bar {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding: 8px;
    margin: -10px -10px 10px -10px;
    scrollbar-width: none;
  }

  .user-stats-bar::-webkit-scrollbar {
    display: none;
  }

  .stat-card {
    flex: 0 0 auto;
    min-width: 60px;
    padding: 6px 8px;
    border-radius: 8px;
  }

  .stat-icon {
    font-size: 1rem;
    margin-bottom: 1px;
  }

  .stat-value {
    font-size: 0.85rem;
  }

  .stat-label {
    font-size: 0.5rem;
  }

  /* 区块标题 - 紧凑 */
  .section-header {
    margin-bottom: 8px;
    padding: 0;
  }

  .section-header h2 {
    font-size: 0.88rem;
  }

  .section-header h2 .icon {
    font-size: 0.95rem;
  }

  .view-all {
    font-size: 0.65rem;
    padding: 4px 7px;
  }

  /* 热门赛事列表 - 紧凑 */
  .hot-events-list {
    gap: 5px;
  }

  .hot-event-item {
    padding: 7px 8px;
    border-radius: 7px;
  }

  .hot-event-item .match-time {
    font-size: 0.6rem;
    min-width: 40px;
  }

  .hot-event-item .teams {
    font-size: 0.7rem;
    gap: 3px;
  }

  .hot-event-item .odds {
    font-size: 0.75rem;
    padding: 2px 5px;
    min-width: 40px;
  }

  /* 游戏快速入口 - 紧凑 */
  .games-quick-grid {
    display: flex;
    gap: 5px;
    overflow-x: auto;
    padding: 3px;
    margin: 0 -10px;
    padding-left: 10px;
    padding-right: 10px;
    scrollbar-width: none;
  }

  .games-quick-grid::-webkit-scrollbar {
    display: none;
  }

  .game-quick-card {
    flex: 0 0 auto;
    width: 88px;
    padding: 8px;
    border-radius: 8px;
  }

  .game-bg {
    font-size: 1.6rem;
    margin-bottom: 4px;
  }

  .game-content h4 {
    font-size: 0.75rem;
    margin-bottom: 1px;
  }

  .game-content p {
    font-size: 0.55rem;
  }

  /* 双栏布局改为单栏 - 紧凑 */
  .home-split-layout {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* 游戏卡片网格 - 单列超紧凑 */
  .games-grid-modern {
    grid-template-columns: 1fr;
    gap: 7px;
  }

  .game-card-modern {
    border-radius: 8px;
    padding: 8px;
    display: grid;
    grid-template-columns: 60px 1fr;
    gap: 8px;
    align-items: center;
  }

  .card-visual {
    height: 60px;
    width: 60px;
    border-radius: 7px;
  }

  .game-emoji-large {
    font-size: 1.6rem;
  }

  .card-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .card-content h3 {
    font-size: 0.78rem;
    margin-bottom: 1px;
  }

  .card-content p {
    font-size: 0.6rem;
    margin-bottom: 3px;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  .game-tags {
    gap: 2px;
    margin-bottom: 3px;
  }

  .tag {
    padding: 1px 4px;
    font-size: 0.5rem;
  }

  .game-meta {
    gap: 5px;
    margin-bottom: 0;
  }

  .meta-item {
    font-size: 0.5rem;
    gap: 2px;
  }

  .game-btn-modern {
    display: none;
  }

  /* 游戏弹窗 - 全屏模式 */
  .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1500;
    align-items: stretch;
    justify-content: stretch;
  }

  .game-modal {
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }

  .modal-header {
    padding: 10px 14px;
    min-height: 44px;
    flex-shrink: 0;
  }

  .modal-header h2 {
    font-size: 0.9rem;
  }

  .modal-header .game-icon {
    width: 28px;
    height: 28px;
    font-size: 1rem;
  }

  .modal-close {
    width: 30px;
    height: 30px;
    font-size: 1.1rem;
  }

  .modal-body {
    padding: 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
  }

  .game-info-compact {
    padding: 10px;
    margin-bottom: 10px;
  }

  .game-info-compact h3 {
    font-size: 0.9rem;
  }

  .game-info-compact p {
    font-size: 0.7rem;
  }

  /* 轮盘游戏 - 超紧凑全屏适配 */
  .roulette-premium {
    padding: 6px;
  }

  .roulette-layout {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .wheel-section {
    padding: 8px;
    text-align: center;
  }

  .wheel-container {
    width: 120px;
    height: 120px;
    margin: 0 auto;
  }

  .wheel-plate {
    width: 75px;
    height: 75px;
  }

  .wheel-arrow {
    font-size: 0.9rem;
    top: -15px;
  }

  .wheel-result-text {
    font-size: 0.75rem;
  }

  .rboard-section {
    padding: 6px;
  }

  .rboard-row-numbers {
    grid-template-columns: repeat(7, 1fr);
    gap: 2px;
  }

  .rb-num {
    height: 24px;
    font-size: 0.55rem;
    border-radius: 3px;
  }

  .rb-zero {
    height: 24px;
    font-size: 0.55rem;
  }

  .outside-bets-premium {
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
  }

  .ob-btn {
    padding: 5px 2px;
    font-size: 0.55rem;
    min-height: 28px;
  }

  .bet-controls-compact {
    padding: 8px;
    gap: 6px;
  }

  .bet-amount-display {
    font-size: 1rem;
    padding: 5px 10px;
  }

  .chip-selector {
    gap: 3px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .chip {
    width: 28px;
    height: 28px;
    font-size: 0.55rem;
  }

  .game-actions-compact {
    gap: 5px;
    flex-wrap: wrap;
    justify-content: center;
  }

  .game-actions-compact .btn {
    padding: 7px 12px;
    font-size: 0.75rem;
    min-height: 32px;
    flex: 1;
    min-width: 70px;
  }

  /* 二十一点 - 紧凑 */
  .bj-premium {
    padding: 6px;
  }

  .bj-table-premium {
    padding: 8px 6px;
  }

  .bj-cards-area {
    min-height: 50px;
  }

  .poker-card {
    width: 32px;
    height: 46px;
  }

  .card-rank {
    font-size: 8px;
  }

  .card-suit-sm {
    font-size: 6px;
  }

  .card-center {
    font-size: 13px;
  }

  .bj-actions-premium {
    flex-wrap: wrap;
    gap: 5px;
  }

  .bj-action-btn {
    padding: 7px 10px;
    font-size: 0.75rem;
    min-height: 32px;
    flex: 1;
    min-width: 60px;
  }

  /* 百家乐 - 紧凑 */
  .bac-premium {
    padding: 6px;
  }

  .bac-table-premium {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 8px;
  }

  .bac-cards-area {
    min-height: 50px;
  }

  .bac-options-premium {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .bacp-opt-btn {
    flex-direction: column;
    justify-content: center;
    padding: 8px 4px;
  }

  .bacp-opt-btn .opt-icon {
    font-size: 1.2rem;
  }

  .bacp-opt-btn .opt-text strong {
    font-size: 0.75rem;
  }

  /* 德州扑克 - 紧凑 */
  .pk-premium {
    padding: 6px;
  }

  .pk-table-premium {
    padding: 8px 6px;
  }

  .pkp-players {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .pk-cards-area {
    min-height: 50px;
  }

  .action-buttons-pk {
    grid-template-columns: repeat(2, 1fr);
    gap: 5px;
  }

  .action-btn-pk {
    padding: 8px 5px;
    font-size: 0.75rem;
    min-height: 34px;
  }

  /* 体育竞猜 */
  .sports-header-modern {
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
  }

  .header-left h2 {
    font-size: 1rem;
  }

  .header-left p {
    font-size: 0.7rem;
  }

  .sports-filter-modern {
    padding: 6px 10px;
    gap: 6px;
  }

  .filter-btn {
    padding: 5px 10px;
    font-size: 0.75rem;
    min-height: 32px;
  }

  .filter-btn .icon {
    font-size: 0.85rem;
  }

  .combo-info {
    padding: 10px;
    margin: 10px 12px;
  }

  .combo-info h4 {
    font-size: 0.85rem;
  }

  .combo-info p {
    font-size: 0.7rem;
  }

  .events-container-modern {
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 0 10px;
  }

  .event-card-modern {
    padding: 10px;
    border-radius: 10px;
  }

  .event-header {
    margin-bottom: 8px;
    padding-bottom: 6px;
  }

  .league-name {
    font-size: 0.7rem;
  }

  .match-time {
    font-size: 0.65rem;
  }

  .teams-row {
    flex-direction: row;
    gap: 6px;
    margin-bottom: 8px;
  }

  .team {
    flex: 1;
    padding: 6px;
  }

  .team-name {
    font-size: 0.8rem;
  }

  .vs-divider {
    transform: none;
    font-size: 0.7rem;
    padding: 3px 6px;
  }

  .odds-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 5px;
  }

  .odds-btn {
    padding: 6px 3px;
    min-height: 40px;
  }

  .odds-btn .label {
    font-size: 0.6rem;
  }

  .odds-btn .value {
    font-size: 0.8rem;
  }

  /* 排行榜 */
  .leaderboard-header-modern {
    flex-direction: column;
    gap: 6px;
    padding: 10px 12px;
  }

  .leaderboard-header-modern h2 {
    font-size: 1rem;
  }

  .leaderboard-header-modern p {
    font-size: 0.7rem;
  }

  .leaderboard-grid {
    grid-template-columns: 1fr;
    gap: 6px;
    padding: 0 10px;
  }

  .leaderboard-item {
    padding: 8px 10px;
    border-radius: 8px;
  }

  .rank-number {
    width: 24px;
    height: 24px;
    font-size: 0.75rem;
  }

  .player-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.85rem;
  }

  .player-info .username {
    font-size: 0.8rem;
  }

  .player-rank-title {
    font-size: 0.65rem;
  }

  .points-display {
    font-size: 0.85rem;
  }

  .points-label {
    font-size: 0.55rem;
  }

  /* 个人资料 */
  .profile-header {
    padding: 16px;
  }

  .profile-avatar {
    width: 70px;
    height: 70px;
    font-size: 2rem;
  }

  .profile-name {
    font-size: 1.2rem;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  /* 历史记录 */
  .history-filters {
    flex-wrap: wrap;
    gap: 6px;
  }

  .history-filters select,
  .history-filters input {
    width: 100%;
  }

  .history-table {
    font-size: 0.75rem;
  }

  .history-table th,
  .history-table td {
    padding: 8px 6px;
  }

  /* 结果展示 */
  .result-display-premium {
    padding: 12px;
  }

  .rdp-content {
    padding: 8px 12px;
    gap: 8px;
  }

  .rdp-icon {
    font-size: 1.3rem;
  }

  .rdp-text {
    font-size: 0.8rem;
  }

  /* Toast通知 */
  #toast-container {
    left: 10px;
    right: 10px;
    top: 10px;
    bottom: auto;
  }
}

/* ========== 安全区域适配 (iPhone X+) ========== */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .header {
    padding-bottom: env(safe-area-inset-bottom);
  }

  .section {
    padding-bottom: calc(66px + env(safe-area-inset-bottom));
  }

  #login-page {
    padding-bottom: env(safe-area-inset-bottom);
  }
}

/* ========== Safari 特定修复 ========== */
@supports (-webkit-touch-callout: none) {
  #login-page {
    min-height: -webkit-fill-available;
  }

  .login-container {
    -webkit-overflow-scrolling: touch;
    overflow-y: auto;
  }

  .tab-btn,
  .btn,
  .nav-link,
  button,
  input,
  a {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
  }

  input,
  textarea {
    -webkit-user-select: text;
    user-select: text;
  }

  .tab-btn,
  .btn,
  button {
    -webkit-appearance: none;
    appearance: none;
    border: none;
    background: transparent;
  }

  input {
    -webkit-appearance: none;
    appearance: none;
    border-radius: 10px;
  }

  .tab-btn,
  .btn-large {
    cursor: pointer;
    position: relative;
    z-index: 1;
  }
}
