/**
 * 响应式设计
 */

/* ========== 移动优先断点 ========== */

/* 超小屏幕 (手机 320px+) */
@media screen and (min-width: 320px) {
  html {
    font-size: 15px;
  }
  
  .container {
    padding: 0 12px;
  }
  
  .card {
    padding: 16px;
    margin: 12px;
    border-radius: var(--radius-md);
  }
  
  .btn {
    padding: 10px 20px;
    font-size: 14px;
  }
}

/* 小屏幕 (手机 375px+) */
@media screen and (min-width: 375px) {
  html {
    font-size: 16px;
  }
  
  .container {
    padding: 0 16px;
  }
  
  .card {
    padding: 20px;
    margin: 16px;
    border-radius: var(--radius-lg);
  }
  
  .qimen-palace {
    gap: 6px;
    padding: 10px;
  }
  
  .palace-cell {
    min-height: 80px;
  }
}

/* 中等屏幕 (手机 414px+) */
@media screen and (min-width: 414px) {
  .card {
    padding: 24px;
  }
  
  .qimen-palace {
    gap: 8px;
    padding: 12px;
  }
  
  .palace-cell {
    min-height: 85px;
  }
}

/* ========== 平板断点 ========== */

/* 平板竖屏 (768px+) */
@media screen and (min-width: 768px) {
  html {
    font-size: 17px;
  }
  
  body {
    background: #1a1a2e;
    padding: 20px 0;
  }
  
  .phone-container {
    max-width: 414px;
    margin: 0 auto;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    min-height: calc(100vh - 40px);
    overflow-y: auto;
  }
  
  .tab-bar {
    max-width: 414px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  }
  
  .header {
    padding: calc(var(--safe-top) + 60px) 24px 24px;
  }
}

/* 平板横屏 */
@media screen and (min-width: 768px) and (orientation: landscape) {
  body {
    padding: 10px 0;
  }
  
  .phone-container {
    max-width: 736px;
    min-height: auto;
    max-height: calc(100vh - 20px);
  }
}

/* ========== 桌面断点 ========== */

/* 小桌面 (1024px+) */
@media screen and (min-width: 1024px) {
  body {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 40px 0;
  }
  
  .phone-container {
    max-width: 430px;
    margin: 0 auto;
    max-height: calc(100vh - 80px);
  }
  
  /* 桌面端居中显示 */
  .phone-container::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    pointer-events: none;
    z-index: -1;
  }
}

/* 中桌面 (1280px+) */
@media screen and (min-width: 1280px) {
  .phone-container {
    max-width: 450px;
  }
}

/* 大桌面 (1440px+) */
@media screen and (min-width: 1440px) {
  .phone-container {
    max-width: 480px;
  }
}

/* ========== 特殊适配 ========== */

/* iPhone SE (320px) */
@media screen and (max-width: 374px) {
  .header-title {
    font-size: 18px;
  }
  
  .card-title {
    font-size: 16px;
  }
  
  .coin {
    width: 70px !important;
    height: 70px !important;
  }
  
  .palace-cell {
    padding: 6px 4px !important;
    min-height: 70px !important;
  }
  
  .palace-icon {
    font-size: 20px !important;
  }
  
  .palace-star {
    font-size: 10px !important;
  }
}

/* iPhone 12/13/14 (390px+) */
@media screen and (min-width: 390px) {
  .card {
    margin: 16px;
  }
}

/* iPhone Plus/Max (414px+) */
@media screen and (min-width: 414px) {
  .container {
    padding: 0 20px;
  }
}

/* ========== 横屏适配 ========== */
@media screen and (orientation: landscape) and (max-height: 500px) {
  .header {
    padding: calc(var(--safe-top) + 30px) 20px 12px;
  }
  
  .card {
    padding: 12px 16px;
    margin: 8px 16px;
  }
  
  .tab-bar {
    padding: 6px 0 calc(var(--safe-bottom) + 6px);
  }
  
  .qimen-palace {
    max-height: 180px;
  }
  
  .coin {
    width: 60px !important;
    height: 60px !important;
  }
}

/* ========== 安全区域适配 ========== */
@supports (padding: env(safe-area-inset-top)) {
  .header {
    padding-top: calc(env(safe-area-inset-top) + 50px);
  }
  
  .tab-bar {
    padding-bottom: calc(env(safe-area-inset-bottom) + 8px);
  }
}

/* ========== 打印样式 ========== */
@media print {
  .tab-bar,
  .header-actions,
  .btn,
  .lang-switch {
    display: none !important;
  }
  
  body {
    background: white;
  }
  
  .phone-container {
    max-width: 100%;
    box-shadow: none;
  }
  
  .card {
    break-inside: avoid;
    margin: 8px 0;
  }
}

/* ========== 深色模式（可选） ========== */
@media (prefers-color-scheme: dark) {
  /* 预留深色模式适配 */
}

/* ========== 无障碍 ========== */

/* 减少动画 */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* 高对比度 */
@media (prefers-contrast: high) {
  :root {
    --primary: #a03040;
    --accent: #b8962e;
    --text-primary: #000000;
    --text-secondary: #333333;
    --divider: #666666;
  }
}

/* ========== 触摸设备优化 ========== */
@media (hover: none) and (pointer: coarse) {
  /* 移除hover效果 */
  .palace-cell:hover {
    background: rgba(255, 255, 255, 0.05);
  }
  
  /* 增大触摸目标 */
  .btn {
    min-height: 44px;
  }
  
  .tab-item {
    min-height: 44px;
  }
}

/* ========== 鼠标设备优化 ========== */
@media (hover: hover) and (pointer: fine) {
  .palace-cell:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.02);
  }
  
  .btn:hover {
    opacity: 0.9;
  }
  
  .card:hover {
    box-shadow: var(--shadow-md);
  }
}
