/* Chupu Ming is a self-hosted subset of Hanazono Mincho; see fonts/LICENSE.txt. */
@font-face {
  font-family:"Chupu Ming"; src:url("fonts/ming-a-15a1c02e.woff2") format("woff2");
  font-display:swap; unicode-range:U+0-FFFF;
}
@font-face {
  font-family:"Chupu Ming"; src:url("fonts/ming-b-97c24f57.woff2") format("woff2");
  font-display:swap; unicode-range:U+22CDA;
}
:root { color-scheme: light; --paper:#f5efdf; --card:#fcf7e9; --ink:#282a23; --muted:#56564a; --line:#b7a784; --wood:#dac59c; --wood-light:#e6d6b3; --red:#913323; --green:#23544b; --glint:#895c19; }
* { box-sizing:border-box; }
body { margin:0; color:var(--ink); background:radial-gradient(ellipse at top,#f9f4e8,var(--paper) 65%); font:1rem/1.6 system-ui,sans-serif; }
main { width:min(70rem,100% - 2.5rem); margin:auto; padding:1.5rem 0 3rem; }
a { color:var(--green); text-underline-offset:.18em; }
button,select { font:inherit; color:inherit; min-height:2.75rem; }
button { cursor:pointer; }
button:disabled { opacity:.55; cursor:default; }
button,select { border:1px solid var(--line); border-radius:.45rem; }
button:focus-visible,select:focus-visible,a:focus-visible,summary:focus-visible { outline:3px solid var(--green); outline-offset:3px; }
h1,h2,h3,p { margin:0; }
h1,h2 { font-family:"Songti SC","Noto Serif CJK SC",SimSun,serif; }
.mast { border-bottom:1px solid var(--line); padding:.1rem 0 .65rem; }
h1 { font-size:clamp(2.7rem,7vw,4.45rem); line-height:1.07; letter-spacing:.1em; }
.setup-panel { display:grid; grid-template-columns:minmax(0,1fr) auto; gap:0 clamp(.28rem,1.6vw,1rem); align-items:end; margin:.9rem 0 1rem; }
.setup-panel .seat-settings { grid-area:2/1/3/-1; }
.setup-panel .setup-actions { grid-area:1/2/2/3; }
.setup-panel .toolbar { grid-area:1/1/2/2; }
.toolbar { display:grid; grid-template-columns:auto minmax(0,max-content); gap:clamp(.28rem,1.6vw,1rem); align-items:end; }
.toolbar select { min-width:0; width:100%; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0; }
.field:not([hidden]) { display:grid; }
.field label { font-size:.9rem; color:var(--muted); }
select,.secondary { background:var(--card); padding:.4rem .65rem; }
.secondary { margin-left:auto; }
.arena { display:grid; grid-template-columns:minmax(0,1fr) minmax(16rem,.47fr); gap:1rem; align-items:start; }
.board-panel,.turn-panel { min-width:0; border:1px solid var(--line); border-radius:.65rem; padding:clamp(.65rem,2vw,1.2rem); background:var(--card); }
.board-head { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:.15rem .6rem; }
h2 { font-size:1.5rem; }
.board-key { color:var(--muted); font-size:.9rem; }
.board-key { display:flex; flex-wrap:wrap; gap:0 .7rem; }
/* All landing circles and numbered stones share the thread’s coordinates. */
.felt-board {
  container-type:inline-size;
  --thread:#784458; --cloth:#f5e8cc;
  padding:clamp(.24rem,1vw,.65rem) clamp(.32rem,1.25vw,.85rem);
  margin:.45rem 0 .65rem;
  border:4px solid #793e57;
  border-radius:.95rem;
  background:
    repeating-linear-gradient(0deg,#a6855a0e 0 1px,transparent 1px 3px),
    repeating-linear-gradient(90deg,#a6855a0c 0 1px,transparent 1px 3px),
    radial-gradient(ellipse at center,#fff4dd,var(--cloth) 78%);
  box-shadow:0 1px 0 1px #63384c,inset 0 0 0 2px #c795a5,inset 0 0 0 4px #8f5365;
}
.board { position:relative; aspect-ratio:1; isolation:isolate; }
.stitch-trail { position:absolute; inset:0; width:100%; height:100%; z-index:-1; pointer-events:none; }
.stitch-trail path { fill:none; stroke-linecap:round; vector-effect:non-scaling-stroke; }
.thread-bed { stroke:#ad7e88; stroke-width:1.8px; }
.thread-gate-band { stroke:#cba05d; stroke-width:7px; opacity:.23; }
.thread-gate { stroke:#b07839; stroke-width:2.1px; }
.thread-stitch { stroke:#fff1da; stroke-width:.9px; stroke-dasharray:1 3; }
.cell { position:absolute; display:grid; place-items:center; width:clamp(1.2rem,4.6cqw,2rem); height:clamp(1.2rem,4.6cqw,2rem); transform:translate(-50%,-50%); }
.waypoint { position:relative; display:grid; place-items:center; width:clamp(.34rem,1.05vw,.68rem); aspect-ratio:1; border-radius:50%; border:1px solid #87596d; background:#fff1d5; color:#55313e; white-space:nowrap; }
.stone-layer { position:absolute; inset:0; }
.stone-mark { position:absolute; z-index:1; width:0; height:0; }
.stone-mark::before { content:""; position:absolute; left:0; top:0; width:clamp(3px,.48vw,6px); height:clamp(6px,.85vw,10px); background:#814d47; border-radius:42%; transform:translate(-50%,-50%) rotate(8deg); box-shadow:inset 1px 1px 0 #e9b9889c,0 1px 1px #3e29293d; }
.stone-index { position:absolute; left:0; bottom:clamp(5px,.7vw,8px); transform:translateX(-50%); color:#734245; font:600 clamp(.57rem,1.85cqw,.76rem)/1 system-ui,sans-serif; font-variant-numeric:tabular-nums; }
.board-start,.finish .waypoint { border-color:#476950; background:#466548; color:#fff5df; box-shadow:inset 0 0 0 1px #85a688; }
.board-start { position:absolute; width:clamp(.88rem,3.75cqw,1.28rem); transform:translate(-50%,-50%); }
.finish .waypoint,.hazard .waypoint { width:clamp(.88rem,3.75cqw,1.28rem); }
.board-symbols { margin:.17rem 0; gap:.25rem .72rem; font-size:.86rem; }
.legend-stone,.legend-landing { display:inline-block; margin-inline-end:.22rem; vertical-align:middle; }
.legend-stone { width:5px; height:9px; border-radius:44%; background:#814d47; }
.legend-landing { width:9px; height:9px; border-radius:50%; border:1px solid #87596d; background:#fff1d5; }
.pit .waypoint { border-color:#5b3948; color:#fff0de; background:radial-gradient(circle at 42% 56%,#4a2b3e 18%,#593949 62%,#927267 100%); box-shadow:inset 0 2px 4px #2b1a25b0,0 0 0 1px #bf9e85; }
.trench .waypoint { border-color:#334c46; color:#fff7e2; background:radial-gradient(circle,#375c53,#2c4741); box-shadow:inset 0 2px 4px #253b33aa,0 0 0 1px #9ea990; }
.hazard .waypoint { align-content:center; gap:1px; line-height:1; }
.hazard-name { font:700 clamp(.55rem,1.08vw,.77rem)/1 system-ui,sans-serif; }
.gate .waypoint { border-color:#a15a31; color:#542c21; background:#edc88f; box-shadow:inset 0 0 0 2px #fae1aa; border-radius:32%; }
.target:not(.target-preview) .waypoint { outline:1px solid #865d328a; outline-offset:2px; }
.board.previewing .target:not(.target-preview) .waypoint { outline-color:#865d3240; }
.target-preview { z-index:3; }
.target-preview .waypoint { outline:2px solid #8b440e; outline-offset:3px; box-shadow:0 0 0 5px #f5cf7cc4; }
.target-preview:not(.hazard):not(.finish) .waypoint { background:#ffdc84; border-color:#8b440e; }
.target-preview::after { content:""; pointer-events:none; position:absolute; left:50%; top:50%; width:clamp(1.45rem,6cqw,2.35rem); aspect-ratio:1; border:1px solid #9d581f; border-radius:50%; transform:translate(-50%,-50%); animation:preview-ring .56s ease-out both; }
@keyframes preview-ring { from { opacity:.85; scale:.55; } to { opacity:0; scale:1.3; } }
@media (prefers-reduced-motion:reduce) { .target-preview::after { display:none; } }
.pieces { min-height:0; }
.turn-panel { min-height:20rem; }
#status { min-height:3.2em; color:var(--muted); }
.dice { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:.35rem; margin:.55rem 0; }
.die { text-align:center; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:0; min-height:3.15rem; border-radius:45%; border:1px solid #7d6845; background:#e9dab6; color:#363026; font-weight:700; }
.die.black { background:#34362e; color:#fff7e2; }
.result { min-height:1.7rem; font-weight:700; }
.primary { background:var(--red); color:white; width:100%; font-weight:700; margin:.45rem 0; padding:.35rem .6rem; }
.moves { display:grid; gap:.35rem; }
.moves button { background:#f0e3c4; padding:.4rem .55rem; text-align:left; }
.log-panel { margin-top:.85rem; padding-top:.6rem; border-top:1px solid var(--line); }
.log-panel h3 { font-size:.95rem; }
#log { font-size:.875rem; line-height:1.45; color:var(--muted); list-style:none; padding:0; margin:.25rem 0 0; max-height:10.5rem; overflow:auto; }
#log li { display:grid; grid-template-columns:6.2em minmax(0,1fr); align-items:start; gap:.48rem; padding:.24rem .12rem; }
#log li + li { border-top:1px solid #d6c7a680; }
.log-actor { color:var(--ink); font-weight:650; white-space:nowrap; }
.log-action { min-width:0; overflow-wrap:anywhere; }
.cast-badge {
  display:inline-block; min-inline-size:1.62em; margin-inline:.16em; padding:.10em .22em;
  border:1px solid var(--cast-line); border-radius:.32em; text-align:center;
  background:var(--cast-paper); color:var(--cast-ink); font-weight:700; line-height:1.12;
}
/* Royal seals have a solid, inset rim; common labels stay quiet even in greyscale. */
.cast-badge:not([data-cast="common"]) { box-shadow:inset 0 0 0 1px var(--cast-rim); }
.cast-badge[data-cast="lu"] { --cast-line:#292529; --cast-rim:#866f58; --cast-paper:#302a2d; --cast-ink:#fff0ce; }
.cast-badge[data-cast="zhi"] { --cast-line:#622a32; --cast-rim:#ad7470; --cast-paper:#74363f; --cast-ink:#fff1e7; }
.cast-badge[data-cast="du"] { --cast-line:#704024; --cast-rim:#c3905e; --cast-paper:#88502e; --cast-ink:#fff2dc; }
.cast-badge[data-cast="bai"] { --cast-line:#725a40; --cast-rim:#d7bb88; --cast-paper:#fff9ed; --cast-ink:#44382b; }
.cast-badge[data-cast="common"] {
  --cast-line:#9e9587; --cast-paper:transparent; --cast-ink:#534d43;
  border-style:dashed; font-weight:500;
}
.notes { margin-top:1rem; border-block:1px solid var(--line); }
.notes-body { max-width:52rem; padding:0 0 .66rem; }
.notes-body h2 { font-size:1.08rem; margin:.7rem 0 .24rem; }
.appendix-item { border-top:1px solid #d8c9aa; }
.appendix-item:first-of-type { margin-top:.38rem; }
.appendix-item > summary { padding:.32rem 0; }
.notes [lang=zh-Hant], .cast-name { font-family:"Chupu Ming","Songti TC","Noto Serif CJK TC",serif; }
.appendix-text { max-width:42em; padding:.05rem .24rem .42rem .9rem; font-size:1.03rem; line-height:1.9; }
.appendix-text p { margin:.4rem 0 .62rem; }
.appendix-era { display:inline-block; inline-size:2.8em; color:var(--muted); }
.annotated-classic > p { margin:.55rem 0 .8rem; }
.appendix-note { color:#715744; font-size:.88em; }
.appendix-source { font:.85rem/1.5 system-ui,sans-serif; }
details p, details ol, details table { margin:.4rem 0 .8rem; }
details li { margin:.3rem 0; }
table { border-collapse:collapse; text-align:left; }
th,td { border:1px solid var(--line); padding:.25rem .45rem; }
@media (max-width:760px) {
  main { width:calc(100% - 1.2rem); padding-top:.65rem; }
  .arena { grid-template-columns:1fr; gap:.65rem; }
  .turn-panel { min-height:0; }
  #log { max-height:8rem; }
}
@media (max-width:380px) { .secondary { margin-left:0; } }

/* Carved horse pieces: neutral troughs, cinnabar and jade game pieces. */
.stable-row { display:grid; gap:.34rem; margin:.65rem 0 .1rem; }
.stable { --team:var(--red); min-width:0; display:grid; grid-template-columns:1.7rem minmax(0,1fr); align-items:center; gap:.48rem; border:1px solid #ceb991; border-radius:.42rem; padding:.22rem .36rem; background:#f4ead4; }
.stable-green { --team:var(--green); }
.current-stable { border-color:var(--team); box-shadow:inset 3px 0 var(--team); }
.stable-key { width:1.48rem; height:1.48rem; display:grid; place-items:center; justify-self:center; line-height:1; border:1px solid #54423780; border-radius:50%; color:white; font-size:.7rem; font-weight:700; }
.stable-key:is(.team-gold,.team-white) { color:#322613; }
.stable-slots { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:.3rem; }
.stable-slot { height:2.25rem; display:grid; place-content:center; justify-items:center; border-radius:.32rem; background:#f0dfbb; box-shadow:inset 0 0 0 1px #bea77c88; }
.stable-slot > .horse-piece { width:1.85rem; }
.stable-slot.vacant { background:#fcf6e9c4; border:1px dashed #bdac8a; box-shadow:none; color:#674e3e; line-height:1.15; }
.stable-slot.vacant strong { color:var(--team); font-size:.79rem; }
.stable-slot.vacant span { font-size:clamp(.54rem,1.9vw,.74rem); white-space:nowrap; }
.stable-slot.arrived { border-style:solid; color:#385d4a; background:#e8eddb; }
.horse-piece { --coat:#f5d5a6; --mane:#a15d34; --edge:#653d27; --strap:#91512d; --metal:#ffe7a1; --saddle:#c57543; --base:#bf8a56; position:relative; display:inline-block; width:2rem; aspect-ratio:1; flex:none; filter:drop-shadow(0 1px 0 #34201650); }
.horse-piece.green { --coat:#f4ddaf; --mane:#377456; --edge:#284d3d; --strap:#38664e; --saddle:#56916c; --base:#87a177; }
.horse-piece svg { display:block; width:100%; height:100%; overflow:visible; }
.horse-piece.green svg { transform:scaleX(-1); }
.horse-body { fill:var(--coat); stroke:var(--edge); stroke-width:1.25; stroke-linejoin:round; }
.horse-piece .mane,.horse-piece .hoof { fill:var(--mane); stroke:var(--edge); stroke-width:1.1; stroke-linejoin:round; }
.horse-eye { fill:var(--edge); }
.hoof-base,.glaze-drip { fill:var(--base); }
.ceramic-saddle { fill:var(--saddle); stroke:var(--strap); stroke-width:.85; }
.glaze-light { fill:none; stroke:#fff1cf; stroke-linecap:round; stroke-width:1.45; opacity:.85; }
.bridle { fill:none; stroke:var(--strap); stroke-width:1.2; stroke-linecap:round; }
.horse-seal { position:absolute; bottom:0; right:0; display:grid; place-items:center; min-width:.78rem; height:.78rem; padding:0 .11rem; border-radius:50%; border:1px solid var(--edge); background:var(--metal); color:#291a10; font:700 .57rem/1 system-ui,sans-serif; }
.pieces { position:absolute; display:flex; justify-content:center; align-items:end; z-index:2; bottom:50%; left:50%; transform:translateX(-50%); gap:0; flex-wrap:nowrap; pointer-events:none; }
.gate .pieces { right:calc(50% + .55rem); left:auto; bottom:50%; transform:translateY(50%); }
.pieces .horse-piece { width:clamp(.87rem,4.6cqw,1.76rem); }
.pieces .horse-piece:not(:first-child) { margin-left:-.57rem; }
.pieces .horse-seal { min-width:.55rem; height:.55rem; padding:0; font-size:.39rem; }
.moves button { display:flex; align-items:center; gap:.45rem; }
.moves .horse-piece { width:1.65rem; }
@media (max-width:490px) {
  .pieces .horse-piece:not(:first-child) { margin-left:-.65rem; }
  .pieces .horse-piece:not(:first-child) .horse-seal { display:none; }
}

.cast-guide { margin:.62rem 0 0; border:1px solid var(--line); border-radius:.65rem; background:var(--card); }
.cast-guide summary { padding:.54rem .58rem; color:var(--green); }
.cast-guide summary:focus-visible { border-radius:.65rem; }
.cast-content { padding:.05rem .58rem .7rem; }
.cast-content > h2 { font-size:1.03rem; margin:.45rem 0 .25rem; }
.play-steps { font-size:.9rem; margin:.25rem 0 .45rem; padding-left:1.25rem; }
.play-steps li+li { margin-top:.45rem; }
.play-obstacles { font-size:.9rem; padding:.35rem 0 .55rem; margin-bottom:.55rem; border-bottom:1px solid var(--line); }
.cast-group { margin-top:.55rem; }
.cast-group h2 { margin-bottom:.28rem; font-size:1.12rem; }
.cast-group h2 small { display:block; margin-left:0; color:var(--muted); font:400 .875rem/1.4 system-ui,sans-serif; }
.cast-grid { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.36rem; list-style:none; margin:0; padding:0; }
.cast-card { min-width:0; padding:.24rem .28rem .36rem; border:1px solid var(--line); border-radius:.35rem; background:#f5ead3; }
.cast-head { display:flex; align-items:center; justify-content:space-between; gap:.3rem; }
.cast-count { color:var(--muted); font-size:.875rem; }
.cast-woods { display:grid; grid-template-columns:repeat(5,minmax(0,1fr)); gap:.14rem; }
.cast-woods .die { min-height:2.15rem; font-size:.72rem; }
.cast-mixed { margin-top:.55rem; padding:.16rem .4rem; border:1px solid transparent; border-radius:.35rem; color:var(--muted); font-size:.9rem; }
.cast-guide [aria-current="true"] { border-color:var(--glint); background:#fae9b4; box-shadow:inset 0 0 0 1px var(--glint); }
.win-rule { padding:.36rem .6rem; margin:.35rem 0 .5rem; border-left:3px solid var(--green); background:#f0e7d2; color:var(--ink); font-size:.9rem; }
@media (min-width:761px) { html { scrollbar-gutter:stable; } }

/* Short effects stay inside the play area; no overlays block the next turn. */
.dice { perspective:24rem; }
.dice.rolling .die { animation:wood-tumble .49s cubic-bezier(.22,.7,.3,1) both; will-change:transform; }
.dice.rolling .die:nth-child(2) { animation-delay:.04s; }
.dice.rolling .die:nth-child(3) { animation-delay:.08s; }
.dice.rolling .die:nth-child(4) { animation-delay:.12s; }
.dice.rolling .die:nth-child(5) { animation-delay:.16s; }
@keyframes wood-tumble {
  0% { transform:translateY(0) rotateX(0) rotateZ(-5deg); background:#e9dab6; }
  38% { transform:translateY(-.55rem) rotateX(208deg) rotateZ(12deg); background:#685043; color:#fff3d5; }
  72% { transform:translateY(.1rem) rotateX(322deg) rotateZ(-7deg); }
  100% { transform:translateY(0) rotateX(360deg); background:#e9dab6; }
}
.result { position:relative; isolation:isolate; min-height:2.1rem; padding:.14rem .36rem; border:1px solid transparent; border-radius:.32rem; }
.result[data-cast="rolling"] { color:var(--muted); }
.result.cast-reveal { animation:cast-plain .27s ease-out both; }
.result:is([data-cast="lu"],[data-cast="zhi"],[data-cast="du"],[data-cast="bai"]) { border-color:var(--cast-line); background:var(--cast-paper); color:var(--cast-ink); }
.result .cast-name:first-child { font-size:1.1em; }
.result:is([data-cast="zhi"],[data-cast="du"],[data-cast="bai"]) { padding-inline-start:2.05rem; }
.result:is([data-cast="zhi"],[data-cast="du"],[data-cast="bai"])::before { position:absolute; inset-block-start:50%; inset-inline-start:.55rem; display:grid; place-items:center; transform:translateY(-50%); line-height:1; font-size:1rem; }
.result[data-cast="lu"] { --cast-line:#a7782a; --cast-paper:#f4deb0; --cast-ink:#5e3b18; }
.result[data-cast="lu"].cast-reveal { animation:cast-seal .7s ease-out both; }
.result[data-cast="zhi"] { --cast-line:#b36a6a; --cast-paper:#f3d9d3; --cast-ink:#6d3045; }
.result[data-cast="zhi"]::before { content:""; width:1.1rem; height:.84rem; background:repeating-linear-gradient(119deg,#ad5363 0 2px,#e6a098 2px 3px); border-radius:88% 8% 88% 8%; }
.result[data-cast="zhi"].cast-reveal::before { animation:cast-feather .62s cubic-bezier(.17,.68,.3,1.16) both; }
.result[data-cast="du"] { --cast-line:#a47745; --cast-paper:#efddbc; --cast-ink:#65401d; }
.result[data-cast="du"]::before { content:""; width:.76rem; height:.76rem; border:.16rem double #9c5f36; border-radius:50%; background:#d59662; }
.result[data-cast="du"].cast-reveal::before { animation:cast-ring .55s ease-out both; }
.result[data-cast="bai"] { --cast-line:#8ba6a5; --cast-paper:#eef3ea; --cast-ink:#315956; }
.result[data-cast="bai"]::before { content:""; width:.84rem; height:.84rem; border:1px solid #81a3a0; border-radius:50%; background:radial-gradient(circle at 33% 28%,white 14%,#e4ebd5 46%,#99b9b0 100%); }
.result[data-cast="bai"].cast-reveal::before { animation:cast-pearl .52s ease-out both; }
@keyframes cast-plain { from { opacity:.5; transform:translateY(.15rem); } to { opacity:1; transform:none; } }
@keyframes cast-seal { 0% { opacity:.5; transform:scale(1.06) rotate(-.7deg); } 36% { opacity:1; transform:scale(.985); box-shadow:0 0 0 .22rem #c8914650; } 100% { opacity:1; transform:none; box-shadow:none; } }
@keyframes cast-feather { from { opacity:0;transform:translate(-.4rem,-75%) rotate(-65deg); } to { opacity:1;transform:translate(0,-50%) rotate(0); } }
@keyframes cast-ring { 0% { box-shadow:0 0 0 0 #984c386c; transform:translateY(-50%) scale(.48); } 55% { box-shadow:0 0 0 .27rem #984c3830; } 100% { box-shadow:none; transform:translateY(-50%); } }
@keyframes cast-pearl { from { opacity:.25;box-shadow:0 0 0 .32rem #b0d0c461; } to { opacity:1;box-shadow:none; } }
.horse-in-transit { visibility:hidden; }
.horse-piece.horse-running { --run-size:clamp(1.25rem,3.6vw,2.05rem); position:absolute; width:var(--run-size); top:calc(var(--run-size) / -2); left:calc(var(--run-size) / -2); z-index:4; pointer-events:none; }
.cell:is(.landed,.landed-hit,.landed-pit) .waypoint { animation:trail-impact .54s ease-out both; }
.cell.landed-hit { --trail-glow:#9b392b72; }
.cell.landed-pit { --trail-glow:#693c6372; }
@keyframes trail-impact { from { outline:.27rem solid var(--trail-glow,#687f4370); outline-offset:.05rem; } to { outline:0 solid transparent; outline-offset:.28rem; } }
@media (prefers-reduced-motion: reduce) {
  .dice.rolling .die,.result.cast-reveal,.result.cast-reveal::before,.cell .waypoint { animation:none !important; }
}

.stack-prompt { color:var(--muted); margin:.25rem 0; }
.research-page { max-width:54rem; }
.research-page section { margin-block:1.5rem; padding-block-start:.75rem; border-block-start:1px solid var(--line); }
.research-page nav ul { display:flex; flex-wrap:wrap; gap:.65rem 1.5rem; list-style:none; padding:0; }
.research-page .evidence dt { font-weight:700; margin:.9rem 0 .25rem; }
.research-page .evidence dd { margin:0; line-height:1.7; }
.research-page li { margin-block:.35rem; line-height:1.65; }

.stable-gold { --team:#896023; }
.stable-black { --team:#3f4b54; }
.horse-piece.gold { --coat:#f8dd8e; --mane:#ac762d; --edge:#6d431d; --strap:#743d1f; --metal:#ffecbc; --saddle:#e2a73d; --base:#c99b54; }
.horse-piece.black { --coat:#a3b2b8; --mane:#515962; --edge:#28363f; --strap:#243746; --metal:#e8edf2; --saddle:#5c7384; --base:#657986; }

.setup-actions { display:flex; gap:clamp(.22rem,1vw,.45rem); justify-self:end; align-items:center; }
.setup-actions button { white-space:nowrap; padding:.34rem .64rem; }
.setup-actions #setup-start { min-width:clamp(4.1rem,8.8vw,8rem); padding-inline:.6rem; min-height:2.8rem; font-size:1.04rem; }
.setup-commit { background:var(--red); color:#fff9ef; border-color:#793123; font-weight:700; }
.seat-settings { display:flex; flex-wrap:nowrap; gap:clamp(.22rem,1.1vw,.6rem); margin-top:.6rem; }
.seat-card { cursor:grab; background:#faf2df; border:1px solid #cdb995; border-radius:.55rem; display:grid; grid-template-rows:2.65rem 1.85rem 1.7rem; align-content:start; gap:.17rem; flex:0 1 6.4rem; min-width:0; padding:.25rem clamp(.16rem,.7vw,.55rem); }
.seat-card.seat-first { border-color:#aa7841; }
.seat-card.seat-dragging { opacity:.48; cursor:grabbing; }
.seat-card.seat-drop { outline:2px solid var(--green); outline-offset:1px; }
.seat-card.seat-active { border-color:#986740; box-shadow:inset 0 2px #b48751; }
.seat-badge { position:relative; display:flex; align-items:center; justify-content:center; gap:.28rem; min-width:0; }
.seat-icon { position:relative; display:grid; place-items:center; min-width:0; min-height:0; height:100%; padding:0; border:0; border-radius:.3rem; background:none; cursor:grab; touch-action:none; }
.seat-icon::before { content:""; position:absolute; left:0; top:.08rem; width:.35rem; height:.54rem; opacity:.66; background:radial-gradient(circle,#725437 1px,transparent 1.3px) 0 0 / .175rem .175rem; }
.seat-icon:disabled { opacity:1; cursor:default; }
.seat-icon:disabled::before { display:none; }
.setup-locked .seat-card { cursor:default; }
.seat-card.seat-dragging .seat-icon { cursor:grabbing; }
.seat-icon .horse-piece { width:clamp(1.55rem,5.9vw,2.35rem); }
.seat-select { text-align:center; appearance:none; width:100%; min-height:0; padding:0 .74rem 0 .22rem; font-size:.83rem; background-color:#fff9ec; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%236b4e36' stroke-width='1.6'/%3E%3C/svg%3E"); background-repeat:no-repeat; background-position:right .31rem center; background-size:.48rem auto; }
.seat-select:disabled { color:#5a5043; opacity:1; border-color:transparent; background:transparent; padding:0; }
.seat-color { width:auto; min-width:0; height:1.48rem; font-weight:700; padding-inline:.25rem .67rem; }
.seat-level { font-size:.75rem; }
.setup-locked .seat-card:not(.seat-active) { background:#f4ead7; }
@media(max-width:540px) {
  .setup-actions button,.toolbar select { font-size:.82rem; padding-inline:.37rem; }
  .toolbar { grid-template-columns:max-content minmax(0,1fr) auto; }
  .toolbar select { width:auto; max-width:100%; }
  .seat-card { flex-basis:5.3rem; }
  .seat-badge { gap:.12rem; }
  .seat-select { font-size:.75rem; background-position:right .20rem center; padding-inline:.10rem .57rem; }
  .seat-level { font-size:.7rem; }
}
@media(max-width:360px) {
  .setup-actions button,.toolbar select { font-size:.75rem; padding-inline:.27rem; }
  .seat-icon .horse-piece { width:1.28rem; }
  .seat-icon::before { top:.04rem; }
}
.team-swatch { display:inline-block; width:.8rem; height:.8rem; flex:0 0 auto; border:1px solid #564a3b; border-radius:50%; }
.team-red { background:#a63d32; }
.team-green { background:#287269; }
.team-gold { background:#d7a136; }
.team-white { background:#fffaf0; }
.team-black { background:#2f3637; }
.stable-white { --team:#67605d; }
.horse-piece.white { --coat:#fffbef; --mane:#8d8579; --edge:#49433a; --strap:#635a4d; --metal:#fff9e9; --saddle:#bcb4a3; --base:#d7cfc2; }
.horse-piece.black { --coat:#4b5052; --mane:#28292b; --edge:#201f21; --strap:#c1aa84; --metal:#eee0c6; --saddle:#77716b; --base:#514b44; }

.wood-icon { display:block; width:clamp(1.02rem,3vw,1.7rem); height:auto; max-width:80%; }
.wood-label { line-height:1.25; }
.cast-woods .wood-icon { width:clamp(.65rem,2.1vw,1rem); }

/* End-of-game tableau; the button row never waits for the animation. */
.ending-dialog {
  --ending-beam:#fff1d88f; --ending-pool:#fff7df87;
  --ending-frame:#9d5146;
  --ending-title:#742b25;
  --ending-halo:#f5bba8;
  --ending-ground:#d5a99c;
  --ending-thread:#98514620;
  --ending-seal-bg:#8b362d;
  --ending-seal-ink:#fff4e5;
  --ending-footer:#fff4eb;
  --ending-button:#8b362d;
  --ending-button-ink:#fffaf1;
  --ending-chip:#b0463b;
  --ending-chip-light:#f2ddba;
  --ending-chip-dark:#793535;
  color:var(--ink); background:var(--ending-footer); border:2px solid var(--ending-frame);
  border-radius:1rem; width:min(29rem,calc(100% - 1.2rem));
  max-height:calc(100% - 1.2rem); padding:0; box-shadow:0 .9rem 3rem #311b2677;
  overflow:auto;
}
.ending-dialog[data-winner-color="green"] {
  --ending-beam:#f5ffda90; --ending-pool:#faffdf9e;
  --ending-frame:#4f8472; --ending-title:#1c5042;
  --ending-halo:#b6dcc6; --ending-ground:#a8c4af; --ending-thread:#3c76601e;
  --ending-seal-bg:#295b4b; --ending-seal-ink:#f4ffe9;
  --ending-footer:#f0f7ed; --ending-button:#295b4b; --ending-button-ink:#fffdf0;
  --ending-chip:#468775; --ending-chip-light:#e2e5af; --ending-chip-dark:#245c4b;
}
.ending-dialog[data-winner-color="gold"] {
  --ending-beam:#fff2bf90; --ending-pool:#fff9db99;
  --ending-frame:#a47a36; --ending-title:#654007;
  --ending-halo:#f2cc76; --ending-ground:#d3b677; --ending-thread:#8e6b281f;
  --ending-seal-bg:#80561b; --ending-seal-ink:#fff3d3;
  --ending-footer:#fff7e4; --ending-button:#785119; --ending-button-ink:#fffaec;
  --ending-chip:#bb8430; --ending-chip-light:#fff1bb; --ending-chip-dark:#80581b;
}
.ending-dialog[data-winner-color="white"] {
  --ending-beam:#fffefaa0; --ending-pool:#fffefaa6;
  --ending-frame:#929ca8; --ending-title:#39414e;
  --ending-halo:#dfe5ec; --ending-ground:#bfc7d2; --ending-thread:#5b677d22;
  --ending-seal-bg:#fffdf7; --ending-seal-ink:#3d4654;
  --ending-footer:#fcfaf5; --ending-button:#e4e9f0; --ending-button-ink:#343e4d;
  --ending-chip:#8695aa; --ending-chip-light:#fffdf7; --ending-chip-dark:#5f6d83;
}
.ending-dialog[data-winner-color="black"] {
  --ending-beam:#ffe7bf60; --ending-pool:#fff1d58c;
  --ending-frame:#636671; --ending-title:#fff1e4;
  --ending-halo:#474954; --ending-ground:#252730; --ending-thread:#dfe1eb14;
  --ending-seal-bg:#262731; --ending-seal-ink:#fff3e2;
  --ending-footer:#efeae2; --ending-button:#33343e; --ending-button-ink:#fff6e6;
  --ending-chip:#aeaec1; --ending-chip-light:#efe7cc; --ending-chip-dark:#838695;
}
.ending-dialog::backdrop { background:#30202c82; }
.ending-stage {
  position:relative; isolation:isolate; text-align:center; overflow:hidden;
  padding:clamp(.85rem,4vw,1.55rem) .85rem .8rem;
  background:radial-gradient(ellipse at 50% 38%,var(--ending-halo),transparent 69%),
    repeating-linear-gradient(90deg,var(--ending-thread) 0 1px,transparent 1px 4px),var(--ending-ground);
}
/* The cone opens from the top centre; a soft pool shows through behind the horses. */
.ending-stage::before {
  content:""; position:absolute; inset:0; z-index:-1; pointer-events:none;
  background:
    radial-gradient(ellipse 48% 30% at 50% 84%, var(--ending-pool) 16%, transparent 100%),
    conic-gradient(at 50% -5%, transparent 129deg, var(--ending-beam) 149deg 211deg, transparent 231deg);
  mask-image:linear-gradient(#000 0 79%, transparent 100%);
}
@media (prefers-reduced-motion:no-preference) {
  .ending-dialog[open].ending-animate .ending-stage::before { animation:ending-light .65s ease-out both; }
}
@keyframes ending-light { from { opacity:0; } to { opacity:1; } }
.ending-seal {
  display:grid; place-items:center; width:3.1rem; aspect-ratio:1; margin:0 auto .34rem;
  border:1px solid var(--ending-frame); outline:2px solid var(--ending-title);
  border-radius:.44rem; transform:rotate(-7deg); background:var(--ending-seal-bg); color:var(--ending-seal-ink);
  font:700 1.87rem/1 "Songti SC","Noto Serif CJK SC",SimSun,serif;
  box-shadow:0 .18rem .38rem #53332155;
}
#ending-title { position:relative; color:var(--ending-title); font-size:clamp(1.85rem,7.7vw,2.8rem); line-height:1.25; margin:.5rem 0 .3rem; }
.ending-horses {
  position:relative; display:flex; justify-content:center; align-items:flex-end;
  gap:clamp(.28rem,2.5vw,1.06rem); padding:.1rem .25rem .38rem; margin:.65rem auto 0;
  max-width:21rem; border-bottom:1px solid var(--ending-frame);
}
.ending-horses .horse-piece { width:clamp(2.35rem,13vw,3.85rem); }
.ending-horses .horse-seal { font-size:.68rem; min-width:1rem; height:1rem; }
.ending-actions { display:flex; justify-content:center; gap:.6rem; padding:.8rem .75rem; }
.ending-actions button { padding:.36rem .8rem; background:var(--card); }
#ending-restart { background:var(--ending-button); color:var(--ending-button-ink); border-color:var(--ending-frame); font-weight:700; }
.ending-sparks { position:absolute; z-index:-1; inset:0; pointer-events:none; }
.ending-sparks i {
  position:absolute; left:50%; top:37%; width:.33rem; height:.68rem; border-radius:70% 18%;
  background:var(--ending-chip); opacity:0;
}
.ending-sparks i:nth-child(3n+2) { background:var(--ending-chip-light); }
.ending-sparks i:nth-child(3n) { background:var(--ending-chip-dark); }
.ending-dialog[open].ending-animate { animation:ending-arrive .34s ease-out both; }
.ending-dialog[open].ending-animate .ending-seal { animation:ending-stamp .45s .12s cubic-bezier(.2,.85,.4,1) both; }
.ending-dialog[open].ending-animate .ending-horses .horse-piece { animation:horse-parade .52s calc(.17s + var(--parade-delay)) cubic-bezier(.2,.7,.43,1) both; }
.ending-dialog[open].ending-animate .ending-sparks i { animation:ending-chips .92s .29s ease-out both; }
@keyframes ending-arrive { from { opacity:0; transform:translateY(.65rem) scale(.96); } to { opacity:1; transform:none; } }
@keyframes ending-stamp { 0% { opacity:0; scale:1.34; } 62% { opacity:1; scale:.93; } 100% { opacity:1; scale:1; } }
@keyframes horse-parade {
  0% { opacity:0; transform:translateY(1rem) scale(.84); }
  68% { opacity:1; transform:translateY(-.15rem) scale(1.05); }
  100% { opacity:1; transform:none; }
}
@keyframes ending-chips {
  0% { opacity:0; transform:translate(0,0) rotate(0); }
  20% { opacity:.85; }
  70% { opacity:.61; }
  100% { opacity:0; transform:translate(var(--dx),var(--dy)) rotate(var(--spin)); }
}
@media(prefers-reduced-motion:reduce) {
  .ending-dialog[open].ending-animate, .ending-dialog[open].ending-animate .ending-seal,
  .ending-dialog[open].ending-animate .ending-horses .horse-piece, .ending-dialog[open].ending-animate .ending-sparks i {
    animation:none !important;
  }
}

.ending-preview-page:not([hidden]) {
  width:min(31rem,calc(100% - 2rem)); margin:clamp(2rem,13vh,8rem) auto 2rem;
  padding:clamp(1.2rem,5vw,2rem); border:1px solid var(--line); border-radius:.8rem;
  background:var(--card); text-align:center;
}
.ending-preview-page h1 { font-size:clamp(1.65rem,6vw,2.6rem); margin-bottom:.85rem; }
.ending-preview-colors { display:flex; align-items:center; justify-content:center; gap:.55rem; margin-bottom:.65rem; }
.ending-preview-colors select { min-width:4.2rem; }
.ending-preview-actions { display:flex; flex-wrap:wrap; justify-content:center; gap:.5rem; margin-bottom:.65rem; }
.ending-preview-actions button { padding:.3rem .75rem; background:var(--paper); }
#preview-player { background:var(--red); color:#fffaf1; border-color:var(--red); font-weight:700; }

/* The same game state has a dedicated setup and play layout on a phone. */
.mobile-ui { display:none; }
@media (max-width:760px), (max-width:1050px) and (max-height:540px) and (orientation:landscape) {
  #game-page { width:calc(100% - 1rem); padding:.55rem 0 1.5rem; overflow-anchor:none; }
  #game-page .mast { display:flex; align-items:center; justify-content:space-between; gap:.6rem; padding:0 .2rem .48rem; }
  #game-page h1 { font-size:2.35rem; }
  #game-page .arena { display:flex; flex-direction:column; align-items:stretch; gap:.55rem; }
  #game-page .board-panel,#game-page .board-stage,#game-page .turn-panel { display:contents; }
  #game-page .board-heading { order:0; display:flex; align-items:center; justify-content:space-between; width:100%; gap:.3rem; padding-inline:.22rem; }
  #game-page .board-heading h2 { font-size:1.14rem; white-space:nowrap; }
  #game-page .board-key { margin:0; font-size:.75rem; }
  #game-page .felt-board {
    order:1; align-self:center; width:min(100%,max(15rem,calc(100svh - 18.25rem)));
    margin:0; padding:.24rem .3rem; border-width:3px;
  }
  #game-page #stables { order:3; margin:.25rem 0 0; }
  #game-page .turn-extras { order:4; min-width:0; }
  #game-page .turn-extras .mobile-ui { display:block; }
  #game-page .desktop-win-rule { display:none; }

  #game-page[data-screen="setup"] :is(.board-heading,.felt-board,#stables,.turn-controls,.log-panel) { display:none; }
  #game-page[data-screen="setup"] .setup-panel { display:grid; grid-template-columns:minmax(0,1fr) minmax(0,1.35fr); gap:.65rem .55rem; margin:.8rem 0; }
  #game-page[data-screen="setup"] :is(.toolbar,.setup-actions) { display:contents; }
  #game-page[data-screen="setup"] .toolbar .field { order:0; }
  #game-page[data-screen="setup"] .toolbar select { width:100%; font-size:1rem; }
  #game-page[data-screen="setup"] .seat-settings { order:1; grid-area:auto / 1 / auto / -1; display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.44rem; margin:0; }
  #game-page[data-screen="setup"] .seat-card { grid-template-rows:none; grid-auto-rows:minmax(2.75rem,auto); gap:.2rem; padding:.3rem; }
  #game-page[data-screen="setup"] .seat-icon { min-width:2.75rem; min-height:2.75rem; }
  #game-page[data-screen="setup"] .seat-icon .horse-piece { width:1.9rem; }
  #game-page[data-screen="setup"] .seat-select { min-height:2.75rem; font-size:1rem; padding-inline:.3rem 1rem; background-position:right .36rem center; }
  #game-page[data-screen="setup"] #setup-random { order:2; width:100%; margin:0; font-size:1rem; }
  #game-page[data-screen="setup"] #setup-start { order:2; width:100%; min-height:2.9rem; font-size:1.08rem; }
  #game-page[data-screen="play"] .setup-panel { display:none; }
  #game-page[data-screen="play"] #mobile-restart { display:inline-block; margin:0; font-size:.95rem; white-space:nowrap; }

  #game-page .turn-controls {
    order:2; position:sticky; bottom:0; z-index:5; display:grid;
    grid-template-columns:minmax(0,1fr) auto; grid-template-areas:"title title" "status status" "dice result" "action action";
    align-items:center; gap:.23rem .42rem; padding:.35rem .48rem max(.44rem,env(safe-area-inset-bottom));
    border:1px solid var(--line); border-radius:.65rem; background:var(--card); box-shadow:0 -2px 8px #60452822;
  }
  #game-page #turn-title { grid-area:title; font-size:1.12rem; line-height:1.3; }
  #game-page #turn-title[data-team]::before { content:""; display:inline-block; vertical-align:.05em; width:.65rem; height:.65rem; margin-inline-end:.36rem; border-radius:50%; background:var(--turn-color,var(--ink)); border:1px solid #37282175; }
  #turn-title[data-team="red"] { --turn-color:#a63d32; }
  #turn-title[data-team="green"] { --turn-color:#287269; }
  #turn-title[data-team="gold"] { --turn-color:#d7a136; }
  #turn-title[data-team="white"] { --turn-color:#fffaf0; }
  #turn-title[data-team="black"] { --turn-color:#2f3637; }
  #game-page #status { grid-area:status; min-height:0; font-size:.86rem; line-height:1.25; overflow-wrap:anywhere; }
  #game-page .turn-controls .dice { grid-area:dice; gap:.19rem; margin:0; width:min(100%,12.5rem); }
  #game-page .turn-controls .die { min-height:2.25rem; font-size:.69rem; }
  #game-page .turn-controls .wood-icon { width:.96rem; }
  #game-page #result { grid-area:result; min-height:0; line-height:1.2; font-size:.82rem; padding-block:.26rem; white-space:nowrap; }
  #game-page #roll { grid-area:action; margin:.1rem 0 0; min-height:2.8rem; }
  #game-page #roll:disabled { display:none; }
  #game-page #moves { grid-area:action; grid-template-columns:repeat(2,minmax(0,1fr)); gap:.25rem; max-height:7.2rem; overflow-y:auto; overscroll-behavior:contain; }
  #game-page #moves:empty { display:none; }
  #game-page #moves button { min-width:0; padding:.13rem .26rem; gap:.28rem; justify-content:center; font-size:.82rem; line-height:1.2; }
  #game-page #moves button:focus-visible { outline-offset:-3px; }
  #game-page .full-move-label { display:none; }
  #game-page .compact-move-label { display:inline; overflow-wrap:anywhere; }
  #game-page .stack-prompt { grid-column:1/-1; font-size:.8rem; }
  #game-page .turn-extras .log-panel { margin-top:.55rem; }
}

/* Wide screens spend vertical space on the square board, not on setup. */
@media (min-width:1120px) and (min-aspect-ratio:4/3) {
  #game-page {
    --board-budget:min(49vw,max(24rem,calc(100svh - 8.25rem)));
    width:min(calc(100% - 2rem),calc(var(--board-budget) + 55rem));
    padding:.75rem 0 1.8rem;
    display:grid;
    grid-template-columns:minmax(12.5rem,.87fr) minmax(0,var(--board-budget)) minmax(16rem,1fr);
    grid-template-rows:auto auto auto 1fr auto;
    grid-template-areas:"mast mast mast" "setup board turn" "stables board turn" ". board turn" "notes notes notes";
    gap:.68rem clamp(.65rem,1.15vw,1.35rem);
    align-items:start;
  }
  #game-page[hidden] { display:none; }
  #game-page .mast { grid-area:mast; padding:0 .15rem .42rem; }
  #game-page h1 { font-size:clamp(2.3rem,2.35vw,3.1rem); }
  #game-page .arena,#game-page .board-panel { display:contents; }
  #game-page .board-stage,#game-page .setup-panel {
    min-width:0; border:1px solid var(--line); border-radius:.65rem;
    padding:clamp(.55rem,1vw,.85rem); background:var(--card);
  }
  #game-page .board-stage { grid-area:board; }
  #game-page .board-heading { display:flex; align-items:baseline; justify-content:space-between; gap:.4rem; }
  #game-page .board-heading h2 { font-size:clamp(1.35rem,1.48vw,1.65rem); }
  #game-page .board-heading .board-symbols { margin:0; font-size:.83rem; }
  #game-page .felt-board { margin:.34rem 0 0; }
  #game-page .stone-index { font-size:clamp(.62rem,1.65cqw,1rem); }
  #game-page .board .hazard-name { font-size:clamp(.56rem,1.9cqw,.9rem); }
  #game-page .setup-panel { grid-area:setup; grid-template-columns:minmax(0,1fr); gap:.53rem; margin:0; }
  #game-page .setup-panel .toolbar { grid-area:auto; grid-template-columns:minmax(0,.7fr) minmax(0,1.3fr); gap:.42rem; }
  #game-page .setup-panel .toolbar select { min-width:0; padding-inline:.38rem; font-size:.91rem; }
  #game-page .setup-panel .seat-settings { grid-area:auto; display:grid; gap:.3rem; margin:0; }
  #game-page .seat-card {
    grid-template-columns:minmax(0,1.15fr) minmax(0,.85fr) minmax(0,.85fr);
    grid-template-rows:auto; align-items:center; gap:.2rem; padding:.16rem .24rem;
  }
  #game-page .seat-badge { justify-content:flex-start; gap:.14rem; }
  #game-page .seat-icon { width:clamp(1.6rem,2.25vw,2.35rem); height:2rem; }
  #game-page .seat-icon .horse-piece { width:clamp(1.5rem,1.85vw,2rem); }
  #game-page .seat-select { min-height:1.95rem; }
  #game-page .seat-color { min-height:1.55rem; padding-inline:.17rem .62rem; background-position:right .19rem center; }
  #game-page .setup-panel .setup-actions { grid-area:auto; width:100%; }
  #game-page #setup-start { flex:1; }
  #game-page .setup-panel #setup-random { margin-left:0; }
  #game-page #stables { grid-area:stables; margin:0; }
  #game-page .turn-panel { grid-area:turn; min-height:0; }
  #game-page #status { min-height:2.4em; }
  #game-page #log { max-height:clamp(9rem,calc(100svh - 34rem),29rem); }
  #game-page .notes { grid-area:notes; margin-top:.28rem; }
}

/* Phone matches show a compact overview instead of stacking full-size panels. */
@media (max-width:760px), (max-width:1050px) and (max-height:540px) and (orientation:landscape) {
  #game-page[data-screen="play"] { --match-seats:5; padding-top:.32rem; }
  #game-page[data-screen="play"] .mast { padding:0 .14rem .24rem; gap:.35rem; }
  #game-page[data-screen="play"] h1 { font-size:1.88rem; }
  #game-page[data-screen="play"] #mobile-restart { padding:.13rem .4rem; font-size:.87rem; }
  #game-page[data-screen="play"] .play-key { display:flex; align-items:center; margin-left:auto; gap:.54rem; font-size:.72rem; white-space:nowrap; }
  #game-page[data-screen="play"] .board-heading { clip-path:inset(50%); position:absolute; width:1px; height:1px; overflow:hidden; white-space:nowrap; }
  #game-page[data-screen="play"] .arena { gap:.32rem; }
  #game-page[data-screen="play"] .felt-board {
    width:min(100%,max(13.5rem,calc(100svh - 14.75rem - var(--match-seats) * 1.18rem)));
    margin-top:.32rem;
  }
  #game-page[data-screen="play"] .turn-controls {
    position:static; grid-template-columns:minmax(0,1fr) minmax(0,.85fr);
    grid-template-areas:"title result" "dice action" "choices choices";
    gap:.22rem .32rem; padding:.32rem .42rem;
    box-shadow:none;
  }
  #game-page[data-screen="play"] #status {
    position:absolute; width:1px; height:1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap;
  }
  #game-page[data-screen="play"] .turn-controls .dice { width:100%; max-width:11.2rem; }
  #game-page[data-screen="play"] .turn-controls .die { min-height:1.9rem; }
  #game-page[data-screen="play"] .turn-controls .wood-icon { width:.8rem; }
  #game-page[data-screen="play"] #result { justify-self:end; overflow:hidden; text-overflow:ellipsis; max-width:100%; }
  #game-page[data-screen="play"] #roll { width:100%; margin:0; }
  #game-page[data-screen="play"] #moves { grid-area:choices; grid-template-columns:repeat(4,minmax(0,1fr)); max-height:2.9rem; }
  #game-page[data-screen="play"] #moves .horse-piece { display:none; }
  #game-page[data-screen="play"] #moves button { padding:.1rem .15rem; }
  #game-page[data-screen="play"] #moves:has(.stack-prompt) { grid-template-columns:repeat(2,minmax(0,1fr)); max-height:4.15rem; }
  #game-page[data-screen="play"] #stables {
    gap:.08rem; margin:0; border:1px solid var(--line); border-radius:.46rem; padding:.13rem .25rem;
    background:var(--card);
  }
  #game-page[data-screen="play"] .stable {
    grid-template-columns:2.2rem minmax(0,1fr);
    gap:.14rem; padding:0 .13rem; border:0; border-radius:.19rem;
    background:transparent; min-height:1.12rem;
  }
  #game-page[data-screen="play"] .stable.current-stable { box-shadow:inset 2px 0 var(--team); background:#eae0c5; }
  #game-page[data-screen="play"] .stable-key {
    position:relative; justify-self:start; width:.97rem; height:.97rem; margin-left:.14rem;
    font-size:.64rem;
  }
  #game-page[data-screen="play"] .stable-key::after {
    position:absolute; inset-inline-start:calc(100% + .21rem); content:attr(data-operator);
    color:var(--muted); font-size:.63rem; font-weight:500;
  }
  #game-page[data-screen="play"] .stable-slots { gap:.08rem; }
  #game-page[data-screen="play"] .stable-slot {
    height:1.06rem; border:0; background:#f5edd9; box-shadow:none;
    font:600 .73rem/1.05 system-ui,sans-serif; font-variant-numeric:tabular-nums;
  }
  #game-page[data-screen="play"] .stable-slot > * { display:none; }
  #game-page[data-screen="play"] .stable-slot::before { content:attr(data-summary); white-space:nowrap; }
  #game-page[data-screen="play"] .stable-slot.arrived { color:#31564a; background:#e9efe0; }
  #game-page[data-screen="play"] .match-recent {
    order:4; display:block; padding:0 .18rem; font-size:.73rem; line-height:1.42; color:var(--muted);
    white-space:nowrap; overflow:hidden; text-overflow:ellipsis;
  }
  #game-page[data-screen="play"] .turn-extras { order:5; margin-top:.25rem; }
}

@media (max-width:1050px) and (max-height:540px) and (orientation:landscape) {
  #game-page[data-screen="play"] {
    --land-board:min(43vw,calc(100svh - 1rem));
    display:grid; grid-template-columns:minmax(0,var(--land-board)) minmax(0,1fr) minmax(8.2rem,.76fr);
    grid-template-areas:"board mast mast" "board play stable" "board recent stable" "extra extra extra" "notes notes notes";
    grid-template-rows:auto auto 1fr auto auto; align-items:start; gap:.3rem .48rem;
  }
  #game-page[hidden] { display:none; }
  #game-page[data-screen="play"] .arena { display:contents; }
  #game-page[data-screen="play"] .mast { grid-area:mast; }
  #game-page[data-screen="play"] .felt-board { grid-area:board; width:100%; min-width:0; margin:0; align-self:start; }
  #game-page[data-screen="play"] .turn-controls { grid-area:play; }
  #game-page[data-screen="play"] #stables { grid-area:stable; }
  #game-page[data-screen="play"] .history-mobile-entry { grid-area:recent; }
  #game-page[data-screen="play"] .turn-extras { grid-area:extra; }
  #game-page[data-screen="play"] .notes { grid-area:notes; }
  #game-page[data-screen="play"] #moves { grid-template-columns:repeat(2,minmax(0,1fr)); max-height:6rem; }
  #game-page[data-screen="play"] #result { padding-inline:.14rem; font-size:.72rem; }
  #game-page[data-screen="play"] #result::before { display:none; }
  #game-page[data-screen="play"] .stable { grid-template-columns:1.85rem minmax(0,1fr); gap:.08rem; }
  #game-page[data-screen="play"] .stable-slot { font-size:.66rem; }
}

.release-prompt[hidden] { display:none; }
.release-prompt {
  position:fixed; z-index:15; inset-block-start:max(.55rem,env(safe-area-inset-top)); inset-inline-end:.65rem;
  width:max-content; max-width:calc(100% - 1.3rem); display:flex; flex-wrap:wrap;
  align-items:center; justify-content:flex-end; gap:.42rem; padding:.43rem;
  border:1px solid var(--line); border-radius:.62rem; background:var(--card); box-shadow:0 .22rem .9rem #4a311d38;
}
.release-prompt p { flex:1 1 9.5rem; padding-inline:.15rem; font-size:.9rem; }
.release-prompt button { min-height:2.75rem; margin:0; padding:.3rem .58rem; font-weight:650; }
.release-apply { background:var(--green); color:#fff9ed; border-color:var(--green); }

/* A recent line stays on the board; the full record is a separate modal view. */
.log-heading { display:flex; align-items:center; justify-content:space-between; gap:.5rem; }
.history-button,.history-back {
  display:inline-flex; align-items:center; justify-content:center; gap:.28em;
  padding:.2rem .58rem; font-size:.82rem; font-weight:650; white-space:nowrap;
  color:#23544b; background:#edf0e5; border:1px solid #a2afa1; border-radius:.42rem;
}
.log-heading .history-button { min-height:2.12rem; }
.history-button:hover:not(:disabled) { background:#e2eadd; }
#match-history {
  position:fixed; inset:0; box-sizing:border-box; width:100%; height:100%; max-width:none; max-height:none;
  margin:0; padding:0; border:0; overflow:hidden; color:var(--ink); background:var(--card);
}
#match-history::backdrop { background:var(--card); }
html:has(#match-history[open]) { overflow:hidden; }
.history-screen { height:100%; display:grid; grid-template-rows:auto auto auto minmax(0,1fr); }
.history-bar {
  display:grid; grid-template-columns:1fr auto 1fr; align-items:center; gap:.32rem;
  padding:.42rem max(.65rem,env(safe-area-inset-right)) .42rem max(.65rem,env(safe-area-inset-left));
  padding-top:max(.42rem,env(safe-area-inset-top)); background:#f7efda; border-bottom:1px solid #ded0af;
}
.history-bar h2 { font:700 clamp(1rem,4.6vw,1.24rem)/1.2 system-ui,sans-serif; white-space:nowrap; }
.history-back { justify-self:start; padding-inline:.12rem; background:none; border-color:transparent; }
.history-back span { font-size:1.25em; line-height:1; }
.history-bar > .history-button { justify-self:end; }
.history-width { width:min(100%,48rem); margin-inline:auto; }
.history-page-head {
  display:flex; align-items:center; justify-content:space-between; padding:.65rem 1rem .55rem;
  border-bottom:1px solid #e4d8be; color:#645c4e; font-size:.78rem;
}
.history-page-head strong { color:#754450; font-size:1.32rem; letter-spacing:.1em; }
.history-downloads { padding:.18rem 1rem; color:#23544b; font-size:.88rem; max-height:23vh; overflow:auto; }
.history-downloads a { display:inline-block; padding:.4rem .45rem .4rem 0; }
.history-scroll { grid-row:4; overflow:auto; overscroll-behavior:contain; padding:.72rem 1rem max(1.1rem,env(safe-area-inset-bottom)); }
.history-scroll:focus-visible { outline:2px solid var(--green); outline-offset:-2px; }
.history-round + .history-round { margin-top:1.05rem; }
.history-round > h3 { color:#6f604e; font-size:.82rem; margin:0 0 .45rem; }
.history-card { margin:0 0 .64rem; border:1px solid #ded1b5; border-radius:.55rem; overflow:hidden; background:#fffaf0; }
.history-card h4 { margin:0; padding:.35rem .64rem; color:#383a2c; background:#f3e9d2; font-size:.9rem; border-bottom:1px solid #e6d9bd; }
.history-card[data-color="red"] h4 { background:#f5e6d9; }
.history-color { display:inline-block; width:.55em; height:.55em; border-radius:50%; margin-inline-end:.36rem; vertical-align:.12em; background:var(--history-team,#544b42); }
.history-card[data-color="green"] { --history-team:#3e7067; }
.history-card[data-color="red"] { --history-team:#963b33; }
.history-card[data-color="gold"] { --history-team:#95732b; }
.history-card[data-color="white"] { --history-team:#eee3cd; }
.history-card[data-color="white"] .history-color { outline:1px solid #8c785a; }
.history-card ul { list-style:none; margin:0; padding:.06rem .64rem; }
.history-card li { padding:.35rem 0; font-size:.88rem; overflow-wrap:anywhere; }
.history-card li + li { border-top:1px solid #efe9dc; }
.history-card li:not(.history-cast) { color:#655b50; }
.history-end { margin:.75rem 0; text-align:center; color:#746a5b; font-size:.78rem; }
@media (max-width:760px), (max-width:1050px) and (max-height:540px) and (orientation:landscape) {
  #game-page[data-screen="play"] .history-mobile-entry {
    order:4; display:grid; grid-template-columns:minmax(0,1fr) auto; align-items:center; gap:.2rem;
    min-width:0; padding:.12rem .24rem; background:var(--card); border:1px solid #c9b790; border-radius:.5rem;
  }
  #game-page[data-screen="play"] .history-mobile-entry .match-recent { order:0; min-width:0; }
  #game-page[data-screen="play"] .history-mobile-entry .history-button { min-height:2.15rem; font-size:.76rem; }
}
