/* Play template layout (kit v1). Colours come from theme tokens (--t-*), set by shapes.js.
 * Placeholder look: pattern blocks on a kraft desk mat. Hairline rows, a serif display face, monospace labels.
 * A game restyles through game.css and theme tokens; it does not edit this file. */
:root {
  --t-ground: #efe8da; --t-board: #f8f4ea; --t-ink: #1f1d1a; --t-muted: #6b665c; --t-line: #cdc3b0; --t-accent: #c8412b;
  --display: ui-serif, "Iowan Old Style", Georgia, serif;
  --label: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --body: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", sans-serif;
  --pl-font: var(--body);
  --pl-topbar-bg: var(--t-ground); --pl-topbar-text: var(--t-ink); --pl-control-text: var(--t-ink); --pl-control-bg: var(--t-board);
  --pl-control-border: var(--t-line); --pl-focus: var(--t-accent); --pl-card-bg: var(--t-board); --pl-card-text: var(--t-ink);
  --pl-card-muted: var(--t-muted); --pl-card-border: var(--t-line); --pl-primary: var(--t-ink); --pl-primary-text: var(--t-board);
  --pl-radius-control: 6px; --pl-radius-card: 8px; --pl-radius-picture: 4px; --pl-share-bg: var(--t-board);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--t-ground); color: var(--t-ink); font: 400 16px/1.45 var(--body); -webkit-text-size-adjust: 100%; }
body { min-height: 100svh; }
button { font: inherit; color: inherit; touch-action: manipulation; }
.app { width: min(100%, 430px); margin: 0 auto; padding: calc(64px + env(safe-area-inset-top)) 14px max(20px, env(safe-area-inset-bottom)); }
.screen[hidden] { display: none; }
h1 { font: 600 28px/1.15 var(--display); margin: 10px 0 12px; }
h2 { font: 600 20px/1.2 var(--display); margin: 22px 0 8px; }
.eyebrow, .level-name, .move-count, .hearts, .rule-tag, .row-detail, .note, .credit, .foot, .level-tile small, .stamp small {
  font-family: var(--label); font-size: 13px; letter-spacing: .02em; color: var(--t-muted);
}
.eyebrow { margin: 6px 0 0; text-transform: uppercase; }
.pl-brand-title { font: 600 18px/1 var(--display); color: var(--t-ink); }
[data-pl="back"] svg { flex: none; }

/* buttons: 44 px targets everywhere */
button { min-height: 44px; min-width: 44px; border: 1px solid var(--t-line); border-radius: 6px; background: var(--t-board); padding: 8px 12px; cursor: pointer; }
button:disabled { opacity: .4; cursor: default; }
button.primary { background: var(--t-ink); color: var(--t-board); border-color: var(--t-ink); font-weight: 600; }
button.quiet { background: transparent; border-color: transparent; text-decoration: underline; text-underline-offset: 3px; }
button.danger { border-color: var(--t-accent); color: var(--t-accent); background: transparent; margin-top: 18px; }
:focus-visible { outline: 3px solid var(--t-accent); outline-offset: 2px; }

/* home */
.today { padding: 8px 0 18px; border-bottom: 2px solid var(--t-ink); }
.today h1 { font-size: 30px; }
.today-status { margin: 0 0 14px; color: var(--t-muted); }
.today .primary { width: 100%; font-size: 17px; }
.menu, .rows { display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; padding: 13px 2px; border: 0; border-bottom: 1px solid var(--t-line); border-radius: 0; background: transparent; text-align: left; }
.row-label { font: 500 18px/1.2 var(--display); }
.tagline { margin: 18px 0 0; color: var(--t-muted); font-size: 14px; }

/* play */
.play-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.play-head p { margin: 4px 0; }
.hearts { color: var(--t-accent); letter-spacing: .2em; }
.goal { margin: 2px 0 8px; font: 500 17px/1.3 var(--display); }
.rule-strip { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; padding: 6px 6px 6px 10px; border-left: 3px solid var(--t-accent); background: var(--t-board); font-size: 15px; }
.rule-strip[hidden] { display: none; }
.rule-note-open #goal { display: none; }
.rule-strip span:nth-child(2) { flex: 1; }
.rule-tag { text-transform: uppercase; color: var(--t-accent); }
.meter:empty { display: none; }
.meter { margin: 0 0 8px; }
.board-shell { position: relative; width: 100%; max-width: 360px; margin: 0 auto; }
#board { display: block; width: 100%; height: auto; aspect-ratio: 360 / 430; border: 1px solid var(--t-line); border-radius: 4px; background: var(--t-board); touch-action: none; }
#fx-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.message { min-height: 2.9em; margin: 8px 0; font-size: 15px; }
.message.refused { color: var(--t-accent); }
/* One row that wraps; it stays at the bottom of the screen on a solid fill, so Undo is always reachable. */
.controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; position: sticky; bottom: 0; z-index: 5; padding: 8px 0 max(8px, env(safe-area-inset-bottom)); background: var(--t-ground); }
.controls button { padding: 6px 4px; font-size: 14px; }
.controls.pl-static { position: static; }
.controls button[hidden] { display: none; }
#stuck-button { display: block; margin: 6px auto 0; }
#stuck-button[hidden] { display: none; }
.result-card { margin-top: 12px; padding: 14px 0 0; border-top: 2px solid var(--t-ink); }
.result-card[hidden] { display: none; }
.result-title { margin: 0; font: 600 26px/1.1 var(--display); }
.result-marks { margin: 6px 0; font-family: var(--label); }
.share-line { margin: 0 0 10px; padding: 8px 10px; background: var(--t-board); border: 1px dashed var(--t-line); font-family: var(--label); font-size: 14px; user-select: text; -webkit-user-select: text; }
.result-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.result-actions button { flex: 1 1 40%; }
.reduced-motion * { transition: none !important; animation: none !important; }

/* levels, archive, themes, stats */
.level-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.level-tile { display: flex; flex-direction: column; align-items: flex-start; min-height: 64px; text-align: left; }
.level-tile strong { font: 600 20px/1 var(--display); }
.level-tile.done { border-color: var(--t-ink); box-shadow: inset 0 -3px 0 var(--t-ink); }
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-tile { display: flex; flex-direction: column; gap: 6px; padding: 6px; text-align: left; }
.theme-tile canvas { width: 100%; height: auto; border: 1px solid var(--t-line); }
.theme-tile[aria-pressed="true"] { border: 2px solid var(--t-ink); }
.stats { display: grid; grid-template-columns: 1fr auto; margin: 0; }
.stats dt, .stats dd { padding: 10px 0; border-bottom: 1px solid var(--t-line); margin: 0; }
.stats dd { font: 600 18px/1.2 var(--label); text-align: right; }
.collection { display: flex; flex-wrap: wrap; gap: 6px; }
.stamp { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 72px; padding: 6px 2px; color: var(--t-ink); }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--t-line); }
.seg { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.seg button { padding: 6px 10px; }
.seg button[aria-pressed="true"] { background: var(--t-ink); color: var(--t-board); border-color: var(--t-ink); }
.about p { max-width: 62ch; }
.foot { margin-top: 28px; padding-top: 10px; border-top: 1px solid var(--t-line); }
.foot[hidden] { display: none; }
.foot-link { color: var(--t-muted); }
.load-error { padding: 16px; border: 2px solid var(--t-accent); }
@media (max-width: 359px) {
  .app { padding-left: 10px; padding-right: 10px; }
  .controls button { font-size: 12px; }
  .level-grid { grid-template-columns: repeat(3, 1fr); }
  .pl-brand-title { font-size: 15px; }
}
/* components.js target bar, restyled to the template's hairline look */
.plc-target { padding: 0; border: 0; background: transparent; box-shadow: none; }
.plc-target__head { display: flex; justify-content: space-between; font: 500 13px/1.3 var(--label); color: var(--t-muted); }
.plc-target__count { color: var(--t-ink); }
.plc-target__track { height: 6px; margin-top: 4px; border-radius: 0; background: var(--t-line); overflow: hidden; }
.plc-target__fill { height: 100%; border-radius: 0; background: var(--t-ink); transition: width .3s; }

.first-minute { display:flex; align-items:center; gap:8px; margin:8px 0; padding:8px 10px; border:1px solid var(--t-line); border-radius:8px; background:var(--t-board); color:var(--t-ink); font-size:14px; }
.first-minute[hidden], .first-minute-pointer[hidden] { display:none; }
.first-minute span { flex:1; }
.first-minute button { min-height:44px; min-width:44px; }
.board-shell { position:relative; }
.first-minute-pointer { position:absolute; z-index:3; width:34px; height:34px; transform:translate(-50%,-50%); border:3px solid var(--t-accent); border-radius:50%; box-shadow:0 0 0 5px rgb(255 255 255 / .55); pointer-events:none; }

/* Accessible Play tokens. The player setting changes these before the first paint. */
:root { --text-scale:1; --text-min:calc(18px * var(--text-scale)); --text-body:calc(20px * var(--text-scale)); --text-rule:calc(22px * var(--text-scale)); --text-btn:calc(20px * var(--text-scale)); --text-hud:calc(24px * var(--text-scale)); --text-title:calc(28px * var(--text-scale)); --text-fine:calc(14px * var(--text-scale)); --symbol-size:calc(32px * var(--text-scale)); --target-size:44px; --target-gap:8px; }
:root[data-text-size="huge"] { --text-scale:1.25; }
html, body { font-size:var(--text-body); line-height:1.45; }
button, a, summary { font-size:var(--text-btn); line-height:1.45; }
button, summary { min-width:44px; min-height:44px; }
h1, h2, .today h1, .result-title { font-size:var(--text-title); line-height:1.45; }
p, li, dt, dd, .tagline, .note, .message, .share-line { font-size:var(--text-body); line-height:1.45; }
.eyebrow, .row-detail, .stamp small, .level-tile small, .rule-tag { font-size:var(--text-min); line-height:1.45; }
.level-name, .move-count, .hearts, .stats dd, .plc-target__count { font-size:var(--text-hud); line-height:1.45; }
.goal, .rule-strip, .first-minute, [data-role="rule"], .rule { font-size:var(--text-rule); line-height:1.45; color:var(--t-ink); background:var(--t-board); }
.row-label, .controls button, .today .primary, .pl-brand-title { font-size:var(--text-btn); line-height:1.45; }
.credit, .credits .note { font-size:var(--text-fine); line-height:1.45; }
.credits summary { display:list-item; padding:8px 12px; cursor:pointer; }
.credits { margin-top:16px; }
.menu, .rows, .controls, .result-actions, .seg, .collection { gap:var(--target-gap); }
.controls button { min-width:0; padding:8px 4px; white-space:normal; }
.controls button:disabled { opacity:1; color:var(--t-muted); border-color:var(--t-muted); }
:root:lang(zh-Hant) .message { min-height:3.2em; }
.play-head { flex-wrap:wrap; align-items:center; }
.play-head p { min-width:0; }
.set-row { flex-wrap:wrap; align-items:flex-start; }
.seg { justify-content:flex-start; }
.row { align-items:center; flex-wrap:wrap; }
.row-detail { overflow-wrap:anywhere; }
.level-grid { gap:var(--target-gap); }
.level-tile { min-width:0; }
.theme-grid { grid-template-columns:1fr; }
.theme-tile { min-width:0; }
:focus-visible { outline:3px solid var(--t-accent); outline-offset:2px; }
button:active, button[aria-pressed="true"] { box-shadow:inset 0 0 0 3px var(--t-ink); }
:root[data-contrast="more"] button, :root[data-contrast="more"] .board-shell, :root[data-contrast="more"] #board { border-width:3px; }
:root[data-contrast="more"] .rule-strip, :root[data-contrast="more"] .first-minute { background:var(--t-board); }
@media(prefers-contrast:more) { button, .board-shell, #board { border-width:3px; } .rule-strip, .first-minute { background:var(--t-board); } }
@media(prefers-reduced-motion:reduce) { *, *::before, *::after { animation-duration:.001ms !important; transition-duration:.001ms !important; scroll-behavior:auto !important; } }
:root:lang(zh-Hant) { --text-body:calc(22px * var(--text-scale)); --text-rule:calc(24px * var(--text-scale)); }
:root:lang(zh-Hant) body, :root:lang(zh-Hant) p, :root:lang(zh-Hant) li { line-height:1.6; }
@media(max-width:359px) { .controls button, .pl-brand-title { font-size:var(--text-btn); } }

/* Shared shell reflows its actions under the game's own brand at phone widths. */
[data-pl="topbar"] { height:auto; min-height:112px; }
.pl-topbar__inner { height:auto; min-height:112px; flex-wrap:wrap; align-content:center; row-gap:0; }
.pl-topbar__actions { width:100%; justify-content:space-between; flex-wrap:nowrap; }
.pl-topbar__actions button, .pl-howto-word { font-size:var(--text-btn) !important; line-height:1.45 !important; width:auto !important; }
.pl-topbar__actions button { min-width:44px; min-height:44px; }
.pl-topbar__actions { align-items:center; }
.pl-brand-title, [data-pl="back"] { font-size:var(--text-btn) !important; line-height:1.45 !important; }
.app { padding-top:calc(var(--pl-topbar-h, 64px) + 8px); }
.eyebrow, .row-detail, .plc-target__head { font-size:var(--text-body); }
.foot-link { display:inline-flex; align-items:center; min-height:44px; font-size:var(--text-btn); color:var(--t-ink); }
button.danger { color:var(--t-ink); border:2px solid var(--t-ink); }
.plc-target__head { line-height:1.45; }
.level-tile strong { font-size:var(--text-btn); line-height:1.45; }
[data-pl="howto-lines"] { color:var(--pl-card-text); font-size:var(--text-rule); line-height:1.45; }
[data-pl="howto-lines"] li { font-size:var(--text-rule); line-height:1.45; }
:root[data-contrast="more"] { --pl-overlay:#101c19; }
@media(prefers-contrast:more) { :root { --pl-overlay:#101c19; } }
:root:lang(zh-Hant) { --body:system-ui,-apple-system,"Segoe UI","Noto Sans TC"; --display:Georgia,"Noto Serif TC"; --label:ui-monospace,Menlo,"Noto Sans TC"; }
:root:lang(zh-Hant) :is(button,a,summary,h1,h2,p,li,span,div,dt,dd,figcaption) { line-height:1.6; }
@media(max-width:359px) {
  .pl-howto-word { display:inline !important; }
  .pl-howto-question { display:none !important; }
  .pl-topbar__actions { flex-wrap:nowrap; gap:4px; }
  .pl-topbar__actions button { padding:4px 2px; white-space:normal; max-width:116px; }
}
:root:lang(zh-Hant) .pl-topbar__actions button,
:root:lang(zh-Hant) .pl-howto-word,
:root:lang(zh-Hant) .pl-brand-title,
:root:lang(zh-Hant) [data-pl="back"],
:root:lang(zh-Hant) .level-tile strong { line-height:1.6 !important; }

/* Keep a rule-sized goal slot so opening the note leaves the board in place. */
@media (max-width: 400px) {
  #goal, #rule-strip:not([hidden]) { min-height:calc(60px + 2lh); }
  #rule-strip:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; padding: 6px 8px; }
  #rule-tag { grid-column: 1; grid-row: 1; }
  #rule-ok { grid-column: 2; grid-row: 1; min-height: 44px; }
  #rule-text { grid-column: 1 / -1; grid-row: 2; flex: none; }
  #rule-strip:not([hidden]) { max-height:calc(84px + 2lh); overflow-y:auto; }
}
@media (max-width: 359px) {
  :root[data-text-size="huge"] #goal, :root[data-text-size="huge"] #rule-strip:not([hidden]) { min-height:calc(60px + 3lh); }
}

/* The tall phone keeps two rows, with Levels clear of the game's brand. */
@media (max-width: 400px) and (min-height: 641px) {
  .pl-topbar__inner { position:relative; display:grid; grid-template-columns:minmax(0,1fr) auto auto auto; grid-template-rows:56px 56px; height:112px; min-height:112px; gap:0; }
  .pl-topbar__actions { display:contents; }
  [data-pl="back"] { grid-column:1; grid-row:1; justify-self:start; }
  [data-pl="levels"] { grid-column:2; grid-row:2; }
  [data-pl="lang"] { grid-column:3; grid-row:2; }
  [data-pl="howto"] { grid-column:4; grid-row:2; }
  [data-pl="idea"] { position:absolute; top:6px; right:12px; }
  .pl-howto-word { display:none !important; }
  .pl-howto-question { display:inline !important; font-size:var(--text-btn); line-height:1.45; }
}
@media (max-width: 359px) and (min-height: 641px) {
  [data-pl="levels"] { width:44px !important; min-width:44px; padding:4px; }
  .pl-levels-word { display:none; }
  .pl-levels-icon { display:inline; font-size:var(--text-btn); line-height:1.45; }
}

/* Short phones give the board the space saved by a single-row header. */
@media (max-height: 640px) {
  .app { padding-top:var(--pl-topbar-h, 60px); }
  [data-pl="topbar"] { height:60px; min-height:0; }
  .pl-topbar__inner { height:60px; min-height:0; flex-wrap:nowrap; padding:0 8px; gap:2px; }
  [data-pl="back"] { flex:0 1 auto; min-width:44px; padding:4px; }
  .pl-topbar__actions { width:auto; flex:0 0 auto; gap:2px; }
  .pl-topbar__actions button { min-width:44px; min-height:44px; padding:4px; }
  .pl-howto-word { display:none !important; }
  .pl-howto-question { display:inline !important; font-size:var(--text-btn); line-height:1.45; }
}
@media (max-width:359px) and (max-height:640px) {
  /* kit 23: the brand title shows here again, in place of the logo (see the end of this file). */
  [data-pl="idea"] { width:44px !important; }
  .pl-idea-word { display:none; } /* The idea button keeps its text in aria-label. */
  .pl-idea-icon { display:inline !important; font-size:var(--text-btn); line-height:1.45; }
  /* kit 28: the board is centred at the widest the height allows and the message sits UNDER it in a fixed two-line slot.
     fitBoard() switches to the kit 23 side-by-side layout (class pl-beside: board column + message beside it) only when
     that gives the bigger board: a tall board, or Huge text. --pl-beside-col is that column's width. */
  #play-screen { --pl-beside-col:200px; --pl-beside-msg:178px; }
  #play-screen:not(.pl-beside) #message { margin:4px 0 0; height:2lh; min-height:0; overflow-y:auto; overflow-wrap:anywhere; }
  #play-screen.pl-beside:not([hidden]) { display:grid; grid-template-columns:var(--pl-beside-col) minmax(0,1fr); }
  #play-screen.pl-beside > :not(#board-shell):not(#message) { grid-column:1 / -1; }
  #play-screen.pl-beside #board-shell { grid-column:1; width:100%; }
  #play-screen.pl-beside #message { grid-column:2; margin:0 0 0 8px; height:var(--pl-beside-msg); min-height:0; overflow-y:auto; overflow-wrap:anywhere; }
  /* kit 31: an empty message takes no room under the board (pl-msg-float, set by fitBoard). kit 32: a message that shows
     before the next level floats on a card ABOVE the board (its bottom edge 4 px over the board's top, over the goal,
     lesson and meter), never on the board: kit 31 put it over the board's bottom rows and hid Drum Rule's word rack and
     Market Day's villagers. --pl-board-h (the board's height) and --pl-msg-room (room above the board) come from fitBoard. */
  #play-screen.pl-msg-float:not(.pl-beside) #message { position:absolute; z-index:4; width:var(--pl-msg-w, 100%); height:auto;
    max-height:var(--pl-msg-room, calc(4lh + 10px));
    margin:0; padding:4px 8px; transform:translateY(calc(-100% - var(--pl-board-h, 0px) - 4px)); background:var(--t-board); color:var(--t-ink); border:1px solid var(--t-line);
    border-radius:6px; box-shadow:0 2px 6px rgba(0,0,0,.18); pointer-events:none; overflow:hidden; overflow-wrap:anywhere; }
  #play-screen.pl-msg-float:not(.pl-beside) #message.refused { color:var(--t-accent); }
  #play-screen.pl-msg-float:not(.pl-beside) #message:empty { visibility:hidden; padding:0; border:0; box-shadow:none; }
  #play-screen.pl-msg-float:not(.pl-beside) #message.pl-msg-flash { animation:pl-msg-fade 7s linear forwards; }
  .controls { grid-template-columns:repeat(4,minmax(0,1fr)); }
  .controls button { padding-block:0; overflow-wrap:anywhere; }
  :root[data-text-size="huge"] #goal,
  :root[data-text-size="huge"] #rule-strip:not([hidden]) { height:145px; min-height:0; max-height:145px; overflow-y:auto; }
}

/* On a short Huge phone, the note uses the space beside the scaled board.
   All four actions have their final positions before the first touch. */
@media (max-width:359px) and (max-height:620px) {
  :root[data-text-size="huge"] .app { padding-top:var(--pl-topbar-h, 64px); }
  :root[data-text-size="huge"] .goal,
  :root[data-text-size="huge"] .meter { margin-bottom:0; }
  :root[data-text-size="huge"] #play-screen { --pl-beside-col:158px; --pl-beside-msg:140px; }
  :root[data-text-size="huge"] .controls { grid-template-columns:repeat(4,minmax(0,1fr)); }
  :root[data-text-size="huge"] .controls button { padding-block:0; font-family:"Nimbus Sans Narrow","Liberation Sans Narrow",var(--body); letter-spacing:-.035em; overflow-wrap:anywhere; }
}

/* Colour-blind-safe families (palette-cvd.js has the same values and pieceStyle(role) for the second cue). */
:root {
  --oi-orange:#E69F00; --oi-sky:#56B4E9; --oi-green:#009E73; --oi-yellow:#F0E442; --oi-blue:#0072B2; --oi-vermilion:#D55E00; --oi-purple:#CC79A7; --oi-black:#000000;
  --tol-blue:#4477AA; --tol-cyan:#66CCEE; --tol-green:#228833; --tol-yellow:#CCBB44; --tol-red:#EE6677; --tol-purple:#AA3377; --tol-grey:#BBBBBB;
  --role-primary:var(--t-a); --role-secondary:var(--t-b); --role-good:var(--t-b); --role-bad:var(--t-c); --role-neutral:var(--t-d); --role-accent:var(--t-e);
}

/* Kit 18: one screen (P1FS01, Chen 2026-10-24). During play the page is never taller than the phone: the board takes
 * what is left after the rule, the message and ONE row of controls (the 20 px Accessible Play sizes are kept; the room
 * comes from layout, never from smaller text). The win / end card is a sheet pinned to the bottom of the screen with
 * the primary button (Next level / Play again) first, so it is visible without scrolling; Share and the rest follow
 * inside the sheet, which scrolls by itself when it is long. A game restyles the sheet through game.css. */
:root[data-pl-screen="play"] .app, :root[data-pl-screen="result"] .app { padding-bottom: 0; }
/* no accidental zoom or bounce while playing (double taps are moves in many games; P1TE07) */
html { touch-action: manipulation; overscroll-behavior: none; }
.controls { grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); }
:root[data-pl-screen="result"] .result-card {
  position: fixed; z-index: 30; left: 50%; bottom: 0; width: min(100%, 430px); transform: translateX(-50%);
  display: flex; flex-direction: column; max-height: min(62dvh, calc(100dvh - 72px)); overflow-y: auto; overscroll-behavior: contain;
  margin: 0; padding: 14px 14px max(14px, env(safe-area-inset-bottom)); background: var(--t-board);
  border: 2px solid var(--t-ink); border-bottom: 0; border-radius: 10px 10px 0 0; box-shadow: 0 -8px 28px rgb(0 0 0 / .18);
}
:root[data-pl-screen="result"] .result-card[hidden] { display: none; }
:root[data-pl-screen="result"] .result-title { order: 0; }
:root[data-pl-screen="result"] .result-marks { order: 1; margin: 2px 0 10px; }
:root[data-pl-screen="result"] .result-actions { order: 2; }
:root[data-pl-screen="result"] .share-line { order: 3; margin: 10px 0 0; }
:root[data-pl-screen="result"] .result-card > :not(.result-title):not(.result-marks):not(.result-actions):not(.share-line) { order: 4; }
.result-actions #next-button:not([hidden]), .result-actions .primary:not([hidden]) { flex: 1 1 100%; order: -1; }
/* kit 35: PlayGame.resultLead() may put Try again first (data-lead="again"); Next then sits in the row like the others */
.result-actions[data-lead="again"] #next-button:not([hidden]) { flex: 0 1 auto; order: 0; }
:root[data-pl-screen="result"] .controls { visibility: hidden; }
@media (prefers-reduced-motion: no-preference) {
  :root:not(.reduced-motion)[data-pl-screen="result"] .result-card { animation: pl-sheet-up .22s ease-out; }
}
@keyframes pl-sheet-up { from { transform: translate(-50%, 24px); opacity: 0; } to { transform: translate(-50%, 0); opacity: 1; } }

/* Kit 20: one screen by rule (P1FS05; pipeline designs/onescreen/UX_STUDY.md sections 3-4). Play screen =
 * [top bar][level row + HUD, data-pl="hud"][goal sentence, data-pl="goal"][board, the room that is left][controls row].
 * Read-once text never sits on the play screen; every-move text keeps its Accessible Play size (no shrinking). */
/* the board never traps a vertical swipe: the wrapper pans, the canvas hands non-draggable swipes to the page (input.js) */
.board-shell, [data-pl="board"] { touch-action: pan-y; }
/* sheets and text boards scroll inside themselves; nothing else does */
[data-pl="sheet"], [data-pl="textboard"], .pl-sheet { overscroll-behavior: contain; overflow-y: auto; }
/* HUD: each number with its noun in the same box. Both stay at the HUD size: the study's 18 px noun would shrink HUD text,
 * which Accessible Play forbids (a11y_audit role hud >= 24), so the number is told apart by weight, not size. */
[data-pl="hud"] .pl-num { font-weight: 700; font-variant-numeric: tabular-nums; }
/* goal sentence: rule size, at most two lines at 360 px (template_check fails on three) */
[data-pl="goal"] { font-size: var(--text-rule); line-height: 1.45; }
.rule-note-open #goal { display: block; }
@media (max-width: 400px) { #goal { min-height: 0; } }
/* new-rule callout over the top of the board: taps pass through to the board; the first move or Got it dismisses it */
#board-shell > [data-pl="callout"]:not([hidden]) {
  /* as wide as the screen allows (not the board), so a small board does not squeeze the rule into a column */
  position: absolute; z-index: 6; left: 50%; transform: translateX(-50%); width: calc(min(100vw, 430px) - 16px); max-width: calc(100vw - 16px); top: 6px; margin: 0; min-height: 0; max-height: calc(100% - 12px); overflow-y: auto;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: center; padding: 6px 8px;
  border: 2px solid var(--t-ink); border-left: 6px solid var(--t-accent); border-radius: 8px; background: var(--t-board);
  box-shadow: 0 6px 18px rgb(0 0 0 / .18); pointer-events: none;
}
/* config calloutAt: 'above' (default: just above the board, over the goal and meter, so the whole board stays in
 * sight), 'top' or 'bottom' (over the board's own top or bottom edge, for a game whose edge is empty) */
#board-shell > [data-pl="callout"][data-at="above"]:not([hidden]) { top: auto; bottom: calc(100% + 4px); max-height: none; }
#board-shell > [data-pl="callout"][data-at="bottom"]:not([hidden]) { top: auto; bottom: 6px; }
#board-shell > [data-pl="callout"] #rule-tag { grid-column: 1; grid-row: 1; }
#board-shell > [data-pl="callout"] #rule-ok { grid-column: 2; grid-row: 1; min-height: 44px; pointer-events: auto; }
#board-shell > [data-pl="callout"] #rule-text { grid-column: 1 / -1; grid-row: 2; }
/* rare controls behind More: the open row shows them in place */
.controls .pl-more-away { display: none !important; }
#more-button[aria-expanded="true"] { background: var(--t-board); }

/* Kit 21: short phones (360 to 400 wide, 640 tall or less) show Levels and Idea as icons, as the 320 short phone
   already does, so names up to about 11 characters stay on one line and the brand button stays inside the bar. */
@media (max-width:400px) and (max-height:640px) {
  [data-pl="levels"] { width:44px !important; min-width:44px; padding:4px; }
  .pl-levels-word { display:none; }
  .pl-levels-icon { display:inline; font-size:var(--text-btn); line-height:1.45; }
  [data-pl="idea"] { width:44px !important; }
  .pl-idea-word { display:none; } /* The idea button keeps its text in aria-label. */
  .pl-idea-icon { display:inline !important; font-size:var(--text-btn); line-height:1.45; }
}

/* Kit 23: on a short narrow phone the first-minute lesson takes the goal's slot (the lesson step says what to do on
   level 1) and drops its premise line (the premise card said it just before), so the board and Undo stay on screen
   at Huge text and in zh-Hant. Skip sits under the text so the text keeps the full width.
   Kit 25: every short phone (640 tall or less, up to 400 wide), not only 320: at 360x640 a new game's lesson box plus
   its goal ran the page 27 to 31 px past the screen, so queue/newgame.sh stopped before Pages. */
@media (max-width:400px) and (max-height:640px) {
  .pl-lesson-open #goal { display:none !important; }
  .pl-lesson-open #first-minute .fm-premise { display:none; }
  #first-minute:not([hidden]) { display:block; margin:0 0 8px; padding:4px 8px; max-height:145px; overflow-y:auto; }
  #first-minute #first-minute-skip { float:right; margin:0 0 0 8px; padding:0 6px; }
}

/* Kit 26: the 320 short phone shows the mark AND the game's name on one line (up to 11 characters; a longer title sets
   config shortTitle). Levels, the language switch, Idea and How to play are 44 px each with no spare gap, so the brand
   keeps the rest (kit 29: a 20 px mark, 3 px, and the name at the 20 px button size, see below). Huge text needs more than the bar holds, so there the bar
   keeps the logo alone and the name stays in the button's aria-label (as kit 23). */
@media (max-width:359px) and (max-height:640px) {
  .pl-topbar__inner { padding:0 3px; gap:0; }
  .pl-topbar__actions { gap:0; }
  [data-pl="lang"] { width:44px !important; min-width:44px !important; padding:0 !important; font-size:16px !important; flex:0 0 44px; }
  :root:not([data-text-size="huge"]) [data-pl="back"] { flex:0 1 auto !important; min-width:0; max-width:142px; padding:4px 0; gap:3px; overflow:hidden; }
  :root:not([data-text-size="huge"]) [data-pl="back"] svg { width:20px; height:20px; flex:0 0 20px; }
  :root:not([data-text-size="huge"]) .pl-brand-title { display:block !important; white-space:nowrap; overflow:hidden; text-overflow:clip; max-width:none; }
  :root[data-text-size="huge"] .pl-brand-title { display:none; }
  /* Kit 29: the name keeps the button size (20 px, line height 1.45; zh-Hant 1.6) instead of kit 26's 18 px: text is
     never shrunk to fit (ACCESSIBLE_PLAY.md). To make the room, the mark is 20 px with a 3 px gap and the bar keeps 3 px at its edges; when the
     name still does not fit beside it core.js sets .pl-brand-nomark and the name takes the mark's place. A name too
     long even then needs config shortTitle (template_check row "320 top bar name on one line"). */
  :root:not([data-text-size="huge"]) [data-pl="back"].pl-brand-nomark svg { display:none; }
}

/* Kit 26: on a short phone (600 px tall or less) the result sheet compacts so the title, marks, every button and the
   share line are on screen with no scroll: smaller padding, Save picture and Menu as one row of two text links, text
   no smaller than 18 px. */
@media (max-height: 600px) {
  :root[data-pl-screen="result"] .result-card { max-height: calc(100dvh - 120px); padding: 8px 14px max(8px, env(safe-area-inset-bottom)); }
  :root[data-pl-screen="result"] .result-title { font-size: 20px; line-height: 1.25; margin: 0; }
  :root[data-pl-screen="result"] .result-marks { font-size: 18px; line-height: 1.25; margin: 2px 0 6px; }
  :root[data-pl-screen="result"] .result-actions { gap: 6px; }
  :root[data-pl-screen="result"] .result-actions button { min-height: 44px; padding: 4px 8px; font-size: 18px; line-height: 1.2; }
  :root[data-pl-screen="result"] .result-actions #card-button, :root[data-pl-screen="result"] .result-actions #menu-button {
    flex: 1 1 40%; border-color: transparent; background: transparent; text-decoration: underline; text-underline-offset: 3px; }
  :root[data-pl-screen="result"] .share-line { font-size: 18px; line-height: 1.3; margin: 6px 0 0; padding: 4px 8px; }
}
@keyframes pl-msg-fade { 0%, 85% { opacity:1; } 100% { opacity:0; visibility:hidden; } }

/* kit 35: the New rule note passes Accessible Play at both sizes: the tag and Got it take the rule size, the tag is ink
   on the note's paper (7:1) with the accent kept as the note's left bar */
#rule-strip #rule-tag { font-size: var(--text-rule); color: var(--t-ink); }
#rule-strip #rule-ok { font-size: var(--text-rule); }
/* kit 35: config calloutAt 'inline': the note is a box in the page between the goal and the board, over nothing */
#rule-strip[data-at="inline"]:not([hidden]) { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 8px; align-items: center;
  max-width: 430px; margin: 0 auto 6px; padding: 6px 8px; min-height: 0; border: 2px solid var(--t-ink); border-left: 6px solid var(--t-accent); border-radius: 8px; }
#rule-strip[data-at="inline"] #rule-tag { grid-column: 1; grid-row: 1; }
#rule-strip[data-at="inline"] #rule-ok { grid-column: 2; grid-row: 1; min-height: 44px; }
#rule-strip[data-at="inline"] #rule-text { grid-column: 1 / -1; grid-row: 2; }
