/* Play is the focal point; setup folds away and agent activity shares the viewport. */
.compact-play .proj-header { padding: 0.75rem 1.5rem; gap: 0.75rem; }
.compact-play .proj-header-left { display: grid; flex: 1; min-width: 0; grid-template-columns: auto minmax(0, 1fr); column-gap: 1rem; align-items: center; }
.compact-play .back-btn { grid-row: 1 / 4; margin: 0; }
.compact-play .proj-pg-tag { margin: 0; font-size: 0.6rem; }
.compact-play .proj-pg-title { font-size: clamp(1.25rem, 2.5vw, 2rem); line-height: 1.2; }
.compact-play .proj-pg-sub { margin-top: 0.25rem; }
.compact-play .howto { max-width: none; margin: 0; padding: 0.5rem 1.5rem; }
.compact-play .howto-title { font-size: 0.68rem; }

.play-settings { border-bottom: 1px solid var(--border); background: var(--bg2); }
.play-settings > summary { cursor: pointer; padding: 0.65rem 1.5rem; font-family: var(--mono); font-size: 0.72rem; color: var(--cyan); text-transform: uppercase; letter-spacing: 0.08em; }
.play-settings > summary:hover { color: var(--text); }
.play-settings > summary:focus-visible { outline: 2px solid var(--yellow); outline-offset: -3px; }
.play-settings-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr)); gap: 1rem 1.5rem; padding: 0.5rem 1.5rem 1rem; }
.play-settings-grid > * { min-width: 0; }

.compact-play .play-layout { grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); min-height: 0; align-items: start; }
.play-layout > .proj-game-col { min-width: 0; padding: 1rem 1.5rem; }
.play-layout > .play-inspector { min-width: 0; padding: 1rem; gap: 1rem; position: sticky; top: 52px; max-height: var(--play-available-height, calc(100svh - 240px)); overscroll-behavior: contain; scrollbar-gutter: stable; }
.play-inspector > * { margin-top: 0 !important; min-width: 0; }
.play-inspector .viz-grid { grid-template-columns: 1fr 1fr; gap: 0.6rem; }
.play-inspector .viz-grid > :first-child { grid-column: 1 / -1; }
.play-inspector .mini-grid { align-self: start; }
.play-inspector .viz-panel canvas { height: 140px; }
.play-inspector .cp-spark { height: 60px; }
.play-inspector .lr-charts { grid-template-columns: 1fr; }
.play-inspector .rt-race { gap: 0.5rem; }
.play-inspector .cmp-table { font-size: 0.6rem; }
.play-inspector .cmp-table th, .play-inspector .cmp-table td { padding: 0.35rem 0.25rem; }
.play-inspector .section-title { margin-bottom: 0.6rem; }
.play-layout .field-hint { overflow-wrap: anywhere; }

/* Leave room for the header and action rows instead of growing with the number of cells. */
.play-layout { --play-board-size: clamp(180px, calc(100svh - 410px), 600px); }
.play-layout > .proj-game-col { container-type: inline-size; }
.play-layout :is(.rt-map, .ck-board, .rv-map, .gh-map, .qn-big) { width: min(100%, var(--play-board-size)); height: auto; }
.play-layout :is(.rv-stage, .gh-stage, .lr-stage) { width: fit-content; max-width: 100%; margin-inline: auto; }
.play-layout :is(.rv-map, .gh-map) { width: min(calc(100cqw - 24px), var(--play-board-size)); }
.play-layout .lr-pad-wrap { flex-wrap: nowrap; }
.play-layout .lr-controls { flex: 1; }
.play-layout .gh-pad { grid-template-columns: repeat(5, minmax(0, 1fr)); max-width: 360px; margin: 0.6rem auto 0; }
.play-layout .gh-pad > span { display: none; }
.play-layout .lr-map { width: min(calc(100cqw - 24px), calc(var(--play-board-size) * 1.5)); height: auto; }
.play-layout .cp-stage-wrap { max-width: calc(var(--play-board-size) * 2); margin-inline: auto; }
.play-layout .qn-board { --sq: min(64px, calc((100cqw - 16px) / var(--n)), calc((var(--play-board-size) - 16px) / var(--n))); }
.compact-play .qn-mode .play-layout { --play-board-size: clamp(160px, calc(100svh - 410px), 560px); }
.compact-play .qn-tabs { margin: 0; padding: 0.5rem 1rem; gap: 0.5rem; }

.play-layout .nono-wrap { padding: 8px; }
.play-layout .nono-board { --cell: min(30px, calc((100cqw - 128px) / var(--cols)), calc((var(--play-board-size) - 120px) / var(--rows))); }
.play-layout .ms-board { --tap: var(--cell); --cell: min(var(--preferred-cell), calc((100cqw - 36px) / var(--cols) - 2px), calc((var(--play-board-size) - 24px) / var(--rows) - 2px)); --num-size: calc(var(--cell) * 0.46); }
.play-layout .np-grid { --tile: min(var(--preferred-tile), calc((100cqw - 44px) / var(--n)), calc((var(--play-board-size) - 44px) / var(--n))); grid-template-columns: repeat(var(--n), var(--tile)); }
.play-layout .np-tile { width: var(--tile); height: var(--tile); font-size: clamp(0.7rem, calc(var(--tile) * 0.3), 1.9rem); }
.play-layout :is(.nono-stage, .qn-stage) { gap: 0.6rem; }

/* Keep the card tables compact enough to leave their actions in view. */
.play-layout .bj-table { min-height: 0; padding: 1.25rem 1rem; gap: 0.7rem; }
.play-layout .bj-cards, .play-layout .bj-hands { min-height: 90px; }
.play-layout .bj-card { width: 58px; height: 84px; }
.play-layout .bj-shoe-stack { width: 30px; height: 18px; }
.play-layout .pk-table { min-height: 0; padding: 1rem; gap: 0.5rem; }
.play-layout .pk-center { min-height: 0; gap: 0.35rem; }
.play-layout .pk-cards { min-height: 64px; }
.play-layout .pk-card { width: 44px; height: 62px; font-size: 1.2rem; }
.play-layout :is(.bj-controls, .pk-actions, .cp-controls, .tt-controls, .rv-controls, .gh-controls) { margin-top: 0.6rem; gap: 0.4rem; }
.play-layout .cyber-btn { padding: 0.65rem 0.8rem; }
.play-settings .cyber-btn { padding: 0.65rem 0.8rem; }
.play-layout :is(.bj-actions, .cp-buttons, .cp-mode, .pk-modes) { gap: 0.4rem; }

/* The Tetris buffer keeps its drawing coordinates; CSS scales it without stretching. */
.play-layout .tt-stage { flex-wrap: nowrap; gap: 0.75rem; }
.play-layout .tt-board-wrap { max-width: 100%; }
.play-layout .tt-board { width: auto !important; height: var(--play-board-size) !important; aspect-ratio: 1 / 2; }
.play-layout .tt-side { flex: 0 0 100px; }

.play-study { min-width: 0; padding: 0 1.5rem 1.5rem; }
.play-study > :first-child { margin-top: 1rem !important; }

/* Dealt hands need their own horizontal card row as well as room for the total. */
.play-layout .bj-hand { flex-direction: row; flex-wrap: wrap; justify-content: center; max-width: 100%; gap: 0.35rem; padding: 0.35rem; }
.play-layout .bj-hand-label { flex-basis: 100%; text-align: center; }
@media (max-height: 700px) {
  .play-layout .bj-table { padding: 0.8rem; gap: 0.4rem; }
  .play-layout .bj-card { width: 40px; height: 58px; }
  .play-layout .bj-cards, .play-layout .bj-hands { min-height: 62px; }
  .play-layout .bj-bet { width: 44px; height: 44px; }
  .play-layout .pk-table { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto auto; padding: 0.65rem; gap: 0.35rem; }
  .play-layout .pk-bot { grid-area: 1 / 1; }
  .play-layout .pk-you { grid-area: 1 / 2; }
  .play-layout .pk-you .pk-label { order: -1; }
  .play-layout .pk-center { grid-area: 2 / 1 / auto / -1; gap: 0.25rem; }
  .play-layout .pk-seat { gap: 0.25rem; }
  .play-layout .pk-cards { min-height: 48px; }
  .play-layout .pk-card { width: 34px; height: 46px; font-size: 1rem; }
}

/* On phones, play leads directly into the agent; setup stays above both. */
@media (max-width: 760px) {
  .compact-play .proj-header { padding: 0.6rem 1rem; gap: 0.5rem; }
  .compact-play .proj-header-left { flex-basis: 100%; column-gap: 0.6rem; }
  .compact-play .back-btn { padding: 0.5rem; }
  .compact-play .proj-pg-tag { font-size: 0.5rem; }
  .compact-play .proj-pg-sub { font-size: 0.8rem; }
  .compact-play .stat-chips { gap: 0.3rem; }
  .compact-play .howto { padding: 0.5rem 1rem; }
  .play-settings > summary { padding: 0.6rem 1rem; }
  .play-settings-grid { padding: 0.5rem 1rem 1rem; }
  .compact-play .play-layout { grid-template-columns: minmax(0, 1fr); }
  .play-layout > .proj-game-col { border-right: 0; padding: 0.75rem 1rem; }
  .play-layout > .play-inspector { position: static; max-height: none; border-top: 1px solid var(--border); }
  .play-layout { --play-board-size: clamp(160px, calc(100svh - 430px), 520px); }
  .compact-play .qn-mode .play-layout { --play-board-size: clamp(140px, calc(100svh - 460px), 500px); }
  .play-layout .lr-pad-wrap { flex-wrap: wrap; }
  .play-layout .lr-pad { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(2, 40px); }
  .play-layout .lr-controls { flex-basis: 100%; }
  .play-layout .tt-side { width: 84px; flex: 0 0 84px; flex-direction: column; align-items: start; }
  .play-layout .tt-side .field-hint { display: none; }
  .play-layout .tt-controls { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .play-layout .tt-controls .cyber-btn { padding-inline: 0.4rem; letter-spacing: 0.04em; }
  .play-layout .tt-mobile { gap: 0.4rem; margin-top: 0.5rem; }
  .play-inspector .rt-race { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .play-layout .bj-shoe { position: static; align-self: end; }
  .play-layout .bj-shoe-stack { display: none; }
  .play-layout .cyber-btn, .play-settings .cyber-btn { min-height: 44px; }
  .play-layout .pk-modes .pk-seg-btn { padding-inline: 0.4rem; min-height: 44px; }
  .play-layout .pk-table { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto auto; padding: 0.75rem; gap: 0.35rem; }
  .play-layout .pk-cards { min-height: 48px; }
  .play-layout .pk-card { width: 34px; height: 46px; font-size: 1rem; }
  .play-layout .pk-bot { grid-area: 1 / 1; }
  .play-layout .pk-you { grid-area: 1 / 2; }
  .play-layout .pk-you .pk-label { order: -1; }
  .play-layout .pk-center { grid-area: 2 / 1 / auto / -1; }
}

/* Short laptop windows give play the space used by the introductory subtitle. */
@media (max-height: 700px) {
  .compact-play .proj-header { padding-block: 0.5rem; }
  .compact-play .proj-pg-title { font-size: 1.4rem; }
  .compact-play .proj-pg-sub { display: none; }
}

@media (min-width: 761px) and (max-width: 1100px) {
  .play-layout .pk-table { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: auto auto; }
  .play-layout .pk-bot { grid-area: 1 / 1; }
  .play-layout .pk-you { grid-area: 1 / 2; }
  .play-layout .pk-you .pk-label { order: -1; }
  .play-layout .pk-center { grid-area: 2 / 1 / auto / -1; }
}
