/* 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;
}

/* The board sits in the middle of the page whatever the orientation
   (David, 2026-09-18): main fills the viewport and centers its column. */
main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-sizing: border-box;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(8px, env(safe-area-inset-top)) 0 max(8px, env(safe-area-inset-bottom));
}

/* The board's wrapper carries the canvas's width so the fullscreen
   button can sit over the canvas's top-right corner, in the 44 virtual
   px of margin the tables leave there (the seventh memory stack ends at
   596 of 640; the Turtle's tiles well before that). */
#board {
  position: relative;
  width: min(100vw, 1280px, calc((100vh - 16px) * 1.6));
  width: min(100vw, 1280px, calc((100dvh - 16px) * 1.6));
}

#stage {
  display: block;
  width: 100%;
  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;
}

/* The fullscreen button: a small square in the board's top-right corner,
   an arrow to the upper right, dim until touched, sized as a fraction of
   the board so it stays inside the free margin on every screen (4% of
   the width is 26 virtual px, in a 44 px margin). */
#fullscreen {
  position: absolute;
  top: 1.5%;
  right: 1%;
  width: 4%;
  min-width: 22px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: #cbd3e6;
  background: rgba(19, 26, 43, 0.75);
  border: 1px solid #2a3552;
  border-radius: 3px;
  opacity: 0.55;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#fullscreen svg {
  width: 65%;
  height: 65%;
}

#fullscreen:hover,
#fullscreen:active {
  opacity: 1;
  background: #2a3552;
}

/* Installed as a PWA the manifest already asks for fullscreen, so the
   page's own button is noise (David, 2026-09-17). */
@media (display-mode: fullscreen), (display-mode: standalone) {
  #fullscreen {
    display: none;
  }
}

/* Fullscreen and landscape: the canvas takes the height. 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;
}



/* The RECONNECT card (the web soak row): the page guard shows it over the
   dead frame. The pause panel's look: the C-BG ground at 0.85 over the
   last frame, a 1 px C-BAR-C frame, the word in the block alphabet (drawn
   into the canvas by the guard, 8 px a cell; scaled with the board, the
   cells crisp), the line under it in C-TEXT-DIM. The whole card is the tap
   target; [hidden] wins over the flex display. */
#reconnect {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4%;
  background: rgba(13, 10, 26, 0.85);
  box-shadow: inset 0 0 0 1px #2e1c4d;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  z-index: 5;
}

#reconnect[hidden] {
  display: none;
}

#reconnect canvas {
  display: block;
  width: 44.4%;   /* 71 cells at the menu's ITEM-CELL 4 on the 640 viewport: 284 virtual px */
  height: auto;
  image-rendering: pixelated;
}

#reconnect p {
  margin: 0;
  color: #7380a6;
  font-size: clamp(9px, 1.6vw, 14px);
  letter-spacing: 0.08em;
}
