/* GamePingy shell — one viewport, no page scroll.
 *
 * Every game page is a single-viewport app: the shared top bar takes its
 * natural height and exactly one content region fills the rest, so the document
 * itself never scrolls. Games opt in by giving <body> the `gp-shell` class
 * (gp-header.js stamps it automatically). Load this AFTER the game stylesheet
 * so the frame wins over leftover magic numbers.
 *
 * Contract:
 *   body.gp-shell            -> exactly 100dvh, column flex, overflow hidden
 *   body > #gp-top-bar       -> flex:0 (never scrolls away)
 *   body > .screen/.container/.gp-app -> flex:1, min-height:0 (the app region)
 *   .gp-fill / .gp-fixed     -> mark which child grows vs. stays put
 *   .gp-fit-slot/.gp-fit-square -> a square that always fits the free space
 *
 * Inside a game, the play area should be a `.gp-fill` (or `.gp-fit-slot`) and
 * fixed chrome (hand, buttons, bars) `.gp-fixed`; nothing may use 100vh maths.
 */
html.gp-shell { height: 100%; }

body.gp-shell {
  height: 100dvh;
  max-height: 100dvh;
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}

body.gp-shell > #gp-top-bar { flex: 0 0 auto; }

/* The single flexible content region. It may be the screens themselves, or a
 * wrapper (.container in DiceVersa / #gp-app) that holds them. */
body.gp-shell > .screen,
body.gp-shell > .container,
body.gp-shell > #gp-app {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
}

/* Wrapper form: it is itself a column shell, its screens fill it. */
body.gp-shell > .container,
body.gp-shell > #gp-app {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
}
body.gp-shell > .container > .screen,
body.gp-shell > #gp-app > .screen {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
}

/* ---- fit helpers --------------------------------------------------------- */
.gp-fill { flex: 1 1 0; min-height: 0; min-width: 0; }
.gp-fixed { flex: 0 0 auto; }

/* A slot that hands its free space to a square child which always fits.
 * Rectangular slots work too — the square just centres in the leftover space. */
.gp-fit-slot {
  flex: 1 1 0;
  min-height: 0;
  min-width: 0;
  display: grid;
  place-items: center;
  container-type: size;
}
.gp-fit-square { width: min(100cqw, 100cqh); aspect-ratio: 1 / 1; }

/* Opt-in scroll area, still inside the fixed viewport (lobby/winner only). */
.gp-scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
