/* =========================================================
   冬符弹幕战 · 页面样式（仅 game.html 使用）
   ========================================================= */

.game-wrap {
  display: grid;
  grid-template-columns: minmax(0, var(--stage-w)) 280px;
  gap: 28px;
  justify-content: center;
  align-items: start;
  /* 竖板宽度：由 JS 依据"实际可用竖向空间"计算（见 boot.mjs 的 layoutStage）；
     这里的值只作为未执行 JS 时的兜底 */
  --stage-w: min(880px, calc((100vh - 260px) * 0.75), 96vw);
}

/* ---------- 游戏页：压缩留白，把高度让给棋盘 ---------- */
.page-head { padding-top: 72px; padding-bottom: 6px; }
.section__head { margin-bottom: 8px; }
.section__title { font-size: clamp(1.5rem, 3vw, 2rem); }
.gallery-intro { margin-bottom: 12px; }

/* ---------- 游戏画面 ---------- */
.game-stage {
  position: relative;
  max-height: calc(100vh - 8px);   /* 保险：绝不超出可视区 */
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid rgba(190, 220, 250, .28);
  box-shadow: 0 26px 70px rgba(2, 6, 20, .6), inset 0 1px 0 rgba(255, 255, 255, .08);
  background: #080e22;
}
#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 480 / 640;
  touch-action: pan-y;     /* 画面不再接受触摸操控：只允许上下滚动页面，不接受拖动自机 */
  cursor: default;         /* 电脑端为键盘操控，不用十字光标暗示鼠标 */
}

/* ---------- 覆盖层（开始/暂停/结算） ---------- */
.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 26px;
  background: rgba(5, 9, 22, .76);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.game-overlay[hidden] { display: none; }
.game-overlay__box { max-width: 380px; display: flex; flex-direction: column; gap: 12px; align-items: center; }
#ovTitle {
  margin: 0;
  font-family: var(--font-play);
  font-size: clamp(1.5rem, 5vw, 2.1rem);
  letter-spacing: .08em;
  color: var(--snow);
  text-shadow: 0 0 22px rgba(126, 200, 227, .45);
}
#ovSub {
  margin: 0;
  font-size: .92rem;
  line-height: 1.9;
  color: var(--ink-dim);
}
.ov-keys {
  display: inline-block;
  margin-top: 6px;
  font-size: .84rem;
  color: var(--ice-soft);
  letter-spacing: .02em;
}
.ov-line { margin: 4px 0 0; font-size: .88rem; color: var(--ink-dim); }
.ov-line b { color: var(--snow); font-variant-numeric: tabular-nums; }
#ovExtra { font-size: .88rem; }

/* 手机：开始/暂停界面压缩，保证「开始战斗」和「练习：终符」都完整可见
   （棋盘 overflow:hidden，内容过高会把按钮裁掉） */
@media (max-width: 900px), (pointer: coarse) {
  .game-overlay { padding: 12px; overflow-y: auto; }
  .game-overlay__box { gap: 8px; max-width: 100%; }
  #ovTitle { font-size: 1.3rem; }
  #ovSub { font-size: .82rem; line-height: 1.6; }
  .ov-keys { margin-top: 3px; font-size: .76rem; line-height: 1.5; }
  .ov-btns { gap: 8px; }
  .ov-btns .btn { min-height: 36px; padding: .45em .95em; font-size: .88rem; }
}

/* ---------- 侧栏 HUD ---------- */
.game-hud {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 18px;
}
.hud-block { display: flex; flex-direction: column; gap: 8px; }
.hud-label {
  font-size: .72rem;
  letter-spacing: .28em;
  color: var(--lav);
  text-transform: uppercase;
}
.hud-spell {
  font-family: var(--font-play);
  font-size: 1.06rem;
  line-height: 1.5;
  color: var(--snow);
}
.hud-spell small { display: block; font-size: .78rem; color: var(--ink-dim); letter-spacing: .06em; }
.hud-hp {
  position: relative;
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(190, 220, 250, .14);
  border: 1px solid rgba(190, 220, 250, .2);
}
.hud-hp__fill {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ec8e3, #b19cd9 55%, #ff9ec6);
  transform: scaleX(1);
  transform-origin: left center;
  transition: transform .12s linear;
  box-shadow: 0 0 14px rgba(126, 200, 227, .5);
}
.hud-timer {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-family: var(--font-play);
  font-size: 1.5rem;
  color: var(--snow);
  font-variant-numeric: tabular-nums;
}
.hud-timer small { font-size: .72rem; color: var(--ink-dim); letter-spacing: .1em; }
.hud-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.hud-stat { display: flex; flex-direction: column; gap: 2px; }
.hud-stat span:first-child { font-size: .7rem; letter-spacing: .2em; color: var(--ink-faint); }
.hud-stat span:last-child {
  font-family: var(--font-play);
  font-size: 1.02rem;
  color: var(--snow);
  font-variant-numeric: tabular-nums;
}
.hud-stat--wide { grid-column: 1 / -1; }
#gLives { color: #ff9ec6; letter-spacing: .1em; }
#gBombs { color: #ffe7a6; letter-spacing: .1em; }

.hud-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hud-note {
  margin: 0;
  font-size: .78rem;
  line-height: 1.9;
  color: var(--ink-faint);
}
.hud-note code {
  margin: 0 .15em;
  padding: .1em .5em;
  border-radius: 6px;
  border: 1px solid rgba(150, 200, 240, .18);
  background: rgba(150, 200, 240, .1);
  color: var(--ice-soft);
  font-size: .9em;
}

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
  .game-wrap { grid-template-columns: minmax(0, var(--stage-w)); --stage-w: min(760px, 96vw); }
  .game-hud { order: -1; }
  .hud-stats { grid-template-columns: repeat(4, 1fr); }
  .hud-stat--wide { grid-column: auto; }
}
@media (max-width: 520px) {
  .game-hud { padding: 16px 14px; }
  .hud-stats { grid-template-columns: 1fr 1fr; }
  .hud-actions .btn { flex: 1 1 auto; justify-content: center; }
}

/* 游戏页：隐藏站点雪花与小人层（游戏自带雪景，也省性能） */
#snow, #chibiRun, #chibiRain { display: none; }

/* 游戏页不使用站点 BGM：按钮隐藏但保留占位，保证头部布局与其它页面完全一致 */
.music-toggle { visibility: hidden; pointer-events: none; }

/* =========================================================
   手机端适配：触屏按钮 / 布局重排 / 防误触
   ========================================================= */
.touch-controls {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}
.touch-btn {
  position: absolute;
  pointer-events: auto;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid rgba(200, 230, 255, .38);
  background: rgba(10, 18, 40, .55);
  color: var(--ice-soft);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .04em;
  cursor: pointer;
  display: grid;
  place-items: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition: background .15s ease, transform .12s ease;
}
.touch-btn:active { transform: scale(.92); background: rgba(60, 95, 160, .7); }
.touch-btn--bomb {
  right: 14px;
  bottom: 16px;
  width: 68px;
  height: 68px;
  font-size: 1.25rem;
  color: #fff;
  border-color: rgba(255, 190, 215, .55);
  background: rgba(150, 40, 75, .55);
}
#btnTouchPause { right: 14px; top: 14px; width: 46px; height: 46px; font-size: .8rem; }

/* 游戏区与画布：禁止拖动选择/长按菜单/页面回弹 */
.game-stage, #gameCanvas {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
.game-stage { touch-action: pan-y; overscroll-behavior: contain; }
/* 整页禁用双击缩放：双击放 B 时浏览器不要抢走手势（否则会丢控制） */
@media (max-width: 900px), (pointer: coarse) {
  .page-game { touch-action: manipulation; }
  .touch-btn, .game-overlay, .hud-actions { touch-action: manipulation; }
}

/* ---------- 窄屏 / 触屏布局 ---------- */
@media (max-width: 900px), (pointer: coarse) {
  /* 画面置顶，操作区放在下方（拇指可及） */
  .game-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
  .game-hud { order: 2; width: 100%; max-width: var(--stage-w); }
  .game-stage { order: 1; }
  /* HUD 压缩为横向信息条 */
  .hud-stats { grid-template-columns: repeat(3, 1fr); gap: 8px 10px; }
  .hud-stat--wide { grid-column: 1 / -1; }
  .hud-spell { font-size: 1rem; }
  .hud-timer { font-size: 1.25rem; }
  .hud-actions { gap: 8px; }
  .hud-actions .btn { flex: 1 1 44%; justify-content: center; min-height: 44px; }
  .hud-note { display: none; }          /* 手机上收起长说明 */
  .page-head { padding-top: 74px; padding-bottom: 6px; }
  .section__title { font-size: 1.5rem; }
  .gallery-intro { font-size: .88rem; }
}
@media (max-width: 520px) {
  .touch-btn { width: 54px; height: 54px; }
  .touch-btn--bomb { width: 64px; height: 64px; }
  .hud-actions .btn { flex: 1 1 100%; }
}
/* 桌面端隐藏触屏专用按钮（鼠标拖拽已有） */
@media (hover: hover) and (pointer: fine) {
  #btnTouchBomb, #btnTouchPause { display: none; }   /* 电脑端用键盘 X / P */
}
/* 音效库加载状态（诊断用） */
.hud-sestat {
  font-size: .72rem;
  letter-spacing: .08em;
  color: var(--ink-faint);
  align-self: center;
}

/* 覆盖层按钮组 + 符卡进度徽标 */
.ov-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.hud-phase {
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid rgba(190, 220, 250, .3);
  font-style: normal;
  font-size: .68rem;
  letter-spacing: .08em;
  color: var(--ice-soft);
}

/* 左侧 Bomb 按钮（左右手都能放 B） */
.touch-btn--left { left: 14px; bottom: 16px; right: auto; }
@media (hover: hover) and (pointer: fine) {
  .touch-btn--left { display: none; }
}

/* =========================================================
   手机端操作区（画面下方独立区域：拖动移动 + 大 B 键放弹）
   —— 手指完全离开弹幕区，不会遮挡自机
   ========================================================= */
.touch-pad {
  display: none;                       /* 默认隐藏，手机端由媒体查询打开 */
  width: 100%;
  max-width: var(--stage-w);
  gap: 10px;
  align-items: stretch;
}
.pad-stick {
  position: relative;
  flex: 1 1 auto;
  /* 触摸区：与画面内拖动同一套手感（相对 1:1 跟手），只是一块够大的触控面 */
  min-height: 140px;
  border-radius: 16px;
  border: 1px dashed rgba(190, 220, 250, .3);
  background:
    radial-gradient(120% 100% at 50% 0%, rgba(126, 200, 227, .10), rgba(10, 18, 40, .5)),
    rgba(9, 15, 34, .55);
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
/* 参考十字刻度：方向摇杆的基座跟着手指走，所以不再画固定中心十字（整个规则弃用） */
.pad-stick__hint {
  position: absolute;
  left: 0; right: 0; bottom: 8px;
  text-align: center;
  font-size: .74rem;
  letter-spacing: .06em;
  color: rgba(168, 216, 238, .6);
  pointer-events: none;
}
/* 指尖指示点：跟随手指移动，松手消失（只表示"手指在这儿"，不代表自机位置） */
.pad-knob {
  position: absolute;
  left: 0;
  top: 0;
  width: 44px;
  height: 44px;
  margin: 0;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .42);
  background: radial-gradient(circle at 38% 34%, rgba(255, 255, 255, .62), rgba(126, 200, 227, .3) 55%, rgba(126, 200, 227, .1));
  transform: translate(-50%, -50%);
  transition: opacity .2s ease;
  opacity: 0;
  pointer-events: none;
}
.pad-knob.is-active { opacity: .8; }
.pad-btn {
  flex: 0 0 68px;
  /* 按钮不参与任何手势：一根手指按住触摸区时，另一根手指点 B 不会被判成缩放 */
  touch-action: none;
  border-radius: 16px;
  border: 1px solid rgba(200, 230, 255, .38);
  background: rgba(10, 18, 40, .6);
  color: var(--ice-soft);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  display: grid;
  place-items: center;
}
.pad-btn:active { transform: scale(.96); background: rgba(60, 95, 160, .7); }
.pad-btn--bomb {
  flex: 0 0 84px;
  font-size: 1.5rem;
  color: #fff;
  border-color: rgba(255, 190, 215, .5);
  background: rgba(150, 40, 75, .5);
}
.pad-btn--bomb:active { background: rgba(190, 60, 100, .7); }

/* 手机 / 触屏：显示操作区并置于画面下方、HUD 上方 */
@media (max-width: 900px), (pointer: coarse) {
  .touch-pad { display: flex; order: 2; }
  .game-hud { order: 3; }
  .game-stage { order: 1; }
  /* 操作区是棋盘的等比缩略图：按视口高度自适应，保证拇指区够大又不挤掉棋盘 */
  .pad-stick { height: clamp(140px, 24vh, 224px); }
}
@media (max-width: 520px) {
  .pad-btn { flex: 0 0 62px; }
  .pad-btn--bomb { flex: 0 0 76px; }
  .pad-stick { height: clamp(136px, 25vh, 210px); }
}
/* ---------- 说明栏排版（紧凑但信息完整） ---------- */
.hud-note {
  margin: 0;
  font-size: .76rem;
  line-height: 1.85;
  color: var(--ink-faint);
}
.hud-note code {
  margin: 0 .15em;
  padding: .05em .42em;
  border-radius: 5px;
  border: 1px solid rgba(150, 200, 240, .18);
  background: rgba(150, 200, 240, .1);
  color: var(--ice-soft);
  font-size: .92em;
}
.hud-actions .btn {
  min-width: 44px;
  padding: .42em .9em;
  font-size: .95rem;
}
#btnBgm, #btnSfx, #btnFull { min-width: 42px; }
.hud-debug {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: .7rem;
  letter-spacing: .06em;
  color: var(--ink-faint);
}
.hud-debug[hidden] { display: none; }
/* 手机端：说明栏进一步压扁（只保留关键数值） */
@media (max-width: 900px), (pointer: coarse) {
  .hud-actions .btn { flex: 1 1 30%; min-height: 42px; }
  .hud-note { display: none; }   /* 手机上由操作区提示代替 */
  .hud-stats { grid-template-columns: repeat(3, 1fr); }
  .hud-spell { font-size: .95rem; }
}

/* =========================================================
   页内放大：宽度成为瓶颈时（竖屏 / 窄高窗口），信息栏移到棋盘下方，
   棋盘吃到整幅宽度 —— 不开全屏也能明显变大
   ========================================================= */
body.is-stacked .game-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
body.is-stacked .game-stage { order: 1; }
body.is-stacked .game-hud {
  order: 2;
  width: 100%;
  max-width: var(--stage-w);
}
body.is-stacked .hud-stats { grid-template-columns: repeat(3, 1fr); }
body.is-stacked .hud-actions .btn { flex: 1 1 30%; justify-content: center; }

/* =========================================================
   收尾：棋盘下方到页脚不再留 90px 空档（style.css 里 .site-footer 的边距）
   ========================================================= */
.page-game .site-footer { margin-top: 26px; }

/* 移动端导航抽屉已统一到 style.css（≤900px 或触屏设备），
   这样游戏页与画廊/接力页的导航项排版完全一致。 */
/* =========================================================
   开战时收起吸顶导航（把纵向空间全部让给画面）
   鼠标移到屏幕顶部 / 暂停 / 结算时自动回来
   ========================================================= */
body.game-playing .site-header {
  transform: translateY(-105%);
  opacity: 0;
  pointer-events: none;
  transition: transform .32s ease, opacity .32s ease;
}
body.game-playing .site-header:hover,
body.game-playing .site-header:focus-within {
  transform: none;
  opacity: 1;
  pointer-events: auto;
  background: rgba(3, 6, 16, .92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
.site-header { transition: transform .32s ease, opacity .32s ease, background .3s ease; }
/* 顶部留白再收一点，配合导航收起后的对齐 */
.page-head { padding-top: 66px; padding-bottom: 2px; }
.game-wrap { gap: 18px; }