html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #020308;
  color: #fff;
  font-family: system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
body { height: 100dvh; }

.stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: radial-gradient(ellipse at center, #0d1020 0%, #020308 70%);
}

#screen {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow: 0 0 0 1px rgba(245, 201, 85, 0.15), 0 20px 80px rgba(0, 0, 0, 0.8);
  cursor: pointer;
}

/* Touch controls (phones and tablets only). */
#touch { display: none; }
body.touch #touch { display: block; }
#touch .pad { position: fixed; bottom: max(14px, env(safe-area-inset-bottom)); display: flex; gap: 12px; }
#touch .pad.left { left: max(14px, env(safe-area-inset-left)); }
#touch .pad.right { right: max(14px, env(safe-area-inset-right)); align-items: flex-end; }
#touch .pad.up { left: max(14px, env(safe-area-inset-left)); bottom: calc(max(14px, env(safe-area-inset-bottom)) + 84px); gap: 8px; }
#touch button {
  width: 68px; height: 68px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  background: rgba(10, 14, 28, 0.45);
  color: rgba(255, 255, 255, 0.85);
  font: 700 22px monospace;
  border-radius: 14px;
  backdrop-filter: blur(4px);
  touch-action: none;
}
#touch .pad.up button { width: 52px; height: 40px; font-size: 14px; }
#touch button.a { width: 78px; height: 78px; border-radius: 50%; border-color: rgba(245, 201, 85, 0.7); color: #f5c955; margin-bottom: 26px; }
#touch button.b { width: 64px; height: 64px; border-radius: 50%; border-color: rgba(88, 224, 240, 0.7); color: #58e0f0; }
#touch button.on { background: rgba(255, 255, 255, 0.25); transform: scale(0.94); }
#touch .pause { position: fixed; top: max(10px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); width: 44px; height: 44px; font-size: 14px; border-radius: 10px; }
/* On menus the pads fade: tapping the menu itself works. */
body.touch:not([data-state='play']) #touch .pad { opacity: 0.25; }
body.touch:not([data-state='play']):not([data-state='pause']) #touch .pause { display: none; }
/* Phones held upright: suggest landscape (the game still works). */
@media (orientation: portrait) {
  body.touch .stage::before {
    content: 'ROTATE YOUR PHONE FOR THE BEST VIEW';
    position: absolute; top: max(24px, env(safe-area-inset-top)); left: 0; right: 0;
    text-align: center; font: 700 12px monospace; letter-spacing: 0.12em; color: #f5c955; opacity: 0.8;
  }
}
