/* The Playground (templates/playground.html, frontend/src/playground/app.ts): the set on the left, the code on the right;
   on a phone (640px and narrower) the two stack, the set (and its board) first. Built from the site's own parts: .panel
   sheets, .tab-list tabs, the set page's .board, .fragment, .seat badges, .clock, .replay controls and .move-list, the
   .notice and .dlg dialogs. Only what is new is here, in style.css's tokens; the site is dark only (base.html). The
   editor's own styles are in areas/playground-editor.css. */

.area-playground .page-head { margin-bottom: 1.25rem; }
/* The Playground uses a wider page than the site's --wrap (1200 px): header, content and footer together, so they line up. */
.page-wide { --wrap: 1920px; }
/* The empty bot-moves list says nothing: the heading is enough (app.ts still toggles its hidden). */
.pg-out .pg-empty[data-pg-botmoves-empty] { display: none; }
/* The code on the left, the game on the right (the game comes first in the page, so it stays first once stacked). */
.pg-layout { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); gap: 1.25rem; align-items: start; }
.pg-layout > .pg-code { order: -1; }
.pg-layout > .panel { margin: 0; min-width: 0; padding: 1.1rem 1.25rem 1.25rem; }
.pg-head { margin-bottom: 0.75rem; }
.pg-head h2 { font-size: 1.375rem; }
.pg-note { margin: 0.35rem 0 0; font-size: 0.875rem; max-width: 62ch; }
.pg-empty { margin: 0.5rem 0 0; font-size: 0.875rem; }
.area-playground h3 { font-size: 1rem; margin: 1.25rem 0 0.45rem; }
.area-playground h3 .muted { font-weight: 500; font-size: 0.875rem; margin-left: 0.35rem; }

/* The choices: Format and Opponent side by side, the time limit beside Run. */
.pg-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.pg-field select { width: 100%; }
/* The game's head: the title and state on the left, the house's strength (Easy / Medium / Hard, three radios drawn as one
   segmented switch) on the right, and one short line under it on what the pick does. */
.pg-set-head { align-items: center; margin-bottom: 0.35rem; }
.pg-set-title { display: inline-flex; align-items: center; gap: 0.6rem; }
.pg-level-pick { display: flex; align-items: center; gap: 0.6rem; border: 0; margin: 0; padding: 0; min-width: 0; }
.pg-level-label { font-size: 0.875rem; font-weight: 600; color: var(--ink-2); white-space: nowrap; }
.pg-level-opts { display: inline-flex; border: 1px solid var(--rule-strong); border-radius: 999px; padding: 2px; background: var(--field); }
.area-playground .pg-level-opt { position: relative; display: inline-flex; flex-direction: row; align-items: center; justify-content: center;
  min-height: 2.25rem; padding: 0 0.95rem; border-radius: 999px; font-size: 0.875rem; font-weight: 650; color: var(--ink-2);
  cursor: pointer; transition: background-color 0.15s, color 0.15s; }
.pg-level-opt input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.pg-level-opt:hover { color: var(--ink); }
.area-playground .pg-level-opt:has(input:checked) { background: var(--accent); color: var(--on-action); }
.pg-level-opt:has(input:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }
.pg-level-opt:has(input:disabled) { opacity: 0.6; cursor: not-allowed; }
.pg-level-note { margin: 0 0 0.6rem; font-size: 0.875rem; }
.pg-field select:disabled { opacity: 0.6; cursor: not-allowed; }

/* Tabs as buttons: the set page's .tab-list look (style.css), without a button's fill. */
.area-playground .pg-tabs { margin: 1rem 0 0.85rem; overflow-x: auto; scrollbar-width: none; }
.area-playground .pg-tabs .tab { background: transparent; color: var(--ink-2); border: 0; border-bottom: 2px solid transparent; border-radius: 0; min-height: 2.75rem; padding: 0.5rem 0.9rem; font-weight: 650; gap: 0.45rem; }
.area-playground .pg-tabs .tab:hover { background: var(--hover); color: var(--ink); border-color: transparent; border-bottom-color: var(--rule-strong); }
.area-playground .pg-tabs .tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.area-playground .pg-tabs .tab:disabled { opacity: 0.5; }
.area-playground .pg-tabs .tab:disabled:hover { background: transparent; border-bottom-color: transparent; }
.area-playground .pg-tabs .tab[aria-selected="true"]:disabled:hover { border-bottom-color: var(--accent); }
.area-playground .pg-tabs .tab:focus-visible { outline-offset: -2px; }
.pg-tab-note { font-weight: 500; font-size: 0.8125rem; color: var(--ink-2); }

/* The board: the set page's frame (4:3, the slate), with the two player bars above it. */
.pg-board.board { margin: 0; }
/* Two bars of one fixed size side by side (one above the other on a phone): the note between the name and the clock has a
   slot of its own, so a bar never changes size or row as the game goes on. */
.pg-players { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.5rem; margin-bottom: 0.6rem; }
.pg-player { display: flex; align-items: center; gap: 0.5rem; min-width: 0; padding: 0.3rem 0.4rem 0.3rem 0.4rem; border: 1px solid var(--rule); border-radius: var(--r-control); background: var(--paper); }
.pg-player .badge { min-width: 0; }
.pg-player .badge-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-player.on-move { border-color: var(--rule-strong); }
.pg-player .badge { --seat-c: var(--seat-e); }
.pg-player-note { margin-left: auto; font-size: 0.75rem; font-weight: 650; white-space: nowrap; }
.pg-player-note.is-won { color: var(--teal); }
/* On move: a lit dot (the words stay for a screen reader), so the name keeps its room. */
.pg-player-note.is-move { flex: none; width: 0.55rem; height: 0.55rem; overflow: hidden; border-radius: 50%; background: var(--teal); color: transparent; font-size: 0; }
.pg-player .clock { flex: none; margin-left: 0.15rem; }
.pg-player-note:empty + .clock { margin-left: auto; }
.pg-fragment .board-msg-nojs { display: none; }
.area-playground[data-playground] .pg-fragment:not([data-shown]) .ag-board .board-msg { visibility: hidden; }
.pg-board-msg { display: grid; place-items: center; height: 100%; padding: 1rem; text-align: center; color: var(--slate-ink-2); visibility: visible; }
.pg-fragment .ag-board { display: grid; place-items: center; }

/* The transport: the set page's replay controls, a step back and forward, and the 2D / 3D switch. */
.pg-replay { margin-top: 0.65rem; }
.pg-replay .replay-controls { gap: 0.5rem; }
.pg-replay .replay-controls .replay-scrub { flex: 1 1 10rem; }
.pg-replay .pg-step { width: 2.25rem; padding: 0; }
.pg-replay .pg-step svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pg-replay .replay-slider:disabled { opacity: 0.45; }
/* The board keeps the set page's 4:3, but never taller than about 60% of the window: on a wide page the column would make
   it huge, so the stage narrows (centred) instead of the board stretching. */
.pg-stage { position: relative; max-width: calc(60vh * 4 / 3); margin-inline: auto; }
.pg-style { position: absolute; z-index: 3; top: 0.6rem; right: 0.6rem; display: inline-flex; border: 1.5px solid var(--rule-strong); border-radius: var(--r-control); overflow: hidden; background: color-mix(in srgb, var(--sheet) 85%, transparent); }
.pg-style[hidden] { display: none; }
.pg-style button { min-height: 2.25rem; padding: 0.3rem 0.8rem; border: 0; border-radius: 0; background: transparent; color: var(--ink-2); font-size: 0.875rem; }
.pg-style button:hover { background: var(--hover); color: var(--ink); }
.pg-style button[aria-pressed="true"] { background: var(--action); color: var(--on-action); }
.pg-style button:focus-visible { outline-offset: -3px; }

/* The result: one card for the set, a line per game. */
.pg-result { margin: 1rem 0 0; padding: 0.8rem 1rem; background: var(--paper); border: 1px solid var(--rule); border-left: 4px solid var(--rule-strong); border-radius: var(--r-sheet); }
.pg-result[data-kind="won"] { border-left-color: var(--check); }
.pg-result[data-kind="lost"], .pg-result[data-kind="error"] { border-left-color: var(--err); }
.pg-result[data-kind="drawn"] { border-left-color: var(--ink); }
.pg-result-title { margin: 0; font-size: 1.125rem; }
.pg-result[data-kind="won"] .pg-result-title { color: var(--check); }
.pg-result-games { margin: 0.4rem 0 0; padding-left: 1.1rem; font-size: 0.9375rem; }
.pg-result-games li { margin: 0.2rem 0; }

/* The moves, in words: the set page's move list. */
.pg-moves h3 { margin-top: 1.25rem; }
/* A steady height while a set plays: the list (and its empty note) keep the space of some eight moves, then scroll. */
.pg-moves ol.move-list { height: 18rem; max-height: none; }
.pg-moves .pg-empty { margin: 0; }
.area-playground.is-running .pg-moves .pg-empty { min-height: 18rem; }
.pg-moves ol.move-list .mv { grid-template-columns: 2.75rem minmax(0, 7.5rem) minmax(0, 1fr) auto; }
.pg-mv-text { font-size: 0.875rem; min-width: 0; }
.pg-moves ol.move-list:empty { display: none; }

/* The code panel. */
.pg-lang-name { font-weight: 650; color: var(--ink); }
/* The page head: the title, and the LLM's two buttons at the far right (under it on a narrow screen). */
.pg-page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 1rem; }
.pg-llm-actions { display: inline-flex; flex-wrap: wrap; gap: 0.5rem; margin-left: auto; }
.pg-llm-actions .pg-llm-btn, .pg-llm-actions .pg-prompts-btn { flex: none; }

/* Prompts for LLM: the categories as a small segmented switch, then one card a prompt (title, Copy, the filled text). */
/* In a pop-up (dialog.pg-prompts-dialog) that scrolls as one: the intro and the categories go off the top, the title
   and its close button stay. */
.pg-prompts-lead { margin: 0.25rem 0 0.75rem; font-size: 0.875rem; }
dialog.pg-prompts-dialog { width: min(40rem, calc(100vw - 32px)); max-height: min(44rem, calc(100vh - 48px)); }
.pg-prompts-dialog .pg-llm-top { position: sticky; top: 0; z-index: 1; background: var(--sheet); padding-bottom: 0.5rem; }
.pg-prompts-dialog .pg-prompts-lead, .pg-prompts-dialog .pg-prompt-cats { margin-left: 1.5rem; margin-right: 1.5rem; }
.pg-prompts-dialog .pg-prompts-lead { margin-top: 0.5rem; }
.pg-prompts-dialog .pg-prompt-list { padding: 0 1.5rem 1.25rem; }
.pg-prompts-dialog .pg-prompt-list { align-content: start; grid-auto-rows: max-content; }
/* A prompt copied before: greyed, still copyable. */
.pg-prompt.is-used { opacity: 0.55; }
.pg-prompt.is-used:hover, .pg-prompt.is-used:focus-within { opacity: 0.85; }
.pg-prompt-used { margin-left: 0.4rem; font-size: 0.75rem; font-weight: 400; color: var(--ink-2); }
/* The cards keep their own height and stack from the top (a grid would otherwise stretch one or two to fill the panel). */
.pg-prompt-cats { display: flex; flex-wrap: wrap; gap: 0.4rem; margin: 0 0 0.9rem; }
.pg-prompt-cats .pg-prompt-cat { min-height: 2.25rem; padding: 0 0.85rem; border: 1px solid var(--rule-strong); border-radius: 999px;
  background: transparent; color: var(--ink-2); font-size: 0.875rem; font-weight: 650; }
.pg-prompt-cats .pg-prompt-cat:hover { color: var(--ink); border-color: var(--ink-2); }
.pg-prompt-cats .pg-prompt-cat[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-action); }
.pg-prompt-list { display: grid; gap: 0.6rem; margin: 0; padding: 0; list-style: none; }
.pg-prompt { padding: 0.75rem 0.9rem; border: 1px solid var(--rule); border-radius: var(--r-control); background: var(--field); }
.pg-prompt-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.pg-prompt-title { margin: 0; line-height: 1.3; font-size: 0.9375rem; font-weight: 700; color: var(--ink); }
.pg-prompt-head .pg-prompt-copy { flex: none; min-width: 5rem; }
.pg-prompt-text { margin: 0.35rem 0 0; min-height: 3em; font-size: 0.875rem; line-height: 1.5; color: var(--ink-2); }   /* two lines: even cards */
.pg-prompt > .pg-copy-said:not(:empty) { display: block; margin-top: 0.35rem; }
.pg-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; margin: 0 0 0.6rem; }
/* The editor's menu: the hamburger at the toolbar's right, its list dropping below it, right-aligned. */
.pg-menu { position: relative; margin-left: auto; }
.pg-menu > summary { list-style: none; display: inline-grid; place-items: center; width: 2.5rem; padding: 0; cursor: pointer; }
.pg-menu > summary::-webkit-details-marker { display: none; }
.pg-menu-btn .ic { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.pg-menu[open] > summary { border-color: var(--accent); color: var(--accent); }
.pg-menu-list { position: absolute; right: 0; top: calc(100% + 0.35rem); z-index: 20; display: flex; flex-direction: column; align-items: stretch;
  gap: 0.35rem; min-width: 12rem; padding: 0.5rem; background: var(--sheet); border: 1px solid var(--rule-strong); border-radius: var(--r-sheet);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35); }
.pg-menu-list > button { justify-content: flex-start; }
.pg-view { display: inline-flex; align-items: center; gap: 0.3rem; }
.pg-view .pg-size { min-width: 2.4rem; padding-inline: 0.5rem; font-weight: 700; }
.pg-size-now { min-width: 3.1rem; text-align: center; font-family: var(--font-mono); font-size: 0.75rem; }
.pg-full-btn { display: inline-flex; align-items: center; gap: 0.35rem; }
.pg-full-btn .ic { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Full screen (app.ts enterFull): the editor block fills the screen, through the Fullscreen API where the browser has it
   and as a fixed layer over the page where it does not (an iPhone); Run, Stop, the progress line and the console move
   into .pg-dock under the editor while it lasts. */
html.pg-noscroll, html.pg-noscroll body { overflow: hidden; }
.pg-editor-wrap.is-full { position: fixed; inset: 0; z-index: 150; display: grid; grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  gap: 0.5rem; padding: 0.75rem max(0.75rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
  background: var(--paper); }
.pg-editor-wrap.is-full:fullscreen { width: 100%; height: 100%; }
.pg-editor-wrap.is-full .pg-toolbar { margin: 0; }
.pg-editor-wrap.is-full .pg-editor-slot { min-height: 0; }
.pg-editor-wrap.is-full .pg-editor-lang, .pg-editor-wrap.is-full .pg-editor-slot .pg-editor { height: 100%; }
.pg-editor-wrap.is-full .pg-status { margin: 0; }
.pg-dock[hidden] { display: none; }
.pg-dock { display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "act prog" "out out"; align-items: center; gap: 0.4rem 0.9rem; }
.pg-dock .pg-actions { grid-area: act; margin: 0; }
.pg-dock .pg-progress { grid-area: prog; margin: 0; }
.pg-dock .pg-out { grid-area: out; }
.pg-dock .pg-out h3 { margin-top: 0; }
.pg-dock .pg-console { max-height: 22vh; }
.pg-toolbar button:disabled { opacity: 0.45; }
.pg-editor-slot { position: relative; border: 1px solid var(--rule-strong); border-radius: var(--r-sheet); overflow: hidden; background: var(--field); min-height: 12rem; }
.pg-editor-slot .pg-editor { height: 24rem; }
@media (min-width: 900px) { .pg-editor-slot .pg-editor { height: clamp(30rem, 58vh, 42rem); } }
.pg-editor-lang[hidden] { display: none; }
.pg-editor-wait { margin: 0; padding: 1rem; font-size: 0.875rem; }
.area-playground.is-running .pg-editor-slot { border-color: var(--rule); }
.pg-status { margin: 0.4rem 0 0; font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.6; overflow-wrap: anywhere; }
.pg-status.pg-too-big { color: var(--err); }
.pg-status .pg-note-inline { font-family: var(--font); font-size: 0.8125rem; color: var(--ink); }
.pg-status button.linklike { min-height: 0; font: 600 0.8125rem var(--font); color: var(--teal); text-decoration: underline; text-underline-offset: 0.2em; }
.pg-contract { margin: 0.9rem 0 0; font-size: 0.9375rem; }
.pg-run-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.75rem 1rem; margin-top: 1rem; }
.pg-run-row .pg-field { flex: 0 1 12rem; }
.pg-actions { flex: 1 1 auto; }
.pg-actions .pg-run { min-width: 10rem; min-height: 2.75rem; font-size: 1rem; }
.pg-actions [hidden] { display: none; }
/* The code panel's head: "Your bot", then the time limit and Run my bot on the same line (wrapping under on a phone). */
.pg-code-head { align-items: center; }
.pg-code-head .pg-run-row { margin: 0; align-items: center; flex-wrap: nowrap; gap: 0.75rem; }
.pg-code-head .pg-actions { flex: none; margin: 0; }
.pg-code-head .pg-actions .pg-run { min-width: 9rem; }
.pg-code-head + .pg-run-hint, .pg-code-head ~ .pg-progress { margin: -0.25rem 0 0.75rem; }
.pg-progress { margin: 0.6rem 0 0; padding: 0.5rem 0.75rem; font-size: 0.875rem; background: var(--paper); border: 1px solid var(--rule); border-left: 3px solid var(--teal); border-radius: var(--r-control); }
.pg-progress[hidden] { display: none; }


.pg-how { margin-top: 1rem; padding: 0.6rem 0.85rem; border: 1px solid var(--rule); border-radius: var(--r-sheet); background: var(--paper); }
.pg-how ol { margin: 0.6rem 0 0.25rem; padding-left: 1.2rem; font-size: 0.9rem; }
.pg-how p { margin: 0.5rem 0 0.1rem; font-size: 0.875rem; color: var(--ink-2); }

/* The bot's moves and the console: text that scrolls in its own box. */
.pg-out h3 { margin-top: 1.25rem; }
.pg-botmoves { list-style: none; margin: 0; padding: 0; max-height: 11rem; overflow-y: auto; border: 1px solid var(--rule); border-radius: var(--r-sheet); background: var(--paper); }
.pg-botmoves:empty { display: none; }
.pg-bm { display: grid; grid-template-columns: minmax(0, 8.5rem) minmax(0, 1fr) auto; gap: 0.75rem; align-items: baseline; margin: 0; padding: 0.3rem 0.75rem; border-bottom: 1px solid var(--rule); font-size: 0.8125rem; }
.pg-bm:last-child { border-bottom: 0; }
.pg-bm-n { color: var(--ink-2); white-space: nowrap; }
.pg-bm-move { font-family: var(--font-mono); font-size: 0.75rem; background: none; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-bm-ms { font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink-2); text-align: right; white-space: nowrap; }
.pg-bm-bad .pg-bm-ms { color: var(--err); font-family: var(--font); font-weight: 650; }
.pg-console-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 1.25rem; }
.pg-console-head h3 { margin: 0; }
.pg-console { margin-top: 0.45rem; max-height: 14rem; min-height: 4rem; overflow: auto; padding: 0.5rem 0.75rem; background: var(--slate); border: 1px solid var(--rule); border-radius: var(--r-sheet); font-family: var(--font-mono); font-size: 0.75rem; line-height: 1.55; }
.pg-console .pg-empty { font-family: var(--font); margin: 0; }
.pg-line { white-space: pre-wrap; overflow-wrap: anywhere; color: var(--ink); }
.pg-line.pg-stderr { color: var(--slate-err); border-left: 2px solid var(--err-line); padding-left: 0.5rem; margin-left: -0.6rem; }
.pg-line.pg-info { color: var(--ink-2); font-style: italic; }
.pg-foot { margin: 1.25rem 0 0; padding-top: 0.9rem; border-top: 1px solid var(--rule); font-size: 0.9375rem; }

.pg-runner { position: absolute; width: 0; height: 0; border: 0; visibility: hidden; }

/* The Claude dialogs (style.css's .dlg). */
dialog.pg-dialog { width: min(620px, calc(100vw - 32px)); }
.pg-dialog .dlg-copy { min-height: 14rem; }
.pg-dialog-said { margin: 0 0 0.5rem; font-size: 0.875rem; }
.pg-dialog-said:empty { display: none; }
.pg-dialog [role="alert"] { color: var(--err); }

/* Connect your LLM (app.ts, agent-link.ts): the button's dot, the banner and the review bar above the editor, the
   Run hint during a review, and the dialog. A state is a data-state attribute ("connected", "waiting", ...). */
.pg-llm-btn { display: inline-flex; align-items: center; gap: 0.45rem; }
.pg-llm-btn::before { content: ""; flex: none; width: 0.5rem; height: 0.5rem; border-radius: 50%; border: 1.5px solid var(--ink-2); box-sizing: border-box; }
.pg-llm-btn[data-state="connected"]::before { background: var(--teal); border-color: var(--teal); }
.pg-llm-btn[data-state="waiting"]::before, .pg-llm-btn[data-state="connecting"]::before, .pg-llm-btn[data-state="reconnecting"]::before { border-color: var(--amber); }
.pg-llm-btn[data-state="elsewhere"]::before { border-color: var(--ink-2); background: var(--ink-2); }

.pg-agent-strip { display: grid; gap: 0.5rem; }
.pg-agent-strip:has(> :not([hidden])) { margin-bottom: 0.6rem; }
.pg-editor-wrap.is-full .pg-agent-strip { margin: 0; }
.pg-agent-banner { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; padding: 0.35rem 0.5rem 0.35rem 0.75rem; background: var(--paper); border: 1px solid var(--rule); border-left: 3px solid var(--teal); border-radius: var(--r-control); font-size: 0.875rem; }
.pg-agent-banner:not([data-state="connected"]) { border-left-color: var(--amber); }
.pg-agent-banner[data-state="elsewhere"] { border-left-color: var(--rule-strong); }
.pg-agent-dot { flex: none; width: 0.55rem; height: 0.55rem; border-radius: 50%; background: var(--teal); }
.pg-agent-banner:not([data-state="connected"]) .pg-agent-dot { background: transparent; border: 1.5px solid var(--amber); }
.pg-agent-banner[data-state="elsewhere"] .pg-agent-dot { border-color: var(--ink-2); }
.pg-agent-text { flex: 1 1 14rem; min-width: 0; }
.pg-agent-text strong { font-weight: 650; }
.pg-agent-last { font-size: 0.8125rem; overflow-wrap: anywhere; }
.pg-agent-banner-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-left: auto; }

.pg-review { padding: 0.65rem 0.75rem 0.55rem; background: var(--sheet); border: 1px solid var(--rule-strong); border-left: 4px solid var(--amber); border-radius: var(--r-sheet); }
.pg-review-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 0 0.75rem; }
.pg-review-title { margin: 0; font-weight: 650; }
.pg-review-count { margin-left: 0.35rem; font-weight: 500; font-size: 0.875rem; color: var(--ink-2); }
.pg-review-head button.linklike { min-height: 2rem; color: var(--teal); text-decoration: underline; text-underline-offset: 0.2em; font-size: 0.875rem; }
.pg-review-actions { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0.5rem; margin-top: 0.5rem; }
.pg-review-actions > button { min-height: 2.5rem; }
.pg-review-note { flex: 1 1 14rem; display: grid; gap: 0.2rem; min-width: 0; font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); }
.pg-review-note .muted { font-weight: 500; }
.pg-review-note input { width: 100%; min-height: 2.5rem; font-size: 0.875rem; }
.pg-check { display: inline-flex; flex-direction: row; align-items: center; gap: 0.5rem; min-height: 2.5rem; margin-top: 0.25rem; font-size: 0.875rem; cursor: pointer; }
.pg-check input { flex: none; accent-color: var(--teal); }
.area-playground.is-reviewing .pg-editor-slot { border-color: var(--amber); }
.pg-run-hint { color: var(--amber); font-weight: 600; }

/* The Playground's dialogs are the page's last elements, and style.css's main.wrap > :last-child rule takes their bottom
   margin away, which pushed a modal low (and off the bottom of a short window). Give them back the centred auto margins. */
.area-playground dialog.dlg.pg-dialog:modal { margin: auto; }
dialog.pg-llm-dialog { width: min(36rem, calc(100vw - 32px)); }
/* The title with a close ✕ at its right. */
.pg-llm-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; padding-right: 1rem; }
.pg-dialog .pg-llm-x { display: inline-grid; place-items: center; flex: none; width: 2.25rem; height: 2.25rem; min-height: 2.25rem; margin-top: 1rem; padding: 0; color: var(--ink-2); }
.pg-llm-x:hover { color: var(--ink); }
.pg-dialog .pg-llm-x svg { flex: none; width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
/* Two numbered steps: 1, the message (a read-only card that fits its text) and a full-width Copy; 2, where to paste it. */
.pg-llm-stepline { display: flex; align-items: center; gap: 0.6rem; margin: 0 0 0.55rem; font-weight: 650; color: var(--ink); }
.pg-llm-stepline label { font: inherit; color: inherit; }
.pg-llm-num { flex: none; display: inline-grid; place-items: center; width: 1.5rem; height: 1.5rem; border-radius: 50%; background: var(--hover);
  border: 1px solid var(--rule-strong); font-size: 0.8125rem; font-weight: 700; color: var(--ink); }
.pg-llm-apps { display: block; font-weight: 500; font-size: 0.875rem; color: var(--ink-2); }
.pg-llm-copy + .pg-llm-stepline { margin-top: 1.1rem; }
.pg-llm-dialog .pg-llm-message { min-height: 0; height: 8.5rem; margin: 0 0 0.6rem; padding: 0.75rem 0.9rem; resize: none; overflow: auto;
  border: 1px solid var(--rule); border-radius: var(--r-control); background: var(--field); color: var(--ink); cursor: text;
  font-family: var(--font); font-size: 0.9375rem; line-height: 1.5; overflow-wrap: anywhere; }
@supports (field-sizing: content) { .pg-llm-dialog .pg-llm-message { height: auto; field-sizing: content; } }
.pg-llm-dialog .pg-llm-message:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.pg-llm-copy { display: flex; flex-direction: column; align-items: stretch; gap: 0.4rem; }
.pg-llm-copy > .pg-llm-go { width: 100%; min-height: 2.75rem; }
.pg-llm-copy > .pg-copy-said { text-align: center; }
.pg-copy-said { font-size: 0.875rem; font-weight: 600; color: var(--teal); }
.pg-copy-said[data-how="selected"] { color: var(--amber); }
.pg-copy-said:empty { display: none; }
.pg-llm-dialog .pg-llm-state { margin-top: 1.1rem; }
.pg-llm-dialog .pg-llm-status { padding: 0.35rem 0.8rem; border: 1px solid var(--rule); border-radius: 999px; background: var(--paper); font-size: 0.875rem; }
/* "More options": everything past the one message, folded away. */
.pg-llm-more { margin: 1rem 0 0.25rem; border-top: 1px solid var(--rule); }
.pg-llm-more > summary { display: flex; align-items: center; gap: 0.45rem; list-style: none; min-height: 2.75rem; cursor: pointer; font-weight: 650; color: var(--ink-2); }
.pg-llm-more > summary::-webkit-details-marker { display: none; }
.pg-llm-more > summary::before { content: ""; flex: none; width: 0.4rem; height: 0.4rem; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); }
.pg-llm-more[open] > summary::before { transform: rotate(45deg); }
.pg-llm-more > summary:hover { color: var(--ink); }
.pg-llm-more > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-control); }
.pg-llm-more-body { padding: 0.25rem 0 0.5rem; }
.pg-llm-more-body > .pg-llm-step + .pg-llm-step, .pg-llm-more-body > .pg-check { margin-top: 0.25rem; }
.pg-llm-more-body .pg-llm-hint { margin-bottom: 0.5rem; }
.pg-llm-more-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.pg-llm-step > .pg-copy-said:not(:empty) { display: block; margin-top: 0.3rem; }
.pg-llm-step { margin: 0 0 1.15rem; padding: 0; border: 0; min-width: 0; }
.pg-llm-step legend, .pg-llm-dialog .pg-llm-h { margin: 0 0 0.5rem; padding: 0; font-size: 1rem; font-weight: 650; color: var(--ink); }
/* The app picker: radio buttons drawn as a row of pills (each still a native radio, so the arrow keys move between them). */
.pg-seg { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.pg-seg label { position: relative; display: inline-flex; }
.pg-seg input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.pg-seg span { display: inline-flex; align-items: center; min-height: 2.5rem; padding: 0.35rem 0.85rem; border: 1.5px solid var(--rule-strong); border-radius: 999px; font-size: 0.875rem; font-weight: 600; color: var(--ink-2); }
.pg-seg label:hover span { background: var(--hover); color: var(--ink); }
.pg-seg input:checked + span { background: var(--action); border-color: var(--action); color: var(--on-action); }
.pg-seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.pg-llm-action { display: grid; gap: 0.4rem; margin-bottom: 0.75rem; }
.pg-llm-action .pg-llm-go { justify-self: start; min-height: 2.75rem; }
.pg-llm-action a.pg-llm-go { display: inline-flex; align-items: center; padding: 0.5rem 1.1rem; text-decoration: none; }
.pg-llm-hint { margin: 0; font-size: 0.875rem; color: var(--ink-2); }
.pg-llm-label { display: block; margin: 0 0 0.25rem; font-size: 0.8125rem; font-weight: 600; color: var(--ink-2); }
.pg-copyrow { display: flex; gap: 0.4rem; align-items: stretch; }
.pg-copyrow .pg-llm-field { flex: 1 1 auto; }
.pg-copyrow > button { flex: none; }
.pg-llm-field { min-width: 0; font-family: var(--font-mono); font-size: 0.8125rem; }
.pg-llm-dialog .pg-llm-code { min-height: 5.5rem; margin: 0 0 0.4rem; }
.pg-llm-dialog .pg-llm-prompt { min-height: 4.5rem; font-family: var(--font); font-size: 0.875rem; }
.pg-llm-json-box { margin-top: 0.75rem; }
.pg-llm-state { display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem 0.75rem; }
.pg-llm-status { display: inline-flex; align-items: center; gap: 0.5rem; margin: 0; font-weight: 600; }
.pg-llm-status::before { content: ""; flex: none; width: 0.55rem; height: 0.55rem; border-radius: 50%; border: 1.5px solid var(--ink-2); box-sizing: border-box; }
.pg-llm-status[data-state="connected"]::before { background: var(--teal); border-color: var(--teal); }
.pg-llm-status[data-state="waiting"]::before, .pg-llm-status[data-state="connecting"]::before, .pg-llm-status[data-state="reconnecting"]::before { border-color: var(--amber); }
.pg-llm-activity { list-style: none; margin: 0.5rem 0 0; padding: 0; font-size: 0.875rem; }
.pg-llm-activity:empty { display: none; }
.pg-llm-activity li { padding: 0.2rem 0; border-top: 1px solid var(--rule); overflow-wrap: anywhere; }
.pg-llm-at { font-family: var(--font-mono); font-size: 0.75rem; }

/* Tablet: the panels stack once the code would get too narrow, the set (with the board) first. */
@media (max-width: 960px) {
  .pg-layout { grid-template-columns: minmax(0, 1fr); }
  .pg-layout > .pg-code { order: 0; }
}
/* Phone: the site's 16px gutter (style.css); the panels go edge to edge of it with less padding. */
@media (max-width: 640px) {
  .area-playground .page-head { margin-top: 1.25rem; }
  .area-playground .page-head h1 { font-size: 1.875rem; }
  .pg-layout > .panel { padding: 0.9rem 0.85rem 1rem; }
  .pg-choices { grid-template-columns: minmax(0, 1fr); gap: 0.6rem; }
  .pg-players { grid-template-columns: minmax(0, 1fr); gap: 0.4rem; }
  .pg-replay .replay-controls .replay-scrub { flex-basis: 100%; order: 5; }
  .pg-code-head .pg-run-row { flex: 1 1 100%; }
  .pg-code-head .pg-actions { flex: 1 1 auto; }
  .pg-code-head .pg-actions .pg-run { width: 100%; min-width: 0; }
  .pg-dock .pg-console { max-height: 18vh; }
  .pg-run-row .pg-field { flex: 1 1 100%; }
  .pg-actions .pg-run { flex: 1 1 auto; }
  .pg-moves ol.move-list .mv { grid-template-columns: 2.25rem minmax(0, 1fr) auto; }
  .pg-moves ol.move-list .mv .mv-seat { display: none; }
  .pg-bm { grid-template-columns: minmax(0, 1fr) auto; }
  .pg-bm-n { grid-column: 1 / -1; }
  .pg-agent-banner-actions { margin-left: 0; }
  .pg-review-actions > button { flex: 1 1 auto; }
  .pg-review-note { flex-basis: 100%; }
  .pg-llm-action .pg-llm-go { justify-self: stretch; justify-content: center; }
  .pg-llm-copy > .pg-llm-go { flex: 1 1 100%; }
  .pg-llm-dialog .pg-llm-message { height: 14.5rem; }
  @supports (field-sizing: content) { .pg-llm-dialog .pg-llm-message { height: auto; } }
  .pg-llm-dialog .pg-copyrow { flex-wrap: wrap; }
  .pg-llm-dialog .pg-copyrow .pg-llm-field { flex-basis: 100%; }
}
@media (prefers-reduced-motion: no-preference) {
  .pg-result:not([hidden]) { animation: board-in 0.25s ease-out; }
}
/* A notice, the status lines and the result stay hidden until the script shows them (.notice's own display would show them). */
.area-playground [hidden] { display: none !important; }
.pg-botmoves, .pg-console, .pg-moves ol.move-list { scrollbar-color: var(--rule-strong) transparent; scrollbar-width: thin; }
