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

body {
  background: #000;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  -ms-touch-action: none;
}

#game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  height: 100%;
}

canvas {
  display: block;
  image-rendering: pixelated;
}

/* タッチコントローラー — スマホのみ表示 */
#touch-controls {
  display: none;
  width: 100%;
  padding: 12px 16px;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.touch-left, .touch-right {
  display: flex;
  gap: 12px;
}

.touch-btn {
  border: none;
  border-radius: 50%;
  font-family: monospace;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.touch-arrow {
  width: 64px;
  height: 64px;
  font-size: 24px;
  background: rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.touch-action {
  width: 72px;
  height: 72px;
  font-size: 13px;
  background: rgba(68, 136, 255, 0.25);
  color: rgba(255, 255, 255, 0.8);
  border: 2px solid rgba(68, 136, 255, 0.4);
}

.touch-attack {
  background: rgba(255, 68, 68, 0.25);
  border-color: rgba(255, 68, 68, 0.4);
}

.touch-btn:active, .touch-btn.active {
  transform: scale(0.9);
  filter: brightness(1.5);
}

.touch-arrow:active, .touch-arrow.active {
  background: rgba(255, 255, 255, 0.3);
}

.touch-action:active, .touch-action.active {
  background: rgba(68, 136, 255, 0.5);
}

.touch-attack:active, .touch-attack.active {
  background: rgba(255, 68, 68, 0.5);
}

/* スマホ: CSSフォールバック */
@media (hover: none), (pointer: coarse), (max-width: 900px) {
  #touch-controls { display: flex !important; }
  body { align-items: flex-start !important; }
  canvas { width: 100vw !important; height: auto !important; aspect-ratio: 16 / 9; }
}

/* スマホ: JSで .is-touch クラスが付与される */
body.is-touch {
  align-items: flex-start;
}

body.is-touch #game-container {
  justify-content: flex-start;
}

body.is-touch canvas {
  width: 100vw !important;
  height: auto !important;
  aspect-ratio: 16 / 9;
}

body.is-touch #touch-controls {
  display: flex;
  flex-shrink: 0;
}
