/* 坦克大战 - 响应式布局（桌面 + 手机触屏） */
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  height: 100%;
  background: #0d0d14;
  color: #eee;
  font-family: 'Courier New', monospace;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
}

#wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 600px;
  padding: 6px;
}

#game {
  width: min(96vw, 560px);
  height: auto;
  aspect-ratio: 560 / 448;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #000;
  border-radius: 4px;
  box-shadow: 0 0 28px rgba(0, 0, 0, 0.7);
  touch-action: none;
}

#hint {
  margin-top: 10px;
  font-size: 12px;
  color: #888;
  text-align: center;
}

#rotate-tip {
  display: none;
  margin-top: 8px;
  font-size: 12px;
  color: #6cf0ff;
}

/* ---------- 触屏控件（默认隐藏，触屏设备显示） ---------- */
#touch-controls {
  display: none;
  width: 100%;
  max-width: 560px;
  padding: 12px 12px 16px;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  overflow: hidden;
}
body.touch #touch-controls { display: flex; }
body.touch #hint { display: none; }

@media (pointer: coarse) and (orientation: portrait) {
  #rotate-tip { display: block; }
}

#dpad {
  position: relative;
  width: 132px;
  height: 132px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #2c2c3e, #15151f 75%);
  border: 2px solid #484858;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.6);
  touch-action: none;
}
.dpad-arrow {
  position: absolute;
  font-size: 18px;
  color: #777;
  pointer-events: none;
  transition: color 0.08s;
}
.a-up { top: 8px; left: 50%; transform: translateX(-50%); }
.a-down { bottom: 8px; left: 50%; transform: translateX(-50%); }
.a-left { left: 10px; top: 50%; transform: translateY(-50%); }
.a-right { right: 10px; top: 50%; transform: translateY(-50%); }
#dpad.on-up .a-up, #dpad.on-down .a-down,
#dpad.on-left .a-left, #dpad.on-right .a-right { color: #ffd800; }
#dpad.on-up { box-shadow: inset 0 14px 18px -8px rgba(255, 216, 0, 0.45); }
#dpad.on-down { box-shadow: inset 0 -14px 18px -8px rgba(255, 216, 0, 0.45); }
#dpad.on-left { box-shadow: inset 14px 0 18px -8px rgba(255, 216, 0, 0.45); }
#dpad.on-right { box-shadow: inset -14px 0 18px -8px rgba(255, 216, 0, 0.45); }

#mid-btns {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  flex: 0 0 auto;
}
#btn-start, #btn-pause { white-space: nowrap; max-width: 96px; overflow: hidden; }

/* 窄屏手机进一步收紧控件 */
@media (max-width: 480px) {
  #dpad { width: 116px; height: 116px; }
  #btn-fire { width: 76px; height: 76px; font-size: 14px; }
  #btn-start, #btn-pause { padding: 7px 8px; font-size: 10px; }
}
#btn-start, #btn-pause {
  padding: 9px 10px;
  border-radius: 10px;
  border: 2px solid #555;
  background: #26262f;
  color: #ccc;
  font: bold 11px 'Courier New', monospace;
  letter-spacing: 1px;
}
#btn-start.active, #btn-pause.active { background: #3a3a4a; border-color: #ffd800; color: #ffd800; }

#btn-fire {
  width: 88px;
  height: 88px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 3px solid #e74c3c;
  background: radial-gradient(circle at 50% 35%, #d35450, #8e241a 75%);
  color: #fff;
  font: bold 16px 'Courier New', monospace;
  letter-spacing: 1px;
  box-shadow: 0 4px 14px rgba(231, 76, 60, 0.35);
  touch-action: none;
}
#btn-fire.active {
  background: radial-gradient(circle at 50% 35%, #f08080, #c0392b 75%);
  transform: scale(0.94);
}

/* ---------- 手机横屏：控件悬浮于画面两侧 ---------- */
@media (orientation: landscape) and (max-height: 560px) {
  #wrap { max-width: none; }
  #game {
    width: auto;
    height: calc(100vh - 12px);
    max-width: 97vw;
  }
  #rotate-tip { display: none; }
  body.touch #touch-controls {
    position: fixed;
    inset: 0;
    max-width: none;
    padding: 0;
    pointer-events: none;
    z-index: 10;
    display: block;
  }
  body.touch #dpad {
    position: absolute;
    left: 16px;
    bottom: 16px;
    opacity: 0.62;
    pointer-events: auto;
  }
  body.touch #btn-fire {
    position: absolute;
    right: 18px;
    bottom: 18px;
    opacity: 0.72;
    pointer-events: auto;
  }
  body.touch #mid-btns {
    position: absolute;
    right: 22px;
    bottom: 128px;
    flex-direction: row;
    opacity: 0.72;
    pointer-events: auto;
  }
}
