/* 触屏操作（CHG-332）：手机与平板共用——触屏方向键、互动键、竖屏“请横过来”、默认全屏按钮。
   只在 .mobile-device（js/platform/mobile.js 按 PlatformDevice.touch() 打上）下生效，键盘电脑不受影响。
   尺寸布局不要写在这里：手机布局写 mobile.css，PC/平板布局写 style.css。 */

/* 移动设备由输入模块识别，不以窄窗口代替设备判断。 */
.mobile-device {
  --pad-key: 50px;
  --control-space: calc(var(--pad-key) * 3 + 24px + var(--safe-bottom));
}
.mobile-controls {
  position: absolute; inset: auto 0 0; height: var(--control-space);
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px max(24px, var(--safe-right))
    calc(12px + var(--safe-bottom)) max(24px, var(--safe-left));
  pointer-events: none;
}
/* CHG-318：按参考图改为浅色半透明圆形按键，叠在场地上；十字四键相互分开、没有底板与中心块。 */
.touch-pad {
  display: grid; grid-template: repeat(3, var(--pad-key)) / repeat(3, var(--pad-key));
  pointer-events: auto; touch-action: none;
}
.touch-pad button, .touch-action {
  pointer-events: auto; touch-action: none; -webkit-touch-callout: none;
  background: rgba(252, 251, 236, .62); color: rgba(132, 150, 44, .92);
  border: 2px solid rgba(255, 255, 250, .8); border-radius: 50%;
  box-shadow: 0 3px 8px rgba(70, 86, 30, .16), inset 0 1px 0 rgba(255, 255, 255, .6);
  -webkit-backdrop-filter: blur(2px); backdrop-filter: blur(2px);
  font-size: calc(var(--pad-key) * .36); line-height: 1; padding: 0;
}
/* 四个键比格子略大，彼此贴近但不重叠成一块；触控范围仍是整格。 */
.touch-pad button { transform: scale(1.06); }
.touch-pad [data-direction="up"] { grid-area: 1 / 2; }
.touch-pad [data-direction="left"] { grid-area: 2 / 1; }
.touch-pad [data-direction="right"] { grid-area: 2 / 3; }
.touch-pad [data-direction="down"] { grid-area: 3 / 2; }
.pad-center { grid-area: 2 / 2; visibility: hidden; }
.touch-action {
  width: calc(var(--pad-key) * 1.75); height: calc(var(--pad-key) * 1.75);
  display: grid; place-items: center; font-size: calc(var(--pad-key) * .34); font-weight: 800;
}
/* 互动键平时显示吃豆人图标（无文字）；QTE / 吐弹时由脚本换成文字提示。 */
.touch-action .glyph { width: 46%; height: 46%; display: block; fill: currentColor; }
.touch-action.ready { border-color: var(--lime); color: #6f8a00; background: rgba(252, 255, 222, .86); }
.touch-action.ready.urgent { border-color: #ff5a3a; color: #ffd0c4; animation: spit-urgent .1s steps(2) infinite; }
@media (prefers-reduced-motion: reduce) { .touch-action.ready.urgent { animation: none; background: rgba(255,70,40,.3); } }
/* CHG-241：吐弹教学（慢动作）期间互动键闪烁放大，提示玩家按下。 */
.touch-action.ready.lesson { border-color: #fff27a; color: #fff; animation: spit-lesson .5s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .touch-action.ready.lesson { animation: none; background: rgba(255,230,90,.45); } }
.touch-pad button.pressed, .touch-action.pressed { background: rgba(141, 162, 0, .9); color: #fff; border-color: rgba(255, 255, 255, .95); transform: scale(.94); }
/* 横屏：按键叠在场地两侧，垂直居中偏下（参考图），不再贴底。 */
@media (orientation: landscape) {
  .mobile-device { --pad-key: clamp(46px, 13vh, 64px); }
  .mobile-controls {
    inset: 0; height: auto; align-items: center;
    padding: calc(24vh + var(--safe-top)) max(22px, var(--safe-right)) calc(4vh + var(--safe-bottom)) max(22px, var(--safe-left));
  }
}
.mobile-device .hud {
  height: calc(70px + var(--safe-top));
  padding: calc(12px + var(--safe-top)) max(14px, var(--safe-right)) 0 max(14px, var(--safe-left));
}
.mobile-device .icon-btn { width: 44px; height: 44px; }
.mobile-device #gl { touch-action: none; }
.touch-playing .qte { bottom: calc(var(--control-space) + 8px); pointer-events: none; }
.mobile-device .start-tip { bottom: calc(12px + var(--safe-bottom)); }
@media (max-height: 520px), (max-width: 360px) {
  .mobile-device { --pad-key: 44px; }
  .mobile-controls { padding-left: max(16px, var(--safe-left)); padding-right: max(16px, var(--safe-right)); }
  .touch-playing .qte { padding: 8px 12px; width: min(360px, 90vw); border-radius: 16px; }
  .touch-playing .qte-title { font-size: 18px; }
  .touch-playing .qte-bar { margin: 6px 0; height: 14px; }
  .touch-playing .qte-hint { gap: 5px; font-size: 11px; }
  .touch-playing .qte-hint kbd { padding: 3px 8px; }
}

/* APK横屏：背景满窗口，刘海只避让控件，紧凑HUD留出更多场地高度。 */
.android-app .mobile-device .hud {
  height: calc(56px + var(--safe-top));
  padding-top: calc(6px + var(--safe-top));
}
.android-app .mobile-device .hud-title { font-size: 13px; letter-spacing: .22em; }
.android-app .mobile-device .hud-score { font-size: 30px; }
.android-app .touch-action { width: 72px; height: 72px; font-size: 18px; }
.android-app #scr-start, .android-app #scr-pause { touch-action: none; }
/* CHG-327：手机竖屏时整屏盖住游戏，只显示“请将手机横过来”。桌面与横屏不显示。 */
/* CHG-338：触屏设备上吐弹提示不显示空格键帽；第二颗引导炸弹期间互动键闪烁。 */
.mobile-device .bomb-guide-key { display: none; }
.mobile-device.spit-lesson .touch-action { animation: spit-lesson .5s ease-in-out infinite; border-color: #fff27a; }
@media (prefers-reduced-motion: reduce) { .mobile-device.spit-lesson .touch-action { animation: none; background: rgba(255,230,90,.45); } }
/* CHG-337：触屏设备的转向教程显示方向箭头（不显示 WSAD），左侧方向键一起闪烁。 */
.mobile-device .turn-guide .tk-key { display: none; }
.mobile-device .turn-guide .tk-arrow { display: block; }
/* CHG-337 追加：左侧方向键与提示里的箭头同步，按 上 → 左 → 下 → 右 逐个亮起，一轮 2.4 秒。 */
.mobile-device.turn-lesson .touch-pad button { animation: turnPadBlink 2.4s ease-in-out infinite; }
.mobile-device.turn-lesson .touch-pad [data-direction="up"] { animation-delay: 0s; }
.mobile-device.turn-lesson .touch-pad [data-direction="left"] { animation-delay: .6s; }
.mobile-device.turn-lesson .touch-pad [data-direction="down"] { animation-delay: 1.2s; }
.mobile-device.turn-lesson .touch-pad [data-direction="right"] { animation-delay: 1.8s; }
@keyframes turnPadBlink { 0%, 30%, 100% { background: rgba(252, 251, 236, .62); } 8%, 22% { background: rgba(220, 245, 66, .85); border-color: #fff; } }
@media (prefers-reduced-motion: reduce) { .mobile-device.turn-lesson .touch-pad button { animation: none; } }
.rotate-hint { display: none; }
@media (orientation: portrait) {
  .mobile-device .rotate-hint {
    position: fixed; inset: 0; z-index: 5000; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
    background: radial-gradient(90% 75% at 50% 45%, #fbf8ee 0%, #f2eedf 70%, #e9e4d2 100%);
    color: var(--olive-deep); font: 700 18px var(--font-cn); letter-spacing: .08em; text-align: center; padding: 24px;
  }
  .mobile-device .rotate-hint p { margin: 0; }
  .mobile-device #app { visibility: hidden; }
}
.rotate-icon { width: 96px; height: 96px; fill: none; stroke: currentColor; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; animation: rotateHint 2.2s ease-in-out infinite; transform-origin: 32px 30px; }
@media (prefers-reduced-motion: reduce) { .rotate-icon { animation: none; transform: rotate(-90deg); } }
.menu-fullscreen { position: absolute; z-index: 5; top: calc(6px + var(--safe-top)); right: calc(max(8px, var(--safe-right)) + 46px); width: 32px; height: 32px; padding: 0; border-radius: 50%; display: grid; place-items: center; color: var(--olive-ink); background: rgba(255, 255, 240, .72); box-shadow: inset 0 0 0 1px rgba(141, 162, 0, .3); cursor: pointer; }
.menu-fullscreen[hidden] { display: none; }
.menu-fullscreen svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.menu-fullscreen:active { transform: scale(.94); }
.menu-fullscreen .fs-off, .menu-fullscreen.active .fs-on { display: none; }
.menu-fullscreen.active .fs-off { display: block; }
.menu-fullscreen.active { color: #6f8a00; box-shadow: inset 0 0 0 2px var(--lime); }
.mobile-device .hud .hud-settings { width: 44px; height: 44px; }
