* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #0b0f17;
  color: #e7f0ff;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans JP", sans-serif;
  display: flex;
  flex-direction: column;
}

.hud {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
  backdrop-filter: blur(6px);
  position: sticky;
  top: 0;
  z-index: 10;
  font-size: 14px;
}

.hud span {
  margin-right: 10px;
  opacity: 0.9;
}

.hud strong {
  font-variant-numeric: tabular-nums;
}

.game-wrap {
  position: relative;
  width: min(100vw, 520px);
  margin: 0 auto;
  aspect-ratio: 9 / 16;
  max-height: calc(100vh - 120px);
}

#game {
  width: 100%;
  height: 100%;
  display: block;
  background: radial-gradient(120% 100% at 50% 0%, #122035, #070b12 70%);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

/* タップゾーン */
/* キャンバスの操作を最優先にする */
.touch-zones {
  pointer-events: none;
  /* ← これで下のcanvasにイベントが届く */
}

.touch-zones button {
  pointer-events: none;
  /* 念のため */
}


.touch-zones button {
  width: 100%;
  height: 100%;
  background: transparent;
  border: 0;
  touch-action: none;
}

/* Game Over */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.35);
}

.overlay.hidden {
  display: none;
}

.panel {
  background: rgba(8, 16, 28, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  padding: 18px 22px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.panel .title {
  font-weight: 800;
  font-size: 24px;
  margin-bottom: 6px;
}

.panel .sub {
  opacity: 0.8;
  font-size: 14px;
}

.tips {
  text-align: center;
  padding: 8px 0 16px;
  opacity: 0.75;
  font-size: 13px;
}

/* style.css に追加 */
html,
body {
  overscroll-behavior: none;
}

#game {
  touch-action: none;
  /* モバイルのスクロール/戻るジェスチャ無効 */
}

/* キャンバスの入力を最優先に通す */
.touch-zones,
.touch-zones button {
  pointer-events: none;
}

/* --- セーフエリア＆モバイルUIの重なり対策 --- */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* 旧iOS用フォールバック（あっても害なし） */
@supports (padding: constant(safe-area-inset-bottom)) {
  :root {
    --safe-top: constant(safe-area-inset-top);
    --safe-bottom: constant(safe-area-inset-bottom);
  }
}

/* 画面の実可視高を使う（ブラウザUIを除外） */
html,
body {
  margin: 0;
  background: #0a0f18;
  min-height: 100svh;
  /* 対応ブラウザではこれが効く。未対応でも通常表示 */
}

/* キャンバスが下バーに隠れないように底に余白を付ける */
body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(var(--safe-top) + 8px) 0 calc(var(--safe-bottom) + 12px);
}

#game {
  display: block;
}

/* 念のため */