/* 縦持ち (body.portrait。アプリは縦だけ)。横持ちの並び (story.css・game.css・app.css) を、縦長の画面に合わせて置きなおす。
   上はカメラの穴 (--safe-t)、下はホームバー (--safe-b) をよける */
body.portrait .story {
  --safe-t: max(56px, env(safe-area-inset-top));
  --safe-b: max(20px, env(safe-area-inset-bottom));
}

/* ゲームの絵の上の帯 (時間など): カメラの穴の下へ。縮めた絵の中なので、少し大きく (--stage-safe-t は main.js の fit が決める) */
body.portrait .hud { top: var(--stage-safe-t, 160px); transform: translateX(-50%) scale(1.5); transform-origin: 50% 0; }

/* ---- 共通の見出し ---- */
body.portrait .st-head { top: var(--safe-t); }
body.portrait .st-world span { display: none; }
body.portrait .st-mat { padding: 0 7px 0 6px; gap: 4px; }

/* ---- 名前をつける・魂が宿る ---- */
body.portrait .st-naming { top: calc(var(--safe-t) + 4px); left: var(--safe-l); right: var(--safe-r); width: auto; }
body.portrait .st-cer-glow { width: 90vw; height: 90vw; margin: -45vw 0 0 -45vw; }
body.portrait .st-born { bottom: calc(var(--safe-b) + 90px); }
body.portrait .st-born-name { font-size: clamp(36px, 11vw, 56px); }

/* ---- 旅の地図: 道は上から下へ (story-ui.js)。下に、ステージの札と、ボタンの列 ---- */
body.portrait .st-path { top: calc(var(--safe-t) + 56px); height: calc(100% - var(--safe-t) - 56px - 300px - var(--safe-b)); }
body.portrait .st-map-bottom { height: auto; flex-direction: column; gap: 8px; }
body.portrait .st-map-side { order: 2; flex-direction: row; padding: 0; gap: 8px; }
body.portrait .st-map-side .st-btn { flex: 1; min-height: 40px; padding: 0 6px; font-size: 13px; }
body.portrait .st-stage { min-height: 150px; }

/* ---- ガレージ: コマは上、強さは左上、パーツの一覧は下 ---- */
body.portrait .st-stats { top: calc(var(--safe-t) + 52px); bottom: auto; width: min(56vw, 240px); }
body.portrait .st-garage { top: auto; left: var(--safe-l); right: var(--safe-r); bottom: var(--safe-b); width: auto; height: 48vh; }

/* ---- 説明・結果の板: 横はいっぱいに ---- */
body.portrait .st-howto { width: calc(100vw - 20px); max-height: calc(100vh - var(--safe-t) - var(--safe-b) - 12px); overflow-y: auto; padding: 12px 16px 14px; }
body.portrait .st-howto-row { grid-template-columns: 72px 1fr; gap: 8px; }
body.portrait .st-howto-row b { font-size: 12px; }
body.portrait .st-howto-row span { font-size: 12px; }
body.portrait .st-howto .st-actions .st-btn { flex: 1 1 40%; }
body.portrait .st-result { left: var(--safe-l); right: var(--safe-r); width: auto; margin-left: 0; bottom: var(--safe-b); }
body.portrait .st-result .st-actions .st-btn { flex: 1 1 28%; }

/* ---- 試合の操作: 上に スコア・時間・一時停止 と 相手の耐久、下に 自分の耐久・必殺・操作の早見 ---- */
body.portrait .st-pause { top: var(--safe-t); bottom: auto; }
body.portrait .st-hud { left: var(--safe-l); right: calc(var(--safe-r) + 108px); width: auto; bottom: calc(var(--safe-b) + 44px); }
body.portrait .st-hints,
body.portrait .dl-hints { left: var(--safe-l); right: var(--safe-r); bottom: var(--safe-b); justify-content: center; }
body.portrait .st-hint small,
body.portrait .dl-hint small { font-size: 8px; }
body.portrait .st-launch-prompt { top: 34%; }
body.portrait .st-grade { top: 40%; }
body.portrait .dl-score { top: calc(var(--safe-t) + 52px); }
body.portrait .dl-rival { top: calc(var(--safe-t) + 52px); left: calc(var(--safe-l) + 150px); right: var(--safe-r); width: auto; }
body.portrait .dl-special { right: var(--safe-r); bottom: calc(var(--safe-b) + 44px); width: 96px; height: 62px; }
body.portrait .dl-special b { font-size: 20px; }
body.portrait .dl-combo { bottom: calc(var(--safe-b) + 44px + 82px); }

/* ---- 設定のメニュー: 画面の横いっぱい。タブは上に横ならび (--menu-scale・--menu-h は main.js の fit が決める) ---- */
body.portrait .menu-panel { width: 620px; height: var(--menu-h, 1100px); }
body.portrait .menu-main { flex-direction: column; }
body.portrait .menu-tabs { width: auto; flex-direction: row; flex-wrap: wrap; padding: 14px 18px; border-right: 0; border-bottom: 2px solid var(--line); }
body.portrait .menu-tab { flex: 1 1 28%; }
body.portrait .menu-body { padding: 20px 24px 26px; }
body.portrait .menu-sub { display: none; }
body.portrait .st-screen-title { white-space: nowrap; }

/* ---- フリーバトル: ランキングと左上の名前も、カメラの穴の下へ ---- */
body.portrait .board { top: calc(var(--stage-safe-t, 160px) + 260px); }
body.portrait .logo { top: calc(var(--stage-safe-t, 160px) + 10px); }
