* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #050514;
  font-family: 'Orbitron', sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#game-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
  position: relative;
}

#canvas {
  display: block;
  image-rendering: auto;
}

#mobile-controls {
  display: none;
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
}

#dpad {
  display: grid;
  grid-template-columns: 60px 60px 60px;
  grid-template-rows: 60px 60px;
  gap: 4px;
}

.dpad-btn {
  width: 60px;
  height: 60px;
  border: 2px solid rgba(0, 245, 255, 0.3);
  background: rgba(0, 245, 255, 0.08);
  color: rgba(0, 245, 255, 0.7);
  border-radius: 12px;
  font-size: 22px;
  cursor: pointer;
  outline: none;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-user-select: none;
  user-select: none;
}

.dpad-btn:active {
  background: rgba(0, 245, 255, 0.25);
  border-color: rgba(0, 245, 255, 0.6);
}

#btn-up {
  grid-column: 2;
  grid-row: 1;
}
#btn-left {
  grid-column: 1;
  grid-row: 2;
}
#btn-center {
  grid-column: 2;
  grid-row: 2;
  border: none;
  background: none;
  pointer-events: none;
}
#btn-right {
  grid-column: 3;
  grid-row: 2;
}
#btn-down {
  grid-column: 2;
  grid-row: 2;
  display: none;
}

/* Rearrange for 3-row diamond layout */
#dpad {
  grid-template-rows: 60px 60px 60px;
}
#btn-left { grid-row: 2; }
#btn-center { grid-row: 2; display: none; }
#btn-right { grid-row: 2; }
#btn-down {
  display: flex;
  grid-column: 2;
  grid-row: 3;
}

@media (pointer: coarse), (max-width: 768px) {
  #mobile-controls {
    display: block;
  }
}

#footer {
  position: fixed;
  bottom: 4px;
  text-align: center;
  z-index: 50;
}

#footer a {
  color: rgba(0, 245, 255, 0.3);
  text-decoration: none;
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  letter-spacing: 1px;
}

#footer a:hover {
  color: rgba(0, 245, 255, 0.7);
}