/* Peony Dream: noon at the painting window. A limewash wall, a cypress table, raw silk in daylight (visual round 2026-11-13). */
@font-face {
  font-family: "PD Kai";
  src: url("fonts/pd-kai.woff2") format("woff2");
  font-display: swap;
}

:root {
  --pd-wall: #DCDFD6;
  --pd-wall-deep: #C9CEC3;
  --pd-table: #CFB78E;
  --pd-silk: #F2EBDA;
  --pd-text: #23201C;
  --pd-muted: #4C4F47;
  --pd-wet: #120F0C;
  --pd-rouge: #8E2250;
  --pd-mount: #9FB5AA;
  --pd-rod: #6E8A7E;
  --pd-bronze: #8C6A36;
  --pd-verdigris: #3F7262;
  /* The story plates and how-to pictures still sit on the night ground until the board round redraws them. */
  --pd-night: #2A1D18;
  --pl-font: "Iowan Old Style", Georgia, "Noto Serif TC", "Songti TC", "Noto Serif CJK TC", serif;
  --pd-title-font: "PD Kai", "Iowan Old Style", Georgia, "Kaiti TC", serif;
  --pl-topbar-bg: #DCDFD6;
  --pl-topbar-text: #23201C;
  --pl-control-text: #23201C;
  --pl-control-bg: #F2EBDA;
  --pl-control-border: #23201C;
  --pl-focus: #3F7262;
  --pl-overlay: rgb(35 32 28 / .55);
  --pl-card-bg: #F2EBDA;
  --pl-card-text: #23201C;
  --pl-card-muted: #4C4F47;
  --pl-card-border: #9FB5AA;
  --pl-primary: #23201C;
  --pl-primary-text: #F2EBDA;
  --pl-shadow: rgb(35 32 28 / .22);
  --pl-share-bg: #F2EBDA;
  --pl-radius-control: 6px;
  --pl-radius-card: 6px;
  --pl-radius-picture: 4px;
  color-scheme: light;
  font-family: var(--pl-font);
  color: var(--pd-text);
  background: var(--pd-wall);
}

body { background: var(--pd-wall); color: var(--pd-text); }
@media (min-width: 700px) { .shell { background: var(--pd-wall); border-color: var(--pd-wall-deep); box-shadow: none; } }

/* Top bar: wall, one quiet rule, the name in Kai, buttons as words. */
[data-pl="topbar"] { box-shadow: 0 1px 0 var(--pd-wall-deep); }
[data-pl="back"][data-brand] { gap: 7px; padding: 4px 2px; color: var(--pd-text); font: 400 26px/1 var(--pd-title-font); }
[data-pl="back"][data-brand] img { display: block; flex: none; }
.pl-brand-title { font-weight: 400; }
.pl-topbar__actions button { color: var(--pd-text); background: transparent; border-color: transparent; font-weight: 400; font-size: 17px; white-space: nowrap; }
.pl-topbar__actions { gap: 2px; }
@media (min-width: 360px) and (max-width: 430px) { [data-pl="back"][data-brand] { font-size: 24px; } }
@media (max-width: 359px) {
  [data-pl="back"][data-brand] { font-size: 22px; gap: 5px; }
  [data-pl="back"][data-brand] img { width: 24px; height: 24px; }
  .pl-topbar__inner { padding: 0 6px 0 10px; gap: 2px; }
  .pl-topbar__actions button { width: auto; min-width: 44px; padding: 4px 3px; font-size: 16px; }
  .pl-howto-question { font-size: 22px; }
}

/* LXGW WenKai TC (subset): name and level names only, so the font stays small. */
.pd-title, .level-name, .result-title, .level-tile strong, .map-heading h1 { font-family: var(--pd-title-font); }
.pd-title { margin: 0 3px 2px; color: var(--pd-text); font-size: 13px; }

/* HUD: two rows. Nouns small and muted, numbers large; the only bold on the page is the numbers. */
.level-row { align-items: baseline; padding: 0 4px; }
.level-name { color: var(--pd-text); font-weight: 400; font-size: 28px; line-height: 1.2; }
.pd-hud-cell { display: flex; align-items: baseline; gap: 6px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.pd-noun { color: var(--pd-muted); font-size: 20px; }
.pd-num, .move-count { margin: 0; color: var(--pd-text); font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }
.pd-hud2 { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 0; padding: 0 4px; }
.pd-hud2 .pd-hud-cell:first-child { align-items: center; gap: 9px; }
#pd-portrait-count { font-weight: 400; }
.pd-ticks { display: inline-flex; gap: 4px; }
.pd-ticks i { display: inline-block; width: 9px; height: 22px; border: 2px solid var(--pd-text); border-radius: 5px 5px 4px 4px / 8px 8px 4px 4px; transform: rotate(8deg); }
.pd-ticks i.on { background: var(--pd-wet); }
.pd-ticks.many i { width: 7px; }
#pd-progress { display: none !important; }
.instruction { margin: 4px 4px 0; color: var(--pd-text); font-size: 20px; line-height: 1.35; }
.instruction:empty { display: none; }
.message { color: var(--pd-text); font-size: 18px; }
.message:empty { min-height: 0; margin: 0; }
.message.refused { color: var(--pd-rouge); }

/* Reused hint pointer: an ink hand over the silk. */
.board-shell .plc-hint { z-index: 4; }
.board-shell .plc-hint__hand { border-color: var(--pd-silk); background: var(--pd-text); box-shadow: none; }
.board-shell .plc-hint__hand::before { border-color: var(--pd-silk); background: var(--pd-text); }
.board-shell .plc-hint__ring { border-color: var(--pd-text); }

.board-shell { margin-top: 6px; border: 0; border-radius: 0; background: var(--pd-table); box-shadow: none; }
.hand-demo, .success-effect { display: none !important; }

.pd-rule { display: flex; align-items: baseline; gap: 10px; min-height: 0; margin: 6px 4px 0; color: var(--pd-text); font-size: 20px; line-height: 1.35; }
.pd-rule:empty { display: none; }
:lang(zh-Hant) .pd-rule { font-size: 22px; }
.pd-new { flex: none; padding: 0 6px; border: 2px solid var(--pd-text); border-radius: 3px; color: var(--pd-text); font-size: 18px; line-height: 1.3; }
.pd-coach { margin: 6px 4px 0; color: var(--pd-text); font-size: 20px; }

/* Buttons: Undo is ink, Reset level is silk with an ink edge. No shadows; a press sinks 2 px. */
button { border-color: var(--pd-text); background: var(--pd-silk); color: var(--pd-text); font-family: var(--pl-font); }
.controls { gap: 12px; padding: 10px 0 12px; }
.controls button { min-height: 48px; min-width: 120px; padding: 0 18px; border: 2px solid var(--pd-text); border-radius: 6px; font-size: 20px; font-weight: 400; box-shadow: none; }
#undo-button { background: var(--pd-text); color: var(--pd-silk); }
#reset-button { background: var(--pd-silk); color: var(--pd-text); }
#undo-button:disabled { opacity: 1; background: var(--pd-wall-deep); border-color: var(--pd-muted); color: var(--pd-muted); }
.controls button:active:not(:disabled), .result-actions button:active, .pd-howto-reset:active { transform: translateY(2px); }
.primary-button { border: 2px solid var(--pd-text); background: var(--pd-text); box-shadow: none; color: var(--pd-silk); font-weight: 400; }
.primary-button:active { box-shadow: none; }

/* Win sheet: silk, pinned to the bottom; a mounted portrait slot (filled by the board round), the title and one line. */
.result-card { position: relative; overflow: hidden; border: 0; border-top: 3px solid var(--pd-mount); border-radius: 0; background: var(--pd-silk); color: var(--pd-text); box-shadow: 0 -2px 0 rgb(35 32 28 / .08); text-align: left; }
.result-card::before, .result-card::after { content: none; display: none; }
.pd-win-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.pd-mount { flex: none; padding: 6px 7px; background: var(--pd-mount); border-top: 5px solid var(--pd-rod); border-bottom: 7px solid var(--pd-rod); }
.pd-mount #pd-result-portrait { display: block; width: 120px; height: 120px; }
.pd-mount #pd-result-portrait canvas { display: block; width: 120px; height: 120px; }
.pd-mount.pd-portrait-empty { display: none; }
.result-title { margin: 0; color: var(--pd-text); font-size: 28px; font-weight: 400; }
.result-marks { margin: 2px 0 0; font-size: 24px; font-weight: 400; font-variant-numeric: tabular-nums; }
.result-marks:empty { display: none; }
.result-actions { gap: 12px; }
.result-actions button { flex: 1 1 0; min-height: 48px; border: 2px solid var(--pd-text); border-radius: 6px; background: var(--pd-silk); color: var(--pd-text); font-size: 20px; font-weight: 400; }
.result-actions #next-button { min-height: 54px; background: var(--pd-text); color: var(--pd-silk); font-size: 22px; }
.share-line { color: var(--pd-muted); font-size: 16px; }
.pd-hold .result-card { opacity: 0; transform: translateY(24px); pointer-events: none; }
.pd-in .result-card { animation: pd-rise .42s cubic-bezier(.2,.7,.3,1) both; }
@keyframes pd-rise { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.pd-l1 #share-line, .pd-l1 #share-button { display: none; }
.pd-hold .controls, .pd-in .controls { visibility: hidden; }
#play-screen:has(#result-screen:not([hidden])) .controls { display: none; }

/* Level screen */
.map-heading h1 { color: var(--pd-text); font-weight: 400; }
.eyebrow { color: var(--pd-muted); }
#map-copy { display: none; }
.quiet-button { color: var(--pd-text); font-weight: 400; }
.pd-garden { display: block; width: 100%; height: auto; margin-top: 14px; border-radius: 4px; box-shadow: inset 0 0 0 1px var(--pd-wall-deep); }
.level-map { margin-top: 12px; }
.level-tile { border: 2px solid var(--pd-wall-deep); border-radius: 6px; background: var(--pd-silk); color: var(--pd-text); }
.level-tile small { color: var(--pd-muted); font-size: 14px; }
.level-tile.complete { border-color: var(--pd-verdigris); background: var(--pd-silk); }
.level-tile.today-tile { border-color: var(--pd-text); }
.pd-album { display: flex; gap: 10px; overflow-x: auto; margin: 16px 0 6px; padding: 8px 2px 10px; }
.pd-album[hidden] { display: none; }
.pd-scroll { flex: none; width: 72px; height: 126px; }
.pd-plate-thumb { flex: none; width: 76px; height: 126px; padding: 2px; border: 1px solid var(--pd-wall-deep); background: transparent; }
.pd-plate-thumb canvas { display: block; width: 72px; height: 112px; }

/* Story plates: one picture, no words; tap to skip */
.pd-plate { position: fixed; z-index: 60; inset: 0; display: grid; place-items: center; background: var(--pd-night); animation: pd-fade .3s ease both; }
.pd-plate canvas { width: min(100vw, calc(100dvh * 360 / 560)); height: auto; max-height: 100dvh; }
.pd-plate { grid-template-rows: auto auto; align-content: center; }
.pd-plate-line { margin: 12px 20px 0; max-width: 32ch; color: var(--pd-silk); font-size: 1.15rem; line-height: 1.45; text-align: center; }
.pd-plate-out { opacity: 0; transition: opacity .2s ease; }
@keyframes pd-fade { from { opacity: 0; } to { opacity: 1; } }

/* How to play card on silk */
[data-pl="howto-card"] { background: var(--pd-silk); color: var(--pd-text); }
[data-pl="howto-card"] h2 { font-weight: 400; font-family: var(--pd-title-font); }
[data-pl="howto-pictures"] canvas { background: var(--pd-table); }
[data-pl="howto-lines"] { padding-left: 0; list-style: none; }
[data-pl="howto-lines"] li { text-align: center; }
.pl-howto-footer button { border: 2px solid var(--pd-text); font-weight: 400; }
.pd-first-howto [data-pl="sound"], .pd-first-howto [data-pl="motion"], .pd-first-howto .pl-howto-footer .pd-howto-reset { display: none; }
.pd-first-howto .pl-howto-footer { justify-content: flex-end; }
[data-pl="howto-start"] { font-weight: 400; }
.pl-howto-footer .pd-howto-reset { display: none; }
.pl-howto-creditlink { display: inline-block; min-height: 44px; line-height: 44px; color: inherit; text-decoration: underline; }

/* One screen (taste/ONE_SCREEN.md): the win sheet is pinned to the bottom of the screen, Next level first and full width. */
.result-card:not([hidden]) {
  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 16px max(14px, env(safe-area-inset-bottom));
}
.result-card .pd-win-head { order: 0; }
.result-card .result-actions { order: 2; }
.result-card .share-line { order: 3; margin: 10px 0 0; }
.result-actions #next-button:not([hidden]) { flex: 1 1 100%; order: -1; }
.pd-hold .result-card { transform: translate(-50%, 24px); }
.pd-in .result-card { animation: pd-sheet-rise .42s cubic-bezier(.2,.7,.3,1) both; }
@keyframes pd-sheet-rise { from { opacity: 0; transform: translate(-50%, 24px); } to { opacity: 1; transform: translateX(-50%); } }
/* Say the name once (the top bar has it). */
#pd-title { display: none; }
@media (max-height: 760px) {
  .controls { padding: 6px 0 8px; }
  .shell { padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
}

/* Short screens: Undo sits on the table between the sleeper and the ink stone; Reset level moves into How to play.
   shell.js moves .controls into the board box while this query matches. */
@media (max-height: 640px) {
  .shell { padding-top: calc(60px + env(safe-area-inset-top)); padding-left: 8px; padding-right: 8px; }
  #play-screen { padding-top: 2px; }
  .level-name { font-size: 26px; }
  .pd-hud2 { margin-top: 0; }
  .pd-rule, .instruction { margin-top: 2px; }
  .board-shell { margin-top: 4px; }
  /* Centred on the gap between the sleeper's tap area (to x 128 of 360) and the ink stone (from x 236): x 182. */
  .board-shell .controls { position: absolute; z-index: 5; left: 0; right: 0; bottom: 3.5%; padding: 0 0 0 1.12%; pointer-events: none; }
  /* The two HUD rows already say the goal (Portrait 0/2, Par 2), so the goal sentence gives its two lines to the silk. */
  .instruction { display: none; }
  .board-shell .controls button { pointer-events: auto; min-width: 88px; min-height: 44px; height: 44px; padding: 0 10px; }
  .board-shell #reset-button { display: none; }
  .pl-howto-footer .pd-howto-reset { display: inline-flex; }
  .result-card { padding: 12px 14px 10px; }
  .result-actions { gap: 8px; }
}
.pd-howto-reset[hidden] { display: none !important; }
.pl-howto-footer .pl-howto-start { font-weight: 400; }

/* First-minute lesson on the new wall (first-minute.css keeps its layout; these win on specificity). */
.pd-lesson-active #pd-hud2 { display: none; }
#play-screen #pd-lesson .pd-lesson-head { color: var(--pd-text); font: 400 26px/1.3 var(--pd-title-font); }
#play-screen #pd-lesson #pd-lesson-count { color: var(--pd-muted); font: 400 20px/1.3 var(--pl-font); font-variant-numeric: tabular-nums; }
#play-screen #pd-lesson #pd-lesson-board { border-radius: 0; background: var(--pd-table); box-shadow: none; }
#play-screen #pd-lesson #pd-lesson-line { color: var(--pd-text); font: 400 22px/1.35 var(--pl-font); }
#play-screen #pd-lesson #pd-lesson-note { color: var(--pd-muted); font-size: 18px; }
#play-screen #pd-lesson .pd-lesson-actions button { border: 2px solid var(--pd-text); border-radius: 6px; color: var(--pd-text); background: var(--pd-silk); font-size: 20px; }
#play-screen #pd-lesson #pd-lesson-next { color: var(--pd-silk); background: var(--pd-text); }
#play-screen #pd-lesson #pd-lesson-skip { border-color: transparent; color: var(--pd-text); background: transparent; font-size: 18px; text-decoration: underline; }

/* Top bar never wraps: below 380 px How to play uses the short label the shell already has. */
@media (max-width: 379px) {
  .pl-howto-word { display: none; }
  .pl-howto-question { display: inline; font-size: 22px; }
}
@media (min-width: 360px) and (max-width: 430px) {
  [data-pl="back"][data-brand] { font-size: 23px; }
  .pl-topbar__actions button { padding: 6px 4px; font-size: 16px; }
}
@media (max-height: 640px) {
  #play-screen #pd-lesson { margin-top: 2px; }
  #play-screen #pd-lesson .pd-lesson-head { margin-bottom: 4px; font-size: 24px; }
  #play-screen #pd-lesson #pd-lesson-line { margin-top: 6px; font-size: 20px; }
  #play-screen #pd-lesson #pd-lesson-note { min-height: 0; font-size: 18px; }
  #play-screen #pd-lesson .pd-lesson-actions { margin-top: 2px; }
}
