/* Crash The Stack - the page around the board. The board itself is drawn
   by the game into #stage at a 640x400 virtual viewport; sigil-graphics
   letterboxes it into whatever buffer size the canvas has. The page only
   decides the canvas's CSS size: the full width on a phone, capped on a
   desktop, always 16:10 so the letterbox bars stay empty. */

html, body {
  margin: 0;
  background: #06080f;
  color: #9aa4b8;
  font: 14px/1.4 ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) 0 max(12px, env(safe-area-inset-bottom));
}

#stage {
  display: block;
  width: min(100vw, 1280px, calc((100vh - 120px) * 1.6));
  aspect-ratio: 16 / 10;
  background: #000;
  /* The board owns every touch on it: no scroll, no pinch zoom, no delay. */
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  image-rendering: pixelated;
}

#status:empty,
#status [data-sigil-booting] {
  display: none;
}

#status {
  color: #ff5f7a;
  max-width: 90vw;
  text-align: center;
  color: #ff5f7a;
}

.commands {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.commands button {
  font: inherit;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #cbd3e6;
  background: #131a2b;
  border: 1px solid #2a3552;
  border-radius: 4px;
  padding: 10px 14px;
  min-width: 64px;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

.commands button:active {
  background: #2a3552;
}

/* Fullscreen and landscape: the canvas takes the height, the buttons stand
   in a column beside it instead of a row below. In fullscreen the container
   paints its own ground (the browser gives a fullscreen element a black
   backdrop otherwise) and centres the board. */
main:fullscreen {
  background: #06080f;
  justify-content: center;
  min-height: 100%;
  padding: 0;
}

@media (orientation: landscape) {
  main {
    flex-direction: row;
    justify-content: center;
  }

  #stage {
    width: min(100vw - 112px, 1280px, 100vh * 1.6);
  }

  .commands {
    flex-direction: column;
    justify-content: center;
  }
}
