/* ビームシューターゲーム - iOS 70/30 レイアウト */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
}

::selection {
  background: transparent;
  color: inherit;
}

html, body {
  width: 100%;
  height: 100%;
  height: 100dvh;
  height: -webkit-fill-available;
  overflow: hidden;
  overscroll-behavior: none;
  background: #000428;
}

body {
  font-family: Arial, sans-serif;
  color: #fff;
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(14, 75, 110, 0.45), transparent 34%),
    linear-gradient(135deg, #01030f, #061528 48%, #01030f);
}

#gameContainer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: #000011;
  display: flex;
  flex-direction: column;
}

/* PCでは縦型ゲーム筐体として中央表示。スマホは全幅のまま */
@media (min-width: 700px) {
  #gameContainer {
    left: 50%;
    right: auto;
    width: min(560px, 100vw);
    transform: translateX(-50%);
    border-left: 1px solid rgba(0, 255, 204, 0.28);
    border-right: 1px solid rgba(0, 255, 204, 0.28);
    box-shadow: 0 0 48px rgba(0, 190, 255, 0.18), 0 0 100px rgba(0, 0, 0, 0.8);
  }
}

/* 上70%: プレイ画面（HUDは重ねて領域を奪わない） */
#playArea {
  position: relative;
  flex: 1 1 70%;
  width: 100%;
  min-height: 0;
  z-index: 1;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #000011;
  border: none;
  border-radius: 0;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  padding: calc(4px + env(safe-area-inset-top, 0px)) 10px 8px;
  background: linear-gradient(to bottom, rgba(0, 8, 20, 0.78) 0%, rgba(0, 8, 20, 0.35) 70%, transparent 100%);
  pointer-events: none;
}

#hud .game-btn {
  pointer-events: auto;
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: clamp(13px, 3.8vw, 16px);
  font-weight: bold;
  line-height: 1.25;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000, 0 0 8px #000;
}

.hud-row-sub {
  margin-top: 2px;
  opacity: 0.95;
}

.hud-icon {
  width: 40px;
  min-width: 40px;
  height: 40px;
  min-height: 40px;
  padding: 0;
  border: 1px solid rgba(0, 255, 204, 0.4);
  border-radius: 8px;
  background: rgba(0, 20, 40, 0.75);
  color: #00ffcc;
  font-size: 18px;
}

/* 下30%: コントロールパネル（プレイ画面と分離） */
#gameControls {
  --ctrl-h: 30dvh;
  --ctrl-inner: calc(var(--ctrl-h) - env(safe-area-inset-bottom, 0px) - 12px);
  --pad-size: clamp(48px, calc(var(--ctrl-inner) / 3.25), 68px);
  position: relative;
  flex: 0 0 30%;
  height: 30%;
  min-height: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom, 0px));
  background:
    linear-gradient(180deg, #0a1a28 0%, #040c14 100%);
  border-top: 2px solid rgba(0, 255, 204, 0.35);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

#touchControls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 520px;
  height: 100%;
  pointer-events: none;
}

#touchControls > * {
  pointer-events: auto;
}

#moveControls {
  display: grid;
  grid-template-columns: repeat(3, var(--pad-size));
  grid-template-rows: repeat(3, var(--pad-size));
  gap: 3px;
  touch-action: none;
  border-radius: 50%;
}

#moveControls::after {
  content: '';
  grid-column: 2;
  grid-row: 2;
  width: 45%;
  height: 45%;
  place-self: center;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0, 255, 204, 0.42), rgba(0, 80, 72, 0.28));
  box-shadow: 0 0 10px rgba(0, 255, 204, 0.24);
  pointer-events: none;
}

#leftBtn { grid-column: 1; grid-row: 2; }
#rightBtn { grid-column: 3; grid-row: 2; }
#upBtn { grid-column: 2; grid-row: 1; }
#downBtn { grid-column: 2; grid-row: 3; }

#fireControls {
  display: flex;
  align-items: center;
  gap: 10px;
}

#bombContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.game-btn {
  cursor: pointer;
  color: #fff;
  border: none;
  font-weight: bold;
  transition: transform 0.08s ease, opacity 0.08s ease, filter 0.08s ease;
  will-change: transform;
  touch-action: manipulation;
}

.game-btn:active,
.game-btn.is-pressed {
  transform: scale(0.9) translateY(2px);
  opacity: 0.88;
  filter: brightness(1.25);
}

.game-btn:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.pad-btn,
.action-btn {
  width: var(--pad-size);
  height: var(--pad-size);
  min-width: 48px;
  min-height: 48px;
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(0, 180, 160, 0.7), rgba(0, 90, 80, 0.75));
  border: 1px solid rgba(0, 255, 204, 0.45);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  font-size: 1.1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.action-btn small {
  font-size: 8px;
  letter-spacing: 0.08em;
}

#shootBtn {
  width: calc(var(--pad-size) * 1.22);
  height: calc(var(--pad-size) * 1.22);
  min-width: 48px;
  min-height: 48px;
  background: linear-gradient(145deg, rgba(244, 67, 54, 0.85), rgba(183, 28, 28, 0.85));
  border-color: rgba(255, 180, 180, 0.55);
}

#bombBtn {
  background: linear-gradient(145deg, #9e9e9e, #616161);
  border-color: rgba(220, 220, 220, 0.4);
}

#bombCountDisplay {
  margin-top: 2px;
  font-size: 11px;
  font-weight: bold;
  color: #00ffcc;
}

#gameTitle {
  font-size: clamp(1.15rem, 5vw, 1.7rem);
  font-weight: bold;
  color: #00ffcc;
  text-shadow: 0 0 8px #00ffcc, 2px 2px 4px rgba(0, 0, 0, 0.5);
  margin-bottom: 4px;
  flex: 0 0 auto;
}

.overlay-panel,
#startScreen {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: rgba(0, 8, 20, 0.94);
  padding: max(8px, env(safe-area-inset-top)) 10px 8px 10px;
  overflow: hidden;
}

.overlay-panel {
  border: none;
  border-radius: 0;
}

#pauseScreen {
  background: rgba(20, 12, 0, 0.92);
}

#pauseScreen h2 {
  color: #ffa500;
  margin-bottom: 12px;
  font-size: 1.6em;
}

#gameOver h2 {
  color: #f44336;
  margin-bottom: 12px;
  font-size: 1.6em;
}

#gameClear h2 {
  color: #4CAF50;
  margin-bottom: 12px;
  font-size: 1.6em;
}

#startScreen h2 {
  font-size: 0.85rem;
  margin-bottom: 6px;
  color: #9be7ff;
  flex: 0 0 auto;
}

#restartBtn,
#clearRestartBtn,
#startBtn,
#resumeBtn {
  background: linear-gradient(145deg, #4CAF50, #2e7d32);
  padding: 12px 24px;
  font-size: 1rem;
  border-radius: 12px;
  margin-top: 8px;
  min-height: 48px;
  border: 1px solid rgba(180, 255, 180, 0.35);
  flex: 0 0 auto;
}

.hidden {
  display: none !important;
}

/* 開始画面の武器一覧: 2列・全アイテムを縦スクロールで確認 */
#itemList {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 8px;
  width: 100%;
  max-width: 420px;
  margin: 0 0 4px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
  flex: 0 1 auto;
  min-height: 0;
}

#itemList li {
  list-style: none;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 4px 6px;
  background: rgba(0, 40, 60, 0.45);
  border: 1px solid rgba(0, 255, 204, 0.18);
  border-radius: 8px;
}

.item-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  text-align: left;
  line-height: 1.15;
}

.item-text b {
  font-size: clamp(0.68rem, 3.1vw, 0.82rem);
  font-weight: 700;
  color: #e8ffff;
}

.item-text small {
  font-size: clamp(0.55rem, 2.5vw, 0.68rem);
  font-weight: 400;
  color: #9be7ff;
  opacity: 0.9;
}

.colorBox {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid #fff;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .hud-row,
  .hud-row-sub {
    font-size: clamp(13px, 3.7vw, 15px);
  }
}

@media (max-height: 620px) {
  #itemList {
    gap: 2px 6px;
  }
  #itemList li {
    padding: 2px 4px;
  }
  .item-text small {
    display: none;
  }
  #gameTitle {
    font-size: 1.05rem;
    margin-bottom: 2px;
  }
  #startScreen h2 {
    font-size: 0.75rem;
    margin-bottom: 4px;
  }
}
