:root {
  color-scheme:light;
  --paper:#f6f2e9; --ink:#1c293a; --muted:#5f6769; --rule:#cec9bb;
  --teal:#234f50; --brass:#a07b46; --red:#a34536;
  --dark-square:#62837e; --light-square:#e6ddc4;
  --text:"Microsoft YaHei UI","PingFang SC",system-ui,sans-serif;
  --serif:Georgia,"STSong","Songti SC","SimSun",serif;
  color:var(--ink); background:var(--paper); font-family:var(--text);
}
* {box-sizing:border-box}
body {margin:0;min-height:100vh}
h1,h2,p,ol {margin:0}
a {color:inherit;text-decoration:none}
button {font:inherit;color:inherit;cursor:pointer}
button:disabled {cursor:default}
[hidden] {display:none!important}
a:focus-visible,button:focus-visible {outline:3px solid var(--red);outline-offset:3px}
.wrap {width:min(1120px,calc(100% - 72px));margin-inline:auto}
.skip {position:fixed;top:-65px;left:12px;background:var(--paper);z-index:5;padding:10px}
.skip:focus {top:8px}
.mast-inner {display:flex;align-items:stretch;gap:clamp(22px,5vw,66px);min-height:60px}
.brand,.mast nav,.mast nav a {display:flex;align-items:center}
.brand {gap:10px;font:bold 1.7rem/1 var(--serif);white-space:nowrap}
.brand-mark {display:grid;grid-template:repeat(2,8px)/repeat(2,8px);gap:2px}
.brand-mark i {border-radius:50%;background:currentColor}
.mast nav {gap:22px}
.mast nav a {align-self:stretch;white-space:nowrap}
.page-head {display:flex;align-items:center;justify-content:space-between;gap:16px;margin:clamp(15px,2.9vh,30px) 0 12px;padding-bottom:14px;border-bottom:1px solid var(--rule)}
h1 {display:flex;align-items:baseline;gap:.25em;font:700 clamp(2.2rem,3.8vw,3.65rem)/1.08 var(--serif);letter-spacing:-.065em}
h1 span {font:500 .43em/1.1 var(--serif);letter-spacing:.04em;color:#626c70;white-space:nowrap}
.mode-picker {display:inline-flex;flex:none;gap:3px;padding:3px;border:1px solid #c9c5b8;border-radius:7px;background:#eae6db}
.mode-picker button {min-height:36px;padding:6px 16px;border:0;border-radius:4px;color:#596163;background:transparent;font-size:.85rem;font-weight:600}
.mode-picker [aria-pressed=true] {color:#fff9eb;background:var(--ink);box-shadow:0 1px 3px #15233220}
.mode-picker button[aria-pressed=false]:hover {background:#f6f3eb;color:var(--ink)}
.desk {display:grid;grid-template-columns:minmax(0,min(60%,max(382px,calc(100svh - 268px)),660px)) minmax(272px,1fr);align-items:start;gap:clamp(25px,4vw,56px);padding-bottom:32px}
.table,.analysis {min-width:0}
.seat {min-height:40px;display:flex;align-items:center;gap:8px;font-size:.82rem}
.seat strong {font-size:.83rem;color:var(--ink)}
.seat-symbol {display:grid;place-items:center;width:27px;aspect-ratio:1;border-radius:50%;box-shadow:inset 0 0 0 1px #c4b9a4;background:#e5ddc9}
#white-seat .seat-symbol {background:#4b6262;box-shadow:inset 0 0 0 1px #354d50}
.seat .piece {width:86%;height:86%}
.seat-name {color:var(--muted);border-left:1px solid var(--rule);padding-left:9px}
.seat-turn {margin-left:auto;color:var(--teal);font-size:.75rem;font-weight:650}
.seat-turn:not(:empty)::before {content:"";display:inline-block;margin-right:6px;width:5px;height:5px;background:var(--red);border-radius:50%;vertical-align:2px}
.board-frame {
  --rim:clamp(12px,1.45vw,20px);
  border-radius:4px;border:1px solid #222e32;padding:var(--rim);
  background:repeating-linear-gradient(105deg,transparent 0 3px,#e9d6ac06 4px,transparent 5px 11px),
    linear-gradient(138deg,#50524a,#293638 43%,#293638 65%,#434744);
  box-shadow:inset 0 0 0 2px #3d4744,inset 0 0 0 3px #b6a47b85,0 3px 0 #333c37,0 10px 20px -10px #142a2a73;
}
#board {display:grid;grid-template:repeat(8,minmax(0,1fr))/repeat(8,minmax(0,1fr));aspect-ratio:1;isolation:isolate;container-type:inline-size;box-shadow:0 0 0 1px #b7a479,0 0 0 3px #263034}
.square {position:relative;display:grid;place-items:center;min-width:0;min-height:0;border:0;border-radius:0;padding:0;background-color:var(--light-square);background-image:linear-gradient(125deg,#fff5cf17,#433c2e05);touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.square.dark {background-color:var(--dark-square);background-image:linear-gradient(128deg,#e5e1bb10,#1731320d)}
.square.last {background-color:#e9d191}.square.dark.last {background-color:#a5aa77}
.square.selected,.square.dark.selected {background-color:#d9b670;box-shadow:inset 0 0 0 3px #a36630}
.square.check,.square.dark.check {background:radial-gradient(ellipse,#e3b29c 15%,#be6856 100%)}
.square.target::after {content:"";position:absolute;width:22%;height:22%;border-radius:50%;background:#244c4be0;box-shadow:0 0 0 1px #fbf0d490;pointer-events:none}
.square.capture::after {width:auto;height:auto;inset:4%;border:3px solid #87472e;background:transparent;box-shadow:inset 0 0 0 1px #f1dcbc}
.square:focus-visible {outline:2px dashed #172e37;outline-offset:-5px;z-index:2}
.square[draggable=true] {cursor:grab;user-select:none}
.square.drop-target {outline:3px solid #244c4b;outline-offset:-3px}
@media(hover:hover) {.square:not(.selected,[aria-disabled=true]):hover {box-shadow:inset 0 0 0 2px #193c4080}}
.piece {width:91%;height:91%;min-width:0;min-height:0;pointer-events:none}
.coordinate {position:absolute;color:#f8edcf;font:600 clamp(9px,1.65cqw,12px)/1 Consolas,monospace;pointer-events:none}
.rank-coordinate {right:100%;width:var(--rim);top:50%;transform:translateY(-50%);text-align:center}
.file-coordinate {top:100%;left:50%;height:var(--rim);display:flex;align-items:center;transform:translateX(-50%)}
.analysis {margin-top:40px;border:1px solid #cec8b9;border-top:0;border-radius:3px;background:#fbf8ee;box-shadow:0 3px 0 -1px #f2eddf,0 4px 0 -1px #cfc7b5}
.position {position:relative;isolation:isolate;overflow:hidden;padding:20px clamp(18px,2vw,28px) 22px;color:#faf6e9;border-radius:3px 3px 0 0;background:linear-gradient(110deg,#1b2938,#253c43 90%);border-bottom:2px solid #ab8a55}
.position::after {content:"";position:absolute;inset:0 0 0 47%;z-index:-1;background:repeating-conic-gradient(#ddc99411 0 25%,transparent 0 50%) 0 0 / 40px 40px;mask-image:linear-gradient(90deg,transparent,#000);pointer-events:none}
.position-top,.sheet-title {display:flex;align-items:center;justify-content:space-between;gap:8px}
.position-top h2 {font-size:.81rem;font-weight:550;letter-spacing:.08em;color:#ead4a6}
.position-top button {border:1px solid #76817c;border-radius:3px;background:transparent;padding:4px 9px;color:#f4efdf;font-size:.76rem;min-height:30px}
.position-top button:hover:not(:disabled) {background:#ffffff18}.position-top button:disabled {color:#cbd0c8;border-color:#637174}
#turn-status {font:700 clamp(1.65rem,2.4vw,2.35rem)/1.22 var(--serif);margin:10px 0 5px;letter-spacing:-.015em}
#move-hint {max-width:33em;font-size:.85rem;line-height:1.55;color:#e2e7de}
.sheet {padding:0 clamp(16px,2vw,27px)}
.sheet-title {padding:18px 0 12px}
.sheet-title h2,dialog h2 {font:700 1.4rem/1.2 var(--serif)}
#move-count {font:600 .82rem/1.3 Consolas,"Microsoft YaHei UI",sans-serif;color:#5f665f;font-variant-numeric:tabular-nums}
.sheet-header,.sheet li {display:grid;grid-template-columns:minmax(44px,.67fr) 1fr 1fr;align-items:center}
.sheet-header {color:#4f5959;font-size:.76rem;font-weight:650;border-block:1px solid #c4c0b2;background:#eeeade}
.sheet-header span,.sheet li .round {padding:7px 9px}
.sheet-scroll {position:relative;min-height:109px;max-height:clamp(150px,28vh,295px);overflow:auto;scrollbar-width:thin;background:repeating-linear-gradient(to bottom,transparent 0 35px,#d1caba 35px 36px)}
#moves {padding:0;list-style:none}
.sheet li {min-height:36px;border-bottom:1px solid #d1caba;background:#fbf8ee;font-family:Consolas,"Courier New",monospace}
.sheet li .round {font-size:.82rem;color:var(--muted)}
.sheet li button {border:0;background:transparent;text-align:left;padding:6px 9px;min-width:0;min-height:35px;color:var(--ink);font-weight:650}
.sheet li button:hover,.sheet li button:focus-visible {text-decoration:underline}
.sheet li [aria-current=step] {background:#dfe7de;color:#1f4749;box-shadow:inset 3px 0 #427069}
#empty-moves {width:fit-content;background:#fbf8ee;color:var(--muted);line-height:1.5;font-size:.83rem;padding:8px 9px 7px}
.replay {display:flex;gap:7px;flex-wrap:wrap;padding:15px 0 0;border-top:1px solid var(--rule)}
.replay button,dialog button {border:1px solid #a9b0a7;border-radius:4px;background:#fbf8ee;padding:7px 10px;color:var(--teal);font-size:.8rem;font-weight:600;min-height:36px}
.replay button:disabled {border-color:#d1cabc;color:#6a6d67;background:transparent}
.replay button:not(:disabled):hover,dialog button:hover {background:#e4e9df}
#live {margin-left:auto}
.save-note {margin:13px clamp(16px,2vw,27px) 16px;color:var(--muted);font-size:.76rem;line-height:1.6}
dialog {width:min(378px,calc(100% - 30px));padding:22px;border:1px solid var(--ink);border-top:3px solid var(--brass);border-radius:4px;background:var(--paper);color:var(--ink);box-shadow:0 15px 60px #10242d55}
dialog::backdrop {background:#13242cb0}
dialog p {margin:8px 0 18px;color:var(--muted);font-size:.9rem;line-height:1.65}
.dialog-actions,.promotion-options {display:flex;gap:8px}
.promotion-options button {flex:1;min-width:0;background:#e9e4d5}
.promotion-options canvas {display:block;width:44px;height:44px;max-width:100%;margin:auto}
dialog .muted-button {margin-top:16px}.dialog-actions {justify-content:flex-end}
dialog .solid-button {color:#fffaf0;background:var(--teal)}dialog .solid-button:hover {background:#173c39}
@media(min-width:881px) and (max-height:770px) {
  main.wrap {max-width:1040px}
  .desk {grid-template-columns:minmax(0,min(58%,max(370px,calc(100svh - 222px)))) minmax(260px,1fr)}
  .page-head {margin:12px 0 7px;padding-bottom:10px}
  h1 {font-size:clamp(2.1rem,3.45vw,3.05rem)}
  .seat {min-height:33px}.analysis {margin-top:33px}
}
@media(max-width:880px) {
  .wrap {width:min(580px,calc(100% - 28px))}
  .desk {display:block}
  .page-head {margin:17px 0 4px;padding-bottom:10px}
  .mode-picker button {padding:6px 10px}
  .analysis {margin-top:12px}
  .position {padding:13px 16px 15px}
  .sheet {padding:0 15px}.sheet-title {padding:14px 0 10px}
  .sheet-scroll {min-height:73px;max-height:215px}
  .seat {min-height:36px}.seat-symbol {width:24px}
  .replay button,.sheet li button {min-height:40px}
}
@media(max-width:475px) {
  .mast-inner {min-height:50px;gap:14px}.mast nav {gap:12px}.mast nav a {font-size:.76rem}
  .brand {font-size:1.4rem;gap:7px}.brand-mark {grid-template:repeat(2,6px)/repeat(2,6px)}
  .wrap {width:calc(100% - 24px)}
  h1 {font-size:clamp(1.55rem,7.4vw,2rem)}
  .page-head {gap:5px}
  .mode-picker {gap:1px;padding:2px}
  .mode-picker button {font-size:.75rem;min-height:34px;padding:4px 8px}
  .board-frame {--rim:13px}
  .replay {gap:5px}.replay button {padding-inline:8px}
}
@media(max-width:350px) {
  .wrap {width:calc(100% - 18px)}
  .mode-picker button {padding-inline:6px}
  .board-frame {--rim:12px}
}
