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

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

#game-wrapper {
  position: relative;
  width: 100%;
  max-width: 900px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#canvas {
  width: 100%;
  max-width: 900px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 2px solid #ff00aa;
  box-shadow: 0 0 30px rgba(255, 0, 170, 0.4), 0 0 60px rgba(150, 0, 255, 0.2);
}

#touch-controls {
  display: none;
  width: 100%;
  max-width: 900px;
  padding: 10px;
  justify-content: space-between;
  align-items: center;
  position: fixed;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  pointer-events: none;
}

#dpad {
  display: grid;
  grid-template-areas:
    ". up ."
    "left . right"
    ". down .";
  grid-template-columns: 50px 50px 50px;
  grid-template-rows: 50px 50px 50px;
  gap: 2px;
  pointer-events: auto;
}

#btn-up { grid-area: up; }
#btn-left { grid-area: left; }
#btn-right { grid-area: right; }
#btn-down { grid-area: down; }

.dpad-btn {
  background: rgba(255, 0, 170, 0.5);
  border: 2px solid #ff00aa;
  border-radius: 8px;
  color: white;
  font-size: 18px;
  font-family: 'Press Start 2P', monospace;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.dpad-btn:active {
  background: rgba(255, 0, 170, 0.9);
}

#action-buttons {
  display: grid;
  grid-template-columns: 55px 55px;
  grid-template-rows: 55px 55px;
  gap: 6px;
  pointer-events: auto;
}

.action-btn {
  background: rgba(200, 0, 255, 0.5);
  border: 2px solid #c800ff;
  border-radius: 50%;
  color: white;
  font-size: 14px;
  font-family: 'Press Start 2P', monospace;
  width: 55px;
  height: 55px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

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

footer {
  margin-top: 10px;
  padding: 8px;
}

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

footer a:hover {
  color: #ff00aa;
  text-shadow: 0 0 8px #ff00aa;
}

@media (max-width: 768px) {
  #touch-controls {
    display: flex;
  }
  footer { display: none; }
}

@media (pointer: coarse) {
  #touch-controls {
    display: flex;
  }
}