/* 小向クエスト2 用。1の game/style.css のコピーだが、canvas の id が #game2 なので
   セレクタを差し替えてある（#game のままだとサイズ指定が一切当たらない）。
   文脈のデザイン言語準拠: ダーク基調・オレンジ #ff7f0e アクセント・システムフォント */
:root {
  --bg: #15171a;
  --ink: #d0d3d6;
  --accent: #ff7f0e;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", sans-serif;
  overflow: hidden;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  /* ノッチ/ダイナミックアイランドを避ける（viewport-fit=cover と併用） */
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#frame {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

#game2 {
  /* 縦・横どちらにも収まるよう 16:9 を保ったまま contain（はみ出さない）。
     width:auto だと canvas の属性値(480)が初期幅になり、JS が毎フレーム
     canvas.width = 表示幅 x dpr を書き戻すため、dpr によって最終サイズが変わる
     （dpr=1 では 480 のまま小さく、dpr=2 では膨張し続けて画面が壊れる）。
     表示幅をビューポートから直接決めて dpr に依存しないようにする。 */
  aspect-ratio: 16 / 9;
  width: min(100%, calc((100dvh - 3.6rem) * 16 / 9));
  height: auto;
  max-width: 100%;
  max-height: calc(100% - 3.6rem); /* 下のキー説明ぶん(2行)を確保 */
  background: #000;
  border-radius: 10px;
  border: 1px solid #2a2e34;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  /* 高DPI描画なので滑らかに表示（ドット絵自体はimageSmoothing=falseでくっきり） */
  /* タッチ操作中のスクロール/ズームを抑止 */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#hint {
  flex: 0 0 auto;
  font-size: 13px;
  color: #8b9097;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

/* タッチ端末では画面内に操作UIが出るので、下のキー説明は隠して全面をゲームに使う */
@media (pointer: coarse) {
  #hint { display: none; }
  #game2 { width: min(100%, calc(100dvh * 16 / 9)); max-height: 100%; }
}

/* 縦持ち: 16:9の画面を縦長の端末に入れると高さの26%しか使えない。
   3D版と同じく、画面ごと90°回して縦画面いっぱいに出す。横スクロールのゲームなので向きは横で固定。
   タッチ判定は offsetX/offsetY（要素自身の座標系）で取っているため回してもずれない。 */
@media (orientation: portrait) and (pointer: coarse) {
  #frame { position: relative; gap: 0; }
  #game2 {
    position: absolute; left: 50%; top: 50%;
    --w: min(100dvh, 100vw * 16 / 9);
    width: var(--w); height: calc(var(--w) * 9 / 16);
    max-width: none; max-height: none;
    transform: translate(-50%, -50%) rotate(90deg);
    border-radius: 0; border: 0;
  }
}
