html, body {
  margin: 0;
  height: 100%;
  background: #1a1c2c;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

#wrap {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  outline: none;
  box-shadow: 0 0 0 4px #333c57, 0 8px 32px rgba(0, 0, 0, 0.5);
}

#touch {
  display: none;
  width: 100%;
  max-width: 640px;
  padding: 0 16px;
  box-sizing: border-box;
  justify-content: space-between;
}

#touch .pad { display: flex; gap: 14px; }

#touch button {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 3px solid #1a1c2c;
  background: #94b0c2;
  color: #1a1c2c;
  font: bold 22px monospace;
  box-shadow: 0 4px 0 #333c57;
  touch-action: none;
}
#touch button:active { transform: translateY(3px); box-shadow: 0 1px 0 #333c57; }
#touch button.a { background: #ffcd75; }
#touch button.b { background: #ef7d57; }

#rotate { display: none; }

/* ---------- phones (body classes are set in main.js) ---------- */
body.touch canvas { box-shadow: none; }
body.touch #touch { display: flex; }
body.touch #wrap { gap: 0; }

/* Portrait: game edge to edge, big buttons in the free space below. */
body.portrait #wrap { justify-content: flex-start; padding-top: 8px; gap: 14px; }
body.portrait #touch { max-width: none; padding: 0 20px; }
body.portrait #rotate {
  display: block;
  border: 2px solid #566c86;
  background: #333c57;
  color: #ffcd75;
  font: bold 14px monospace;
  padding: 8px 12px;
  border-radius: 8px;
  margin: 0 16px;
}

/* Landscape: game fills the screen, buttons float over the corners. */
body.landscape #touch {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 10px;
  max-width: none;
  padding: 0 10px;
  pointer-events: none;
}
body.landscape #touch button {
  pointer-events: auto;
  width: 54px;
  height: 54px;
  opacity: 0.6;
  font-size: 18px;
}
body.landscape #touch .pad { gap: 8px; }
/* A/B stacked so they fit in the side gutter (B on top, A below). */
body.landscape #touch .pad:last-child { flex-direction: column; }
body.landscape #mute {
  top: 10px;
  right: 10px;
  opacity: 0.5;
}
body.portrait #mute {
  top: auto;
  bottom: 16px;
  right: 16px;
}

#mute {
  position: fixed;
  top: 10px;
  right: 10px;
  width: 34px;
  height: 34px;
  border: 2px solid #566c86;
  background: #333c57;
  color: #f4f4f4;
  font: 18px monospace;
  cursor: pointer;
  border-radius: 6px;
}
#mute.off { opacity: 0.4; text-decoration: line-through; }
