* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: #111;
  color: #fff;
  font-family: "Courier New", monospace;
}

body {
  display: flex;
  justify-content: center;
  padding: 16px;
}

.game-shell { width: min(1024px, 100%); }

.topbar, .hud, .mode-panel {
  background: #1c1c1c;
  border: 3px solid #333;
}

.topbar {
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 7px 12px;
  gap: 12px;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: 5px;
}

.top-center { text-align: center; }
#turnLabel { font-size: 16px; font-weight: bold; }
#modeLabel { color: #aaa; font-size: 10px; margin-top: 2px; }

button {
  background: #eee;
  color: #111;
  border: 0;
  padding: 9px 14px;
  font: bold 14px "Courier New", monospace;
  cursor: pointer;
}

button:hover { background: #fff; }
button:focus-visible { outline: 3px solid #ffdf4d; outline-offset: 2px; }

#restartButton { justify-self: end; }

.mode-panel {
  border-top: 0;
  min-height: 48px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  font-size: 12px;
}

.mode-panel > span { color: #aaa; margin-right: 4px; }
.mode-button { padding: 7px 12px; font-size: 12px; }
.mode-button.active { background: #ffdf4d; color: #111; }

.hud {
  border-top: 0;
  min-height: 56px;
  display: grid;
  grid-template-columns: 1fr 1.7fr 1fr;
  align-items: center;
  padding: 6px 12px;
  gap: 10px;
  font-size: 13px;
}

.tank-status { display: flex; align-items: center; gap: 8px; }
.red-status { justify-content: flex-end; }
.swatch { width: 13px; height: 13px; display: inline-block; }
.swatch.blue { background: #1565ff; }
.swatch.red { background: #e53935; }

.controls {
  display: flex;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.controls strong { color: #ffdf4d; }
.power-control { display: inline-flex; align-items: center; gap: 5px; }
.power-control small { color: #aaa; font-size: 10px; white-space: nowrap; }
.power-meter {
  position: relative;
  display: inline-block;
  width: 126px;
  height: 18px;
  overflow: hidden;
  border: 1px solid #e9e9e9;
  background: #080808;
  vertical-align: middle;
}
.power-meter-fill {
  display: block;
  width: 43%;
  height: 100%;
  background: linear-gradient(90deg, #3ddc64, #ffdf4d, #e95a45);
  transition: width .08s linear;
}
.power-meter strong {
  position: absolute;
  inset: 0;
  color: #fff;
  line-height: 16px;
  text-shadow: 1px 1px 1px #000;
}
.hint { color: #aaa; }

.canvas-wrap {
  position: relative;
  width: 100%;
  background: #fff;
  border: 3px solid #333;
  border-top: 0;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  background: #fff;
}

.message {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, .72);
  font-size: clamp(22px, 5vw, 48px);
  font-weight: bold;
  text-align: center;
  letter-spacing: 3px;
  padding: 20px;
}

.message.hidden { display: none; }
footer { color: #777; text-align: center; font-size: 11px; padding: 10px; }

@media (max-width: 700px) {
  body { padding: 5px; }
  .topbar { grid-template-columns: 1fr auto; }
  .top-center { grid-column: 1 / -1; grid-row: 2; order: 3; padding: 3px; }
  .mode-panel { flex-wrap: wrap; }
  .hud { grid-template-columns: 1fr 1fr; }
  .controls { grid-column: 1 / -1; grid-row: 1; flex-wrap: wrap; gap: 10px; }
  .tank-status { grid-row: 2; }
  .hint { display: none; }
}
