/* Asteroids — page layout, canvas and touch controls. */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: black;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  display: block;
  width: 100vw;
  height: 100dvh;
  background: black;
  touch-action: none;
}

/* ---- Touch controls --------------------------------------------------
   Hidden by default (desktop), shown on touch devices via the media
   query below, or when input.js adds `force-touch` to <html> (?touch=1).
   The container itself lets taps pass through to the canvas; only the
   buttons capture pointers. */

#touch-controls {
  position: fixed;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 10;
}

#touch-controls .cluster {
  position: absolute;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: flex-end;
  gap: 18px;
  pointer-events: none;
}

.cluster-left {
  left: calc(16px + env(safe-area-inset-left, 0px));
}

.cluster-right {
  right: calc(16px + env(safe-area-inset-right, 0px));
}

#touch-controls button {
  pointer-events: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;

  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.9);
  font-size: 26px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: background 80ms ease, border-color 80ms ease, transform 80ms ease;
}

#touch-controls button.active {
  background: rgba(255, 255, 255, 0.45);
  border-color: rgba(255, 255, 255, 0.95);
  color: black;
  transform: scale(0.94);
}

#touch-controls button.fire {
  width: 88px;
  height: 88px;
  font-size: 34px;
  border-width: 3px;
}

/* Show on touch devices... */
@media (hover: none) and (pointer: coarse) {
  #touch-controls {
    display: block;
  }
}

/* ...or when forced on with ?touch=1 (input.js adds the class). */
html.force-touch #touch-controls {
  display: block;
}

/* Keep the clusters clear of the notch / home bar on landscape phones. */
@media (orientation: landscape) {
  .cluster-left {
    left: calc(20px + env(safe-area-inset-left, 0px));
  }
  .cluster-right {
    right: calc(20px + env(safe-area-inset-right, 0px));
  }
}
