/* =========================================================
   ゲピミニファイト - レイアウト / UI
   スマホ横向き（ランドスケープ）前提
   ========================================================= */

:root {
  color-scheme: dark;
  --bg: #07090b;
  --ink: #f2f6f8;
  --muted: #9fb0ba;
  --line: #2c3740;
  --accent: #5fc3e4;
  --danger: #e2483f;
  --good: #6fd07a;
  --warn: #f2c14e;

  /* 画面の 1%（JS が実寸から設定する）。
     vh / vw は端末やアドレスバーで値がぶれるうえ、
     回転モードでは縦横が入れ替わってしまうため使わない。 */
  --vw: 1vw;
  --vh: 1vh;

  /* セーフエリア（ノッチ対応）。生の値と、ゲームから見た向きを分けて持つ。 */
  --raw-t: env(safe-area-inset-top, 0px);
  --raw-r: env(safe-area-inset-right, 0px);
  --raw-b: env(safe-area-inset-bottom, 0px);
  --raw-l: env(safe-area-inset-left, 0px);
  --safe-l: var(--raw-l);
  --safe-r: var(--raw-r);
  --safe-t: var(--raw-t);
  --safe-b: var(--raw-b);
}

/* 中身を 90 度回すモードでは、ゲームの上下左右と物理的な上下左右がずれる */
body.forced-landscape {
  --safe-l: var(--raw-t);
  --safe-r: var(--raw-b);
  --safe-t: var(--raw-r);
  --safe-b: var(--raw-l);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  /* ゲーム内の文字はすべてドット風フォントで統一する */
  font-family: "DotGothic16", "Press Start 2P", "MS Gothic", monospace;
  /* ゲーム中のスクロール・ピンチズームを抑止 */
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ---------------------------------------------------------
   ステージ枠：16:9 を画面いっぱいにフィットさせて中央寄せ
   --------------------------------------------------------- */
#app {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: #000;
}

/* 画面いっぱいに広げる。左右に黒帯を出さないため、
   キャンバスの内部解像度（横幅）を画面の比率に合わせて JS 側で決める。 */
#stage {
  position: relative;
  /* 実寸は JS（viewport.js）が px で設定する */
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: #000;
}

#game {
  display: block;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  /* 実寸は JS が画面に合わせて設定する */
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ---------------------------------------------------------
   HUD
   --------------------------------------------------------- */
#hud {
  position: absolute;
  top: var(--safe-t);
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 2%;
  padding: calc(1.4% + 4px) calc(2% + var(--safe-l)) 0 calc(2% + var(--safe-r));
  pointer-events: none;
  font-size: clamp(9px, calc(var(--vh) * 1.7), 15px);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.7);
}

.hud-left,
.hud-right {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.hud-right {
  align-items: flex-end;
}

/* キャラ名と「HP」の文字は画面を狭くするだけなので出さない */
.name-plate,
.gauge-label {
  display: none;
}

/* HP ゲージ：装飾の枠（assets/ui/gauge-hp.webp）は中央が空洞なので、
   その穴の位置にゲージの中身を敷いて、枠を上から重ねる。
   穴の位置は tools/build_assets.py が切り出した画像から実測した値。 */
.gauge {
  position: relative;
  /* % だと親要素の幅が基準になってしまうので、画面基準の --vw を使う */
  width: min(calc(var(--vw) * 25), 240px);
  aspect-ratio: 1053 / 235;
}



/* 枠の空洞を上下に分け、上を青いチャージ、下を HP にする */
.charge-bar {
  position: absolute;
  left: 21.3%;
  top: 24.3%;
  width: 70.8%;
  height: 16%;
  background: #10161d;
  overflow: hidden;
  border-radius: 2px;
}

.charge-bar > i {
  display: block;
  width: 0%;
  height: 100%;
  background: linear-gradient(180deg, #a8e8ff, #35a7dd 60%, #1a5f8a);
  transition: width 0.1s linear;
}

/* 満タン＝回復中は光らせて、効いていることを分かるようにする */
.charge-bar > i.full {
  background: linear-gradient(180deg, #e6f9ff, #6fd8ff 60%, #2b8fc4);
  box-shadow: 0 0 8px rgba(120, 220, 255, 0.9);
  animation: charge-pulse 0.7s ease-in-out infinite;
}

@keyframes charge-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.45); }
}

@media (prefers-reduced-motion: reduce) {
  .charge-bar > i.full { animation: none; }
}

.gauge-bar {
  position: absolute;
  left: 21.3%;
  top: 42.5%;
  width: 70.8%;
  height: 29.5%;
  background: #14181d;
  overflow: hidden;
  border-radius: 3px;
}

.gauge::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url("assets/ui/gauge-hp.webp") center / 100% 100% no-repeat;
  pointer-events: none;
}

.gauge-bar > i {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #b6f5bd, var(--good) 60%, #3f9a4c);
  transition: width 0.15s linear;
}

.gauge-bar > i.low {
  background: linear-gradient(180deg, #ffb0a6, var(--danger) 60%, #9c2b23);
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex: 1;
}

/* --- 画面上部中央：残り時間（格闘ゲーム風） --- */
.time-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  gap: 1px;
}

.time-label {
  font-size: 0.72em;
  letter-spacing: 0.22em;
  color: var(--muted);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.8);
}

.time-value {
  font-size: clamp(20px, calc(var(--vh) * 5.2), 46px);
  font-variant-numeric: tabular-nums;
  color: #ffffff;
  -webkit-text-stroke: 4px #14100c;
  paint-order: stroke fill;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.5);
}

/* 残り 20 秒を切ったら赤く点滅させて煽る */
.time-value.hurry {
  color: #ff6b5a;
  animation: time-blink 0.5s steps(2, end) infinite;
}

@keyframes time-blink {
  0%, 60% { opacity: 1; }
  61%, 100% { opacity: 0.4; }
}

@media (prefers-reduced-motion: reduce) {
  .time-value.hurry { animation: none; }
}

/* --- 画面上部中央：スコアとコンボ --- */
.score-block {
  display: flex;
  align-items: baseline;
  gap: 6px;
  line-height: 1;
  /* HP ゲージの左下に置く（枠の内側の位置に合わせる） */
  margin-top: -2%;
  padding-left: 3%;
}

.score-label {
  font-size: 0.78em;
  font-weight: 900;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.score-value {
  font-size: clamp(15px, calc(var(--vh) * 3.6), 32px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.55), 0 0 14px rgba(255, 220, 120, 0.35);
}

.combo {
  display: flex;
  align-items: baseline;
  gap: 5px;
  line-height: 1;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.14s linear, transform 0.14s linear;
}

.combo.on {
  opacity: 1;
  transform: translateY(0);
}

.combo b {
  font-size: clamp(16px, calc(var(--vh) * 3.6), 32px);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--warn);
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6);
}

.combo-label {
  font-size: 0.76em;
  font-weight: 900;
  letter-spacing: 0.14em;
  color: var(--warn);
  opacity: 0.85;
}

/* 10 コンボ以上は色を変えて煽る */
.combo.hot b,
.combo.hot .combo-label {
  color: #ff8b5e;
}

.combo.hot b {
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.6), 0 0 16px rgba(255, 140, 80, 0.7);
}

/* 数字が増えた瞬間だけ弾ませる */
.combo.pop b {
  animation: combo-pop 0.22s ease-out;
}

@keyframes combo-pop {
  0% {
    transform: scale(1.45);
  }
  100% {
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .combo.pop b {
    animation: none;
  }
}

/* フェーズは画面中央のバナーで知らせるので、上部のラベルとバーは出さない */
#stageLabel,
#progressBar {
  display: none;
}

#progressBar {
  width: min(calc(var(--vw) * 28), 260px);
  height: 6px;
  background: #0b0f13;
  border: 2px solid #3a464f;
}

#progressBar > i {
  display: block;
  width: 0%;
  height: 100%;
  background: var(--accent);
}

/* アイテムスロットも同じ要領で、枠の空洞に中身を置く */
.item-slot {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: min(calc(var(--vw) * 11), 100px);
  aspect-ratio: 378 / 353;
  padding: 14% 8% 16%;
  text-align: center;
}

.item-slot::before {
  content: "";
  position: absolute;
  inset: 0;
  background: url("assets/ui/slot.webp") center / 100% 100% no-repeat;
  z-index: -1;
}

.item-slot-label {
  font-size: 0.8em;
  font-weight: 900;
  color: var(--muted);
}

.item-slot-name {
  font-weight: 900;
  color: var(--ink);
}

/* ---------------------------------------------------------
   コントローラー（画面内オーバーレイ）
   --------------------------------------------------------- */
#controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.2s linear;
}

/* タイトル・結果画面のあいだは操作系を出さない
   （スタジオロゴやボタンと重ならないように） */
#controls.hidden {
  opacity: 0;
  pointer-events: none;
}

#controls.hidden .pad,
#controls.hidden .btn {
  pointer-events: none;
}

/* --- 左：フローティングパッド ---
   画面の左半分すべてがタッチ受付エリア。触った場所にパッドが現れる。
   端末の大きさに関係なく、親指の届く位置で操作できる。 */
.pad-zone {
  position: absolute;
  left: 0;
  top: 0;
  width: 48%;
  height: 100%;
  pointer-events: auto;
  touch-action: none;
}

.pad {
  position: absolute;
  /* 起点は JS が触れた位置に合わせて動かす */
  left: 0;
  top: 0;
  width: clamp(104px, min(calc(var(--vh) * 30), calc(var(--vw) * 21)), 190px);
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  pointer-events: none;
  opacity: 0.32;
  transition: opacity 0.14s linear;
}

.pad.active {
  opacity: 0.72;
}

.pad-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: url("assets/ui/pad.webp") center / 100% 100% no-repeat;
}

.pad-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 42%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: url("assets/ui/knob.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
}

.pad.active .pad-knob {
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5)) brightness(1.2);
}


/* --- 右下：A / B / C ボタン --- */
/* --- 右：アクションボタン ---
   小さいスマホでも押しやすく、タブレットで大きくなりすぎないよう、
   縦（vh）と横（vw）の小さいほうを基準にする。 */
.buttons {
  position: absolute;
  right: calc(3.5% + var(--safe-r));
  bottom: calc(5% + var(--safe-b));
  width: clamp(138px, min(calc(var(--vh) * 34), calc(var(--vw) * 25)), 250px);
  aspect-ratio: 1;
  pointer-events: none;
}

.btn {
  position: absolute;
  /* 指の腹で押せるよう、最低でも 52px は確保する */
  width: 46%;
  min-width: 52px;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 0;
  background: center / 100% 100% no-repeat;
  color: #fff;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  gap: 2px;
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  /* 画面を隠しすぎないよう 40% ほど透過させる */
  opacity: 0.6;
  filter: drop-shadow(0 5px 8px rgba(0, 0, 0, 0.5));
  transition: transform 0.05s linear, filter 0.05s linear, opacity 0.12s linear;
}

.btn.pressed,
.btn:active {
  opacity: 0.92;
}

.btn-key {
  font-size: clamp(15px, calc(var(--vh) * 3.4), 30px);
  font-weight: 400;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.9);
}

.btn-sub {
  font-size: clamp(7px, calc(var(--vh) * 1.35), 12px);
  font-weight: 700;
  opacity: 0.9;
}

/* A は右下（親指の定位置）、B は左、C は上 */
.btn-a {
  right: 0;
  bottom: 2%;
  background-image: url("assets/ui/btn-a.webp");
}

.btn-a.pressed {
  background-image: url("assets/ui/btn-a-on.webp");
}

.btn-b {
  left: 0;
  bottom: 12%;
  background-image: url("assets/ui/btn-b.webp");
}

.btn-b.pressed {
  background-image: url("assets/ui/btn-b-on.webp");
}

.btn-c {
  right: 10%;
  top: 0;
  background-image: url("assets/ui/btn-c.webp");
}

.btn-c.pressed {
  background-image: url("assets/ui/btn-c-on.webp");
}

.btn.pressed {
  transform: translateY(4px) scale(0.95);
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5)) brightness(1.12);
}

/* ---------------------------------------------------------
   タイトル / オーバーレイ画面
   --------------------------------------------------------- */
.overlay-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--vh) * 2);
  background: radial-gradient(
    circle at 50% 45%,
    rgba(12, 22, 30, 0.82),
    rgba(4, 7, 10, 0.94)
  );
  z-index: 20;
  text-align: center;
  padding: 4%;
}

.overlay-screen.hidden {
  display: none;
}

/* --- タイトル画面：キービジュアルを敷いてロゴを重ねる --- */
.title-screen {
  background: url("assets/title-bg.webp") center / cover no-repeat;
  /* 高さが足りない端末でもボタンが画面外へ出ないよう、中央そろえにする */
  justify-content: center;
  gap: 2%;
  padding: 12% 8% 10%;
  overflow: hidden;
}

/* 下側を暗く落として、ボタンと注記を読めるようにする */
.title-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(6, 8, 12, 0.15) 0%,
    rgba(6, 8, 12, 0.1) 42%,
    rgba(6, 8, 12, 0.82) 100%
  );
  pointer-events: none;
}

.title-screen > * {
  position: relative;
  z-index: 1;
}

.title-logo-img {
  /* 幅・高さの両方に上限を置き、どちらに当たっても比率を保って収める */
  max-width: 72%;
  max-height: 46%;
  width: auto;
  height: auto;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.75));
}

/* 左上のバージョン表記 */
.title-screen .version {
  position: absolute;
  left: calc(3.5% + var(--safe-l));
  top: calc(3.5% + var(--safe-t));
  z-index: 2;
  font-size: clamp(9px, calc(var(--vh) * 1.9), 15px);
  letter-spacing: 0.08em;
  color: rgba(255, 255, 255, 0.82);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

/* 右下のスタジオロゴ */
.title-screen .studio-logo {
  position: absolute;
  right: calc(3.5% + var(--safe-r));
  bottom: calc(4% + var(--safe-b));
  z-index: 2;
  width: clamp(72px, calc(var(--vw) * 15), 170px);
  height: auto;
  border-radius: 5px;
  opacity: 0.9;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

/* PRESS START：白抜き＋黒フチのドット文字をゆっくり点滅させる */
.press-start {
  margin-top: calc(var(--vh) * 1);
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  font-family: "Press Start 2P", "DotGothic16", monospace;
  font-size: clamp(13px, calc(var(--vh) * 3.4), 30px);
  letter-spacing: 0.12em;
  color: #ffffff;
  -webkit-text-stroke: 5px #14100c;
  paint-order: stroke fill;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.55);
  animation: press-blink 1.6s steps(1, end) infinite;
}

.press-start:active {
  transform: translateY(3px);
}

@keyframes press-blink {
  0%, 62% { opacity: 1; }
  63%, 100% { opacity: 0.18; }
}

@media (prefers-reduced-motion: reduce) {
  .press-start {
    animation: none;
  }
}

/* 全画面ボタン。白地に黒文字・黒フチ。 */
/* 全画面 API が使えない環境向けの案内 */
.fs-hint {
  margin: calc(var(--vh) * 0.4) 0 0;
  max-width: 78%;
  text-align: center;
  font-size: clamp(8px, calc(var(--vh) * 1.7), 13px);
  line-height: 1.5;
  color: #cbd8e0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95);
}

.fs-hint.hidden {
  display: none;
}

.title-hint {
  margin: 0;
  font-size: clamp(9px, calc(var(--vh) * 1.7), 14px);
  color: #b9c7d0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.9);
}

/* --- ボスの体力ゲージ（戦闘中だけ出す） --- */
.gauge.boss {
  width: min(calc(var(--vw) * 40), 380px);
  margin-top: 2px;
  /* 出ていないときに場所を取ると、下のスコアが押し下げられてしまう */
  display: none;
}

.gauge.boss.on {
  display: block;
}

.gauge.boss::after {
  background-image: url("assets/ui/gauge-boss.webp");
}

.gauge.boss {
  aspect-ratio: 1013 / 210;
}

.gauge.boss .gauge-bar {
  left: 20.1%;
  top: 43.3%;
  width: 70%;
  height: 24.3%;
}

.gauge.boss .gauge-bar > i {
  background: linear-gradient(180deg, #ff9a8f, #d63b30 60%, #8d1d16);
}

/* --- アイテムの残り使用回数 --- */
.item-slot-uses {
  font-size: 0.8em;
  font-weight: 900;
  color: var(--warn);
  font-variant-numeric: tabular-nums;
}

/* 結果画面は、倒れた主人公が見えるように薄くかぶせる */
#overScreen {
  background: linear-gradient(
    180deg,
    rgba(6, 9, 13, 0.55) 0%,
    rgba(6, 9, 13, 0.2) 45%,
    rgba(6, 9, 13, 0.75) 100%
  );
  justify-content: flex-start;
  padding-top: 8%;
  gap: calc(var(--vh) * 1.4);
}

/* --- ゲームオーバー --- */
.over-title {
  margin: 0;
  font-size: clamp(24px, calc(var(--vh) * 7), 60px);
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--danger);
  text-shadow: 0 4px 0 #5e1a15, 0 8px 22px rgba(0, 0, 0, 0.7);
}

/* ステージクリアのときは色を変える */
.over-title.clear {
  color: var(--warn);
  text-shadow: 0 4px 0 #7a4f10, 0 8px 22px rgba(0, 0, 0, 0.7);
}

/* --- リザルトの内訳 ---
   数字はすべて白地に黒フチ。TOTAL だけ大きくして目線が行くようにする。 */
.result {
  display: grid;
  gap: calc(var(--vh) * 0.5);
  min-width: min(58%, 420px);
}

.result-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 6%;
}

.result-label {
  font-size: clamp(9px, calc(var(--vh) * 1.9), 16px);
  letter-spacing: 0.14em;
  color: #b9c7d0;
  text-shadow: 0 2px 3px rgba(0, 0, 0, 0.9);
}

.result-num {
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  font-size: clamp(13px, calc(var(--vh) * 2.7), 24px);
  color: #ffffff;
  -webkit-text-stroke: 4px #14100c;
  paint-order: stroke fill;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
}

/* 合計は 2 倍以上の大きさにして、ひと目で分かるようにする */
.result-total {
  margin-top: calc(var(--vh) * 0.8);
  padding-top: calc(var(--vh) * 1);
  border-top: 2px solid rgba(255, 255, 255, 0.28);
}

.result-total .result-label {
  font-size: clamp(11px, calc(var(--vh) * 2.3), 20px);
  color: #ffffff;
}

.result-total .result-num {
  font-size: clamp(26px, calc(var(--vh) * 6.4), 58px);
  -webkit-text-stroke: 7px #14100c;
  text-shadow: 0 5px 0 rgba(0, 0, 0, 0.55);
}

/* ---------------------------------------------------------
   デバッグ表示（Phase 1 入力検知の確認用）
   --------------------------------------------------------- */
.debug {
  position: absolute;
  left: calc(2% + var(--safe-l));
  top: 26%;
  font-size: clamp(8px, calc(var(--vh) * 1.4), 12px);
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  color: #7fe0a4;
  background: rgba(0, 0, 0, 0.42);
  padding: 4px 8px;
  line-height: 1.5;
  white-space: pre;
  pointer-events: none;
  display: none;
}

.debug.on {
  display: block;
}

/* ---------------------------------------------------------
   縦向き警告
   --------------------------------------------------------- */
#rotateOverlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #06090c;
  text-align: center;
  padding: 8vw;
}

.rotate-icon {
  position: relative;
  display: grid;
  place-items: center;
}

.rotate-phone {
  width: 74px;
  height: 128px;
  border: 5px solid #ffffff;
  border-radius: 12px;
  animation: rotate-hint 2.4s ease-in-out infinite;
}

.rotate-arrow {
  position: absolute;
  right: -46px;
  font-size: 34px;
  color: #ffffff;
}

@keyframes rotate-hint {
  0%,
  30% {
    transform: rotate(0deg);
  }
  60%,
  100% {
    transform: rotate(-90deg);
  }
}

.rotate-text {
  margin: 0;
  font-size: clamp(18px, 5.5vw, 30px);
  font-weight: 900;
}

.rotate-sub {
  margin: 0;
  font-size: clamp(11px, 3.2vw, 16px);
  color: var(--muted);
}

/* 縦向き & タッチデバイスのときだけ案内を出す（PC の縦長ウィンドウでは出さない） */
@media (orientation: portrait) and (pointer: coarse) {
  #rotateOverlay {
    display: flex;
  }
  #app {
    visibility: hidden;
  }
}

/* --- 画面の回転ロック中でも遊べるモード ---
   端末を回しても縦のままの人向けに、中身のほうを 90 度回して表示する。
   このときは案内オーバーレイを出さない。 */
body.forced-landscape #rotateOverlay {
  display: none !important;
}

body.forced-landscape #app {
  visibility: visible !important;
}

body.forced-landscape #stage {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(90deg);
  transform-origin: center center;
}

/* 回転モードでは、ブラウザの上下のバーが画面の左右に並ぶ。
   その帯に指が触れないよう、操作系と HUD を内側へ寄せる。 */
body.forced-landscape .pad-zone {
  left: 7%;
  width: 40%;
}

body.forced-landscape .buttons {
  right: calc(8% + var(--safe-r));
}

body.forced-landscape #hud {
  padding-left: 8%;
  padding-right: 8%;
}

body.forced-landscape .title-screen .version {
  left: 8%;
}

body.forced-landscape .title-screen .studio-logo {
  right: 8%;
}

/* 案内オーバーレイの「このまま遊ぶ」ボタン */
/* 案内オーバーレイのボタン。白地に黒文字・黒フチ。 */
.rotate-play {
  margin-top: 8px;
  padding: 12px 26px;
  border: 3px solid #14100c;
  border-radius: 999px;
  background: #ffffff;
  color: #14100c;
  font-family: inherit;
  font-size: clamp(12px, 3.4vw, 18px);
  cursor: pointer;
  box-shadow: 0 4px 0 #14100c;
}

.rotate-play:active {
  transform: translateY(4px);
  box-shadow: none;
}
