* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1a2e;
  touch-action: none;
}

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

#touchControls {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 10;
}

#touchLeft, #touchRight {
  display: flex;
  gap: 10px;
  pointer-events: auto;
}

.touchBtn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.15);
  color: rgba(255, 255, 255, 0.8);
  font-size: 24px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.touchBtn:active, .touchBtn.pressed {
  background: rgba(255, 255, 255, 0.35);
  border-color: rgba(255, 255, 255, 0.8);
  transform: scale(0.92);
}

.actionBtn {
  width: 72px;
  height: 72px;
  font-size: 28px;
}

#btnJump {
  background: rgba(100, 200, 100, 0.2);
  border-color: rgba(100, 200, 100, 0.6);
}

#btnAttack {
  background: rgba(255, 180, 100, 0.2);
  border-color: rgba(255, 180, 100, 0.6);
}

@media (hover: none) and (pointer: coarse) {
  #touchControls {
    display: flex;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .touchBtn {
    width: 52px;
    height: 52px;
    font-size: 20px;
  }
  .actionBtn {
    width: 60px;
    height: 60px;
    font-size: 24px;
  }
  #touchControls {
    padding: 8px 12px;
  }
}
