/* SquashAndCrush Web 用テンプレート。
   Unity 既定テンプレートの 960x600 固定枠とフッターロゴは使わない。

   レイアウト方針：
     スマホ（縦長）          … ゲームがビューポート全体
     PC・タブレット（横長）  … ゲームを縦持ち比率(9:16)で中央に固定し、
                               余った両脇をディスプレイ広告に使う
   UI は 1080x1920 基準で組まれているので、横長画面で canvas を
   全面に広げると縦持ち前提の配置が間延びする。だから比率を固定する。 */

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #14141a;
  /* iOS のアドレスバー出入りで高さが変わるのを抑える */
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", sans-serif;
  color: #e8e8ee;
}

#unity-container {
  position: fixed;
  top: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
  left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

/* canvas とオーバーレイ（ローディング・警告）の基準枠 */
#unity-stage {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  height: 100%;
}

#unity-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #14141a;
  /* ダブルタップ拡大と長押しメニューを殺す（連打・長押し操作のゲームが多い） */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* ── サイトへ戻るバー ─────────────────────────────────────
   静的ファイル配信なので Next.js のヘッダーが乗らない。
   サイトの外に出たまま戻れなくなるのを防ぐため、最小限の帯を自前で置く。 */

:root { --bar-h: 44px; }

#site-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: calc(var(--bar-h) + env(safe-area-inset-top, 0px));
  padding: env(safe-area-inset-top, 0px) 14px 0;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #0d0d12;
  border-bottom: 1px solid #26262f;
  z-index: 30;
  font-size: 13px;
}

#site-bar a {
  color: #b9b9c6;
  text-decoration: none;
  white-space: nowrap;
}

#site-bar a:hover { color: #fff; }

#site-bar .home { font-weight: 700; color: #e0483c; }

#site-bar .links { display: flex; gap: 16px; }

/* ── 両脇の広告 ───────────────────────────────────────────── */

.ad-rail {
  display: none;   /* 既定は非表示。横長かつ十分に広い画面でだけ出す */
  flex: 0 0 300px;
  width: 300px;
  height: 600px;
  overflow: hidden;
}

/* 横長画面：ゲームを縦持ち比率に固定して中央へ */
@media (min-aspect-ratio: 1/1) {
  #unity-stage {
    height: 100%;
    width: auto;
    aspect-ratio: 9 / 16;
  }
}

/* さらに広い画面：両脇に広告を出す。
   ゲーム(=100vh*9/16)＋広告300px×2＋余白 が収まる幅を条件にする。 */
@media (min-aspect-ratio: 1/1) and (min-width: 1280px) {
  .ad-rail { display: block; }
}

/* ── 読み込み中 ───────────────────────────────────────────── */

#unity-loading-bar {
  position: absolute;
  inset: 0;
  display: none;          /* index.html 側で flex にする */
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: #14141a;
  z-index: 10;
}

#unity-loading-title {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.18em;
}

#unity-loading-note {
  font-size: 13px;
  color: #8b8b99;
  letter-spacing: 0.08em;
}

#unity-progress-bar-empty {
  width: min(260px, 62vw);
  height: 6px;
  border-radius: 3px;
  background: #2b2b36;
  overflow: hidden;
}

#unity-progress-bar-full {
  width: 0%;
  height: 100%;
  background: #e0483c;
  transition: width 0.15s linear;
}

/* ── 警告バナー ───────────────────────────────────────────── */

#unity-warning {
  position: absolute;
  left: 50%;
  top: 12px;
  transform: translate(-50%, 0);
  display: none;
  z-index: 20;
  color: #14141a;
  font-size: 13px;
  text-align: center;
}
