:root{--game-accent:#5a2fb8;--game-stage-bg:#1a1230;--ch-night:#1a1230;--ch-deep:#0d0920;--ch-coral:#ff8a5b;--ch-mint:#5df2d6;--ch-gold:#ffd166;--ch-cream:#fff3cf;--ch-violet:#6c3bd1;--ch-light:#f1e3c3;--ch-dark:#6a4bb0}
.chess-page{background:radial-gradient(circle at 10% 0%,rgba(108,59,209,.12),transparent 26rem),radial-gradient(circle at 90% 4%,rgba(93,242,214,.12),transparent 24rem),#f6f3ee!important;overflow-x:hidden}
.chess-heading h1{letter-spacing:-.06em}
.chess-hud strong{font-variant-numeric:tabular-nums}
.chess-layout{display:grid;grid-template-columns:minmax(0,600px);justify-content:center;gap:1rem;align-items:start}
@media(min-width:900px){.chess-layout{grid-template-columns:minmax(320px,min(600px,calc(100vh - 15rem))) minmax(250px,320px)}}
.chess-play{min-width:0}
.chess-player{display:flex;align-items:center;justify-content:space-between;gap:.6rem;min-height:38px;padding:.25rem .2rem;color:var(--game-shell-muted);font:800 .78rem/1.2 var(--game-shell-body)}
.chess-player strong{display:inline-flex;align-items:center;gap:.45rem;color:var(--game-shell-ink);white-space:nowrap}
.chess-player strong::before{content:"";width:.6rem;height:.6rem;border-radius:50%;background:#d9d4db}
.chess-player.is-turn strong::before{background:var(--ch-mint);box-shadow:0 0 0 3px rgba(93,242,214,.3)}
.chess-captured{display:flex;flex-wrap:wrap;justify-content:flex-end;align-items:center;min-width:0}
.chess-captured__piece{display:inline-block;width:20px;height:20px;margin-left:-5px}
.chess-captured__piece svg{display:block;width:100%;height:100%}
.chess-captured__lead{margin-left:.35rem;color:var(--game-shell-ink);font:800 .75rem/1 var(--game-shell-mono)}
.chess-stage{border-color:#2d2050;box-shadow:0 22px 70px rgba(26,18,48,.24);padding:clamp(4px,1vw,8px);border-radius:16px}
.chess-board{display:grid;grid-template-rows:repeat(8,1fr);aspect-ratio:1;width:100%;border-radius:10px;overflow:hidden;-webkit-user-select:none;user-select:none;touch-action:manipulation}
.chess-row{display:grid;grid-template-columns:repeat(8,1fr);min-height:0}
.chess-square{position:relative;display:block;width:100%;height:100%;min-width:0;min-height:0;margin:0;padding:0;border:0;border-radius:0;background:var(--ch-light);cursor:pointer;touch-action:manipulation;-webkit-tap-highlight-color:transparent}
.chess-square.is-dark{background:var(--ch-dark)}
.chess-square.is-last{background:#f6cf74}
.chess-square.is-dark.is-last{background:#b88fc8}
.chess-square.is-selected{background:#a6f5e6}
.chess-square.is-dark.is-selected{background:#3fb8a8}
.chess-square.is-check{background:radial-gradient(circle,var(--ch-coral) 0 35%,rgba(255,138,91,.55) 55%,transparent 75%),var(--ch-light)}
.chess-square.is-dark.is-check{background:radial-gradient(circle,var(--ch-coral) 0 35%,rgba(255,138,91,.55) 55%,transparent 75%),var(--ch-dark)}
.chess-board .chess-square:focus,.chess-board .chess-square:focus-visible{outline:none!important}
.chess-board.is-keyboard:focus-within .chess-square.is-cursor::before{content:"";position:absolute;inset:0;z-index:3;box-shadow:inset 0 0 0 3px var(--ch-coral);pointer-events:none}
.chess-square.is-target::after{content:"";position:absolute;left:50%;top:50%;z-index:2;width:28%;height:28%;border-radius:50%;background:rgba(26,18,48,.38);transform:translate(-50%,-50%);pointer-events:none}
.chess-square.is-capture::after{content:"";position:absolute;inset:6%;z-index:2;border:4px solid rgba(26,18,48,.42);border-radius:50%;pointer-events:none}
.chess-piece{position:absolute;inset:4%;z-index:1;display:block;pointer-events:none}
.chess-piece svg{display:block;width:100%;height:100%;filter:drop-shadow(0 2px 0 rgba(13,9,32,.28))}
.chess-square.is-dragging .chess-piece{opacity:.25}
.chess-coord{position:absolute;z-index:1;font:800 clamp(.5rem,1.6vw,.7rem)/1 var(--game-shell-mono);pointer-events:none;color:var(--ch-dark)}
.chess-square.is-dark .chess-coord{color:var(--ch-light)}
.chess-coord--rank{top:3px;left:3px}
.chess-coord--file{right:3px;bottom:3px}
.chess-ghost{position:fixed;left:0;top:0;z-index:1000;pointer-events:none;filter:drop-shadow(0 8px 10px rgba(13,9,32,.35))}
.chess-ghost svg{display:block;width:100%;height:100%}
.chess-overlay{z-index:6;background:rgba(13,9,32,.6);padding:.6rem;border-radius:16px}
.chess-overlay>div{max-height:100%;overflow:auto;border-top:6px solid var(--ch-gold);padding:1rem 1.1rem}
.chess-overlay h2{font-size:clamp(1.5rem,4.5vw,2.4rem)}
.chess-overlay p{margin:.2rem 0 .6rem}
.chess-setup{display:grid;gap:.4rem;margin:.3rem 0 .6rem;text-align:left}
.chess-setup fieldset{display:flex;flex-wrap:wrap;gap:.35rem;margin:0;padding:0;border:0}
.chess-setup fieldset[hidden]{display:none}
.chess-setup legend{width:100%;margin-bottom:.2rem;color:var(--game-shell-muted);font:800 .64rem/1.2 var(--game-shell-mono);letter-spacing:.08em;text-transform:uppercase}
.chess-setup label{flex:1 1 0;min-width:0}
.chess-setup input{position:absolute;opacity:0;pointer-events:none}
.chess-setup label span{display:flex;align-items:center;justify-content:center;min-height:44px;padding:.4rem .5rem;border:1px solid #cfc7dc;border-radius:12px;background:#fff;color:var(--game-shell-ink);font:800 .82rem/1.1 var(--game-shell-body);text-align:center;cursor:pointer}
.chess-setup input:checked+span{border-color:var(--ch-night);background:var(--ch-night);color:var(--ch-cream)}
.chess-setup input:focus-visible+span{outline:3px solid var(--ch-coral);outline-offset:2px}
.chess-overlay__actions{display:flex;flex-wrap:wrap;justify-content:center;gap:.5rem}
.chess-overlay .chess-quiet{background:#fff;color:var(--game-shell-ink);border:1px solid var(--game-shell-ink)}
.chess-promotion{position:absolute;inset:0;z-index:5;display:grid;place-items:center;background:rgba(13,9,32,.5)}
.chess-promotion[hidden]{display:none}
.chess-promotion>div{padding:.9rem;border-radius:18px;background:#fff;border-top:6px solid var(--ch-mint);text-align:center;box-shadow:0 20px 60px rgba(0,0,0,.3)}
.chess-promotion p{margin:0 0 .5rem;color:var(--game-shell-ink);font:800 1rem/1.2 var(--game-shell-display)}
.chess-promotion__choices{display:grid;grid-template-columns:repeat(4,64px);gap:.4rem}
.chess-promotion__choices button{display:grid;justify-items:center;gap:.1rem;min-height:72px;padding:.3rem;border:1px solid #cfc7dc;border-radius:12px;background:var(--ch-light);cursor:pointer;font:800 .62rem/1 var(--game-shell-mono);text-transform:uppercase;color:var(--ch-night)}
.chess-promotion__choices button svg{width:44px;height:44px}
.chess-promotion__choices button:focus-visible,.chess-promotion__choices button:hover{outline:3px solid var(--ch-coral);outline-offset:1px}
.chess-promotion__cancel{margin-top:.6rem;min-height:44px;padding:.5rem 1rem;border:1px solid var(--game-shell-ink);border-radius:999px;background:#fff;font:800 .8rem/1 var(--game-shell-body);cursor:pointer}
.chess-panel{min-width:0;padding:1rem;border:1px solid var(--game-shell-border);border-radius:18px;background:#fff;box-shadow:0 16px 42px rgba(20,18,24,.07)}
@media(min-width:900px){.chess-panel{margin-top:38px}}
.chess-status{min-height:2.6em;margin:0 0 .8rem;padding:.6rem .75rem;border-left:4px solid var(--ch-mint);border-radius:8px;background:#f4f0fb;color:var(--game-shell-ink);font:800 .95rem/1.3 var(--game-shell-display)}
.chess-buttons{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:.45rem}
.chess-buttons button{min-height:48px;padding:.5rem .4rem;border:1px solid var(--game-shell-ink);border-radius:14px;background:#fff;color:var(--game-shell-ink);font:800 .8rem/1.1 var(--game-shell-body);cursor:pointer;touch-action:manipulation}
.chess-buttons button:hover:not(:disabled){background:var(--ch-night);color:var(--ch-cream)}
.chess-buttons button:disabled{opacity:.4;cursor:default}
.chess-buttons button:focus-visible{outline:3px solid var(--ch-coral);outline-offset:2px}
.chess-moves-title{margin:1rem 0 .4rem;color:var(--game-shell-muted);font:800 .66rem/1.2 var(--game-shell-mono);letter-spacing:.08em;text-transform:uppercase}
.chess-moves{max-height:min(46vh,420px);margin:0;padding:0;overflow-y:auto;list-style:none;font:700 .86rem/1.2 var(--game-shell-mono)}
.chess-moves li{display:grid;grid-template-columns:2.6rem 1fr 1fr;gap:.3rem;padding:.3rem .4rem;border-radius:6px}
.chess-moves li:nth-child(odd){background:#f7f4fb}
.chess-moves li span:first-child{color:var(--game-shell-muted)}
.chess-moves li.is-current{box-shadow:inset 3px 0 0 var(--ch-gold)}
.chess-moves .chess-moves__empty{display:block;color:var(--game-shell-muted);background:none}
.chess-howto{width:min(100%,720px);margin:1rem auto 0;padding:.9rem 1rem;border:1px solid var(--game-shell-border);border-radius:14px;background:#fff;color:var(--game-shell-muted);font-size:.9rem;line-height:1.55}
.chess-howto h2{margin:0 0 .35rem;color:var(--game-shell-ink);font:800 1rem/1.2 var(--game-shell-display)}
.chess-howto p{margin:0}
@media(max-width:899px){.chess-layout{grid-template-columns:minmax(0,600px)}.chess-moves{max-height:200px}}
@media(max-width:520px){.chess-hud{grid-template-columns:repeat(5,minmax(0,1fr))!important}.chess-hud>div{padding:.45rem .2rem}.chess-hud span{font-size:.52rem}.chess-hud strong{font-size:.8rem}.chess-stage{padding:3px;border-radius:12px}.chess-board{border-radius:8px}.chess-promotion__choices{grid-template-columns:repeat(4,58px)}.chess-overlay>div{padding:.7rem .8rem}.chess-overlay h2{margin-bottom:.3rem}.chess-setup label span{min-height:40px}}
@media(prefers-reduced-motion:reduce){.chess-ghost{filter:none}}
