/* Mushroom at the End. The closure survey print: paper, one ink, one stamp colour. design/STYLE.md is the spec.
   Every colour is a token; the collection (docs/themes.js) swaps the tokens, never the layout. */
@font-face { font-family: "Big Shoulders Stencil"; font-weight: 800; font-display: swap; src: url("fonts/big-shoulders-stencil-800.woff2") format("woff2"); }
@font-face { font-family: "Atkinson Hyperlegible"; font-weight: 700; font-display: swap; src: url("fonts/atkinson-hyperlegible-700.woff2") format("woff2"); }
@font-face { font-family: "Sometype Mono"; font-weight: 400; font-display: swap; src: url("fonts/sometype-mono.woff2") format("woff2"); }

:root {
  /* palette (Stool / diazo print; themes.js rewrites these seven) */
  --paper: #EFEADB; --ink: #26487A; --stamp: #B2362B; --wash: #F3D9CF; --tint: #DCE1E6; --mute: #4F607A; --body: #1C2C46;
  /* type */
  --stencil: "Big Shoulders Stencil", "Atkinson Hyperlegible", "Noto Sans TC", sans-serif;
  --atk: "Atkinson Hyperlegible", system-ui, "Noto Sans TC", sans-serif;
  --mono: "Sometype Mono", ui-monospace, "Noto Sans TC", monospace;
  --t-label: 20px; --t-btn: 20px; --t-body: 22px; --t-hud: 24px; --t-title: 30px;
  /* spacing: 4 8 12 16 24 */
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px;
  --rule: 2px solid var(--ink);
  /* the shared kit reads these */
  --pl-font: var(--atk);
  --pl-topbar-bg: var(--paper); --pl-topbar-text: var(--ink); --pl-control-text: var(--ink); --pl-control-bg: var(--paper);
  --pl-control-border: var(--ink); --pl-focus: var(--stamp); --pl-overlay: rgb(25 23 21 / .72);
  --pl-card-bg: var(--paper); --pl-card-text: var(--body); --pl-card-muted: var(--body); --pl-card-border: var(--ink);
  --pl-primary: var(--ink); --pl-primary-text: var(--paper); --pl-shadow: rgb(25 23 21 / .28); --pl-share-bg: var(--paper);
  --pl-radius-control: 0; --pl-radius-card: 0; --pl-radius-picture: 0;
  color-scheme: light;
  font-family: var(--atk);
  background: var(--paper);
  color: var(--body);
  -webkit-tap-highlight-color: transparent;
}
:root[data-theme="shelf"], :root[data-theme="cluster"] { color-scheme: dark; }

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; }
body { min-width: 320px; background: var(--paper); color: var(--body); font-family: var(--atk); }
html[lang="zh-Hant"] body { line-height: 1.6; }
button, a { font: inherit; }

/* ---- buttons: square, a 2 px ink rule, 20 px labels, 52 px tall (44 px minimum anywhere) ---- */
button {
  min-height: 52px; min-width: 44px; padding: var(--s2) var(--s4);
  border: var(--rule); border-radius: 0; background: var(--paper); color: var(--ink);
  font: 700 var(--t-btn)/1.45 var(--atk); cursor: pointer; touch-action: manipulation;
}
button:active { background: var(--ink); color: var(--paper); transition: none; }
button:focus-visible, a:focus-visible { outline: 3px solid var(--stamp); outline-offset: 3px; }
button:disabled { border-style: dashed; color: var(--mute); border-color: var(--mute); cursor: not-allowed; background: var(--paper); }
.primary-button { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.primary-button:active { background: var(--paper); color: var(--ink); }
.quiet-button { border-color: transparent; background: transparent; }

.shell { width: min(100%, 430px); min-height: 100dvh; margin: 0 auto; padding: calc(60px + env(safe-area-inset-top)) 12px calc(16px + env(safe-area-inset-bottom)); }
@media (min-width: 700px) { .shell { margin-top: 18px; min-height: calc(100dvh - 36px); border: var(--rule); } }

/* ---- the play screen: one survey sheet (title block, board, meters, score line) ---- */
#play-screen { padding-top: var(--s1); }
.sheet { border: var(--rule); background: var(--paper); }
.tb { display: grid; grid-template-columns: 1fr auto; border-bottom: var(--rule); color: var(--ink); font: 400 var(--t-label)/1.45 var(--mono); }
.tb > div { padding: var(--s1) 9px; } .tb > div + div { border-left: var(--rule); min-width: 104px; }
.tb strong, .tb .level-name { display: block; margin: 0; font: 700 var(--t-hud)/1.45 var(--atk); color: var(--ink); font-variant-numeric: tabular-nums; }
.move-count { display: none; }
.board-shell { position: relative; width: 100%; overflow: hidden; background: var(--paper); }
#board { display: block; width: 100%; height: auto; touch-action: none; user-select: none; }
.meters { display: grid; grid-template-columns: auto 1fr; border-top: var(--rule); color: var(--ink); font-variant-numeric: tabular-nums; }
.meters > div { padding: 2px 9px var(--s1); min-width: 0; } .meters > div + div { border-left: var(--rule); text-align: right; background: var(--wash); color: var(--body); }
.meters .m-label { display: block; font: 400 var(--t-label)/1.45 var(--mono); white-space: nowrap; }
.meters strong { display: block; font: 700 var(--t-hud)/1.45 var(--atk); white-space: nowrap; }
.instruction { min-height: 0; margin: var(--s1) 2px 0; color: var(--body); font: 700 var(--t-body)/1.45 var(--atk); }
html[lang="zh-Hant"] .instruction { font-size: 24px; line-height: 1.6; }
.instruction:empty { display: none; }
.message { min-height: 2.9em; margin: 0 2px; color: var(--mute); font: 700 var(--t-body)/1.45 var(--atk); }
.message b { color: var(--stamp); font-weight: 700; }
.message.refused { color: var(--stamp); }
.controls { display: flex; gap: var(--s3); padding: var(--s2) 0 var(--s3); }
.controls button { flex: 1; min-width: 0; }

/* ---- the result: pinned to the bottom of the screen, Next first ---- */
.result-card { position: relative; z-index: 4; margin: var(--s3) 0; padding: var(--s4); border: var(--rule); background: var(--paper); color: var(--body); text-align: center; }
.result-card:not([hidden]) { position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 406px; max-height: calc(100svh - 140px); overflow: auto; z-index: 6; box-shadow: 0 6px 0 var(--ink); }
.result-title { margin: 0; color: var(--ink); font: 800 var(--t-title)/1.45 var(--stencil); letter-spacing: .02em; }
.result-card[data-outcome="whole"] .result-title { color: var(--stamp); }
.result-marks { margin: var(--s2) 0 var(--s1); font: 700 var(--t-body)/1.4 var(--atk); font-variant-numeric: tabular-nums; }
.result-next { margin: 0 0 var(--s1); color: var(--body); font: 700 var(--t-body)/1.4 var(--atk); font-variant-numeric: tabular-nums; }
.result-next[hidden] { display: none; }
.result-caps { display: flex; justify-content: center; gap: var(--s4); margin: var(--s1) 0; font: 700 var(--t-body)/1.45 var(--atk); font-variant-numeric: tabular-nums; color: var(--mute); }
.cap-mark { display: inline-flex; align-items: center; gap: 6px; }
.cap-mark i { display: inline-flex; gap: 2px; }
.cap-mark b, .tile-cap { display: inline-block; width: 18px; height: 11px; border: 2px solid currentColor; border-radius: 18px 18px 2px 2px; }
.cap-mark.earned { color: var(--stamp); }
.cap-mark.earned b { background: var(--stamp); border-color: var(--stamp); }
.result-more { margin: var(--s1) 0 var(--s2); color: var(--body); font: 700 var(--t-body)/1.4 var(--atk); font-variant-numeric: tabular-nums; }
.share-line { display: none; } /* the Share button sends it; the card stays short enough to keep Next on screen */
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--s2); }
.result-actions button { flex: 1 1 40%; }
.result-actions .primary-button { flex-basis: 100%; }

/* ---- levels, daily floor, collection: the same ruled boxes as the sheet ---- */
.map-heading { display: flex; align-items: center; justify-content: space-between; gap: var(--s4); padding: var(--s3) 4px var(--s1); }
.map-heading h1 { margin: 0; color: var(--ink); font: 800 34px/1.45 var(--stencil); }
#map-copy { color: var(--body); }
.level-map { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s2); margin-top: var(--s4); }
.level-tile { display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; min-height: 88px; padding: var(--s2); text-align: left; color: var(--ink); }
.level-tile strong, .level-tile small { display: block; }
.level-tile strong { font: 800 30px/1.45 var(--stencil); }
.level-tile .tile-name { display: block; font: 700 var(--t-btn)/1.45 var(--atk); }
.level-tile small { margin-top: var(--s1); color: var(--mute); font: 700 var(--t-btn)/1.45 var(--atk); font-variant-numeric: tabular-nums; }
.level-tile.complete { background: var(--ink); color: var(--paper); }
.level-tile.complete small { color: var(--paper); }
.level-tile.current { outline: 3px solid var(--stamp); outline-offset: 2px; }
.tile-caps { display: flex; gap: 3px; margin-top: 6px; }
.tile-cap { width: 16px; height: 10px; color: inherit; opacity: .55; }
.tile-cap.earned { background: var(--stamp); border-color: var(--stamp); opacity: 1; }
.level-tile.complete .tile-cap.earned { background: var(--paper); border-color: var(--paper); }
.map-extra { margin: var(--s5) 0 0; padding: var(--s3); border: var(--rule); background: var(--paper); }
.map-extra h2 { margin: 0 0 var(--s1); color: var(--ink); font: 800 28px/1.45 var(--stencil); letter-spacing: .02em; }
.map-extra p { margin: 0 0 var(--s3); color: var(--body); font: 700 var(--t-body)/1.45 var(--atk); }
.daily-choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--s2); }
.daily-choices button { min-width: 0; padding-inline: var(--s1); }
#collection-list { display: grid; gap: var(--s2); }
.collection-kind { display: grid; grid-template-columns: 72px 1fr; gap: var(--s3); align-items: center; width: 100%; min-height: 88px; padding: var(--s2); text-align: left; color: var(--ink); background: var(--paper); }
.collection-kind canvas { width: 72px; height: 72px; border: var(--rule); display: block; }
.collection-kind:disabled { color: var(--mute); }
.collection-kind.current { outline: 3px solid var(--stamp); outline-offset: 2px; }
.kind-words strong, .kind-words span { display: block; }
.kind-words strong { font: 800 28px/1.45 var(--stencil); letter-spacing: .02em; }
html[lang="zh-Hant"] .kind-words strong { font: 700 24px/1.3 var(--atk); }
.kind-words span { margin-top: 2px; font: 700 var(--t-btn)/1.45 var(--atk); }
.map-credit { margin: var(--s4) 2px var(--s1); color: var(--mute); font: 700 var(--t-label)/1.4 var(--atk); }
.load-error { margin: 54px 8px; padding: 18px; border: var(--rule); color: var(--body); line-height: 1.4; }

/* ---- the kit's top bar and How to play card, in the house type ---- */
[data-pl="topbar"] { box-shadow: 0 2px 0 var(--ink); }
[data-pl="back"] { min-width: 0; max-width: 6.2em; overflow: hidden; color: var(--ink); font: 800 20px/1.0 var(--stencil); letter-spacing: .02em; text-transform: uppercase; white-space: normal; text-align: left; flex: 0 1 auto; }
.pl-brand-mark { width: 24px; height: 24px; margin-right: 8px; flex: 0 0 auto; }
.pl-topbar__inner { gap: 6px; } .pl-topbar__actions { flex: 0 0 auto; flex-wrap: nowrap; gap: 2px; } .pl-topbar__actions button { white-space: nowrap; }
[data-pl="lang"], [data-pl="levels"], [data-pl="howto"] { min-width: 44px; min-height: 44px; padding: 8px 6px !important; border: 0; background: transparent !important; color: var(--ink) !important; font: 700 var(--t-btn)/1.1 var(--atk) !important; box-shadow: none !important; }
[data-pl="howto"] { border: var(--rule) !important; }
[data-pl="howto"] { padding: 2px 6px !important; }
[data-pl="howto"] .pl-howto-word { display: inline-block; max-width: 4.2em; white-space: normal; text-align: center; line-height: 1.0; }
@media (min-width: 360px) and (max-width: 429px) { .pl-brand-mark { display: none; } [data-pl="back"] { max-width: 5.2em; } }
@media (max-width: 359px) { [data-pl="back"] { max-width: 6em; } }
@media (max-width: 359px) { [data-pl="howto"] .pl-howto-word { display: none !important; } [data-pl="howto"] .pl-howto-question { display: inline !important; font-size: 24px; font-weight: 700; } }
[data-pl="howto-card"] h2 { font: 800 var(--t-title)/1.45 var(--stencil); letter-spacing: .02em; color: var(--ink); }
[data-pl="howto-lines"] li { font: 700 var(--t-body)/1.45 var(--atk); color: var(--body); }
html[lang="zh-Hant"] [data-pl="howto-lines"] li { font-size: 24px; line-height: 1.6; }
.pl-howto-footer button { min-height: 52px; font: 700 var(--t-btn)/1.45 var(--atk); border: var(--rule); }
[data-pl="howto-pictures"] { flex-wrap: wrap; align-items: center; gap: 6px; }
[data-pl="howto-pictures"] canvas { width: calc(50% - 3px); min-width: 0; min-height: 0; background: var(--ink); border-color: var(--ink); }
[data-pl="howto-pictures"] canvas:first-child { width: 100%; min-height: 80px; }
[data-pl="share-fallback"] { font: 700 var(--t-label)/1.4 var(--atk); }

/* ---- the hand (a drawn mitten) and the stamp confetti ---- */
.hand-demo { position: absolute; z-index: 2; display: none; width: 42px; height: 45px; margin: 0; pointer-events: none; background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-6 -6 42 45'%3E%3Cpath transform='rotate(-35)' d='M-4 0Q0-5 4 0L4 14Q14 11 17 18Q20 32 10 40L-8 40Q-16 32-14 22Q-12 15-4 16Z' fill='%23fff' stroke='%23141210' stroke-width='2.5' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat center / contain; }
.hand-demo span { display: none; }
.hand-demo.running { display: block; animation: mitten-press 1.3s ease-in-out infinite; }
@keyframes mitten-press { 0%, 100% { transform: translate(3px, 3px); opacity: .5; } 45%, 65% { transform: translate(0, 0); opacity: 1; } }
.success-effect { position: absolute; inset: 0; z-index: 3; overflow: hidden; pointer-events: none; }
.success-effect i { position: absolute; top: 47%; left: 50%; width: 10px; height: 8px; opacity: 0; background: var(--stamp); border-radius: 50% 50% 2px 2px; }
.success-effect.on i { animation: confetti .72s ease-out both; }
.success-effect i:nth-child(2) { animation-delay: .05s; } .success-effect i:nth-child(3) { animation-delay: .1s; } .success-effect i:nth-child(5) { animation-delay: .12s; }
@keyframes confetti { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 100% { transform: translate(var(--x, 0), var(--y, 0)) rotate(240deg); opacity: 0; } }
.success-effect i:nth-child(1) { --x: -112px; --y: -105px; } .success-effect i:nth-child(2) { --x: 106px; --y: -96px; } .success-effect i:nth-child(3) { --x: 130px; --y: 92px; } .success-effect i:nth-child(4) { --x: -126px; --y: 78px; } .success-effect i:nth-child(5) { --x: 8px; --y: -145px; }

.reduced-motion *, .reduced-motion *::before, .reduced-motion *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; } }

/* narrow phones: tighter gutters, never smaller text */
@media (max-width: 380px) {
  .shell { padding-left: 8px; padding-right: 8px; }
  .tb > div { padding: 2px 6px; } .tb > div + div { min-width: 88px; }
  .meters > div { padding-left: 6px; padding-right: 6px; }
  .pl-brand-mark { width: 20px; height: 20px; margin-right: 4px; }
}
/* the stamp in the top bar follows the set in use */
.pl-brand-mark circle { stroke: var(--stamp); } .pl-brand-mark path { fill: var(--stamp); }
html[lang="zh-Hant"] [data-pl="back"] { max-width: none; white-space: nowrap; }
.pl-topbar__actions { gap: 6px !important; }
@media (max-width: 359px) {
  .pl-topbar__actions button { width: auto !important; }
  /* MUSHROOMS × PATCHES stays one line at 320: 18 px (the floor), tighter letters and padding, never smaller */
  .meters > div { padding-left: 4px; padding-right: 4px; }
  .meters .m-label { white-space: nowrap; font-size: 18px; letter-spacing: -.07em; }
  /* the title block gives the daily's date and difficulty one line: the TOP SCORE cell is only as wide as its words */
  .tb > div > span { font-size: 18px; letter-spacing: -.07em; white-space: nowrap; }
  .tb > div { padding-left: 5px; padding-right: 5px; } .tb > div + div { min-width: 0; }
}
@media (max-width: 359px) {
  html[lang] [data-pl="back"] { max-width: 5.4em; padding: 4px; font-size: 18px; line-height: 1.1; }
  .pl-brand-mark { display: none; }
}

/* fixes round 2: while the result card is up, the controls and the message under the board are hidden, so no half-cut Undo / Reset */
#play-screen.result-on .controls, #play-screen.result-on .message, #play-screen.result-on .instruction { visibility: hidden; }
.result-more { text-wrap: balance; }
@media (max-width: 359px) {
  /* a short card: the top half of the board stays visible */
  .result-card:not([hidden]) { left: 8px; right: 8px; padding: var(--s2) var(--s3); box-shadow: 0 4px 0 var(--ink); }
  .result-title { font-size: 26px; line-height: 1.25; }
  .result-marks { margin: 2px 0 0; font-size: 18px; line-height: 1.3; }
  .result-caps { margin: 2px 0; font-size: 18px; line-height: 1.3; gap: var(--s3); }
  .result-more { margin: 2px 0 var(--s2); font-size: 18px; line-height: 1.3; }
  .result-actions { gap: 6px; }
  .result-actions button { min-height: 44px; padding: 4px 8px; font-size: 18px; line-height: 1.2; white-space: nowrap; }
  /* the card covers the meter strip here; the card carries the score, so the strip hides instead of being sliced */
  #play-screen.result-on .meters { visibility: hidden; }
}
