/* v8：おにごっこモード（js/game.js とセット）。逃げる役はハチローくん、最後に大きいイチローくん */

/* スクロールバーの有無で配置がずれないように、常に場所を確保（ゲーム中はページのスクロールを止める） */
html { scrollbar-gutter: stable; }
html.game-on { overflow: hidden; }

/* ゲームの層：画面全体を受け止め、下のページを触れないようにする */
.game-layer {
  position: fixed; inset: 0; z-index: 70;
  touch-action: none; overscroll-behavior: contain;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  background: rgb(255 255 255 / .12);
}
.game-props { position: absolute; inset: 0; pointer-events: none; }
.game-prop { position: absolute !important; left: 0 !important; top: 0 !important; margin: 0 !important; transform-origin: center center; will-change: transform; z-index: 1; }

/* 文字・線・動画の枠の複製（v8） */
.game-glyph { display: block; white-space: pre; text-align: center; overflow: visible; }
.game-line { display: block; border-radius: 2px; }
.game-frame { display: block; overflow: hidden; background: #111; box-sizing: border-box; }
.game-frame canvas { display: block; width: 100%; height: 100%; }
/* 折り曲げ：左右の半分を重ね、右半分だけ中央の折れ目で回す（UI の複製のみ） */
.game-bend-half { position: absolute !important; left: 0 !important; top: 0 !important; margin: 0 !important; transform-origin: 50% 50%; }

/* ハチローくん（押せるボタン）。画像全体の移動とポーズの差し替えだけ */
.game-char {
  position: absolute; left: 0; top: 0; z-index: 3; padding: 0; border: none; background: none;
  cursor: grab; touch-action: none; border-radius: 16px; will-change: transform;
}
.game-char.is-drag { cursor: grabbing; }
.game-char:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 6px var(--yellow); }
.game-char-img, .game-guest-img { display: block; width: 100%; height: 100%; pointer-events: none; -webkit-user-drag: none; }
.game-char.is-landing .game-char-img { animation: buddy-land 420ms cubic-bezier(.2, .8, .2, 1); }
.game-guest { position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none; } /* 持っている部品（4）より手前＝拳が部品の端に重なって「持っている」と分かる */

/* 吹き出し：部品より手前で読みやすく */
.game-bubble {
  position: absolute; left: 0; top: 0; z-index: 7; margin: 0; padding: 5px 14px;
  background: var(--white); border: 2px solid var(--ink); border-radius: 14px; box-shadow: 2px 2px 0 var(--ink);
  font-size: 15px; font-weight: 700; line-height: 1.5; color: var(--ink); pointer-events: none;
  width: max-content; white-space: normal; word-break: auto-phrase; overflow-wrap: anywhere; line-break: strict;
}
.game-bubble.is-in { animation: bubble-in 260ms cubic-bezier(.34, 1.56, .64, 1); }

/* 案内と「おわる」：物理演算の対象外。常に手前で押せる */
.game-hud {
  position: fixed; top: 10px; left: 50%; translate: -50% 0; z-index: 80;
  display: flex; align-items: center; gap: 10px; max-width: calc(100vw - 20px);
  padding: 6px 6px 6px 14px; background: var(--white); border: 2px solid var(--ink); border-radius: 999px;
  box-shadow: 3px 3px 0 var(--ink); font-size: 13px;
}
.game-title { margin: 0; display: inline-flex; align-items: center; gap: 6px; font-weight: 700; color: var(--ink); white-space: nowrap; }
.game-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pink, #ff5fa2); border: 1.5px solid var(--ink); }
.game-help { margin: 0; color: var(--body); line-height: 1.4; }
.game-mode, .game-end {
  flex: none; min-height: 38px; padding: 0 14px; border: 2px solid var(--ink); border-radius: 999px;
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.game-mode { background: var(--white); color: var(--ink); }
.game-end { background: var(--ink); color: var(--white); display: inline-flex; align-items: center; gap: 6px; }
.game-key { font-size: 10px; padding: 0 5px; border: 1px solid currentColor; border-radius: 4px; opacity: .8; }
.game-mode:focus-visible, .game-end:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 6px var(--yellow); }
/* 大暴れの後：もう一度遊ぶ／サイトに戻る（案内と重ならない中央） */
.game-finale {
  position: absolute; left: 50%; top: 50%; translate: -50% -50%; z-index: 8;
  display: grid; gap: 14px; justify-items: center; padding: 20px 24px;
  background: var(--white); border: 2px solid var(--ink); border-radius: 20px; box-shadow: 4px 4px 0 var(--ink);
}
.game-finale-title { margin: 0; font-size: 20px; font-weight: 700; color: var(--ink); }
.game-finale-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.game-again, .game-back { min-height: 44px; padding: 0 18px; border: 2px solid var(--ink); border-radius: 999px; font-size: 15px; font-weight: 700; }
.game-again { background: var(--yellow); color: var(--ink); }
.game-back { background: var(--white); color: var(--ink); }
.game-again:focus-visible, .game-back:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; box-shadow: 0 0 0 6px var(--pink-light, #ffa3cb); }
/* 終了時：ハチローくんは左下へ戻って受け渡すので消さない（イチローくん・吹き出しだけ消す） */
.game-layer.is-ending .game-guest, .game-layer.is-ending .game-bubble { opacity: 0; transition: opacity 200ms; }

/* スマートフォン：案内は下に、終了ボタンは大きく */
@media (max-width: 767px) {
  .game-hud {
    top: auto; bottom: 10px; left: 10px; right: 10px; translate: none; max-width: none;
    flex-wrap: wrap; justify-content: space-between; border-radius: 18px; padding: 8px 8px 8px 12px;
  }
  .game-help { order: 3; flex: 1 1 100%; font-size: 12px; }
  .game-end { min-height: 46px; padding: 0 18px; font-size: 15px; }
  .game-mode { min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .game-char.is-landing .game-char-img, .game-bubble.is-in { animation: none; }
}
body.force-reduce .game-char.is-landing .game-char-img, body.force-reduce .game-bubble.is-in { animation: none; }


@media (hover: none) { .game-key { display: none; } }

/* v10：動画の外枠（縁の線と影だけ）と、真っ二つにした破片 */
.game-ring, .game-ring-half { display: block; box-sizing: border-box; background: transparent; }

/* v11：イチローくんが扱っている部品の層（ほかの部品・動画の面より手前。押せない） */
.game-fore { position: absolute; inset: 0; pointer-events: none; }
.game-fore > * { pointer-events: none !important; }
.game-still-half { display: block; overflow: hidden; box-sizing: border-box; }
