:root{--chess-ahead-ink:#1c6849;--chess-behind-ink:#ad352d}
:root[data-theme="dark"]{--chess-ahead-ink:#70d3ad;--chess-behind-ink:#ff9d8f}
/* Rounded, illustrated pieces remain clear on either board color without paint servers. */
.piece-svg{--piece-fill:#fff1d4;--piece-edge:#4a392e;--piece-detail:#87674f;--piece-halo:#382b25;--piece-cheek:#e9a18e;display:block;position:relative;z-index:2;width:94%;height:94%;overflow:visible;pointer-events:none;filter:drop-shadow(0 2px 1px #0005) drop-shadow(0 4px 3px #0002)}
.piece-svg.is-black{--piece-fill:#30485c;--piece-edge:#102333;--piece-detail:#f5f8fb;--piece-halo:#fff5dd;--piece-cheek:#88a7bc;filter:drop-shadow(0 2px 1px #0008) drop-shadow(0 4px 3px #0005)}
.piece-svg g{stroke-linecap:round;stroke-linejoin:round}.piece-svg .piece-halo{fill:var(--piece-fill);stroke:var(--piece-halo);stroke-width:5}.piece-svg .piece-body{fill:var(--piece-fill);stroke:var(--piece-edge);stroke-width:2.5}.piece-svg .piece-detail{fill:none;stroke:var(--piece-detail);stroke-width:2.15}.piece-svg .piece-eye{fill:var(--piece-detail);stroke:none}.piece-svg .piece-cheek{fill:var(--piece-cheek);stroke:none;opacity:.7}.piece-svg .piece-smile{stroke-width:1.75}

/* Shared by live and offline boards: the contrast flips with the square. */
.square.is-legal::before,
.practice-chess-board > button.is-legal::before { position:absolute; z-index:1; width:20%; aspect-ratio:1; border:2px solid rgba(255,255,255,.58); border-radius:50%; background:rgba(19,27,39,.64); box-shadow:0 1px 2px rgba(0,0,0,.38); content:""; pointer-events:none; }
.square.is-dark.is-legal::before,
.practice-chess-board > button.is-dark.is-legal::before { border-color:rgba(15,25,37,.52); background:rgba(255,255,255,.76); box-shadow:0 1px 2px rgba(0,0,0,.28); }
.square.is-legal.is-capture::before,
.practice-chess-board > button.is-legal.is-capture::before { width:76%; border:clamp(3px,.7cqw,5px) solid rgba(19,27,39,.8); background:transparent; box-shadow:0 0 0 1px rgba(255,255,255,.7),0 1px 2px rgba(0,0,0,.36); }
.square.is-dark.is-legal.is-capture::before,
.practice-chess-board > button.is-dark.is-legal.is-capture::before { border-color:rgba(255,255,255,.92); box-shadow:0 0 0 1px rgba(15,25,37,.55),0 1px 2px rgba(0,0,0,.35); }
/* Offline used an older after-pseudo dot; this shared treatment replaces it. */
.practice-chess-board > button.is-legal::after { content:none; }

/* Read-only match information is shared by live and offline chess. */
.chess-match-info{display:grid;gap:10px;padding:12px;border:1px solid var(--line,var(--practice-line,#cbd5df));border-radius:10px;color:var(--ink,var(--practice-ink,#182533));background:var(--panel,var(--practice-card,#fff));box-shadow:0 4px 14px rgba(29,42,58,.05)}.chess-match-info__material{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.chess-match-info__side{min-width:0;padding:8px;border:1px solid var(--line,var(--practice-line,#cbd5df));border-radius:7px;background:var(--field,var(--practice-soft,#f4f7f9))}.chess-match-info__side-head{display:flex;align-items:center;justify-content:space-between;gap:6px;color:var(--muted,var(--practice-muted,#526170));font-size:.72rem;font-weight:900;text-transform:uppercase}.chess-match-info__advantage{display:inline-flex;align-items:center;gap:3px;padding:2px 6px;border-radius:999px;font-size:.7rem;line-height:1}.chess-match-info__advantage.is-ahead{color:var(--chess-ahead-ink);background:color-mix(in srgb,var(--green-cell,#216d54) 13%,transparent)}.chess-match-info__advantage.is-behind{color:var(--chess-behind-ink);background:color-mix(in srgb,var(--red,#b5413c) 12%,transparent)}.chess-match-info__advantage.is-even{color:var(--muted,var(--practice-muted,#526170));background:var(--mini-cell,var(--practice-soft,#f4f7f9))}.chess-match-info__captures{display:flex;align-items:center;min-height:25px;margin-top:4px;overflow:hidden}.chess-match-info__captures .piece-svg{width:24px;height:24px;margin-right:-7px;filter:drop-shadow(0 1px 0 #0003)}.chess-match-info__tally{margin-left:9px;color:var(--muted,var(--practice-muted,#526170));font-size:.73rem;font-weight:900}.chess-match-info__recent{display:grid;gap:6px}.chess-match-info__title{margin:0;color:var(--muted,var(--practice-muted,#526170));font-size:.72rem;font-weight:900;letter-spacing:.04em;text-transform:uppercase}.chess-match-info__moves{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}.chess-match-info__move{display:grid;grid-template-columns:auto minmax(0,1fr) minmax(0,1fr);gap:6px;align-items:baseline;padding:7px 8px;border-radius:6px;background:var(--mini-cell,var(--practice-soft,#f4f7f9));font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:.77rem;font-weight:800}.chess-match-info__move-number{color:var(--muted,var(--practice-muted,#526170))}.chess-match-info__move span:not(.chess-match-info__move-number){overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.chess-match-info details{border-top:1px solid var(--line,var(--practice-line,#cbd5df));padding-top:8px}.chess-match-info summary{cursor:pointer;color:var(--accent,var(--practice-accent,#2463a5));font-size:.8rem;font-weight:900}.chess-match-info__all-moves{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:5px;margin:8px 0 0;padding:0;list-style:none}.chess-match-info__empty{margin:0;color:var(--muted,var(--practice-muted,#526170));font-size:.82rem;font-weight:800}
@media (max-width:720px){.chess-match-info__moves,.chess-match-info__all-moves{grid-template-columns:1fr}}

/* ARENA_CHESS_EXPERIENCE_BUNDLE */
/* A board-first chess stage shared with local play. Arena's surrounding identity stays intact. */
.chess-companion{display:grid;grid-template-columns:58px minmax(0,1fr);align-items:center;gap:9px;min-height:78px;margin:0 auto 12px;padding:6px 56px 6px 0;width:min(100%,600px);color:var(--ink,var(--practice-ink));font-family:var(--brand-text-font,system-ui,sans-serif)}
.chess-companion[hidden]{display:none}.rook-buddy{display:block;width:58px;height:58px;color:var(--ink,var(--practice-ink));transform-origin:50% 90%}.rook-buddy svg{width:100%;height:100%;overflow:visible}.rook-buddy-body,.rook-buddy-base{fill:var(--accent,var(--practice-accent));stroke:var(--ink,var(--practice-ink));stroke-width:2;stroke-linejoin:round}.rook-buddy-base{fill:color-mix(in srgb,var(--accent,var(--practice-accent)) 75%,var(--field,var(--practice-card)))}.rook-buddy-shine{fill:none;stroke:#fff;opacity:.5;stroke-width:3;stroke-linecap:round}.rook-buddy-eyes{fill:var(--accent-ink,var(--practice-bg))}.rook-buddy-smile,.rook-buddy-brows{fill:none;stroke:var(--accent-ink,var(--practice-bg));stroke-width:2.5;stroke-linecap:round}.rook-buddy-brows{opacity:0}.chess-companion[data-mood=check] .rook-buddy-brows{opacity:1}.chess-companion[data-mood=waiting] .rook-buddy-eyes{transform:translateY(1px)}
.chess-companion-copy{min-width:0;position:relative;padding:10px 13px;border:1px solid var(--line,var(--practice-line));border-radius:15px 15px 15px 3px;background:var(--field,var(--practice-card))}.chess-companion-copy strong{display:block;font-size:.98rem;line-height:1.25;font-weight:900}.chess-companion-copy p{margin:4px 0 0;color:var(--muted,var(--practice-muted));font-size:.75rem;line-height:1.35;font-weight:650}
.chess-page #gameView.has-chess-board{position:relative}.chess-page #gameView.has-chess-board>.game-topbar{display:none}.chess-page #gameView.has-chess-board>#chessMoveHint{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap}
.chess-page #gameView.has-chess-board>.board-tools{position:absolute;top:17px;right:0;z-index:8;margin:0;padding:0;width:44px;border:0;background:none;box-shadow:none}.chess-page .board-tools>summary{display:grid;place-items:center;min-height:44px;width:44px;padding:0;border:1px solid var(--line);border-radius:50%;background:var(--field);color:var(--accent-strong);font-size:0;list-style:none;cursor:pointer}.chess-page .board-tools>summary::after{display:none}.chess-page .board-tools>summary::-webkit-details-marker{display:none}.chess-page .board-tools>summary svg{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}.chess-page .board-tools>summary #boardStyleValue{display:none}.chess-page .board-tools .board-style-options{position:absolute;right:0;top:52px;display:grid;gap:14px;min-width:min(310px,calc(100vw - 40px));padding:16px;border:1px solid var(--line);border-radius:20px;background:var(--bg);box-shadow:0 16px 42px #0003}.chess-page .board-tools:not([open]) .board-style-options{display:none}.chess-page .board-tools[open]>summary{border-color:var(--accent-border);background:var(--self-bg)}
.chess-page #gameView.has-chess-board .game-layout{display:flex;flex-direction:column;align-items:center;gap:10px}.chess-page .board-section{display:grid;grid-template-columns:minmax(0,1fr) 94px;grid-template-areas:'black clockBlack' 'board board' 'white clockWhite';gap:8px;width:min(100%,600px);margin:0 auto}.chess-page .board-section.is-viewing-b{grid-template-areas:'white clockWhite' 'board board' 'black clockBlack'}.chess-page #blackPlayer{grid-area:black}.chess-page #whitePlayer{grid-area:white}.chess-page #blackClock{grid-area:clockBlack}.chess-page #whiteClock{grid-area:clockWhite}.chess-page .board-frame{grid-area:board}
.chess-page .player-card{display:grid;grid-template-columns:28px minmax(0,1fr) auto;grid-template-rows:auto auto;gap:1px 8px;align-content:center;min-height:50px;margin:0;padding:5px 8px;border:1px solid transparent;border-radius:14px;background:transparent;box-shadow:none}.chess-page .player-card .piece-dot.chess-player-avatar{grid-column:1;grid-row:1 / span 2;display:grid;place-items:center;width:28px;height:32px;margin:0;border:0;border-radius:11px;background:var(--field)}.chess-player-avatar .piece-svg{width:26px;height:29px;filter:none}.chess-page .player-card .chess-player-name{grid-column:2;grid-row:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;min-width:0;font:850 .9rem/1.2 var(--brand-text-font,system-ui,sans-serif)}.chess-page .player-card .player-meta{display:block!important;grid-column:2;grid-row:2;margin:0;padding:0;font-size:.65rem;line-height:1.25;white-space:nowrap;color:var(--muted)}.chess-page .player-card.is-turn{background:color-mix(in srgb,var(--accent) 14%,var(--field));border-color:var(--accent-border);box-shadow:inset 3px 0 0 var(--accent)}.chess-page .player-card .chess-material-badge{grid-column:3;grid-row:1 / span 2;margin:0;padding:5px 7px;white-space:nowrap;font-size:.74rem}.chess-page .clock-card{display:grid;place-items:center;align-content:center;min-width:0;min-height:50px;margin:0;padding:6px;border:1px solid var(--line);border-radius:14px;background:var(--field);box-shadow:none}.chess-page .clock-card>span{display:none}.chess-page .clock-card strong{font-size:1.2rem;line-height:1.2;letter-spacing:-.04em}.chess-page .clock-card.is-active{border-color:var(--accent-border);background:var(--self-bg);box-shadow:inset 0 -3px 0 var(--accent)}
.chess-page .board-frame{padding:3px 3px 21px 21px;border:1px solid var(--line);border-radius:12px;background:color-mix(in srgb,var(--bg) 82%,var(--ink));box-shadow:0 8px 18px #0002}.chess-page .chess-board{border-radius:5px;touch-action:none}.chess-page .chess-coordinates{inset:3px}.chess-page .chess-coordinates,.practice-chess-ranks,.practice-chess-files{font-family:var(--brand-text-font,system-ui,sans-serif);font-size:10px;color:var(--muted,var(--practice-muted))}.chess-page .square{isolation:auto;transition:background-color 100ms ease}.chess-page .square.is-selected::after{border:2px solid var(--accent);background:color-mix(in srgb,var(--accent) 20%,transparent);border-radius:4px}.chess-page .square.is-last::after{background:rgba(214,178,74,.26)}.chess-page .square.is-check::after{border-width:3px}.chess-page .square.is-legal::before{width:18%;background:color-mix(in srgb,var(--accent) 75%,var(--ink));box-shadow:0 0 0 3px color-mix(in srgb,var(--field) 30%,transparent)}.chess-page .square.is-legal.is-capture::before{width:82%;border-width:3px}
.chess-page .chess-board-controls{display:block;position:relative;width:min(100%,600px);margin:0;padding:2px 0;border:0;border-radius:0;background:transparent;box-shadow:none}.chess-page .chess-board-utilities{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:10px}.chess-page .chess-board-tool,.chess-match-menu>summary{display:flex;align-items:center;justify-content:center;gap:7px;min-height:44px;padding:8px;border:1px solid var(--line);border-radius:14px;background:var(--panel);color:var(--ink);font:800 .76rem/1.2 var(--brand-text-font,system-ui,sans-serif);cursor:pointer;list-style:none}.chess-match-menu>summary::-webkit-details-marker{display:none}.chess-match-menu>summary::marker{content:''}.chess-board-tool>svg,.chess-match-menu>summary>svg{width:17px;height:17px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}.chess-match-menu{position:relative}.chess-match-menu-panel{position:absolute;right:0;bottom:calc(100% + 8px);z-index:12;display:grid;min-width:180px;padding:7px;border:1px solid var(--line);border-radius:18px;background:var(--bg);box-shadow:0 12px 32px #0003}.chess-page .chess-match-actions{display:grid;border:0;padding:0;gap:3px}.chess-match-menu-panel button{width:100%;min-height:44px;padding:10px 12px;border:0;border-radius:10px;background:transparent;color:var(--ink);font:750 .84rem/1.2 var(--brand-text-font,system-ui,sans-serif);text-align:left}.chess-match-menu-panel button:hover{background:var(--field)}.chess-match-menu-panel #resignButton{color:var(--chess-behind-ink)}.chess-match-menu:not([open]) .chess-match-menu-panel{display:none}.chess-page .game-rail{display:none!important}
.chess-extra-details{width:min(100%,600px);margin:4px auto 0}.chess-extra-details>summary{display:flex;align-items:center;gap:8px;min-height:44px;padding:9px 4px;color:var(--muted);font:750 .78rem/1.3 var(--brand-text-font,system-ui,sans-serif);cursor:pointer}.chess-extra-details>summary::after{content:'⌄';margin-left:auto;font-size:1rem}.chess-extra-content{display:grid;gap:10px}.chess-extra-details:not([open])>.chess-extra-content{display:none}.chess-extra-content .arena-standings{margin:0}.chess-extra-content .chess-match-info{margin:0;width:100%}
.chess-page .chess-embedded .board-section,.chess-page.chess-embedded .board-section{width:min(100%,600px,max(240px,calc(var(--arena-viewport-height,844px) - 350px)))}
.practice-table:has(.practice-chess){padding:8px;border:0;background:none;box-shadow:none;margin-top:8px}.practice-table:has(.practice-chess)>.practice-game-heading,.practice-table:has(.practice-chess)>.practice-message{display:none}.practice-chess{width:min(100%,540px);margin:auto}.practice-chess .chess-companion{padding-right:0;margin-bottom:8px}.practice-chess-board{touch-action:none}.practice-chess-frame{padding:3px 3px 21px 21px;border:1px solid var(--practice-line);border-radius:12px;background:var(--practice-card);box-shadow:0 8px 18px #0002}.practice-chess-ranks{top:3px;bottom:21px;left:1px}.practice-chess-frame .practice-chess-files{left:21px;right:3px;bottom:1px}.practice-table:has(.practice-chess) #practiceControls{display:flex;flex-direction:column;gap:8px;max-width:540px;margin:auto}.practice-table:has(.practice-chess) .practice-actions{margin:6px 0;display:flex;gap:8px}.practice-table:has(.practice-chess) .practice-actions button{flex:1;padding:8px;min-height:44px;font-size:.8rem}.practice-table:has(.practice-chess) .practice-history{display:none}.practice-chess .chess-match-info{margin-top:10px;padding:10px}.practice-chess .chess-match-info__title{font-size:.78rem}.practice-chess .chess-match-info__material{gap:6px}
@media(max-width:360px){.chess-companion{grid-template-columns:47px minmax(0,1fr);gap:6px;min-height:72px;padding-right:49px}.rook-buddy{width:47px;height:47px}.chess-companion-copy{padding:8px 10px}.chess-companion-copy strong{font-size:.9rem}.chess-companion-copy p{font-size:.7rem}.chess-page .board-section{grid-template-columns:minmax(0,1fr) 82px;gap:6px}.chess-page .player-card{padding:4px 6px;gap:1px 5px;grid-template-columns:23px minmax(0,1fr) auto}.chess-page .player-card .piece-dot.chess-player-avatar{width:23px}.chess-page .player-card .chess-player-name{font-size:.8rem}.chess-page .player-card .chess-material-badge{font-size:.68rem;padding:4px}.chess-page .clock-card strong{font-size:1.1rem}}
@media(min-width:620px){.chess-page.chess-compact-landscape #chessCompanion{display:none}.chess-page.chess-compact-landscape #gameView.has-chess-board>.board-tools{top:0}.chess-page.chess-compact-landscape #gameView.has-chess-board .game-layout{display:grid;grid-template-columns:minmax(0,1fr) 190px;align-items:start}.chess-page.chess-compact-landscape .board-section,.chess-page.chess-compact-landscape.chess-embedded .board-section{grid-column:1;grid-row:1;width:min(100%,max(224px,calc(var(--arena-viewport-height,390px) - 170px)))}.chess-page.chess-compact-landscape #chessBoardControls{grid-column:2;grid-row:1;padding-top:58px}.chess-page.chess-compact-landscape .chess-board-utilities{grid-template-columns:1fr}.chess-page.chess-compact-landscape .chess-extra-details{grid-column:1/-1}.chess-page.chess-compact-landscape .chess-companion-copy p{display:none}}
@media(prefers-reduced-motion:no-preference){.chess-companion[data-mood=capture] .rook-buddy{animation:rook-delight 380ms ease-out}@keyframes rook-delight{0%,100%{transform:rotate(0)}35%{transform:rotate(-7deg) translateY(-3px)}70%{transform:rotate(5deg)}}}
@media(prefers-reduced-motion:reduce){.chess-companion *,.chess-page .player-card{transition:none!important;animation:none!important}}
.practice-chess-settings{flex:1;position:relative}.practice-chess-settings>summary{display:grid;place-items:center;min-height:44px;padding:8px;border:1px solid var(--practice-line);border-radius:14px;background:var(--practice-card);font-size:.8rem;font-weight:750;cursor:pointer;list-style:none}.practice-chess-settings>summary::-webkit-details-marker{display:none}.practice-chess-settings>label{position:absolute;bottom:calc(100% + 8px);right:0;width:220px;padding:14px;border:1px solid var(--practice-line);border-radius:18px;background:var(--practice-bg);box-shadow:0 12px 32px #0003;z-index:8}.practice-chess-settings:not([open])>label{display:none}.chess-page .board-tools>summary:focus-visible,.chess-match-menu>summary:focus-visible,.chess-extra-details>summary:focus-visible{outline:3px solid var(--accent);outline-offset:3px}
.chess-companion-balance{display:inline-flex;align-items:center;margin-top:5px;padding:3px 7px;border-radius:99px;font:850 .74rem/1.1 var(--brand-text-font,system-ui,sans-serif);background:var(--practice-soft,var(--field));color:var(--muted,var(--practice-muted))}.chess-companion-balance.is-ahead{color:var(--chess-ahead-ink);background:color-mix(in srgb,var(--chess-ahead-ink) 12%,transparent)}.chess-companion-balance.is-behind{color:var(--chess-behind-ink);background:color-mix(in srgb,var(--chess-behind-ink) 12%,transparent)}.practice-chess-review{margin-top:8px}.practice-chess-review>summary{min-height:44px;padding:10px 4px;cursor:pointer;font-size:.78rem;font-weight:750;color:var(--practice-muted)}.practice-chess-review:not([open])>.chess-match-info{display:none}
@media(min-width:620px){.chess-page.chess-compact-landscape .board-section,.chess-page.chess-compact-landscape.chess-embedded .board-section{width:min(100%,max(160px,calc(var(--arena-viewport-height,390px) - 210px)));grid-template-columns:minmax(0,1fr) 76px;gap:6px}.chess-page.chess-compact-landscape .player-card{grid-template-columns:minmax(0,1fr) auto;min-height:44px;padding:4px 6px}.chess-page.chess-compact-landscape .player-card .piece-dot.chess-player-avatar{display:none}.chess-page.chess-compact-landscape .player-card .chess-player-name,.chess-page.chess-compact-landscape .player-card .player-meta{grid-column:1}.chess-page.chess-compact-landscape .player-card .chess-material-badge{grid-column:2;padding:4px}.chess-page.chess-compact-landscape .clock-card{min-height:44px}.chess-page.chess-compact-landscape .clock-card strong{font-size:1.05rem}}

