/* Each board keeps its own materials and colours, including the reading surface. */
:is(body[data-chess-theme=xiangqi],.board-theme-xiangqi){--table-bg:#f5efe5;--table-paper:#fffaf0;--table-text:#402e24;--table-muted:#76634e;--table-line:#d9c7ad;--table-accent:#963e32;--table-soft:#f1e1ce;--wood:#e7c895;--wood-edge:#8c5d36;--wood-line:#765735;--table-serif:'Noto Serif CJK SC','Songti SC','SimSun',serif}
:is(body[data-chess-theme=gomoku],.board-theme-gomoku){--table-bg:#f0f1ec;--table-paper:#fafbf7;--table-text:#29352f;--table-muted:#5d6b60;--table-line:#ccd4c8;--table-accent:#365e4b;--table-soft:#e3e9df;--wood:#e5c68e;--wood-edge:#a27b4f;--wood-line:#806640;--table-serif:inherit}
html[data-theme=dark] :is(body[data-chess-theme=xiangqi],.board-theme-xiangqi){--table-bg:#241f1b;--table-paper:#302820;--table-text:#eee1cf;--table-muted:#c3b099;--table-line:#65503f;--table-accent:#efb3a0;--table-soft:#403027;--wood:#765b3f;--wood-edge:#4a3527;--wood-line:#c4a37a}
html[data-theme=dark] :is(body[data-chess-theme=gomoku],.board-theme-gomoku){--table-bg:#1b2420;--table-paper:#26322b;--table-text:#e5ebdf;--table-muted:#b7c4b6;--table-line:#4d6152;--table-accent:#b1d4b8;--table-soft:#34473b;--wood:#7b6849;--wood-edge:#4a3e2b;--wood-line:#c2ac7c}
html body.unified-ui[data-page]:is([data-chess-theme=xiangqi],[data-chess-theme=gomoku]){background:var(--table-bg);color:var(--table-text);--muted:var(--table-muted);--line:var(--table-line);--green:var(--table-accent)}
body[data-chess-theme] :is(.board-theme-xiangqi,.board-theme-gomoku){color:var(--table-text);max-width:600px;margin-inline:auto}
body[data-chess-theme] :is(.chess-setup,.chess-play,.chess-result) :is(h1,h2,h3,.section-kicker,.back,.text-btn,.help-text,.chess-meta,.chess-meta b,.chess-status strong,.chess-status span,.chess-record,.chess-result-metrics span){color:var(--table-text)}
body[data-chess-theme] :is(.chess-intro p,.chess-intro .section-kicker,.help-text,.chess-meta,.chess-status span,.chess-result-metrics span){color:var(--table-muted)}
body[data-chess-theme=xiangqi] :is(.chess-setup,.chess-play,.chess-result) :is(h1,h2,.chess-outcome){font-family:var(--table-serif);letter-spacing:.04em}
body[data-chess-theme] :is(.chess-setup,.chess-play,.chess-result) :is(.panel,.setup-start-dock,.chess-saved){background:var(--table-paper);border:1px solid var(--table-line);box-shadow:none;color:var(--table-text)}
body[data-chess-theme] :is(.primary,.secondary,.text-btn,.back){color:var(--table-accent)}
body[data-chess-theme] .primary,.chess-manual .primary{background:var(--table-accent);color:var(--table-paper);border:1px solid var(--table-accent);box-shadow:none}
body[data-chess-theme] .secondary{background:var(--table-paper);border-color:var(--table-line);color:var(--table-text);box-shadow:none}
body[data-chess-theme] :is(.chess-setup,.chess-play,.chess-result) :is(.panel,.secondary,.primary,.chess-modes button){border-radius:12px}
body[data-chess-theme] .chess-intro{gap:14px;margin:18px 0 12px}.chess-intro h2{font-size:23px}.chess-intro .section-kicker{font-size:13px;letter-spacing:.12em}.chess-intro p{margin:8px 0 0;font-size:15px}
.chess-emblem{position:relative;display:grid;place-items:center;flex:none;width:54px;height:64px;font-size:36px;font-family:var(--table-serif);border:1px solid var(--table-accent);border-radius:6px;color:var(--table-accent);outline:1px solid var(--table-line);outline-offset:3px}
.board-theme-gomoku .chess-emblem{border:0;outline:0;width:62px}.chess-emblem .go-stone{position:absolute;width:39px;height:39px}.chess-emblem .go-black{left:0;top:6px}.chess-emblem .go-white{right:0;bottom:6px}
body[data-chess-theme] .chess-preview{width:min(100%,232px);margin:18px auto 20px}.chess-preview>p{font-size:13px;text-align:center;color:var(--table-muted);margin:10px -15px 0}.chess-preview .chess-scroll{border:5px solid var(--wood-edge);border-radius:8px;box-shadow:0 5px 10px #2e1d1515}.chess-preview .chess-board{border-radius:2px}
body[data-chess-theme] .chess-board{background-color:var(--wood);background-image:repeating-linear-gradient(96deg,transparent 0,transparent 12px,#6a402204 13px,transparent 16px);border-radius:4px}
body[data-chess-theme] .chess-lines{stroke:var(--wood-line);fill:var(--wood-line);stroke-width:2.2}body[data-chess-theme] .xiangqi-board .chess-lines{stroke-width:2.7}body[data-chess-theme] .chess-lines text{fill:var(--wood-line);font-family:'Noto Serif CJK SC','SimSun',serif;font-size:38px;letter-spacing:10px}.xq-start-mark{stroke-width:1.8}
body[data-chess-theme] .chess-play #play-panel,body[data-chess-theme] .chess-replay .play-panel{background:var(--wood-edge);border:1px solid var(--wood-edge);padding:8px;border-radius:12px;box-shadow:0 5px 14px #30201614,inset 0 0 0 2px #ffffff0c}.chess-players{display:flex;align-items:center;justify-content:space-between;gap:10px;margin:12px 0 0;padding:8px 0;border-top:1px solid var(--table-line);border-bottom:1px solid var(--table-line)}
.chess-player{display:flex;gap:9px;align-items:center;flex:1;min-width:0}.chess-player:last-child{justify-content:flex-end}.chess-player>span:last-child{display:flex;flex-direction:column;gap:3px}.chess-player strong{font-size:16px;font-weight:650}.chess-player small{font-size:12px;font-weight:400;color:var(--table-muted);margin-left:7px}.chess-player em{font-size:12px;font-style:normal;color:var(--table-muted)}.chess-player.is-turn em{color:var(--table-accent);font-weight:700}.chess-player.is-turn em:before{content:'';display:inline-block;width:6px;height:6px;background:currentColor;border-radius:50%;margin-right:5px}.players-divider{color:var(--table-muted)}
.chess-player .player-piece{width:31px;height:31px;flex:none;border-radius:50%;display:grid;place-items:center;font-family:'SimSun',serif;font-size:21px;line-height:1;font-weight:700}.player-red,.player-black{background:#f1dbb6;border:1px solid currentColor;box-shadow:inset 0 0 0 2px #f1dbb6,inset 0 0 0 3px currentColor}.player-red{color:#91382d}.player-black{color:#332b24}
body[data-chess-theme] .chess-meta{padding:9px 2px 11px;font-size:13px;letter-spacing:.02em}body[data-chess-theme] .chess-meta b{font-size:16px}
body[data-chess-theme] .xq-piece{background:radial-gradient(circle at 35% 25%,#fff1d2,#ecd2a2);color:#982f25;border:2px solid currentColor;outline:1px solid #9a724b;outline-offset:1px;box-shadow:inset 0 0 0 2px #f4dfb6,0 2px 0 #a57e52;font-size:clamp(20px,5.8vw,33px);width:86%;height:86%;font-family:'Noto Serif CJK SC','SimSun',serif}
body[data-chess-theme] .black-side .xq-piece{color:#302b24}body[data-chess-theme] .chess-selected .xq-piece{outline:3px solid #256f66;outline-offset:1px;background:#fff5da}body[data-chess-theme] .chess-last .xq-piece{box-shadow:inset 0 0 0 2px #f4dfb6,0 0 0 3px #b77a20}body[data-chess-theme] .chess-legal:after{background:#286657;border-color:#ffedc8}body[data-chess-theme] .chess-legal.occupied:after{background:transparent;border-color:#286657}body[data-chess-theme] .chess-origin:before{border-color:#8c5d25}
body[data-chess-theme] .go-black{background:radial-gradient(circle at 32% 26%,#505650 0,#242a26 35%,#111713 80%);border-color:#101710}body[data-chess-theme] .go-white{background:radial-gradient(circle at 32% 26%,#fff 0,#f7f6f1 45%,#deded3 100%);border-color:#a7a99d}body[data-chess-theme] .chess-last .go-stone:after{border-color:#d99f38;border-width:2px;inset:33%}body[data-chess-theme] .chess-winning .go-stone{outline-color:#236c52}
.chess-manual-entry{display:flex;align-items:center;gap:12px;width:100%;padding:16px 14px;background:var(--table-paper);border:1px solid var(--table-line);border-left:3px solid var(--table-accent);border-radius:12px;color:var(--table-text);text-align:left;margin:16px 0 22px}.chess-manual-entry>span:nth-child(2){flex:1}.chess-manual-entry strong{display:block;font-size:18px}.chess-manual-entry small{display:block;font-size:13px;line-height:1.6;color:var(--table-muted);margin-top:5px}.chess-book-icon{font-size:30px;color:var(--table-accent)}.chess-manual-entry>b{font-size:28px;font-weight:400;color:var(--table-accent)}
body[data-chess-theme] .chess-modes{margin-top:16px;gap:10px}body[data-chess-theme] .chess-modes button{background:var(--table-bg);color:var(--table-text);border:1px solid var(--table-line)}body[data-chess-theme] .chess-modes button.active{background:var(--table-soft);border:1px solid var(--table-accent);box-shadow:inset 0 0 0 1px var(--table-accent);color:var(--table-accent)}.chess-modes strong{font-size:19px}.chess-modes span{font-size:14px}
body[data-chess-theme] .chess-status{padding:15px 2px 10px;min-height:76px}body[data-chess-theme] .chess-status strong{font-size:21px;color:var(--table-accent)}body[data-chess-theme] .chess-status span{font-size:15px;line-height:1.7}body[data-chess-theme] .chess-status.is-check strong{color:#a0392c}.chess-help-link{display:block;width:100%;background:transparent;border:1px solid var(--table-line);border-radius:10px;color:var(--table-accent);font-size:17px;min-height:52px;padding:12px;margin:18px 0}.chess-help-link span{font-size:13px;color:var(--table-muted);margin-left:9px}
body[data-chess-theme] .training-focus{border-color:var(--table-line)}body[data-chess-theme] .training-focus :is(strong,h2,p,.focus-caption,.focus-eyebrow){color:var(--table-muted)}body[data-chess-theme] .focus-symbol{background:var(--table-soft);color:var(--table-accent)}
body[data-chess-theme] .chess-result-hero{background:var(--table-paper);border:1px solid var(--table-line);border-top:4px solid var(--table-accent);border-radius:12px;color:var(--table-text)}body[data-chess-theme] .chess-outcome{color:var(--table-accent);font-size:48px}.chess-result-hero h1{font-size:24px}.chess-result-hero p{font-size:16px}body[data-chess-theme] .chess-record{border-color:var(--table-line)}body[data-chess-theme] .chess-replay-range{accent-color:var(--table-accent)}
html[data-theme=dark] body[data-chess-theme] .xq-piece{background:radial-gradient(circle at 35% 25%,#efddbd,#d7b98a);color:#7e2d25;outline-color:#b79b71;box-shadow:inset 0 0 0 2px #dfc69f,0 2px 0 #4b3525}html[data-theme=dark] body[data-chess-theme] .black-side .xq-piece{color:#2a2821}html[data-theme=dark] body[data-chess-theme] .chess-selected .xq-piece{outline-color:#a3dbc1}html[data-theme=dark] body[data-chess-theme] .chess-legal:after{background:#addec9;border-color:#334b3d}html[data-theme=dark] body[data-chess-theme] .chess-legal.occupied:after{background:transparent;border-color:#addec9}html[data-theme=dark] body[data-chess-theme] .chess-last .xq-piece{box-shadow:inset 0 0 0 2px #dfc69f,0 0 0 3px #e5bb62}html[data-theme=dark] body[data-chess-theme] .chess-origin:before{border-color:#e5bb62}html[data-theme=dark] body[data-chess-theme] .chess-status.is-check strong{color:#ffc1ae}
/* Readable, user-opened guide. The game board is never displaced by instructions. */
body[data-chess-theme] .setup-start-dock .primary{background:var(--table-accent);color:var(--table-paper);border-color:var(--table-accent)}
body[data-chess-theme] .chess-preview .xq-piece{font-size:clamp(12px,3.6vw,18px);border-width:1px;outline-offset:0;box-shadow:inset 0 0 0 1px #f4dfb6,0 1px 1px #61462444}
body[data-chess-theme] .text-btn{background:var(--table-paper);border-color:var(--table-line)}
body[data-chess-theme] :is(.confirm-dialog,#exit-dialog){background:var(--table-paper);color:var(--table-text);border-color:var(--table-line)}
.piece-diagram svg,.five-examples svg{height:auto}
html[data-theme] body.unified-ui[data-chess-theme] .primary{background:var(--table-accent);color:var(--table-paper);border-color:var(--table-accent)}
html[data-theme] body.unified-ui[data-chess-theme] .setup-start-choice span{color:var(--table-muted)}
html[data-theme] body.unified-ui[data-chess-theme] :is(.secondary,.text-btn){background:var(--table-paper);color:var(--table-text);border-color:var(--table-line)}
html[data-theme] body.unified-ui[data-chess-theme] .back{background:transparent;color:var(--table-accent)}
html[data-theme] body.unified-ui[data-chess-theme] :is(.confirm-dialog,#exit-dialog){background:var(--table-paper);color:var(--table-text);border-color:var(--table-line)}
html[data-theme] body.unified-ui[data-chess-theme] .training-focus{border-color:var(--table-line)}
html[data-theme] body.unified-ui[data-chess-theme] .training-focus :is(strong,h2,p,.focus-caption,.focus-eyebrow){color:var(--table-muted)}
.chess-manual.manual-large .manual-scroll{font-size:21px}.chess-manual.manual-large .manual-index button{font-size:18px}
.chess-meta-help-wrap{display:flex;align-items:center;gap:8px}.chess-meta-help{font-size:14px;color:var(--table-accent);padding:8px 9px;min-height:40px;border:1px solid var(--table-line);border-radius:7px;background:var(--table-paper)}
html[data-theme] dialog.chess-manual{width:min(720px,calc(100vw - 24px));height:min(92dvh,1000px);max-height:calc(100dvh - 24px);max-width:none;padding:0;border:1px solid var(--table-line);border-radius:18px;background:var(--table-bg);color:var(--table-text);box-sizing:border-box;overflow:hidden}dialog.chess-manual[open]{display:flex;flex-direction:column}dialog.chess-manual::backdrop{background:#171b17a8}.manual-header{display:flex;align-items:center;gap:12px;flex:none;padding:14px 16px;border-bottom:1px solid var(--table-line);background:var(--table-paper)}.manual-header h2{font-family:var(--table-serif);font-size:21px;margin:0;flex:1;text-align:center}.manual-header .back{color:var(--table-accent);padding:8px 0;min-height:44px;font-size:17px}.manual-seal{border:1px solid var(--table-accent);color:var(--table-accent);font-family:var(--table-serif);font-size:20px;padding:2px 5px;border-radius:3px}.manual-scroll{overflow:auto;overscroll-behavior:contain;scrollbar-gutter:stable;padding:20px 22px 30px;min-height:0;line-height:1.9;font-size:18px}.manual-lead{color:var(--table-muted);margin:0 0 18px}.manual-index{display:grid;grid-template-columns:1fr 1fr;gap:8px}.manual-index button{background:var(--table-paper);color:var(--table-accent);border:1px solid var(--table-line);border-radius:8px;padding:10px 4px;font-size:16px;min-height:46px}.manual-section{padding:26px 0 18px;border-bottom:1px solid var(--table-line);scroll-margin-top:12px}.manual-number{display:block;color:var(--table-accent);font-size:14px;letter-spacing:.14em;font-weight:700}.manual-section h3{font-size:23px;margin:3px 0 14px;color:var(--table-text);font-family:var(--table-serif)}.manual-section p{margin:12px 0}.manual-section strong{color:var(--table-text)}.manual-steps{padding-left:24px;margin:12px 0}.manual-steps li{padding-left:5px;margin:15px 0}.manual-steps li::marker{color:var(--table-accent);font-weight:700}.manual-tip,.manual-rule-note{border-left:3px solid var(--table-accent);background:var(--table-soft);padding:14px 16px;border-radius:0 10px 10px 0;color:var(--table-text)}.manual-tip strong{display:block;margin-bottom:4px}.manual-rule-note h4{font-size:18px;margin:0}.manual-caption{font-size:14px;color:var(--table-muted)}.manual-terms{margin:16px 0}.manual-terms dt{font-size:19px;font-weight:700;color:var(--table-accent);margin:18px 0 5px}.manual-terms dd{margin:0}.manual-scroll>.primary{font-size:18px;margin-top:26px;min-height:52px;border-radius:10px}
.piece-picker{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:9px;margin:18px 0}.piece-picker button{display:flex;align-items:center;flex-direction:column;gap:6px;padding:10px 3px;border:1px solid var(--table-line);border-radius:10px;background:var(--table-paper);color:var(--table-text)}.piece-picker button[aria-pressed=true]{border-color:var(--table-accent);box-shadow:inset 0 0 0 1px var(--table-accent);background:var(--table-soft)}.piece-picker b{display:grid;place-items:center;width:36px;height:36px;border-radius:50%;background:#f0dab5;border:1px solid #9a4a36;color:#8b3025;font-family:'SimSun',serif;font-size:25px;line-height:1}.piece-picker span{font-size:13px}.manual-piece-content h3{font-size:26px}.manual-piece-content h3>span{display:block;font-family:system-ui,sans-serif;font-size:16px;font-weight:500;color:var(--table-muted);margin-top:4px}.lesson-diagrams{display:flex;justify-content:center;gap:15px;flex-wrap:wrap;margin:20px 0}.piece-diagram{margin:0;flex:1;min-width:150px;max-width:270px}.piece-diagram svg,.five-examples svg{display:block;width:100%;background:var(--wood);border:1px solid var(--wood-edge);border-radius:10px}.piece-diagram figcaption,.five-examples figcaption{font-size:14px;line-height:1.65;text-align:center;color:var(--table-muted);margin-top:10px}.lesson-grid{stroke:var(--wood-line);stroke-width:1;fill:none}.lesson-piece circle{fill:#f5dfb5;stroke:#923c2d;stroke-width:1.5}.lesson-piece text{fill:#923c2d;font-size:23px;text-anchor:middle;font-family:'SimSun',serif;font-weight:700}.lesson-piece.enemy circle{stroke:#332d26}.lesson-piece.enemy text{fill:#332d26}.lesson-dot{fill:#235e4a;stroke:#f7e6be;stroke-width:1.5}.lesson-capture{fill:none;stroke:#235e4a;stroke-width:3;stroke-dasharray:5 3}.lesson-blocked{stroke:#8b3025;stroke-width:3;fill:none}.lesson-river{fill:var(--wood)}.lesson-river-label{font-size:13px;fill:var(--wood-line);text-anchor:middle}.five-examples{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin:20px 0}.five-examples figure{margin:0}.lesson-go-black{fill:#242b25;stroke:#111810;stroke-width:1}.lesson-go-white{fill:#fffdf3;stroke:#7a786a;stroke-width:1}.lesson-five-line{stroke:#d4a44c;stroke-width:3;stroke-linecap:round}.large .manual-scroll{font-size:21px}.large .manual-index button{font-size:18px}
html[data-theme=dark] .chess-manual :is(.lesson-dot,.lesson-capture){stroke:#daedce}html[data-theme=dark] .chess-manual .lesson-blocked{stroke:#ffdfca}
@media(max-width:380px){body[data-chess-theme] .chess-intro h2{font-size:20px}.chess-intro .section-kicker{font-size:11px}.chess-intro p{font-size:13px}.chess-emblem{width:44px;height:54px;font-size:30px}.chess-manual-entry{padding:12px 10px;gap:9px}.chess-manual-entry strong{font-size:17px}.chess-manual-entry small{font-size:12px}.chess-preview{max-width:208px}.chess-player small{margin-left:4px;font-size:11px}.chess-player .player-piece{width:27px;height:27px}.chess-player strong{font-size:15px}body[data-chess-theme] .chess-play #play-panel{padding:6px}.chess-help-link span{display:block;margin:4px 0 0}.manual-header{padding:10px 12px;gap:8px}.manual-header h2{font-size:19px}.manual-scroll{padding:18px 16px 26px;font-size:17px}.manual-section h3{font-size:21px}.piece-picker{gap:6px}.piece-picker span{font-size:12px}.piece-diagram{min-width:140px}.five-examples{gap:10px}.chess-replay-controls{grid-template-columns:repeat(2,1fr)}}
.game-art.chess-cover{background:#d7b27c;background-image:none;isolation:isolate}
.game-art.chess-cover>svg{display:block;width:100%;height:100%;flex-shrink:0}
html[data-theme=dark] .game-art.chess-cover{background-image:none;filter:brightness(.82) saturate(.85)}
