* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #101820;
  color: #f5f5f5;
  font-family: 'Courier New', monospace;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px;
}

#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: 480px;
}

header { text-align: center; width: 100%; }

h1 {
  margin: 0 0 6px;
  font-size: 18px;
  letter-spacing: 2px;
  color: #ffd93b;
  text-shadow: 2px 2px 0 #000;
}

#hud {
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 13px;
  background: #1f2a36;
  padding: 6px;
  border-radius: 6px;
  border: 2px solid #3a4a5a;
}

#canvas-container {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-width: 420px;
  border: 4px solid #3a4a5a;
  border-radius: 8px;
  background: #000;
  overflow: hidden;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#message {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0, 0, 0, 0.75);
  color: #ffd93b;
  font-size: 22px;
  text-align: center;
  padding: 20px;
  text-shadow: 2px 2px 0 #000;
  cursor: pointer;
}

#message.hidden { display: none; }

#touch-controls {
  display: none;
  width: 100%;
  justify-content: space-between;
  align-items: center;
  padding: 0 10px;
  margin-top: 4px;
}

.dpad {
  position: relative;
  width: 150px;
  height: 150px;
}

.dpad-btn {
  position: absolute;
  width: 50px;
  height: 50px;
  background: #3a4a5a;
  color: #ffd93b;
  border: 2px solid #6a7a8a;
  border-radius: 8px;
  font-size: 18px;
  display: flex;
  justify-content: center;
  align-items: center;
  touch-action: manipulation;
}

.dpad-btn:active { background: #6a7a8a; }
.dpad-btn.up    { top: 0;    left: 50px; }
.dpad-btn.down  { bottom: 0; left: 50px; }
.dpad-btn.left  { left: 0;   top: 50px; }
.dpad-btn.right { right: 0;  top: 50px; }

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

#btn-shoot {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: #ff8a1f;
  color: #fff;
  border: 3px solid #ffb86b;
  font-size: 26px;
  touch-action: manipulation;
  box-shadow: 0 4px 0 #a04a00;
}
#btn-shoot:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #a04a00;
}

#btn-restart {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: #d94b4b;
  color: #fff;
  border: 2px solid #ff7a7a;
  font-size: 18px;
  touch-action: manipulation;
}

footer p {
  margin: 4px 0;
  font-size: 11px;
  color: #8899aa;
  text-align: center;
}

@media (hover: none) and (pointer: coarse) {
  #touch-controls { display: flex; }
  footer { display: none; }
}