@font-face{font-family:Story;src:url('./assets/story-heading.ttf') format('truetype');font-display:swap}
:root{--paper:#fff5dd;--canvas:#f4ead6;--ink:#3d3024;--muted:#75624d;--green:#285b46;--line:#d6c5a5;--gold:#b68a42;--light-square:#f4e5bf;--dark-square:#729180;color:var(--ink);font-family:'PingFang SC','Microsoft YaHei',sans-serif;background:var(--canvas);font-synthesis:none}
*{box-sizing:border-box}body{margin:0}button,a,input,select{-webkit-tap-highlight-color:transparent}button,select{font:inherit;color:inherit}button{cursor:pointer;min-height:44px;border:1px solid var(--line);border-radius:10px;background:#fff9ed;padding:10px 17px;transition:background .18s,transform .18s}button:hover:not(:disabled){background:#e9dfc8}button:active:not(:disabled){transform:translateY(1px)}button:disabled{opacity:.45;cursor:default}button:focus-visible,a:focus-visible,select:focus-visible,input:focus-visible{outline:3px solid #226496;outline-offset:3px}::selection{background:#cadcc5;color:#213a2f}svg{width:22px;height:22px;fill:none;stroke:currentColor;stroke-width:1.7;stroke-linecap:round;stroke-linejoin:round}h1,h2,h3,p{margin:0}h1,h2{font-family:Story,serif;font-weight:400;text-wrap:balance}p{line-height:1.7}a{color:inherit;text-decoration:none}small{display:block}button.primary{background:var(--green);color:#fff9e9;border-color:var(--green)}button.primary:hover{background:#1b4433}.masthead{height:88px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;max-width:1224px;margin:auto;padding:0 24px}.brand{display:flex;align-items:center;gap:12px;font-family:Story,serif;font-size:23px;color:var(--green)}.brand>svg{width:37px;height:37px;stroke-width:1.4}.brand-sub{display:block;font:11px/1.8 'PingFang SC',sans-serif;color:var(--muted);letter-spacing:.12em}.header-actions{display:flex;align-items:center;gap:18px;font-size:12px;color:var(--muted)}.icon-button{padding:8px;display:grid;place-items:center;min-width:44px;border:0;background:transparent;font-size:26px}.header-actions .icon-button{border:1px solid var(--line)}main{max-width:1180px;margin:auto;padding:32px 24px 0}.title-row{display:flex;justify-content:space-between;align-items:center;gap:24px;margin-bottom:26px}h1{font-size:38px;line-height:1.2}h1 span{font-size:18px;color:var(--muted);margin-left:16px}.subtitle{font-size:13px;color:var(--muted);margin-top:10px}.mode-nav{display:flex;border-bottom:1px solid var(--line);gap:6px;align-self:end}.mode-nav button{border:0;border-radius:0;background:none;padding:13px 18px;font-size:14px}.mode-nav button.active{border-bottom:3px solid var(--green);color:var(--green);font-weight:700}.game-layout{display:grid;grid-template-columns:minmax(0,650px) minmax(260px,1fr);gap:50px;align-items:start}.play-area{min-width:0}.player-row{display:flex;align-items:center;gap:12px;min-height:66px;padding:4px 6px 12px}.player-row strong{font-size:15px;display:block}.player-row strong span{font-size:12px;font-weight:400;color:var(--muted);margin-left:8px}.avatar{width:44px;height:44px;border-radius:50%;overflow:hidden;border:1px solid #ccb486;background:#e3d9eb;flex-shrink:0}.avatar.sun{background:#f0d7a3}.avatar img{width:100%;height:130%;object-fit:cover;object-position:top}.difficulty-label{margin-left:auto;display:flex;gap:8px;align-items:center;font-size:12px;color:var(--muted)}select{background:#fff8e8;border:1px solid var(--line);padding:9px 25px 9px 10px;border-radius:8px;min-height:44px}.board-frame{--frame-edge:24px;padding:var(--frame-edge);background:#6b4a30;border-radius:10px;box-shadow:0 12px 25px #49311e24;position:relative}.board{display:grid;grid-template-columns:repeat(8,1fr);aspect-ratio:1;border:2px solid #493822;touch-action:manipulation}.square{position:relative;min-width:0;min-height:0;padding:0;border:0;border-radius:0;background:var(--light-square);aspect-ratio:1;isolation:isolate;display:grid;place-items:center}.square.dark{background:var(--dark-square)}.square:hover:not(:disabled){background:#ded3a8}.square.dark:hover:not(:disabled){background:#8fa18a}.square:active:not(:disabled){transform:none}.square img{height:91%;width:91%;object-fit:contain;user-select:none;pointer-events:none;filter:drop-shadow(0 2px 1px #24150d35);z-index:1}.square.selected{box-shadow:inset 0 0 0 4px #e5b342;background:#ead58f}.square.last-move:not(.selected){background:#d9d38d}.square.dark.last-move:not(.selected){background:#9aa96a}.square.hint{box-shadow:inset 0 0 0 4px #17708b}.square.check{background:#e8a28a}.square.legal::after{content:'';position:absolute;width:23%;height:23%;border-radius:50%;background:#244e40a8;z-index:3;pointer-events:none}.square.capture::after{width:86%;height:86%;background:none;border:3px solid #bf542d}.square:focus-visible{outline:3px solid #145675;outline-offset:-3px;z-index:4}.piece-label{position:absolute;bottom:2px;right:2px;z-index:2;font-size:10px;line-height:15px;min-width:15px;border-radius:3px;text-align:center;background:#fffaeae8;color:#543e26;pointer-events:none}.square.black-piece .piece-label{background:#43394ee8;color:#fff7e4}.human{padding:15px 6px 8px}.turn-indicator{margin-left:auto;font-size:12px;color:var(--green);display:flex;align-items:center;gap:7px}.turn-indicator::before{content:'';width:7px;height:7px;border-radius:50%;background:currentColor}.captured{display:flex;align-items:center;min-height:13px;margin-top:3px;font-size:11px;color:var(--muted);gap:3px}.captured img{height:22px;width:19px;object-fit:contain}.board-tools{display:flex;justify-content:center;gap:12px;padding:16px 0 0}.board-tools button{display:flex;align-items:center;justify-content:center;gap:8px;flex:1;font-size:13px;background:transparent}.board-tools button svg{width:18px;height:18px}.coach-panel{padding-top:13px;min-width:0}.chapter-marker{display:flex;justify-content:space-between;font-size:12px;color:var(--muted);border-block:1px solid var(--line);padding:12px 0;margin-bottom:25px}.coach-panel h2{font-size:28px;margin-bottom:12px;line-height:1.35}.coach-panel>p{font-size:14px;min-height:72px;max-width:32em}.character-stage{height:270px;position:relative;display:flex;align-items:center;justify-content:center;margin-top:12px}.character-stage>img{height:245px;max-width:94%;object-fit:contain;z-index:1;filter:drop-shadow(0 12px 9px #66481b1c);animation:arrival .55s ease-out}.stage-orbit{position:absolute;bottom:26px;left:18%;right:18%;height:24px;background:#d7c4a465;border-radius:50%}.character-caption{position:absolute;bottom:-9px;left:0;right:0;text-align:center;color:var(--muted);font-size:11px}.piece-notes{border-top:1px solid var(--line);margin-top:33px;padding-top:16px}.piece-title{display:flex;justify-content:space-between;align-items:center;gap:8px}.piece-title h3{font-size:15px;font-weight:600}.text-button{border:0;background:none;padding:5px 0;color:var(--green);font-size:12px;text-decoration:underline;text-underline-offset:4px}.piece-notes p{font-size:13px;color:var(--muted);margin-top:2px}.practice-note{display:flex;gap:12px;align-items:center;margin-top:24px;color:var(--muted);font-size:12px}.practice-note svg{width:26px;height:26px;color:#96702d;flex-shrink:0}.lesson-actions{display:flex;gap:10px;margin-top:20px}.lesson-actions button{flex:1}.journey{padding:20px 0 27px;border-top:1px solid var(--line);margin-bottom:24px;border-bottom:1px solid var(--line)}.journey-heading{display:flex;justify-content:space-between;align-items:center;margin-bottom:18px}.journey h2{font-size:24px}.journey p{font-size:13px;color:var(--muted);margin-top:5px}.journey-heading>span{font-size:13px;color:var(--green)}.lesson-list{display:grid;grid-template-columns:repeat(4,1fr);gap:0 24px}.lesson-list button{border:0;border-bottom:1px solid var(--line);border-radius:0;background:none;text-align:left;display:flex;align-items:center;gap:12px;padding:13px 0;font-size:13px}.lesson-list .lesson-number{font-family:Story,serif;font-size:20px;color:var(--muted);width:22px}.lesson-list button.completed .lesson-number{color:var(--green)}.lesson-list button.current{font-weight:bold;color:var(--green)}.lesson-list .lesson-done{margin-left:auto;font-size:11px;color:var(--green)}footer{border-top:1px solid var(--line);margin-top:32px;display:flex;justify-content:space-between;gap:12px;padding:20px 0 24px;color:var(--muted);font-size:11px}dialog{border:1px solid var(--line);background:var(--paper);color:var(--ink);border-radius:16px;padding:28px;max-width:min(580px,calc(100vw - 28px));max-height:85dvh;overflow:auto;box-shadow:0 24px 80px #30241340}dialog::backdrop{background:#253b3280}dialog h2{font-size:28px}dialog p{font-size:14px;margin-block:12px}.dialog-heading{display:flex;align-items:center;justify-content:space-between;gap:20px;margin-bottom:16px}.setting-row{display:flex;align-items:center;justify-content:space-between;gap:30px;padding:17px 0;border-bottom:1px solid var(--line);font-size:15px}.setting-row small{font-size:12px;color:var(--muted);margin-top:7px}.setting-row input{accent-color:var(--green);width:22px;height:22px;flex-shrink:0}.dialog-note{color:var(--muted);font-size:12px!important;line-height:1.8}.dialog-buttons{display:flex;gap:12px;justify-content:end;margin-top:24px}.promotion-options{display:flex;gap:10px;margin:20px 0}.promotion-options button{padding:10px;flex:1}.promotion-options img{width:100%;height:90px;object-fit:contain;display:block}.guide-list{display:grid;grid-template-columns:1fr 1fr;gap:10px 24px}.guide-entry{display:flex;align-items:center;gap:12px;padding:12px 0;border-bottom:1px solid var(--line)}.guide-entry img{width:65px;height:90px;object-fit:contain}.guide-entry h3{font-size:15px}.guide-entry p{font-size:12px;margin:5px 0;color:var(--muted)}[hidden]{display:none!important}@keyframes arrival{from{transform:translateY(7px);opacity:.6}to{transform:translateY(0);opacity:1}}
@media(min-width:1200px){.game-layout{grid-template-columns:minmax(0,610px) minmax(260px,1fr);gap:66px}.coach-panel{padding-inline:10px 22px}.character-stage{height:285px}.character-stage>img{height:265px}}
@media(max-width:900px){main{padding:25px 20px 0}.game-layout{gap:25px;grid-template-columns:minmax(0,1fr) 260px}h1{font-size:30px}h1 span{display:none}.mode-nav button{padding:12px;font-size:13px}.character-stage{height:220px}.character-stage>img{height:205px}.coach-panel h2{font-size:24px}.board-frame{--frame-edge:20px}.player-row strong span{display:block;margin:3px 0 0}.difficulty-label{gap:4px}.player-row{gap:8px}.board-tools{gap:7px}.board-tools button{padding:10px 6px;font-size:12px}.coach-panel>p{font-size:13px}.lesson-list{grid-template-columns:repeat(3,1fr)}}
@media(max-width:680px){.masthead{height:70px;padding:0 18px}.brand{font-size:20px;gap:8px}.brand>svg{width:28px;height:28px}.brand-sub{font-size:9px}.header-actions{gap:7px;font-size:10px}main{padding:23px 12px 0}.title-row{display:block;margin-bottom:16px;padding:0 5px}h1{font-size:31px}.subtitle{font-size:12px;margin-top:7px}.mode-nav{margin-top:17px;justify-content:space-between}.mode-nav button{flex:1;padding:11px 6px;font-size:13px}.game-layout{display:flex;flex-direction:column;gap:17px}.play-area{width:100%}.player-row{padding-inline:4px;min-height:57px}.player-row strong span{display:inline;margin-left:6px;font-size:11px}.avatar{height:36px;width:36px}.player-row strong{font-size:13px}.board-frame{--frame-edge:20px;border-radius:7px}.piece-label{font-size:9px;line-height:13px;min-width:13px;bottom:1px;right:1px}.square img{width:94%;height:94%}.human{padding-top:12px}.board-tools{padding-top:8px;gap:8px}.board-tools button{font-size:12px;gap:6px}.coach-panel{padding:18px 8px 0;border-top:1px solid var(--line);width:100%;display:grid;grid-template-columns:minmax(0,1fr) 100px;column-gap:12px}.chapter-marker{grid-column:1/-1;margin-bottom:13px;padding:0;border:0;font-size:11px}.coach-panel h2{font-size:23px;margin-bottom:8px;grid-column:1}.coach-panel>p{grid-column:1;font-size:13px;min-height:0}.character-stage{grid-column:2;grid-row:2/4;height:120px;margin:0;align-self:center}.character-stage>img{height:120px;max-width:100%}.character-caption,.stage-orbit{display:none}.piece-notes{grid-column:1/-1;margin-top:17px;padding-top:7px}.practice-note{grid-column:1/-1;margin-top:14px;font-size:11px}.practice-note br{display:none}.lesson-actions{grid-column:1/-1;margin-top:15px}.lesson-list{grid-template-columns:1fr 1fr;gap:0 15px}.lesson-list button{font-size:12px;gap:8px}.journey{padding:15px 5px 20px}.journey h2{font-size:22px}.journey p{font-size:12px;max-width:21em}.journey-heading>span{white-space:nowrap;font-size:12px}.journey-heading{gap:10px}footer{margin-top:24px;font-size:10px;padding:16px 4px;flex-wrap:wrap}dialog{padding:22px}.guide-list{grid-template-columns:1fr}.guide-entry img{height:76px}.setting-row{gap:16px}.dialog-buttons button{flex:1}}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none!important;transition:none!important;scroll-behavior:auto!important}}

/* Moving pieces live above the board until the computer's move lands. */
.square.piece-in-flight>img,.square.piece-in-flight>.piece-label{visibility:hidden}
.computer-moving-piece{position:absolute;z-index:8;object-fit:contain;pointer-events:none;user-select:none;filter:drop-shadow(0 4px 3px #24150d40);will-change:transform}

/* Coordinates align with square centers, on the wooden frame only. */
.board-ranks,.board-files{position:absolute;display:grid;color:#fff5dd;font-size:12px;font-weight:600;line-height:1;pointer-events:none;user-select:none}
.board-ranks{left:0;width:var(--frame-edge);top:calc(var(--frame-edge) + 2px);bottom:calc(var(--frame-edge) + 2px);grid-template-rows:repeat(8,1fr)}
.board-files{bottom:0;height:var(--frame-edge);left:calc(var(--frame-edge) + 2px);right:calc(var(--frame-edge) + 2px);grid-template-columns:repeat(8,1fr)}
.board-ranks span,.board-files span{display:grid;place-items:center}
