* {
  margin: 0;
  padding: 0;
  font-family: BlinkMacSystemFont, -apple-system, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Fira Sans',
    'Droid Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

body {
  color: #1b1b1b;
  overflow: hidden;
}

div#info-text {
  position: relative;
  justify-content: center;
  font-size: 18px;
  height: 0;
  top: 36px;
  z-index: 1;
  margin: 0px 48px;
  text-align: center;
}

div#info-text p {
  margin-bottom: 16px;
}

/* ---------------------------------------------------------------------------
   Viewport and orientation.

   The page had no sizing rules at all, so the canvas was the only thing giving
   the body a height. Pin html/body to the viewport instead, so a rotation
   reflows the page rather than leaving a portrait-shaped canvas in a landscape
   window. See app/orientation.js for the JS half of this.
   --------------------------------------------------------------------------- */

html,
body {
  width: 100%;
  height: 100%;
  /* dvh tracks Safari's URL bar as it slides away; the vh line is the fallback
     for browsers without dvh and must stay FIRST. */
  height: 100vh;
  height: 100dvh;
  background: #000;
  /* Stops iOS rubber-band scrolling and pull-to-refresh from firing while a
     thumb is dragging a joystick. */
  overscroll-behavior: none;
}

canvas {
  display: block;   /* kills the inline-element baseline gap under the canvas */
  /* The joysticks handle their own touches; without this iOS steals the drag
     for panning and zooming the page. */
  touch-action: none;
}

/* ---------------------------------------------------------------------------
   The portrait hint.

   BOTH ORIENTATIONS ARE SUPPORTED. This used to be a full-screen gate that made
   portrait unusable; it is now a dismissible bar that suggests landscape and
   otherwise stays out of the way. The camera does the real work of making
   portrait viable — see verticalFov() in app/orientation.js.

   Scoped to .is-touch (set by installOrientationGate) so a narrow DESKTOP window
   never gets it, and anchored to the TOP because the joysticks (?touch=sticks) own the bottom
   ~135px of the screen on both sides.
   --------------------------------------------------------------------------- */

#rotate-hint {
  display: none;
}

@media (orientation: portrait) {
  .is-touch #rotate-hint {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    /* Above the live FPS panel, which three's Stats pins at z-index 10000 and which
       shares this corner. The hint is temporary and one tap dismisses it, so covering
       the counter for a moment is the right trade. */
    z-index: 10001;

    display: flex;
    align-items: center;
    gap: 12px;

    padding: 12px 14px;
    /* Clears the iPhone notch / status bar in a browser that reports it. */
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    box-sizing: border-box;

    background: rgba(11, 11, 13, 0.82);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    color: #f4f4f5;
    font-size: 14px;
    line-height: 1.35;
  }
}

/* While the hint is up, the corner buttons (Sound, Scenarios) step down below it
   instead of hiding underneath. It is removed from the page once dismissed. */
@media (orientation: portrait) {
  .is-touch:has(#rotate-hint) #sound-toggle,
  .is-touch:has(#rotate-hint) .walls-bar {
    top: calc(76px + env(safe-area-inset-top, 0px));
  }
}

#rotate-hint .rotate-icon {
  flex: 0 0 auto;
  width: 18px;
  height: 26px;
  border: 2px solid currentColor;
  border-radius: 4px;
  opacity: 0.8;
  animation: rotate-hint 2.6s ease-in-out infinite;
}

@keyframes rotate-hint {
  0%, 35%   { transform: rotate(0deg); }
  60%, 100% { transform: rotate(-90deg); }
}

@media (prefers-reduced-motion: reduce) {
  #rotate-hint .rotate-icon {
    animation: none;
    transform: rotate(-90deg);
  }
}

#rotate-hint p {
  flex: 1 1 auto;
  margin: 0;
  opacity: 0.9;
}

#rotate-hint button {
  flex: 0 0 auto;
  border: 1px solid rgba(244, 244, 245, 0.3);
  border-radius: 999px;

  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 13px;

  cursor: pointer;
  touch-action: manipulation;
}

#rotate-action {
  padding: 7px 14px;
}

#rotate-hint-dismiss {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  font-size: 17px;
  line-height: 1;
}
