* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, sans-serif;
  background: #111;
  color: #eee;
}

.wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 16px;
  text-align: center;
}

h1, p { margin: 0; }
.hint { color: #bbb; }

canvas {
  display: block;
  margin: 12px auto;
  background: #1b1b1b;
  border: 2px solid #333;
  border-radius: 12px;

  width: 640px;
  height: 480px;

  image-rendering: pixelated;
  image-rendering: crisp-edges;

  touch-action: none;
}

html, body {
  height: 100%;
  overflow: hidden;
}

.touch-controls {
  display: none;
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: 12px;

  gap: 12px;
  justify-content: space-between;
  align-items: flex-end;

  pointer-events: none;
  z-index: 9999;
}

.touch-controls .pad {
  position: relative;
  display: grid;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 52px);
  gap: 8px;

  pointer-events: auto;
  background: rgba(0,0,0,0.35);
  border: 1px solid #333;
  border-radius: 14px;
  padding: 10px;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  touch-action: none;
}

.touch-controls .pad .label {
  position: absolute;
  left: 50%;
  bottom: -22px;
  transform: translateX(-50%);
  font-size: 12px;
  color: #bbb;
}

.touch-controls button {
  border-radius: 12px;
  border: 1px solid #444;
  background: rgba(30,30,30,0.85);
  color: #fff;
  font-size: 20px;
  -webkit-tap-highlight-color: transparent;
}

.touch-controls button:active {
  transform: scale(0.98);
}

.touch-controls .center { opacity: 0.55; }

.touch-controls,
.touch-controls * {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body, .wrap, canvas {
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

canvas,
.touch-controls {
  touch-action: none;
}

@media (min-width: 900px) and (pointer: fine) {
  .touch-controls { display: none !important; }
}