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

html, body {
  width: 100%; height: 100%;
  background: #0a0b1a;
  overflow: hidden;
  font-family: 'DotGothic16', monospace;
  touch-action: none;
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  position: fixed; inset: 0;
}

/* touch-action は継承されないため、触れる要素すべてに明示する(ダブルタップズーム対策) */
#wrap, #game, #touch, #touch button, #rotate {
  touch-action: none;
}

#wrap {
  width: 100vw; height: 100vh; height: 100dvh;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 40%, #161a3a 0%, #0a0b1a 70%);
}

#game {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #10122b;
  box-shadow: 0 0 0 2px #2b3058, 0 12px 48px rgba(0, 0, 0, .6);
}

/* ---------- タッチ操作 ---------- */
#touch { display: none; }
body.has-touch #touch { display: block; }

.tg {
  position: fixed;
  bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 10px;
  z-index: 10;
}
.tg .lr { display: flex; gap: 12px; }
.tg-left { left: calc(14px + env(safe-area-inset-left, 0px)); align-items: center; }
.tg-right { right: calc(14px + env(safe-area-inset-right, 0px)); align-items: flex-start; }

#touch button {
  width: 66px; height: 66px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35);
  background: rgba(20, 24, 58, .45);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  font-family: 'DotGothic16', monospace;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 2px;
  -webkit-tap-highlight-color: transparent;
}
#touch button small { font-size: 9px; color: rgba(255, 255, 255, .75); }
#touch button:active, #touch button.pressed { background: rgba(255, 255, 255, .35); }

#touch .b-down { width: 54px; height: 54px; font-size: 16px; }
#touch .b-spec { width: 58px; height: 58px; font-size: 18px; margin-left: 4px; }
#touch .b-atk  { border-color: rgba(255, 107, 107, .85); background: rgba(120, 30, 40, .45); width: 72px; height: 72px; }
#touch .b-jump { border-color: rgba(255, 209, 102, .85); background: rgba(110, 85, 20, .45); width: 72px; height: 72px; }
#touch .b-spec { border-color: rgba(90, 167, 255, .85); background: rgba(25, 60, 120, .45); }

#btn-pause {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: calc(10px + env(safe-area-inset-right, 0px));
  width: 44px !important; height: 44px !important;
  font-size: 16px !important;
  border-radius: 12px !important;
  z-index: 11;
}

/* ---------- 縦持ち警告 ---------- */
#rotate { display: none; }
@media (orientation: portrait) {
  body.has-touch #rotate {
    display: flex;
    position: fixed; inset: 0;
    z-index: 100;
    background: rgba(8, 9, 24, .92);
    align-items: center; justify-content: center;
    text-align: center;
    color: #ffd166;
    font-size: 22px;
    line-height: 1.8;
  }
}
