html, body {
    margin: 0; padding: 0;
    width: 100%; height: 100%;
    background: #0b1410;
    overflow: hidden;
    font-family: "Yu Gothic", "Hiragino Sans", sans-serif;
    color: #fff;
    user-select: none;
    /* モバイルのタップ遅延(約300ms)とタップ時のハイライトを無効化 */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  #game {
    display: block;
    background: #142019;
    margin: 0 auto;
  }
  /* オーバーレイ共通 */
  .overlay {
    position: absolute; inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.65);
    z-index: 10;
    text-align: center;
  }
  .overlay.active { display: flex; }
  .overlay h1 {
    font-size: 56px;
    margin: 0 0 16px 0;
    text-shadow: 0 0 16px #b178ff, 0 0 4px #fff;
    letter-spacing: 0.05em;
  }
  .overlay h2 {
    font-size: 36px;
    margin: 0 0 16px 0;
    text-shadow: 0 0 8px #ffe79b;
  }
  .overlay p { font-size: 18px; margin: 6px 0; color: #ddd; }
  .overlay button {
    margin-top: 28px;
    padding: 14px 48px;
    font-size: 22px;
    background: linear-gradient(180deg, #b178ff, #6a3ec9);
    color: #fff;
    border: 2px solid #e0c8ff;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    letter-spacing: 0.1em;
    box-shadow: 0 0 16px rgba(177, 120, 255, 0.6);
  }
  .overlay button:hover {
    background: linear-gradient(180deg, #c896ff, #8056d8);
    transform: translateY(-2px);
  }

  /* ゲームオーバー画面: 下に gameover.jpg、上側に文字とボタン */
  #gameover {
    background:
      linear-gradient(rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 25%, rgba(0,0,0,0) 50%, rgba(0,0,0,0) 100%),
      url("gameover.jpg") center 85% / auto 55vh no-repeat,
      #0b1410;
    justify-content: flex-start;
    padding-top: 5vh;
  }
  #gameover p, #gameover h2 { text-shadow: 0 0 6px #000, 0 1px 2px #000; }
  #gameover h2 { font-size: 26px; margin: 0 0 6px 0; }
  #gameover p { font-size: 13px; margin: 1px 0; }
  #go-highscore { font-size: 13px !important; margin-top: 4px !important; }
  #gameover button {
    font-size: 16px;
    padding: 8px 28px;
    margin-top: 14px;
  }

  /* クリア画面: 下に clear.jpg(イージー)を背景的に配置 */
  #clear {
    background:
      linear-gradient(rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 25%, rgba(0,0,0,0) 50%, rgba(0,0,0,0) 100%),
      url("clear.jpg") center 85% / auto 55vh no-repeat,
      #0b1410;
    justify-content: flex-start;
    padding-top: 5vh;
  }
  /* ノーマルモードのクリアは別画像(草原・晴天) */
  #clear.clear-normal {
    background:
      linear-gradient(rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 25%, rgba(0,0,0,0) 50%, rgba(0,0,0,0) 100%),
      url("clear_normal.jpg") center 85% / auto 55vh no-repeat,
      #0b1410;
  }

  /* ステージクリア画面: ステージごとに別画像 */
  #stage-clear {
    justify-content: flex-start;
    padding-top: 2vh;
  }
  #stage-clear h2, #stage-clear p { text-shadow: 0 0 6px #000, 0 1px 2px #000; }
  #stage-clear.stage1 {
    background:
      linear-gradient(rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 25%, rgba(0,0,0,0) 50%, rgba(0,0,0,0) 100%),
      url("stage1_clear.jpg") center 85% / auto 55vh no-repeat,
      #0b1410;
  }
  #stage-clear.stage2 {
    background:
      linear-gradient(rgba(0,0,0,0.85) 0%, rgba(0,0,0,0.5) 25%, rgba(0,0,0,0) 50%, rgba(0,0,0,0) 100%),
      url("stage2_clear.jpg") center 85% / auto 55vh no-repeat,
      #0b1410;
  }
  #clear p, #clear h2 { text-shadow: 0 0 6px #000, 0 1px 2px #000; }
  #clear h2 { font-size: 26px; margin: 0 0 6px 0; }
  #clear p { font-size: 13px; margin: 1px 0; }
  #cl-highscore { font-size: 13px !important; margin-top: 4px !important; }
  #clear button {
    font-size: 16px;
    padding: 8px 28px;
    margin-top: 14px;
  }

  /* タイトル画面: 背景アート + 下方を暗くして文字を読みやすく */
  #title {
    background:
      linear-gradient(rgba(11,20,16,0.05), rgba(11,20,16,0.85)),
      url("title_bg.jpg") center / cover no-repeat,
      #0b1410;
    /* 中身を下側に寄せて上部(エンジェラの顔)を見せる */
    justify-content: flex-end;
    padding-bottom: 0;
  }
  /* タイトルロゴ画像(正方形＋透明余白のため高さ基準で制限) */
  #title-logo {
    width: auto;
    max-width: 86%;
    max-height: 29vh;
    margin: 0 0 -28px 0;
    filter: drop-shadow(0 0 18px rgba(177,120,255,0.55));
  }
  /* タイトルの文字を背景上で読みやすく + 行間を詰める + フォント小さめ */
  #title p { text-shadow: 0 0 6px #000, 0 1px 2px #000; margin: 0; font-size: 13px; }
  /* 最高記録の改行はモバイルのみ(デスクトップでは消す=1行) */
  .hs-mobile-break { display: none; }
  #highscore-display { text-shadow: 0 0 6px #000, 0 1px 2px #000; margin-top: 1px; font-size: 13px; }

  /* モード選択(タイトル画面) */
  #mode-select {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-top: 6px;
    align-items: center;
  }
  /* 画像ボタン(枠+文字が画像に含まれる。HTML側のテキストは非表示)
     箱を画像比率(約3.94:1)に合わせて上下の透明余白をなくす */
  .mode-btn {
    width: min(60%, 270px);
    height: clamp(40px, 15.2vw, 68px);
    aspect-ratio: 622 / 158;
    background-color: transparent !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: contain !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 0 !important;
    cursor: pointer;
    transition: transform 0.1s, filter 0.1s;
  }
  .mode-btn:hover {
    transform: translateY(-2px) scale(1.03);
    filter: drop-shadow(0 0 14px rgba(177,120,255,0.85));
    background-color: transparent !important;
  }
  .mode-easy   { background-image: url("btn_easy.png") !important; }
  .mode-normal { background-image: url("btn_normal.png") !important; }

  /* レベルアップカード */
  #levelup .cards {
    display: flex;
    gap: 20px;
    margin-top: 24px;
  }
  .card {
    width: 200px;
    height: 200px;
    background: linear-gradient(160deg, #3a2868, #1d1640);
    border: 2px solid #8a7bd6;
    border-radius: 12px;
    padding: 16px;
    cursor: pointer;
    box-shadow: 0 0 16px rgba(138, 123, 214, 0.5);
    transition: transform 0.1s, box-shadow 0.1s, border-color 0.1s;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
  }
  .card:hover {
    transform: translateY(-6px);
    box-shadow: 0 0 24px rgba(255, 230, 130, 0.8);
    border-color: #ffe79b;
  }
  .card .icon { font-size: 44px; margin-bottom: 10px; }
  .card .name {
    font-size: 18px;
    font-weight: bold;
    color: #ffe79b;
    margin-bottom: 6px;
  }
  .card .desc { font-size: 13px; color: #ddd; line-height: 1.4; }

  #hint {
    position: absolute;
    left: 12px;
    bottom: 12px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.55);
    z-index: 5;
  }

  /* ミニマップ */
  #minimap {
    position: absolute;
    right: 12px;
    bottom: 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    background: rgba(0,0,0,0.5);
    z-index: 5;
    pointer-events: none;
  }

  /* 仮想スティック（タッチ操作） */
  #joystick-zone {
    position: absolute;
    left: 0; bottom: 0;
    width: 200px; height: 200px;
    z-index: 6;
    display: none;
  }
  #joystick-base {
    position: absolute;
    left: 50px; bottom: 50px;
    width: 100px; height: 100px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    border: 2px solid rgba(255,255,255,0.3);
  }
  #joystick-knob {
    position: absolute;
    width: 44px; height: 44px;
    border-radius: 50%;
    background: rgba(177,120,255,0.7);
    border: 2px solid rgba(255,255,255,0.5);
    top: 50%; left: 50%;
    transform: translate(-50%,-50%);
    transition: box-shadow 0.1s;
  }

  /* ハイスコア表示 */
  #highscore-display {
    font-size: 13px;
    color: #ffe79b;
    margin-top: 4px;
  }

  /* ミュートボタン */
  #mute-btn {
    position: absolute;
    right: 14px;
    bottom: 112px;
    width: 38px; height: 38px;
    z-index: 6;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    background: rgba(0,0,0,0.5);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    padding: 0;
    cursor: pointer;
  }

  /* 狭い画面(モバイル縦持ち等)ではレベルアップカードを縦並び・横長に */
  @media (max-width: 700px) {
    #levelup .cards {
      flex-direction: column;
      gap: 12px;
      width: 100%;
      align-items: center;
    }
    .card {
      width: 88vw;
      max-width: 380px;
      height: auto;
      display: grid;
      grid-template-columns: 52px 1fr;
      grid-template-rows: auto auto;
      column-gap: 14px;
      row-gap: 2px;
      align-items: center;
      padding: 12px 16px;
      text-align: left;
    }
    .card .icon {
      grid-row: 1 / 3;
      grid-column: 1;
      font-size: 38px;
      margin: 0;
      text-align: center;
    }
    .card .name { grid-column: 2; margin: 0; }
    .card .desc { grid-column: 2; margin: 0; }
  }

  /* モバイル(縦長)用タイトル調整: ロゴ・文字を小さくして塊を縮め、顔を見せる */
  @media (max-width: 600px) {
    #title {
      background-position: center top;
      background-size: auto 64vh;
      padding-bottom: 7vh;
    }
    #title-logo {
      max-height: 26vh;
      max-width: 95%;
      margin: 0 0 -12px 0;
    }
    #title p { font-size: 10px; }
    #highscore-display { font-size: 10px; }
    .mode-btn { width: min(66%, 240px); }
    /* モバイルは仮想スティック操作なので WASD 説明を隠す */
    #move-hint { display: none; }
    /* 撃破数の後で改行 */
    .hs-mobile-break { display: inline; }
    /* モバイル: 画像を画面幅に合わせる(横がきれないように) */
    #gameover { background-size: 100% auto; }
    #clear, #clear.clear-normal { background-size: 100% auto; }
    #stage-clear.stage1, #stage-clear.stage2 { background-size: 100% auto; }
  }
