/* 手机布局（CHG-332）：只在 html.layout-mobile 下生效（js/platform/device.js：触屏且屏幕短边 < 600px，或 ?mobile=1）。
   PC 与平板（layout-pc）不读这里的任何规则；在这里改手机布局不会影响 PC。
   每条规则都用 :where(.layout-mobile) 作用域，不增加选择器优先级；本文件在 style.css、touch.css 之后加载。 */
@media (max-height: 520px) {
  :where(.layout-mobile) .settings-card .veil-text { margin-bottom: 6px; font-size: 17px; }
  :where(.layout-mobile) .settings-list { gap: 5px; }
  :where(.layout-mobile) .settings-row { min-height: 34px; padding: 2px 12px; }
  :where(.layout-mobile) .settings-note { margin: 4px 0 2px; }
}

@media (max-width: 720px), (max-height: 520px) {
  :where(.layout-mobile) .pill { min-width: 120px; min-height: 36px; padding: 0 20px; font-size: 14px; letter-spacing: .08em; display: inline-flex; align-items: center; justify-content: center; }
  :where(.layout-mobile) .hud { padding: 12px 14px 0; }
  :where(.layout-mobile) .hud-score { font-size: 32px; }
  :where(.layout-mobile) .hud-title { font-size: 14px; }
  :where(.layout-mobile) .guide-grid { grid-template-columns: 1fr; }
}
@media (max-height: 520px) {
  :where(.layout-mobile) .start .logo { top: 20%; font-size: clamp(28px, min(13vw, 10vh), 52px); }
  /* CHG-330：模式页在矮屏上改为从上到下的普通排版（不再各自按百分比绝对定位）——
     宽而矮的窗口里卡片按宽度放大后会压到按钮上、标题会压到顶部的课程咨询文字（用户截图）。
     课程文字 → 标题 → 卡片 → 按钮依次排列，卡片宽度按屏高限定，任何宽高比下都不会互相重叠。 */
  :where(.layout-mobile) .mode { justify-content: center; gap: clamp(6px, 2.4vh, 14px); padding: calc(var(--safe-top) + 34px) 16px calc(var(--safe-bottom) + 12px); }
  :where(.layout-mobile) .mode .course-contact { top: calc(var(--safe-top) + 8px); font-size: 12px; }
  :where(.layout-mobile) .mode .logo, :where(.layout-mobile) .mode-cards, :where(.layout-mobile) .mode .mode-actions { position: relative; top: auto; bottom: auto; left: auto; transform: none; }
  :where(.layout-mobile) .mode .logo { font-size: clamp(24px, 9vh, 40px); }
  :where(.layout-mobile) .mode-cards { flex: none; }
  :where(.layout-mobile) .mode-card { width: clamp(110px, 38vh, 190px); padding: 8px; }
  :where(.layout-mobile) .mode-thumb { aspect-ratio: 2 / 1; margin-bottom: 4px; }
  :where(.layout-mobile) .mode-card b { font-size: clamp(14px, 4.4vh, 18px); }
  :where(.layout-mobile) .mode-card small { font-size: 11px; }
  :where(.layout-mobile) .mode .mode-actions { flex: none; }
  :where(.layout-mobile) .mode .start-tip { display: none; }
}
@media (max-width: 560px) and (min-height: 521px) {
  :where(.layout-mobile) .mode, :where(.layout-mobile) .guide { --course-contact-top: calc(var(--safe-top) + 32px); }
  :where(.layout-mobile) .mode-cards { flex-direction: column; top: 30%; gap: 10px; }
  :where(.layout-mobile) .mode-card { width: min(78vw, 300px); display: grid; grid-template-columns: 40% 1fr; column-gap: 12px; align-items: center; justify-items: start; border-radius: 18px; }
  :where(.layout-mobile) .mode-card::after { border-radius: 22px; }
  :where(.layout-mobile) .mode-thumb { grid-row: 1 / 3; margin: 0; }
  :where(.layout-mobile) .mode-card b { align-self: end; font-size: 18px; }
  :where(.layout-mobile) .mode-card small { align-self: start; font-size: 12px; }
  :where(.layout-mobile) .mode .mode-actions { top: auto; bottom: 64px; }
}
@media (max-height: 400px) {
  :where(.layout-mobile) .start-tip { font-size: 11px; padding: 4px 10px; }
}

/* 窄竖屏保留中间分数与两侧控件的空间。 */
@media (max-width: 420px) {
  :where(.layout-mobile) .hud-title { font-size: 12px; letter-spacing: .12em; white-space: nowrap; }
  :where(.layout-mobile) .hud-score { font-size: clamp(24px, 7vw, 28px); }
  :where(.layout-mobile) .hud-right { gap: 6px; }
}

/* 短横屏手机（CHG-327 → CHG-329）：标题在上，按钮竖排在标题下方（用户 2026-11-24：主页与结算页按钮保持竖排）；
   三个按钮各 40px，最矮的 375px 屏也放得下。 */
@media (max-height: 520px) and (orientation: landscape) {
  :where(.layout-mobile) .start .nick { top: calc(4px + var(--safe-top)); padding: 6px 12px; font-size: 12px; }
  :where(.layout-mobile) .start .logo { top: 14%; color: var(--olive-deep); text-shadow: 0 1px 0 rgba(255, 255, 255, .55), 0 4px 10px rgba(60, 80, 30, .18); font-size: clamp(26px, min(9vw, 12vh), 48px); }
  :where(.layout-mobile) .start .menu { top: auto; bottom: calc(10% + var(--safe-bottom)); gap: 8px; }
  :where(.layout-mobile) .start .menu .pill { min-width: 136px; padding: 0 22px; font-size: 14px; letter-spacing: .08em; }
  :where(.layout-mobile) .start .account-status, :where(.layout-mobile) .start-tip, :where(.layout-mobile) .start .menu-whale-notice { display: none; }
  /* 结算页：分数缩小、间距收紧，三个按钮竖排后整张卡片落在屏内。 */
  :where(.layout-mobile) .over .over-label { font-size: 14px; }
  :where(.layout-mobile) .over .over-score { font-size: clamp(52px, 16vh, 76px); text-shadow: 0 3px 0 rgba(141, 162, 0, .15); }
  :where(.layout-mobile) .over .over-stats { margin: 2px 0 4px; }
  :where(.layout-mobile) .over .over-cause { margin-bottom: 8px; font-size: 13px; }
  :where(.layout-mobile) .over .platform-status:empty { display: none; }
  :where(.layout-mobile) .over .menu { gap: 8px; }
  :where(.layout-mobile) .over .menu .pill { min-width: 140px; padding: 0 22px; font-size: 14px; }
}
@media (max-width: 700px), (max-height: 560px) {
  :where(.layout-mobile) .replay-layer { padding: 0; }
  :where(.layout-mobile) .replay-panel { width: 100%; height: 100%; border-radius: 0; }
  :where(.layout-mobile) .replay-close { top: 8px; left: 8px; }
}

/* ---------- CHG-332 第 2 步：手机按钮规格 ----------
   依据：Android Material 触摸目标 ≥ 48dp、iOS HIG 点击区域 ≥ 44pt；两者都允许“看得见的按钮”比触摸区域小。
   做法：可见尺寸统一缩小（文字按钮 36px 高、14px 字；图标按钮 36px；分段/页签 32px），
        再用透明的 ::before 把每个可点区域向外扩到 ≥ 44px（不改变外观与排版）。
   替代 CHG-329 的“按钮最小 40px 高”。 */
:where(.layout-mobile) .pill::before,
:where(.layout-mobile) .icon-btn::before,
:where(.layout-mobile) .menu-settings::before,
:where(.layout-mobile) .menu-fullscreen::before,
:where(.layout-mobile) .settings-seg button::before,
:where(.layout-mobile) .rank-tabs button::before,
:where(.layout-mobile) .rank-play::before,
:where(.layout-mobile) .platform-action::before { content: ""; position: absolute; }
/* 文字按钮：可见 36px；上下各扩 4px → 44px（竖排间距 8px，相邻按钮的触摸区刚好相接、不重叠）。 */
:where(.layout-mobile) .pill::before { inset: -4px -2px; }
/* 图标按钮：可见 36px，图标 20px；四周扩 4px → 44px。 */
:where(.layout-mobile) .mobile-device .hud .icon-btn, :where(.layout-mobile) .mobile-device .menu-settings, :where(.layout-mobile) .mobile-device .menu-fullscreen { width: 36px; height: 36px; }
:where(.layout-mobile) .icon-btn, :where(.layout-mobile) .hud .hud-settings { position: relative; }
/* HUD 里的齿轮复用主页齿轮类名，清掉主页的绝对定位偏移，否则 relative 会让它错位。 */
:where(.layout-mobile) .mobile-device .hud .hud-settings { inset: auto; }
:where(.layout-mobile) .icon-btn::before, :where(.layout-mobile) .menu-settings::before, :where(.layout-mobile) .menu-fullscreen::before { inset: -4px; border-radius: 50%; }
:where(.layout-mobile) .hud .icon-btn svg, :where(.layout-mobile) .hud .hud-settings svg { width: 20px; height: 20px; }
:where(.layout-mobile) .hud-right { gap: 10px; }
:where(.layout-mobile) .mobile-device .menu-settings { top: calc(4px + var(--safe-top)); right: max(10px, var(--safe-right)); }
:where(.layout-mobile) .mobile-device .menu-fullscreen { top: calc(4px + var(--safe-top)); right: calc(max(10px, var(--safe-right)) + 46px); }
:where(.layout-mobile) .menu-settings svg { width: 20px; height: 20px; }
:where(.layout-mobile) .menu-fullscreen svg { width: 17px; height: 17px; }
/* 设置页：分段选项可见 32px，上下扩 6px → 44px；行高 44px；课程链接整行高 44px；滑块圆点放大到 24px。 */
:where(.layout-mobile) .settings-row { min-height: 44px; padding: 0 12px; }
:where(.layout-mobile) .settings-seg button { position: relative; min-height: 32px; padding: 0 10px; font-size: 13px; }
:where(.layout-mobile) .settings-seg button::before { inset: -6px 0; }
:where(.layout-mobile) .settings-link { display: inline-flex; align-items: center; min-height: 44px; font-size: 14px; }
:where(.layout-mobile) .settings-input { height: 34px; font-size: 14px; }
/* 滑块：可见轨道仍是 6px 细条，元素本身 44px 高（背景只画中间 6px），整条都能按住拖动。 */
:where(.layout-mobile) .settings-range { height: 44px; background: linear-gradient(rgba(141, 162, 0, .22), rgba(141, 162, 0, .22)) center / 100% 6px no-repeat; border-radius: 0; }
:where(.layout-mobile) .settings-range::-webkit-slider-thumb { width: 24px; height: 24px; }
:where(.layout-mobile) .settings-range::-moz-range-thumb { width: 22px; height: 22px; }
/* 设置卡片底部给“完成”按钮的扩展触摸区留出位置。 */
:where(.layout-mobile) .mobile-device .settings-card { padding-bottom: 6px; }
/* 排行榜：页签 32px（外框 40px）、扩到 44px；回放小圆键可见 24px，四周扩 10px → 44px；平台按钮上下扩到 44px。 */
:where(.layout-mobile) .rank-tabs { margin-bottom: 10px; }
:where(.layout-mobile) .rank-tabs button { min-height: 32px; padding: 0; font-size: 14px; }
:where(.layout-mobile) .rank-tabs button::before { inset: -6px 0; }
:where(.layout-mobile) .rank-play { position: relative; }
:where(.layout-mobile) .rank-play::before { inset: -10px; border-radius: 50%; }
:where(.layout-mobile) .platform-action { position: relative; min-height: 32px; padding: 0 14px; font-size: 13px; }
:where(.layout-mobile) .platform-action::before { inset: -6px 0; }
/* CHG-329：设置页在手机上可上下滑动（内容超过屏高时）；不显示滚动条，与游戏的手势互不干扰。 */
:where(.layout-mobile) .mobile-device .settings-card { overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; scrollbar-width: none; padding-bottom: 4px; }
:where(.layout-mobile) .mobile-device .settings-card::-webkit-scrollbar { display: none; }
/* CHG-337：手机横屏上转向教程缩小，紧贴分数下方。 */
:where(.layout-mobile) .turn-guide { top: calc(var(--safe-top) + 58px); gap: 5px; }
/* CHG-339：吐弹教学提示与转向教程同一位置（手机横屏紧贴分数下方）。 */
:where(.layout-mobile) .bomb-guide { top: calc(var(--safe-top) + 58px); padding: 5px 14px; font-size: 13px; }
:where(.layout-mobile) .turn-keys { grid-template: repeat(2, 30px) / repeat(3, 30px); gap: 4px; }
:where(.layout-mobile) .tk { border-radius: 7px; font-size: 15px; }
:where(.layout-mobile) .tk-arrow { font-size: 12px; }
:where(.layout-mobile) .turn-guide p { padding: 4px 12px; font-size: 13px; }
