:root{color-scheme:dark;--base:#181411;--panel:#231b16;--line:#51402c;--muted:#c9b397;--gold:#e2b976;--ink:#f5e9d6;--accent:#dfb36e}*{box-sizing:border-box}body{margin:0;background:radial-gradient(ellipse at top,#352216 0,transparent 42rem),var(--base);color:var(--ink);font-family:system-ui,-apple-system,"PingFang SC",sans-serif;font-size:16px}button,select{font:inherit}button,select,summary,a{-webkit-tap-highlight-color:transparent}button{cursor:pointer}button:disabled{cursor:default}button:focus-visible,a:focus-visible,select:focus-visible,summary:focus-visible{outline:2px solid #ffdb9e;outline-offset:3px}.shell{max-width:1160px;margin:auto;padding:0 clamp(12px,3vw,44px)}.heading{padding:1.2rem 0 1.85rem}.mast{display:flex;align-items:center;gap:.55rem;font-size:.88rem;letter-spacing:.14em;color:var(--muted);border-bottom:1px solid var(--line);padding-bottom:1rem;margin-bottom:1.8rem}.mark{color:var(--gold);font-size:1.3rem}.over{font-size:.88rem;letter-spacing:.15em;color:var(--gold)}h1,h2{margin:0;font-family:"Songti SC","Noto Serif CJK SC","STSong",Georgia,serif}h1{font-size:clamp(2.75rem,6vw,5rem);line-height:1.13;letter-spacing:.04em;margin:.24em 0 .12em}h1 span{color:var(--gold)}.subtitle{color:var(--muted);display:flex;align-items:center;gap:.85rem;margin:.75rem 0 0}.subtitle span{font-family:Georgia,serif;letter-spacing:.22em;color:var(--gold)}.subtitle i{width:1.6rem;height:1px;background:var(--line)}.layout{display:grid;grid-template-columns:minmax(0,2.3fr) minmax(240px,1fr);align-items:start;gap:1rem}.panel,.board-panel{border:1px solid var(--line);border-radius:12px;background:var(--panel)}.board-panel,.controls{padding:clamp(9px,1.8vw,18px)}.band{display:flex;align-items:center;justify-content:space-between;gap:.4rem;flex-wrap:wrap;margin:0 0 .85rem}.band h2{font-size:1.18rem}.band span,.board-foot,.quiet{font-size:.875rem;color:var(--muted)}.wood{background:repeating-linear-gradient(4deg,#4e2c1e 0,#4e2c1e 3px,#5b3724 4px,#4b2b1b 9px);padding:clamp(4px,1vw,12px);border:1px solid #936744;border-radius:6px;box-shadow:inset 0 0 0 2px #2a1710,0 4px 9px #0004}.board{display:grid;grid-template-columns:repeat(10,minmax(0,1fr));gap:2px}.cell{position:relative;display:grid;place-items:center;isolation:isolate;aspect-ratio:1/1.14;background:linear-gradient(150deg,#e2c69a,#cda775);border:1px solid #a87e50;border-radius:2px;min-width:0;padding:0;color:#382316;touch-action:manipulation;user-select:none}.cell:nth-child(even){background:linear-gradient(145deg,#ddbe8f,#cba172)}.cell[data-water]{background:#9eb4ac;color:#1d3932;border-color:#57766d}.cell[data-ritual]{background:#d5b486}.cell[data-gate]{border-color:#925233}.cell .idx{position:absolute;z-index:1;top:1px;left:3px;font-size:clamp(.64rem,1.35vw,.8rem);line-height:1.15;font-variant-numeric:tabular-nums}.cell .sigil{position:absolute;bottom:1px;right:3px;font-family:Georgia,serif;font-size:clamp(.8rem,2.4vw,1.25rem);line-height:1;color:#624332}.cell[data-water] .sigil{color:#295346}.cell[data-last]{box-shadow:inset 0 0 0 2px #854322}.cell[data-legal]{outline:2px solid #fff4c8;outline-offset:-3px;box-shadow:inset 0 0 0 4px #246353;z-index:2}.cell[data-legal]:hover{filter:brightness(1.13)}.cell[data-legal]:focus-visible{outline:2px solid #fff;outline-offset:1px}.piece,.swatch{display:block;box-shadow:0 2px 2px #261609a0;border:1px solid #35251b}.piece{width:58%;height:54%;margin-top:6%;z-index:2}.ink{background:linear-gradient(155deg,#66564b,#302520 52%,#17110e)}.ivory{background:linear-gradient(150deg,#fff0cb,#e7c38e 63%,#ad7a48);border-color:#9f7449}.piece.ink{clip-path:polygon(47% 0,58% 3%,98% 83%,100% 93%,79% 100%,21% 100%,0 93%,2% 83%);border-radius:20%;filter:drop-shadow(0 2px 1px #422916)}.piece.ivory{border-radius:48% 48% 38% 38%;width:53%;height:49%}.swatch{width:14px;height:14px;flex:none;border-radius:50%;display:inline-block;vertical-align:-2px}.board-foot{display:flex;gap:.7rem;align-items:center;flex-wrap:wrap;margin-top:.8rem}.board-foot .swatch{margin-right:.27rem}.board-foot .path{margin-left:auto}.scoreboard{display:grid;grid-template-columns:1fr 1fr;gap:.5rem}.scoreboard>div{border:1px solid var(--line);border-radius:7px;padding:.56rem;display:flex;align-items:center;gap:.45rem}.scoreboard>div.active{border-color:#c89a5d;background:#382a1d}.scoreboard small{display:block;color:var(--muted);font-size:.83rem;margin-top:.12rem}.turn{color:var(--gold);margin:.8rem 0 .22rem;font-weight:700}.hint{margin:.25rem 0 .65rem;line-height:1.5;min-height:3em}.casting{display:flex;align-items:center;gap:.8rem;min-height:3.1rem;border-top:1px solid var(--line);font-size:.875rem;color:var(--muted)}#sticks{display:flex;gap:.28rem;min-width:5rem}.stick{display:block;width:.78rem;height:2rem;border:1px solid #a67449;border-radius:.4rem;background:#5b3d2b;transform:rotate(12deg)}.stick.light{background:linear-gradient(90deg,#c89966,#f7dba5,#c89966)}.stick.dark{background:linear-gradient(90deg,#4d2e23,#86583a,#513124)}.stick.cast{animation:toss .23s ease-out}@keyframes toss{from{transform:rotate(-30deg) translateY(-8px)}to{transform:rotate(12deg)}}.action{display:flex;gap:.5rem;flex-wrap:wrap}.action button,.quiet{border:1px solid var(--line);border-radius:6px;background:#3b2c21;color:var(--ink);padding:.5rem .8rem;min-height:40px}.action #roll,.action [value=yes]{background:var(--accent);color:#2d1b0d;border-color:#f0c988;font-weight:700}.action #roll:disabled{background:#5a4734;border-color:#665139;color:#f1dbc0}.quiet{background:none;padding:.3rem .5rem;min-height:34px}.mode{display:flex;gap:.55rem;align-items:center;flex-wrap:wrap;font-size:.875rem;color:var(--muted);margin-top:.85rem}.mode select{max-width:100%;background:#2d2119;color:var(--ink);border:1px solid var(--line);border-radius:6px;padding:.35rem .4rem}.extras{display:grid;gap:.65rem;margin:1rem 0}summary{cursor:pointer;color:var(--ink);padding:.85rem 1rem}summary span{color:var(--muted);font-size:.875rem}.detail{padding:0 1rem .7rem;line-height:1.62;color:#e6d4bc}.detail ul,.detail ol{padding-left:1.5rem;margin:.35rem 0}.detail li+li{margin-top:.32rem}a{color:#f0c887;text-underline-offset:3px}footer{text-align:left;color:var(--muted);font-size:.875rem;border-top:1px solid var(--line);padding:1rem 0 1.6rem}dialog{background:#271e17;border:1px solid var(--line);border-radius:12px;color:var(--ink);padding:1.25rem;max-width:calc(100vw - 2rem)}dialog::backdrop{background:#090604aa}[hidden]{display:none!important}@media(max-width:760px){.layout{grid-template-columns:1fr;gap:.7rem}.heading{padding:.65rem 0 1rem}.mast{padding-bottom:.65rem;margin-bottom:1rem}.cell{aspect-ratio:1/1.22}.band{margin-bottom:.6rem}.hint{min-height:0}.board-foot{margin-top:.55rem;gap:.45rem}.board-foot .path{font-size:.78rem}.controls .band{margin-bottom:.5rem}}@media(prefers-reduced-motion:reduce){*{animation:none!important}}

/* Taia display: warm incised wood, box and shallow drawer, glazed faience forms. */
:root{--base:#1c1712;--panel:#282019;--line:#55412c;--gold:#e5bf82;--muted:#cfbba1}
.mast{justify-content:space-between;text-transform:uppercase}.mast-period{letter-spacing:.04em;color:var(--gold)}
.board-key{cursor:pointer;display:inline-flex;gap:.45rem;align-items:center;color:var(--muted);font-size:.9rem;min-height:38px}.board-key input{width:1.1rem;height:1.1rem;margin:0;accent-color:#8ac7b0}
.box-model{filter:drop-shadow(0 8px 9px #0e08067f)}.wood{position:relative;background:repeating-linear-gradient(8deg,#a96934 0,#bd854c 5px,#c08a53 6px,#af7744 11px,#bc844d 16px);border:1px solid #75401c;border-radius:4px 4px 1px 1px;box-shadow:inset 0 0 0 2px #efad6b67,inset 0 0 14px #66341385}
.board{gap:0;border:1px solid #75421e;overflow:visible;background:linear-gradient(110deg,#bf884d,#d6a66b 50%,#b67b45)}
.cell,.cell:nth-child(even),.cell[data-water],.cell[data-ritual]{background:transparent;border:0;border-right:1px solid #744622ba;border-bottom:1px solid #744622ba;box-shadow:inset -1px -1px #f0bd853d;border-radius:0;color:#201108}.cell:nth-child(10n){border-right:0}.cell:nth-child(n+21){border-bottom:0}
.cell:nth-child(3n){background:#70380a09}.cell:nth-child(7n){background:#f8ce9820}
.cell .idx,.cell .sigil{display:none}.teaching .cell .idx,.teaching .cell .sigil{display:block}
.teaching .cell .idx{font-size:clamp(.72rem,1.45vw,.9rem);color:#241306;top:3px;left:3px;text-shadow:0 1px #f8dbaa87}.teaching .cell .sigil{font-family:inherit;font-size:clamp(.54rem,1.25vw,.8rem);font-weight:700;right:2px;bottom:2px;color:#241306;text-shadow:0 1px #f8dbaa87}.teaching .cell[data-water]{background:#57897c87}.teaching .cell[data-gate]{background:#f2c677a1}.cell[data-last]{box-shadow:inset 0 0 0 2px #763a25}.cell[data-legal]{outline:2px solid #fff4c8;outline-offset:-3px;box-shadow:inset 0 0 0 4px #205e50;z-index:2}.cell[data-legal]:focus-visible{outline:2px solid #fff;outline-offset:1px}
.box-face{position:relative;height:clamp(23px,4.6vw,43px);background:repeating-linear-gradient(1deg,#794519,#905223 5px,#9c5c29 6px,#874c24 12px);border:1px solid #4c2711;border-top-color:#6d3a1b;border-radius:0 0 4px 4px;box-shadow:inset 0 2px #ffd3a344,inset 0 -4px #40210885}.box-face:before{content:"";position:absolute;inset:0 2%;background:url(taia-inscription.webp) center / 100% auto no-repeat;opacity:.93;mix-blend-mode:normal}
.ink{background:linear-gradient(155deg,#78bfa6,#317762 52%,#155147);border-color:#194b40}.ivory{background:linear-gradient(155deg,#b5dcc5,#83b9a2 55%,#3c7f6b);border-color:#376e5a}
.piece.ink{height:64%;width:54%}
:is(.piece,.swatch).ink{clip-path:polygon(45% 0,55% 0,63% 7%,68% 35%,99% 90%,100% 94%,82% 100%,18% 100%,0 94%,1% 90%,32% 35%,37% 7%);border-radius:15%}
.piece.ivory{height:54%;width:57%}
:is(.piece,.swatch).ivory{clip-path:polygon(20% 0,80% 0,98% 11%,96% 23%,71% 35%,69% 67%,99% 84%,100% 94%,78% 100%,22% 100%,0 94%,1% 84%,31% 67%,29% 35%,4% 23%,2% 11%);border-radius:22%}
.artifact{max-width:580px;margin:.25rem 0 .85rem}.artifact a{display:block}.artifact img{display:block;width:100%;height:auto;border-radius:5px}.artifact figcaption{color:var(--muted);font-size:.875rem;margin:.3rem 0}

/* Two two-dimensional museum-inspired surfaces sharing one game. */
.visually-hidden{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;border:0}
.board-toolbar{display:flex;justify-content:space-between;gap:.4rem .75rem;align-items:center;flex-wrap:wrap;margin:0 0 .75rem}
.board-switch{display:flex;gap:3px;padding:3px;border:1px solid #5c4833;border-radius:8px;background:#1c1712}
.board-switch button{font-size:.94rem;color:#e7d7be;min-height:34px;padding:.28rem .65rem;background:transparent;border:1px solid transparent;border-radius:5px}
.board-switch button[aria-pressed="true"]{background:#3c2b1e;border-color:#795b38;color:#ffe5b4}
[data-board-style=blue] .board-switch button[aria-pressed="true"]{background:#234941;border-color:#527c6e;color:#d8f6e6}
.board-sign{position:absolute;inset:11%;display:grid;place-items:center;pointer-events:none;color:#51311f;z-index:0}
.board-sign svg{width:100%;height:100%;display:block}
.cell{aspect-ratio:1.14/1;min-height:0;overflow:hidden}.cell[data-legal]{z-index:2}
.board-foot{margin-top:.72rem}
.face-credit{display:flex;gap:.28rem .8rem;align-items:baseline;flex-wrap:wrap;margin-top:.55rem;padding-top:.55rem;border-top:1px solid #594531;font-size:.875rem}
.face-credit>a{color:var(--muted)}
.glyph-guide{flex:1 1 auto}.glyph-guide summary{padding:0;color:#f0ce98;max-width:max-content}
.glyph-guide ol{padding:0;list-style:none;display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,146px),1fr));gap:.4rem;margin:.6rem 0 0}
.glyph-guide li{display:flex;align-items:center;gap:.35rem;border:1px solid #685441;border-radius:6px;padding:.3rem .36rem}
.glyph-guide svg{width:36px;height:36px;flex:none;color:#d8b287}
.glyph-guide small{display:block;color:#d1c0aa;font-size:.8rem;line-height:1.27;margin-top:.12rem}
.glyph-guide p{font-size:.875rem;color:var(--muted);margin:.4rem 0 .15rem}
.detail-photo img{width:100%}
[data-board-style=blue]{--blue-rim:#374c48;--blue-ink:#252444}
[data-board-style=blue] .wood{background:linear-gradient(120deg,#849587,#4c7a70 55%,#587669);border:1px solid #687d71;box-shadow:inset 0 0 0 2px #c1ceaa6c,inset 0 0 12px #213e3c9c;border-radius:5px 5px 2px 2px;padding:clamp(4px,1.25vw,11px)}
[data-board-style=blue] .board{gap:4px;background:#292b43;border:1px solid #292b43;box-shadow:0 0 0 1px #b4b39b}
[data-board-style=blue] .cell{background:radial-gradient(ellipse at 31% 34%,#9bb4a5 0%,transparent 72%),linear-gradient(135deg,#6d9c9e,#528780);box-shadow:inset 0 0 0 1px #aaaea1,inset 0 0 0 2px #26334eaa;border:0;aspect-ratio:1.14/1;color:#19272f}
[data-board-style=blue] .cell:nth-child(3n){background:radial-gradient(ellipse at 75% 68%,#9da48b,transparent 68%),linear-gradient(135deg,#70959a,#6b8e7c)}
[data-board-style=blue] .cell:nth-child(5n){background:radial-gradient(ellipse at 28% 60%,#94a582,transparent 70%),linear-gradient(155deg,#548093,#5c9088)}
[data-board-style=blue] .cell[data-inscribed]{background:radial-gradient(ellipse at 50% 38%,#acb998,transparent 83%),linear-gradient(135deg,#77a299,#638b83)}
[data-board-style=blue] .board-sign{color:#29263c;inset:10%;filter:drop-shadow(0 1px #bec5a4aa)}
[data-board-style=blue] .box-face{height:clamp(16px,2.8vw,28px);border-color:#435650;background:linear-gradient(180deg,#608282,#345b69 36%,#4c7384 72%,#425a60);box-shadow:inset 0 0 0 1px #aac0b268}
[data-board-style=blue] .box-face:before{display:none}
.shell[data-piece-theme=blue] :is(.piece,.swatch).ink{background:linear-gradient(155deg,#576e70,#2c4445 52%,#142b31);border-color:#19363b;filter:drop-shadow(0 2px 1px #1c323f)}
.shell[data-piece-theme=blue] :is(.piece,.swatch).ivory{background:linear-gradient(150deg,#d0d8bc,#9fb49d 63%,#5f8079);border-color:#55786f}
[data-board-style=blue] .glyph-guide svg{color:#adcbb5}
[data-board-style=blue] .teaching .cell .idx,[data-board-style=blue] .teaching .cell .sigil{color:#162632;text-shadow:0 1px #d3e4c4}
[data-board-style=blue] .cell[data-last]{box-shadow:inset 0 0 0 2px #623a30}
[data-board-style=blue] .cell[data-legal]{outline:2px solid #fff3c6;box-shadow:inset 0 0 0 4px #24534d}
[data-board-style=blue] .cell[data-legal]:focus-visible{outline:2px solid #fff;outline-offset:0}
@media(max-width:520px){[data-board-style=blue] .board{gap:2px}.board-sign,[data-board-style=blue] .board-sign{inset:6%}.cell,[data-board-style=blue] .cell{aspect-ratio:1/1.08}.board-toolbar{margin-bottom:.6rem}.board-switch button{padding-inline:.5rem}.board-foot .path{margin-left:0}}

.move-guide{display:inline-block;font-size:.875rem;font-weight:700;line-height:1.35;margin:.05rem 0 .14rem;padding:.24rem .52rem;border-radius:5px;background:#263d30;color:#e4f5e5;border:1px solid #526e56}
.move-guide[data-direction=back]{background:#493520;color:#ffe6bd;border-color:#956b41}.move-guide[data-direction=exit]{background:#443a22;color:#ffecb8;border-color:#8e7848}
.rule-guide>p{margin:.12rem 0 .65rem}.rule-guide>ol{display:grid;gap:.45rem}.rule-guide>details{margin:.7rem 0 .4rem;border-top:1px solid var(--line)}.rule-guide>details summary{padding:.58rem 0 .2rem}
.win-goal{margin:.7rem 0 0;font-size:.93rem;line-height:1.45;color:var(--ink)}.win-goal strong{color:var(--gold)}.win-goal+.board-foot{margin-top:.38rem}
.teaching .cell[data-gate] .sigil{white-space:nowrap;text-align:right;line-height:1;z-index:3;font-size:clamp(.43rem,1.1vw,.77rem)}
.teaching .cell[data-gate] .gate-stop{left:2px;right:auto;text-align:left}
.teaching .cell[data-gate] .board-sign{inset:10% 12% 17%}
@media(max-width:410px){.teaching .cell[data-gate] .sigil{right:1px;letter-spacing:-.08em}.teaching .cell[data-gate] .gate-stop{left:1px;right:auto}.teaching .cell[data-gate] .board-sign{inset:10% 9% 19%}}
.rule-guide h3{font-size:1rem;line-height:1.36;margin:1rem 0 .38rem;color:var(--gold)}
.rule-guide ul{margin-bottom:.4rem}.rule-guide .rule-source{font-size:.875rem;color:var(--muted)}
.houses{width:100%;border-collapse:collapse;table-layout:auto;margin:.35rem 0 .65rem}
.houses :is(th,td){border-bottom:1px solid var(--line);padding:.52rem .55rem;vertical-align:top;text-align:left;overflow-wrap:break-word}
.houses thead th{background:#3a2c21;color:#efd7ae;white-space:nowrap}
.houses tbody th{font-weight:650;color:var(--ink);min-width:5em}
@media(max-width:520px){.houses :is(th,td){padding:.43rem .31rem}.houses tbody th{min-width:3.6em}}
.face-credit{display:block}.face-credit>a{display:block;margin-bottom:.48rem;width:fit-content;max-width:100%}
.glyph-guide{display:block}.glyph-guide summary{margin-bottom:.55rem}
.artifact-stack{display:grid;grid-template-columns:minmax(0,1fr);gap:.65rem;width:100%}
.artifact-stack .artifact{max-width:none;width:100%;margin:0}
.artifact-stack .artifact img{width:100%;height:auto;border-radius:5px}
.artifact-stack .artifact figcaption{margin:.3rem 0 0}
.glyph-guide>ol{margin-top:.85rem}

/* Play first: the first region is always the board and its controls. */
.shell{width:100%;max-width:1100px;padding-inline:clamp(10px,2.8vw,50px)}
.heading{display:flex;align-items:baseline;gap:.8rem;flex-wrap:wrap;padding:.8rem 0 .66rem;border-bottom:1px solid var(--line);margin-bottom:.85rem}
.heading h1{font-size:clamp(1.85rem,3.3vw,3.4rem);line-height:1.1;margin:0;letter-spacing:.035em}
.heading .subtitle{font-size:.86rem;gap:.5rem;margin:0}
.heading .subtitle i{width:1rem}
.layout{gap:clamp(.65rem,1.4vw,1.5rem);grid-template-columns:minmax(0,2.3fr) minmax(255px,1fr);align-items:start}
.board-foot,.board-toolbar{min-width:0}
.controls .action button{min-height:44px}
.game-status{margin:.55rem 0;min-width:0}.game-status .hint{min-height:0;margin:.16rem 0 0}
.cast-zone{border-top:1px solid var(--line);padding-top:.48rem}
.cast-zone .casting{border:0}
.collection .face-credit{border:0;margin-top:0;padding-top:0}
.collection .face-credit>a{margin-bottom:.65rem}
.collection .artifact-stack{max-width:960px}
@media(min-width:1050px) and (orientation:landscape){
 .shell{max-width:1940px}
 .heading{padding-block:clamp(1rem,2.4vh,2rem) .95rem;margin-bottom:1.1rem}
 .layout{grid-template-columns:minmax(0,2.55fr) minmax(300px,1fr)}
 .board-panel,.controls{padding:clamp(16px,1.35vw,24px)}
 .controls .scoreboard>div{padding:.8rem}
 .game-status{margin-block:.9rem}
 .controls .cast-zone .casting{min-height:3.4rem}
 .extras{margin-top:1.15rem}
}
@media(min-width:760px) and (orientation:portrait){
 .layout{grid-template-columns:minmax(0,1fr)}
 .controls{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:.35rem 1.2rem}
 .controls .band{grid-column:1/-1;margin-bottom:.3rem}
 .controls .game-status{grid-column:1;grid-row:3}
 .controls .cast-zone{grid-column:2;grid-row:2/4;border-top:0;border-left:1px solid var(--line);padding:0 0 0 1rem;align-self:center}
 .controls .mode{grid-column:2;margin-top:.15rem}
}
@media(max-width:759px){
 .heading{padding:.68rem 0 .52rem;margin-bottom:.55rem;gap:.55rem}
 .heading .subtitle{font-size:.78rem}
 .layout{grid-template-columns:minmax(0,1fr);gap:.55rem}
 .board-panel,.controls{padding:.55rem .65rem}
 .board-toolbar{margin-bottom:.44rem}
 .board-key{min-height:36px}
 .win-goal{margin-top:.48rem;font-size:.88rem}
 .board-foot{gap:.35rem .58rem;font-size:.82rem}
 .board-foot .path{margin-left:auto}
 .controls .band{margin-bottom:.42rem}
 .controls .scoreboard>div{padding:.35rem .48rem}
 .controls .scoreboard small{margin-top:.04rem}
 .game-status{margin:.44rem 0}.game-status .hint{font-size:.92rem;line-height:1.33}
 .cast-zone{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:.4rem;padding-top:.34rem}
 .cast-zone .casting{gap:.42rem;min-height:2.65rem}
 .controls .mode{margin-top:.42rem}
}
@media(max-width:420px){
 .cast-zone .casting{flex-wrap:wrap;gap:.25rem .4rem}
 .board-foot .path{margin-left:0}
}
@media(max-height:560px) and (min-width:620px) and (orientation:landscape){
 .shell{padding-inline:max(12px,env(safe-area-inset-left),env(safe-area-inset-right))}
 .heading{padding:.33rem 0 .36rem;margin-bottom:.4rem}
 .heading h1{font-size:1.6rem}
 .layout{grid-template-columns:minmax(0,1.65fr) minmax(235px,1fr);gap:.55rem}
 .board-panel,.controls{padding:.48rem .56rem}
 .board-toolbar,.controls .band{margin-bottom:.35rem}
 .board-key{min-height:32px}
 .controls .scoreboard>div{padding:.25rem .4rem}
 .game-status{margin:.30rem 0}.game-status .hint{font-size:.85rem}
 .cast-zone{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:.35rem;align-items:center;padding-top:.28rem}
 .cast-zone .casting{min-height:2.5rem;gap:.25rem;flex-wrap:wrap}
 .controls .mode{margin-top:.35rem}
 .extras{margin-top:.55rem}
}

/* Core interaction invariant: the game changes state without moving its controls. */
html{scrollbar-gutter:stable}
[data-board-style] .wood{padding:clamp(4px,1vw,11px)}
[data-board-style] .board{aspect-ratio:3.8;grid-template-rows:repeat(3,minmax(0,1fr))}
[data-board-style] .cell{aspect-ratio:auto;min-height:0}
[data-board-style] .box-face{height:clamp(18px,3vw,34px)}
[data-board-style=blue] .box-face{height:clamp(18px,3vw,34px)}
.game-status .turn{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;line-height:1.35;font-variant-numeric:tabular-nums}
.game-status .hint{min-height:0;block-size:2.7em;line-height:1.35;overflow:auto;scrollbar-width:none;overflow-wrap:anywhere;scroll-margin:0}
.cast-zone .casting{flex-wrap:nowrap;height:2.7rem;min-height:0}
.cast-zone #steps{font-variant-numeric:tabular-nums;white-space:nowrap}
.cast-zone .action{display:grid;grid-template-columns:5.9rem 4.9rem;gap:.35rem;justify-content:start}
.cast-zone .action button{padding:.35rem .3rem;min-height:44px;white-space:nowrap}
.cast-zone #rescue[aria-hidden=true]{visibility:hidden;pointer-events:none}
@media(max-width:759px) and (orientation:portrait){
 [data-board-style] .board{aspect-ratio:3.07}
 .cast-zone .casting{display:grid;grid-template-rows:1.65rem 1rem;gap:.08rem;align-content:center}
 .cast-zone .casting .stick{height:1.53rem}
 .cast-zone #steps{line-height:1}
}
@media(max-height:560px) and (min-width:620px) and (orientation:landscape){
 .cast-zone{grid-template-columns:minmax(0,1fr);gap:.14rem}
 .cast-zone .casting{height:1.65rem}
 .cast-zone .casting .stick{height:1.36rem}
}
[data-board-style=blue] .cell{aspect-ratio:auto}

/* Opening settings stay outside the board and turn layout. */
.score-copy{min-width:0}
.score-name{display:inline-flex;align-items:baseline;gap:.24rem;white-space:nowrap}
.side-role{font-size:.75rem;color:var(--muted);line-height:1}
.side-role:not(:empty)::before{content:"· ";color:var(--gold)}
.controls .opening-actions{display:flex;gap:.35rem;align-items:center;flex:none}
.controls .opening-actions button{white-space:nowrap}
#setup{width:min(28rem,calc(100% - 2rem));max-height:calc(100dvh - 1rem);padding:1rem 1.2rem;border-color:#84613d;box-shadow:0 16px 70px #080503b0;overflow:auto}
#setup h2{font-size:1.34rem}
#setup form{display:grid;gap:.85rem}
#setup fieldset{margin:0;min-width:0;padding:0;border:0}
#setup legend{margin:0 0 .36rem;color:var(--muted);font-size:.875rem}
.setup-options{display:grid;gap:.4rem}
.setup-modes{grid-template-columns:repeat(2,minmax(0,1fr))}
.setup-sides{grid-template-columns:repeat(3,minmax(0,1fr))}
.setup-options label{position:relative;cursor:pointer}
.setup-options input{position:absolute;opacity:0;width:1px;height:1px;margin:0}
.setup-options label>span{display:block;height:100%;min-height:44px;text-align:center;padding:.55rem .22rem;border:1px solid #67503a;border-radius:7px;background:#30241b;color:var(--ink);white-space:nowrap}
.setup-options label>span .swatch{margin-right:.22rem;width:.8rem;height:.8rem}
.setup-options small{display:block;color:var(--muted);font-size:.8rem;margin-top:.16rem}
.setup-options input:checked+span{border-color:var(--gold);background:#493424;box-shadow:inset 0 0 0 1px var(--gold)}
.setup-options input:focus-visible+span{outline:2px solid #ffdb9e;outline-offset:2px}
.setup-note{margin:0;color:var(--muted);font-size:.875rem}
.setup-actions{display:grid;grid-template-columns:1fr 1fr}
.setup-actions button{min-height:44px}
@media(max-width:600px) and (orientation:portrait){
 #setup{margin:auto auto 0;width:100%;max-width:none;border-radius:15px 15px 0 0;padding:1rem max(1rem,env(safe-area-inset-right)) calc(1rem + env(safe-area-inset-bottom)) max(1rem,env(safe-area-inset-left))}
}
@media(max-height:410px){
 #setup{padding:.7rem 1rem}
 #setup form{gap:.5rem}
 #setup legend{margin-bottom:.22rem}
}

/* Badges sit inside the highlighted origin square and never affect grid size. */
.cell .move-tag{position:absolute;z-index:5;top:1px;right:1px;display:grid;place-items:center;width:1.24em;height:1.24em;border-radius:2px;background:#234d3d;color:#fff9e9;font-size:clamp(.60rem,1.18vw,.90rem);line-height:1;font-weight:750;pointer-events:none}
.cell[data-outcome=swap] .move-tag{background:#674216}
.cell[data-outcome=strike] .move-tag{background:#852f21}
.cell[data-outcome=exit] .move-tag{background:#4d386b}
.cell[data-outcome=water] .move-tag{background:#205167}
[data-board-style] .cell[data-legal]:is([data-outcome=swap],[data-outcome=strike]){outline-color:#ffe0a3;box-shadow:inset 0 0 0 4px #9a4524}
.move-key{margin:.36rem 0 0;color:var(--muted);font-size:clamp(.72rem,1.45vw,.85rem);line-height:1.36}
.move-key b{color:var(--ink);margin:0 .12em 0 .38em}
.move-key b:first-of-type{margin-left:0}
#hint-main,#hint-rule{display:block}
#hint-rule{color:var(--gold)}

/* Miniatures share the board shapes; lighten the dark piece on dark panels. */
.swatch.ink{background:linear-gradient(150deg,#af9986,#66564b 58%,#49392e);border-color:#785c48}
.shell[data-piece-theme=blue] .swatch.ink{background:linear-gradient(150deg,#8aa5a4,#576e70 58%,#304d52);border-color:#526e70}

/* Compact cells: top corners for labels, middle for art and the piece,
   bottom for rules. On inscribed cells a piece parks beside the sign. */
@media(max-width:560px),(max-height:560px) and (max-width:1050px) and (orientation:landscape){
 .board{--cell-top:10px;--cell-bottom:9px}
 .teaching .cell .idx{font-size:9px;line-height:1;top:1px;left:2px}
 .cell .move-tag{font-size:8px;width:10px;height:9px;top:0;right:1px}
 .teaching .cell .sigil,.teaching .cell[data-gate] .sigil{font-size:7px;line-height:1;bottom:1px;right:1px;letter-spacing:0}
 .teaching .cell[data-gate] .sigil{font-size:clamp(6px,1.7vw,7px);letter-spacing:-.08em}
 .teaching .cell[data-gate] .gate-stop{left:1px;right:auto}
 .board .cell .board-sign,[data-board-style=blue] .board .cell .board-sign,
 .teaching .cell[data-gate] .board-sign{
  display:block;inset:var(--cell-top) 2px var(--cell-bottom);filter:none
 }
 .board .cell .board-sign svg{width:100%;height:100%;max-height:100%;overflow:hidden}
 .board .cell .piece{
  position:absolute;top:var(--cell-top);bottom:var(--cell-bottom);left:50%;
  transform:translateX(-50%);width:51%;height:auto;margin:0;max-height:none;filter:none
 }
 .board .cell[data-inscribed][data-occupied] .board-sign{
  left:1px;right:42%
 }
 .board .cell[data-inscribed][data-occupied] .piece{
  left:auto;right:2px;transform:none;width:calc(42% - 4px);
 }
 .board:not(.teaching){--cell-top:10px;--cell-bottom:3px}
}
@media(max-width:560px) and (orientation:portrait){
 [data-board-style] .board{aspect-ratio:2.78}
}
@media(max-height:560px) and (min-width:620px) and (max-width:759px) and (orientation:landscape){
 [data-board-style] .board{aspect-ratio:3.24}
}
@media(max-width:340px){
 .teaching .cell[data-gate] .sigil{transform:scaleX(.84);transform-origin:right center}
 .teaching .cell[data-gate] .gate-stop{transform-origin:left center}
}

.setup-difficulties{grid-template-columns:repeat(2,minmax(0,1fr))}
@media(max-height:410px) and (min-width:580px) and (orientation:landscape){
 #setup form{grid-template-columns:1fr 1fr;column-gap:.65rem}
 #setup h2,#side-options,.setup-note,.setup-actions{grid-column:1/-1}
}

@font-face{font-family:"Senet Hieroglyphs";src:url("fonts/noto-senet.ttf") format("truetype");font-display:block;unicode-range:U+13216,U+13283,U+133CF,U+133E0}
.heading .senet-names{display:inline-flex;align-items:baseline;gap:clamp(.28rem,1vw,.58rem);margin:0;white-space:nowrap;color:var(--gold);line-height:1}
.senet-egy{font:400 clamp(1.10rem,3.4vw,1.75rem)/1 "Senet Hieroglyphs","Noto Sans Egyptian Hieroglyphs",sans-serif}
.senet-separator{color:var(--muted)}
.senet-en{font:400 clamp(.9rem,2vw,1.35rem)/1 Georgia,serif;letter-spacing:.08em}

/* Keep the record button anchored to the right of the round label. */
.turn-row{display:grid;grid-template-columns:minmax(0,1fr) auto;align-items:center;gap:.4rem}
.turn-row .turn{margin:0}
#history-open{white-space:nowrap;min-height:36px;padding:.25rem .46rem;font-size:.8rem}
@media(max-width:369px) and (orientation:portrait){
 .turn-row .turn{font-size:.92rem}
}
@media(max-height:560px) and (min-width:620px) and (orientation:landscape){
 #history-open{min-height:30px;padding:.15rem .4rem}
}
html:has(#match-history[open]){overflow:hidden}
#match-history{inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;border-radius:0;background:var(--base);overflow:hidden}
.history-layout{height:100%;display:grid;grid-template-rows:auto auto minmax(0,1fr)}
.history-head,.history-downloads{
 padding:.72rem max(.8rem,env(safe-area-inset-right)) .72rem max(.8rem,env(safe-area-inset-left));
 background:var(--panel);border-bottom:1px solid var(--line);
}
.history-head{grid-row:1;padding-top:max(.72rem,env(safe-area-inset-top));display:flex;align-items:center;justify-content:space-between;gap:.5rem}
.history-head h2{font-size:clamp(1.1rem,3vw,1.42rem)}
.history-actions,.history-downloads{display:flex;flex-wrap:wrap;gap:.55rem}
.history-actions button{min-height:44px;white-space:nowrap}
.history-actions #history-export{border-color:#ad8151;color:var(--gold)}
.history-actions #history-export:disabled{opacity:.55}
.history-downloads{grid-row:2}
.history-downloads a{display:inline-block;padding:.45rem .18rem}
.history-scroll{grid-row:3;overflow:auto;overscroll-behavior:contain;padding:0 0 max(1.1rem,env(safe-area-inset-bottom))}
.history-summary,#history-content{width:min(44rem,calc(100% - max(1.4rem,env(safe-area-inset-left)) - max(1.4rem,env(safe-area-inset-right))));margin-inline:auto}
.history-summary{color:var(--muted);margin-block:1.1rem .8rem}
.history-turn{margin:.55rem 0 .9rem;border:1px solid var(--line);border-radius:8px;background:var(--panel)}
.history-turn h3{display:flex;align-items:center;gap:.5rem;font-size:1rem;margin:0;padding:.43rem .7rem;color:var(--gold);border-bottom:1px solid var(--line)}
.history-turn h3 small{margin-inline-start:auto;color:var(--muted);font-weight:400}
.history-turn ul{list-style:none;padding:0;margin:0;line-height:1.55}
.history-turn li{padding:.42rem .7rem;overflow-wrap:anywhere}
.history-turn li+li{border-top:1px solid #51402c80}
.history-empty{color:var(--muted)}
.history-turn li{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:.5rem;align-items:start}
.history-tag{display:inline-block;padding:.14rem .42rem;border-radius:.35rem;background:var(--tag-bg,#352b23);color:var(--tag-ink,#dfc7aa);font-size:.8rem;font-weight:700;white-space:nowrap;line-height:1.6}
.history-flow{justify-self:end}
.history-detail{min-width:0;font-variant-numeric:tabular-nums}
.history-turn [data-tone="good"]{--tag-bg:#20463b;--tag-ink:#a8e6ca;--wash:#245a433d}
.history-turn [data-tone="goal"]{--tag-bg:#59421b;--tag-ink:#ffe097;--wash:#a070203a}
.history-turn [data-tone="loss"]{--tag-bg:#572a2a;--tag-ink:#ffc1ad;--wash:#963c3638}
.history-turn [data-tone="again"]{--tag-bg:#243a31;--tag-ink:#bce3c7}
.history-turn [data-tone="switch"]{--tag-bg:#3d302a;--tag-ink:#e1c4ad}
.history-turn li[data-tone]{background:linear-gradient(90deg,var(--wash,transparent),transparent 94%);border-inline-start:3px solid var(--tag-bg,transparent);padding-inline-start:calc(.7rem - 3px)}
.history-export-actions{display:flex;align-items:center;flex-wrap:wrap;gap:.2rem .6rem}
.history-export-actions button{min-height:36px}
.history-share-status:not(:empty){flex-basis:100%;color:var(--muted)}

.history-downloads{max-height:27vh;overflow:auto;align-content:start}
