/* ============================================================
   Snake NFT Generative System — Mobile First Theme
   移动端优先样式修复 & PWA 适配
   ============================================================ */

/* --- 1. 视口与根元素 --- */
html, body {
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  font-size: 16px;
}

body {
  min-height: 100dvh;
  min-height: 100vh;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

/* --- 2. 安全区支持 --- */
.safe-bottom,
.game-bottombar,
.bottombar-bg,
.skill-bar,
nav[class*="bottom"],
footer[class*="action"] {
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
}

.safe-top,
.game-topbar,
.topbar-bg,
header[class*="top"] {
  padding-top: calc(8px + env(safe-area-inset-top, 0px));
}

/* --- 3. 触摸友好的最小尺寸 --- */
button,
.btn,
[role="button"],
.nav-item,
.icon-btn,
.action-btn,
.skill-btn,
.event-btn,
a.nav-item,
a[class*="btn"],
input[type="submit"],
input[type="button"] {
  min-width: 44px;
  min-height: 44px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.icon-btn,
button[class*="icon"] {
  width: 44px !important;
  height: 44px !important;
  min-width: 44px;
  min-height: 44px;
}

/* --- 4. 防止表单聚焦自动缩放 --- */
input,
select,
textarea {
  font-size: 16px !important;
  touch-action: manipulation;
}

/* --- 5. 选中文本颜色 --- */
::selection {
  background: rgba(167, 139, 250, 0.4);
  color: #fff;
}

/* --- 6. 移动端隐藏滚动条 --- */
@media (max-width: 768px) {
  ::-webkit-scrollbar {
    display: none;
    width: 0;
    height: 0;
  }
  * {
    scrollbar-width: none;
  }
}

/* --- 7. 竖屏方向适配 --- */
@media (orientation: portrait) and (max-width: 768px) {
  .skill-buttons {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 12px !important;
    padding: 12px !important;
  }

  .skill-btn {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
  }

  .game-sidenav,
  .sidenav-bg {
    display: none !important;
  }

  .game-main {
    width: 100% !important;
    margin: 0 !important;
    padding: 12px !important;
  }

  .game-rightpanel {
    width: 100% !important;
    margin: 0 !important;
    padding: 12px !important;
  }

  .game-bottombar,
  .bottombar-bg {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
  }

  .action-btn {
    min-width: calc(50% - 8px) !important;
    min-width: 44px;
    flex: 1 1 calc(50% - 8px);
    padding: 12px 16px;
    font-size: 13px;
  }

  .resource-pill {
    font-size: 11px;
    padding: 4px 10px;
  }

  .snake-image-container {
    max-width: 280px !important;
  }

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

  .stat-item {
    min-width: unset;
    padding: 8px 12px;
  }
}

/* --- 8. 超小屏幕 --- */
@media (max-width: 360px) {
  html, body {
    font-size: 14px;
  }
  .action-btn {
    font-size: 11px;
    padding: 10px 8px;
  }
}

/* --- 9. iOS Safari 修复 --- */
@supports (-webkit-touch-callout: none) {
  body {
    background-color: #0a0718;
  }
  .hud-card,
  .panel-card {
    -webkit-backdrop-filter: blur(12px);
  }
}

/* --- 10. 暗色模式 --- */
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
  }
}
