/* chain-reaction · fullscreen — paired with fullscreen-fit.js, which sets --fs-side (the board unit's width),
   --fs-rows and toggles .fs-wide. Only applies while the game-shell's Full screen is on
   (html.pip-immersive); normal play is untouched. */
html.pip-immersive .pip-stage .fs-unit { width: var(--fs-side, 100%); max-width: none; margin-left: auto; margin-right: auto; box-sizing: border-box; }
html.pip-immersive .pip-stage.fs-wide {
  display: grid;
  grid-template-columns: var(--fs-side) var(--fs-side-col, 320px);
  grid-template-rows: repeat(var(--fs-rows, 6), auto) 1fr;
  column-gap: 20px;
  justify-content: center;
  align-content: start;
}
html.pip-immersive .pip-stage.fs-wide > * { grid-column: 2; min-width: 0; }
html.pip-immersive .pip-stage.fs-wide > .fs-unit { grid-column: 1; grid-row: 1 / -1; margin: 0; align-self: start; }

/* chain-reaction: the board and its HUD come first; mode pickers + move scout sit below the fold. */
html.pip-immersive .pip-stage .howto { display: none; }
html.pip-immersive .pip-stage:not(.fs-wide) { display: flex; flex-direction: column; }
html.pip-immersive .pip-stage:not(.fs-wide) > .fs-unit { order: 5; flex: none; }
html.pip-immersive .pip-stage:not(.fs-wide) > .pick { order: 6; }
html.pip-immersive .pip-stage:not(.fs-wide) > .move-scout { order: 7; }
html.pip-immersive .pip-stage:not(.fs-wide) > .rec { order: 8; }
html.pip-immersive .pip-stage.fs-wide > #card-grid.fs-unit { position: sticky; top: 0; margin: 0; }
html.pip-immersive .pip-stage #card-grid { margin: 0; }
/* fsfix: the record line is not play; hide it in fullscreen so the stage never scrolls */
html.pip-immersive .pip-stage .rec, html.pip-immersive .pip-stage #record { display: none; }
/* fsfix: on short screens the mode pickers and move scout cannot share the page with the board; settings are set before going fullscreen */
@media (max-height: 700px) { html.pip-immersive .pip-stage:not(.fs-wide) > .pick, html.pip-immersive .pip-stage:not(.fs-wide) > .move-scout { display: none; } }

/* pass3: immersive finish. Safe-area clearance, 44px HUD controls, hidden goal text, richer result card. */
html.pip-immersive .pip-stage { padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); padding-bottom: max(8px, env(safe-area-inset-bottom)); }
html.pip-immersive .pip-stage .hud .btn { min-height: 44px; min-width: 44px; }
html.pip-immersive .pip-stage .goalbar, html.pip-immersive .pip-stage .pip-actions { display: none; }
html.pip-immersive .pip-stage #status { margin: .2rem 0; font-size: 1rem; }
html.pip-immersive .pip-stage .hud { padding: .25rem 0; }
@media (orientation: landscape) and (max-height: 520px) { html.pip-immersive .pip-stage #status { font-size: .9rem; } }
.overlay { backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
.overlay-card { background: linear-gradient(180deg, #fff 0%, #fef2f2 100%); border: 1px solid #fecaca; }
.overlay-card .btn { min-height: 44px; }
#card-grid button.cell { transition: color .15s, filter .15s, transform .12s; }
#card-grid button.cell:active { transform: scale(.94); }
@media (prefers-reduced-motion: reduce) { #card-grid button.cell:active { transform: none; } }

/* landscape fullscreen: the stage never scrolls; board on the left, HUD column on the right */
html.pip-immersive .pip-stage.fs-wide { overflow: hidden; height: 100%; align-content: center; grid-template-rows: none; grid-auto-rows: min-content; }
html.pip-immersive .pip-stage.fs-wide > .fs-unit { grid-row: 1 / span 20; align-self: center; }
html.pip-immersive .pip-stage.fs-wide > .pick[hidden] { display: none; }
@media (orientation: landscape) and (max-height: 520px) { html.pip-immersive .pip-stage.fs-wide > .pick, html.pip-immersive .pip-stage.fs-wide > .move-scout { display: none; } html.pip-immersive .pip-stage.fs-wide > .pick[hidden] { display: none; } }
