* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: #0a0a12;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  overflow: hidden;
  font-family: 'Press Start 2P', monospace;
}

#game-wrapper {
  position: relative;
  width: 100%;
  max-width: 960px;
  aspect-ratio: 16/9;
}

#canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#mobile-controls {
  display: none;
  position: fixed;
  bottom: 10px;
  left: 0;
  right: 0;
  padding: 0 16px;
  justify-content: space-between;
  align-items: flex-end;
  z-index: 100;
  pointer-events: none;
}

#dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
}

.dpad-row {
  display: flex;
  gap: 40px;
}

.dpad-btn {
  width: 52px;
  height: 52px;
  background: rgba(255,255,255,0.15);
  border: 2px solid rgba(255,255,255,0.3);
  border-radius: 8px;
  color: #fff;
  font-size: 18px;
  font-family: 'Press Start 2P', monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
  background: rgba(255,255,255,0.35);
}

#action-buttons {
  display: flex;
  gap: 12px;
  pointer-events: auto;
}

.action-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.3);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.sword-btn {
  background: rgba(0,229,255,0.25);
}
.gun-btn {
  background: rgba(0,229,255,0.15);
}

.action-btn:active {
  background: rgba(0,229,255,0.5);
}

footer {
  padding: 12px;
  text-align: center;
}

footer a {
  color: #555;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  text-decoration: none;
}

footer a:hover {
  color: #00e5ff;
}

@media (pointer: coarse), (max-width: 768px) {
  #mobile-controls {
    display: flex;
  }
  #game-wrapper {
    aspect-ratio: auto;
    height: 60vh;
    max-width: 100%;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  #game-wrapper {
    height: 80vh;
  }
  #mobile-controls {
    bottom: 2px;
  }
  .dpad-btn, .action-btn {
    width: 44px;
    height: 44px;
    font-size: 14px;
  }
}