/* Page layout, typography, shared button styles and the touch joystick. */

/* Scrolling still works everywhere; the bars themselves stay out of sight. */
* { scrollbar-width: none; -ms-overflow-style: none; }
*::-webkit-scrollbar { width: 0; height: 0; display: none; }

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: #1a1b23;
  color: #f1f1f1;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  display: flex;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  -webkit-user-select: none;      /* a long press on a tablet must not select the page or open its magnifier */
  user-select: none;
  -webkit-touch-callout: none;
}
/* Nothing in the game is text to select: iOS shows its magnifying loupe on a long press over any
   element that still could be (the canvas held down to walk included), so no element is. */
html, * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
textarea, input { -webkit-user-select: text; user-select: text; }   /* the save code is meant to be copied */

#game { width: 100%; max-width: 800px; padding: 16px; }

.stage { position: relative; line-height: 0; }
#screen {
  display: block;
  width: 100%;
  height: auto;
  background: #000;
  outline: none;                  /* focusable (the keyboard follows a click on it), without a ring */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
  user-select: none;
}

#safeProbe {
  position: fixed; left: 0; top: 0; width: 0; height: 0;
  visibility: hidden; pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}

.help { margin: 10px 0 0; font-size: 13px; color: #b7b8c4; text-align: center; line-height: 1.5; }
.hidden { display: none !important; }
.install-hint { margin: 10px 0 0; font-size: 12px; color: #b7b8c4; }

/* Full screen: the page goes black and the canvas sits in the middle, scaled up by a whole number
   on desktop (set from Render.resize) or filling the screen on phones. */
body.fs { background: #000; height: 100vh; min-height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; }
body.fs #game { max-width: none; width: auto; height: auto; padding: 0; }
body.fs .help { display: none; }

button {
  font: inherit;
  font-weight: 600;
  color: #fff;
  background: #3f8f46;
  border: 0;
  border-radius: 6px;
  padding: 6px 14px;
  min-height: 36px;               /* comfortable to tap */
  cursor: pointer;
}
button:hover:not(:disabled) { background: #4aa653; }
button:disabled { opacity: .4; cursor: not-allowed; }
button.secondary { background: #4a4b5e; }
button.secondary:hover:not(:disabled) { background: #5a5b70; }
button.danger { background: #8f3f3f; }
button.danger:hover:not(:disabled) { background: #a64a4a; }

/* The joystick: invisible until a drag starts, then a ring where the finger landed and a knob that follows it. */
.joy-base, .joy-knob {
  position: fixed;
  display: none;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 6;
}
.joy-base { width: 88px; height: 88px; background: rgba(255, 255, 255, .1); border: 2px solid rgba(255, 255, 255, .35); }
.joy-knob { width: 40px; height: 40px; background: rgba(255, 255, 255, .55); box-shadow: 0 2px 8px rgba(0, 0, 0, .4); }
.joy-base.show, .joy-knob.show { display: block; }

/* Phones: the canvas takes the whole screen, edge to edge (the view is cut to the screen's shape),
   nothing scrolls. The world runs under the notch and the home bar; the HUD on the canvas keeps
   inside the safe area (measured with #safeProbe) and so do the buttons over it. */
@media (max-width: 700px), (max-height: 500px) {
  html, body { height: 100%; overflow: hidden; }
  body { display: block; background: #000; }
  #game { max-width: none; height: 100%; padding: 0; }
  .stage { height: 100%; }
  #screen { width: 100%; height: 100%; }
  .help { display: none; }
}
@media (pointer: coarse) {
  .help { display: none; }        /* keyboard hints are noise on touch screens */
}
