* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: #070a12; overflow: hidden; overscroll-behavior: none;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
body { display: flex; align-items: center; justify-content: center; font-family: "Press Start 2P", monospace; }
#game { display: block; image-rendering: pixelated; image-rendering: crisp-edges; }

/* Kept clear of a phone's notch and rounded corners (the safe-area insets). */
#corner { position: fixed; top: max(8px, env(safe-area-inset-top)); right: max(8px, env(safe-area-inset-right)); display: flex; gap: 6px; }
#corner button {
  font: 10px "Press Start 2P", monospace; color: #d8e4ff; background: rgba(11, 15, 26, 0.7);
  border: 2px solid #3a4766; padding: 6px 8px; cursor: pointer;
}
#corner button:hover { border-color: #ffe14d; color: #ffe14d; }
#corner button[hidden] { display: none; }
/* A finger needs a target about 44 px tall. */
body.touch #corner button { font-size: 11px; min-height: 44px; padding: 10px; }

#pad {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; pointer-events: none;
  padding: 0 max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
#pad[hidden] { display: none; }
#pad .side { display: flex; gap: 12px; align-items: flex-end; }
#pad button {
  /* Sized to the screen: big enough for a thumb on a small phone, not huge on a tablet. */
  pointer-events: auto; width: clamp(56px, 17vmin, 84px); height: clamp(56px, 17vmin, 84px); border-radius: 50%; border: 3px solid rgba(255, 255, 255, 0.5);
  background: rgba(11, 15, 26, 0.45); color: #fff; font: 18px "Press Start 2P", monospace; touch-action: none;
}
#pad button.big { width: clamp(72px, 22vmin, 108px); height: clamp(72px, 22vmin, 108px); font-size: 12px; }
#pad button.on { background: rgba(255, 225, 77, 0.5); }

/* A phone held upright: ask for it to be turned. */
#turn {
  position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  background: #070a12; color: #ffe14d; font: 12px/1.9 "Press Start 2P", monospace; text-align: center; padding: 24px;
}
#turn[hidden] { display: none; }
#turn .phone { width: 40px; height: 70px; border: 4px solid #d8e4ff; border-radius: 8px; animation: turn 2.2s ease-in-out infinite; }
@keyframes turn { 0%, 30% { transform: rotate(0deg); } 60%, 100% { transform: rotate(90deg); } }
