/* Single-game pages (~283): game-first template. Loaded after site.css / game-page.css / the game's own style.css and scoped to
   body.page-game, so nothing else on the site is affected. It never touches .game-panel or anything inside it (fullscreen, the
   fullscreen scale wrapper and every game's own layout stay exactly as they were): it only compacts the header block ABOVE the
   game, styles the "Play next" card, and styles the "Back to game" pill added by game-template.js. */

/* ---- phones: the single-column grid must be allowed to shrink ----
   Below 900px the layout is one implicit column, and an implicit column is sized to its widest child's MIN-content. A game with a
   fixed-width board (mahjong, word grids, a 400px canvas) therefore stretched the column - and the whole page - to 397-860px on a
   390px screen (18 games scrolled sideways). minmax(0,1fr) lets the column stay screen-wide; whatever is still wider scrolls
   inside its own container instead of widening the page. */
@media (max-width: 899px) {
  .page-game .game-shell__layout { grid-template-columns: minmax(0, 1fr); }
  .page-game .game-panel, .page-game .side-stack { min-width: 0; }
}

/* ---- compact header block above the game (the game starts ~80px higher) ---- */
.page-game .site-header__inner { padding-top: 6px; padding-bottom: 6px; }
.page-game .game-shell { padding-top: 12px; }
.page-game .game-shell .breadcrumb { margin-bottom: 6px; font-size: 0.82rem; }
.page-game .game-shell__header { margin-bottom: 10px; align-items: center; gap: 12px; }
.page-game .game-shell__title-group h1 { font-size: clamp(1.4rem, 2.6vw, 1.8rem); margin-bottom: 2px; }
.page-game .game-shell__title-group p { font-size: 0.9rem; margin: 0; }
.page-game .game-shell__actions .btn { min-height: 40px; padding: 6px 16px; }

/* ---- "Play next": server-rendered links that fill the column beside the game (Poki / CrazyGames pattern) ---- */
.page-game .pjx-next h2 { font-size: 1.02rem; margin: 0 0 10px; }
.page-game .pjx-next { min-width: 0; }
.page-game .pjx-next ul { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; } /* minmax(0,..): a long title must never widen the column */
.page-game .pjx-next li { margin: 0; padding: 0; min-width: 0; }
.page-game .pjx-next li.is-fit-hidden { display: none; }
.page-game .pjx-next.is-fit-hidden { display: none; }
.page-game .pjx-next a {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px 6px 6px; min-height: 56px; box-sizing: border-box;
  border: 1px solid var(--color-border); border-radius: 12px;
  color: var(--color-text); text-decoration: none;
}
.page-game .pjx-next a:hover, .page-game .pjx-next a:focus-visible { border-color: var(--color-primary); text-decoration: none; }
.page-game .pjx-next__thumb { flex: 0 0 44px; height: 44px; border-radius: 10px; display: grid; place-items: center; font-size: 1.5rem; }
.page-game .pjx-next__text { display: flex; flex-direction: column; min-width: 0; }
.page-game .pjx-next__text b { font-size: 0.92rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-game .pjx-next__text small { color: var(--color-text-soft); font-size: 0.78rem; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 899px) {
  .page-game .pjx-next ul { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  .page-game .pjx-next ul { grid-template-columns: minmax(0, 1fr); }
}

/* when fewer than three tiles fit beside the game, the card moves under it as a full-width strip (game-template.js) */
.page-game .pjx-next--strip { margin-top: 18px; }
.page-game .pjx-next--strip ul { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 899px) { .page-game .pjx-next--strip ul { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* a short game next to a taller "How to play" card: the game card stretches to the column's height (set by game-template.js) */
.page-game .game-shell__layout.pjx-stretch > .game-panel { align-self: stretch; }

/* ---- "Back to game" pill: appears once the game is scrolled out of view ---- */
.pjx-back {
  position: fixed; left: 50%; bottom: 18px; z-index: 40;
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 20px; border: 0; border-radius: 999px;
  background: linear-gradient(135deg, var(--color-primary), var(--color-accent));
  color: #0e0f13; font: inherit; font-size: 0.95rem; font-weight: 800; cursor: pointer;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
  opacity: 0; pointer-events: none; transform: translate(-50%, 12px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.pjx-back.is-visible { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.pjx-back:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .pjx-back { transition: none; } }
