* {
  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;
  /* PC: レターボックス表示（16:9 固定） */
  max-width: 100vw;
  max-height: 100vh;
  width: auto;
  height: auto;
  aspect-ratio: 16 / 9;
}

/* ===== タッチコントローラー ===== */
#touch-controls {
  display: none;
  width: 100%;
  padding: 10px 16px;
  justify-content: space-between;
  align-items: flex-end;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  gap: 12px;
}

.touch-left {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.touch-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.touch-right-bottom {
  display: flex;
  gap: 10px;
}

.touch-btn {
  border: none;
  border-radius: 50%;
  font-family: 'Arial Black', sans-serif;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.08s, filter 0.08s;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* ステアリング（← →） */
.touch-steer {
  width: 68px;
  height: 68px;
  font-size: 26px;
  background: radial-gradient(circle at 35% 35%, rgba(255,255,255,0.2), rgba(255,255,255,0.06));
  color: rgba(255, 255, 255, 0.85);
  border: 2px solid rgba(255, 255, 255, 0.25);
}

/* アクセル（大きめ） */
.touch-accel {
  width: 80px;
  height: 80px;
  font-size: 14px;
  letter-spacing: 1px;
  background: radial-gradient(circle at 35% 35%, rgba(80, 200, 80, 0.6), rgba(40, 140, 40, 0.4));
  color: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(100, 230, 100, 0.5);
}

/* ドリフト */
.touch-drift {
  width: 72px;
  height: 72px;
  font-size: 11px;
  letter-spacing: 1px;
  background: radial-gradient(circle at 35% 35%, rgba(255, 160, 40, 0.6), rgba(200, 100, 20, 0.4));
  color: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(255, 200, 80, 0.5);
}

/* アイテム使用 */
.touch-item {
  width: 72px;
  height: 72px;
  font-size: 11px;
  letter-spacing: 1px;
  background: radial-gradient(circle at 35% 35%, rgba(180, 80, 255, 0.6), rgba(120, 40, 200, 0.4));
  color: rgba(255, 255, 255, 0.95);
  border: 2px solid rgba(200, 140, 255, 0.5);
}

/* ボタン押下時 */
.touch-btn:active,
.touch-btn.active {
  transform: scale(0.88);
  filter: brightness(1.6);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* ===== スマホ表示 ===== */
@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;
    max-height: none;
  }
}

/* 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;
  max-height: none;
}

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