:root{--chess-green:#779556;--chess-light:#EBEED0;--chess-bg:#262522;--chess-panel:#312e2b;--chess-panel-soft:#3a3734;--chess-line:#ffffff12;--chess-text:#f5f5f2;--chess-muted:#aaa8a4;--chess-accent:#81a957;--chess-danger:#d55b55}
body[data-page="chess"]{min-height:100dvh;background:radial-gradient(circle at 47% 18%,#393633 0,#262522 56%,#1f1e1c 100%);color:var(--chess-text)}
body[data-page="chess"] .site-header{background:#211f1d;border-color:#ffffff0d;color:#fff;box-shadow:0 1px 0 #ffffff0a}body[data-page="chess"] .site-header .brand{color:#fff}body[data-page="chess"] .site-header a{color:#ddd}
.chess-page{width:min(1320px,calc(100% - 36px));margin:0 auto;padding:18px 0 32px}
.chess-topbar{display:flex;align-items:flex-end;justify-content:space-between;gap:24px;margin-bottom:14px}.chess-topbar h1{margin:3px 0 0;font-size:clamp(24px,2.5vw,34px);letter-spacing:-.035em}.chess-back{color:#aaa8a4;font-size:12px;font-weight:750;text-decoration:none}.chess-back:hover{color:#fff}
.chess-mode-switch{display:grid;grid-template-columns:1fr 1fr;gap:3px;padding:3px;border-radius:9px;background:#1f1e1c;box-shadow:inset 0 0 0 1px #ffffff0b}.chess-mode-switch button{height:36px;padding:0 14px;border:0;border-radius:7px;background:transparent;color:#a9a7a2;font:inherit;font-size:12px;font-weight:800;cursor:pointer}.chess-mode-switch button[aria-selected="true"]{background:#45413d;color:#fff;box-shadow:0 1px 5px #0007}
.chess-button{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;min-height:40px;padding:0 15px;border:0;border-radius:7px;font:inherit;font-size:12px;font-weight:850;cursor:pointer;transition:background .16s,transform .16s,box-shadow .16s}.chess-button:active{transform:translateY(1px)}.chess-button:focus-visible,.chess-icon-button:focus-visible,.chess-tabs button:focus-visible{outline:3px solid #a9cc7b;outline-offset:2px}.chess-button:disabled{opacity:.45;cursor:not-allowed}.chess-button-primary{background:#81a957;color:#fff;box-shadow:inset 0 -2px 0 #0002}.chess-button-primary:hover{background:#739b4c}.chess-button-muted{border:1px solid #ffffff1b;background:#484440;color:#f3f2ef}.chess-button-muted:hover{background:#55504b}
.chess-online-setup{display:grid;grid-template-columns:1fr minmax(150px,210px) auto;align-items:end;gap:16px;margin-bottom:14px;padding:14px 16px;border:1px solid #ffffff12;border-radius:10px;background:#312e2be8;box-shadow:0 10px 28px #0002}.chess-online-setup[hidden]{display:none}.chess-online-setup strong{display:block;font-size:14px}.chess-online-setup p{margin:3px 0 0;color:var(--chess-muted);font-size:11px}.chess-online-setup label{display:grid;gap:5px;color:#aaa8a4;font-size:10px;font-weight:800}.chess-online-setup select,.chess-settings-panel select{height:38px;padding:0 10px;border:1px solid #ffffff1b;border-radius:7px;background:#242321;color:#fff;font:inherit;font-size:12px}.chess-error{margin:0 0 12px;padding:10px 12px;border:1px solid #ef797933;border-radius:8px;background:#6c29294d;color:#ffd7d5;font-size:12px}
.chess-game{display:grid;grid-template-columns:clamp(440px,calc(100dvh - 190px),760px) minmax(310px,390px);align-items:start;justify-content:center;gap:20px}.chess-board-column{width:100%;min-width:0;align-self:start}.chess-board{position:relative;display:grid;grid-template-columns:repeat(8,minmax(0,1fr));grid-template-rows:repeat(8,minmax(0,1fr));width:100%;height:auto;min-width:0;min-height:0;aspect-ratio:1/1;overflow:hidden;border-radius:4px;box-shadow:0 18px 48px #0007;touch-action:none;user-select:none;-webkit-user-select:none}
.chess-square{position:relative;display:grid;place-items:center;box-sizing:border-box;width:auto;height:auto;min-width:0;min-height:0;aspect-ratio:1/1;overflow:hidden;padding:0;border:0;border-radius:0;background:var(--chess-light);cursor:pointer}.chess-square.dark{background:var(--chess-green)}.chess-square:focus-visible{z-index:6;outline:3px solid #fff;outline-offset:-4px}.chess-square::after{content:"";position:absolute;z-index:1;width:22%;aspect-ratio:1;border-radius:50%;background:#23331f70;opacity:0;transform:scale(.6);transition:opacity .12s,transform .12s}.chess-square.legal::after{opacity:1;transform:scale(1)}.chess-square.legal.occupied::after{width:84%;border:6px solid #23331f66;background:transparent;box-sizing:border-box}.chess-square.selected{box-shadow:inset 0 0 0 999px #f4e45e8c}.chess-square.last-move{box-shadow:inset 0 0 0 999px #f4e65b62}.chess-square.selected.last-move{box-shadow:inset 0 0 0 999px #f4e45e98}.chess-square.in-check{animation:chess-check 1.2s ease-in-out infinite;box-shadow:inset 0 0 0 999px #d84141a8}.chess-square.drop-target{box-shadow:inset 0 0 0 5px #fff9,inset 0 0 0 999px #8fc96771}.chess-square.annotated{box-shadow:inset 0 0 0 999px #e9b94988}.chess-square.drag-source .chess-piece{opacity:.13}@keyframes chess-check{50%{box-shadow:inset 0 0 0 999px #f06262b8}}
.chess-piece{position:relative;z-index:3;display:block;width:100%;height:100%;object-fit:contain;transform:translate3d(0,0,0);transition:transform 200ms ease,opacity 180ms ease;will-change:transform;pointer-events:none}.chess-piece[data-piece="p"]{width:108%;height:108%}.chess-drag-ghost{position:fixed;z-index:9999;display:block;margin:0;object-fit:contain;filter:drop-shadow(0 12px 10px #0008);transform:scale(1.08);transition:none!important;pointer-events:none}.chess-drag-ghost.snap-back{transition:left 200ms ease,top 200ms ease,transform 200ms ease!important;transform:scale(1)}.chess-piece.arriving{animation:chess-arrive 200ms ease}.chess-piece.promoted{animation:chess-promote 240ms ease}.chess-piece.captured{animation:chess-capture 200ms ease forwards}.chess-annotations{position:absolute;inset:0;z-index:4;width:100%;height:100%;overflow:visible;pointer-events:none}.chess-arrow{stroke:#df8d29;stroke-width:.16;stroke-linecap:round;opacity:.84}@keyframes chess-arrive{from{transform:scale(.84)}to{transform:scale(1)}}@keyframes chess-capture{to{opacity:0;transform:scale(.55) rotate(8deg)}}@keyframes chess-promote{0%{transform:scale(.45) rotate(-12deg);opacity:.25}70%{transform:scale(1.14)}100%{transform:scale(1);opacity:1}}
.chess-coordinate{position:absolute;z-index:5;font-size:clamp(8px,1vw,12px);font-weight:900;pointer-events:none}.chess-coordinate.rank{left:4px;top:3px}.chess-coordinate.file{right:4px;bottom:3px}.chess-square.light .chess-coordinate{color:#779556}.chess-square.dark .chess-coordinate{color:#ebeed0}
.chess-player{display:flex;align-items:center;gap:10px;min-height:50px;padding:7px 2px;color:#f5f5f2}.chess-avatar{display:grid;flex:0 0 auto;place-items:center;width:38px;height:38px;overflow:hidden;border-radius:6px;background:linear-gradient(145deg,#eee,#bdbbb7);box-shadow:0 3px 9px #0005}.chess-avatar img{width:94%;height:94%;object-fit:contain}.chess-avatar-black{background:linear-gradient(145deg,#4b4845,#1d1c1a)}.chess-player-info{min-width:0;flex:1}.chess-player-info>strong,.chess-player-info small{display:block}.chess-player-info>strong{overflow:hidden;font-size:13px;text-overflow:ellipsis;white-space:nowrap}.chess-player-info small{margin-top:2px;color:#aaa8a4;font-size:10px}.chess-presence{display:inline-block;width:7px;height:7px;margin-right:5px;border-radius:50%;background:#777;vertical-align:1px}.chess-player.is-online .chess-presence{background:#83b357;box-shadow:0 0 0 3px #83b35720}.chess-player.is-active{color:#fff}.chess-player.is-active .chess-avatar{box-shadow:0 0 0 2px #83a959,0 4px 12px #0006}.chess-clock{min-width:88px;padding:7px 11px;border-radius:6px;background:#4a4743;color:#eee;font-size:23px!important;font-variant-numeric:tabular-nums;text-align:center;box-shadow:inset 0 -2px 0 #0003}.chess-clock.active{background:#8aad5a;color:#fff}.chess-clock.low{background:#bd4f4a;color:#fff}.chess-captured{display:flex;align-items:center;min-height:14px;margin-top:1px}.chess-captured-piece{width:16px;height:16px;margin-right:-4px;object-fit:contain}
.chess-panel{position:relative;display:flex;flex-direction:column;height:clamp(500px,calc(100dvh - 165px),730px);min-height:500px;overflow:hidden;border:1px solid #ffffff0d;border-radius:10px;background:var(--chess-panel);box-shadow:0 18px 48px #0005}.chess-tabs{display:grid;grid-template-columns:repeat(3,1fr);flex:0 0 auto;border-bottom:1px solid var(--chess-line);background:#292724}.chess-tabs button{position:relative;height:48px;border:0;border-bottom:3px solid transparent;background:transparent;color:#aaa8a4;font:inherit;font-size:12px;font-weight:850;cursor:pointer}.chess-tabs button:hover{background:#ffffff08;color:#fff}.chess-tabs button[aria-selected="true"]{border-bottom-color:#81a957;color:#fff;background:#ffffff05}.chess-tab-badge{position:absolute;top:9px;right:14px;width:7px;height:7px;border-radius:50%;background:#d8a94b}.chess-tab-panel{display:flex;min-height:0;flex:1;flex-direction:column;animation:chess-panel-in .16s ease}.chess-tab-panel[hidden]{display:none}@keyframes chess-panel-in{from{opacity:.35;transform:translateY(3px)}to{opacity:1;transform:none}}
.chess-status{display:flex;align-items:center;gap:10px;min-height:54px;padding:10px 14px;border-bottom:1px solid var(--chess-line)}.chess-status>span:first-child{width:13px;height:13px;border:2px solid #ddd;border-radius:3px;background:#f5f5ef;box-shadow:0 0 0 3px #81a95728}.chess-status.black-to-move>span:first-child{background:#222;border-color:#111}.chess-status small,.chess-status strong{display:block}.chess-status small{color:#918f8b;font-size:9px}.chess-status strong{margin-top:1px;font-size:15px}.chess-status.check strong{color:#ff8c86}.chess-opening{min-width:0;margin-left:auto;overflow:hidden;color:#8f8d89;font-size:10px;text-align:right;text-overflow:ellipsis;white-space:nowrap}.chess-result{margin:10px 12px 0;padding:10px 12px;border:1px solid #81a9573b;border-radius:7px;background:#81a9571f;color:#dcebd0;font-size:12px;font-weight:800}.chess-request{margin:10px 12px 0;padding:10px;border:1px solid #d8b76844;border-radius:8px;background:#705f322e}.chess-request p{margin:0 0 8px;font-size:12px}.chess-request>div{display:flex;gap:6px}.chess-request .chess-button{min-height:34px;flex:1}.chess-history-head{display:flex;align-items:center;justify-content:space-between;padding:12px 16px 7px;color:#8f8d89;font-size:10px;font-weight:800;text-transform:uppercase;letter-spacing:.08em}.chess-history-empty{display:grid;flex:1;place-content:center;gap:5px;padding:24px;color:#8f8d89;text-align:center}.chess-history-empty>span{color:#5b5752;font-family:Georgia,serif;font-size:48px}.chess-history-empty strong{color:#bbb9b4;font-size:13px}.chess-history-empty small{font-size:10px}.chess-history{flex:1;margin:0;padding:0 10px 12px;overflow:auto;list-style:none;scrollbar-color:#5e5954 transparent}.chess-history li{display:grid;grid-template-columns:36px 1fr 1fr;align-items:center;min-height:37px;padding:0 6px;border-radius:5px;font-size:13px}.chess-history li:nth-child(odd){background:#ffffff06}.chess-move-number{color:#77746f;font-size:10px}.chess-san{font-weight:750}.chess-san:last-child{color:#d0ceca}.chess-san.current{border-radius:4px;background:#81a95736}.chess-san.reviewable{padding:6px;border:0;border-radius:4px;background:transparent;color:inherit;text-align:left;cursor:pointer}.chess-san.reviewable:hover{background:#ffffff0c}.chess-review-controls{display:grid;grid-template-columns:34px 1fr 34px auto;gap:5px;align-items:center;padding:8px 10px;border-top:1px solid var(--chess-line)}.chess-review-controls[hidden]{display:none}.chess-review-controls button{height:30px;border:1px solid #ffffff16;border-radius:5px;background:#3d3935;color:#ddd;font:inherit;font-size:10px;font-weight:800;cursor:pointer}.chess-review-controls span{font-size:10px;text-align:center}
.chess-panel-placeholder{display:grid;flex:1;place-content:center;gap:7px;padding:24px;color:#8f8d89;text-align:center}.chess-panel-placeholder>span{font-size:44px}.chess-panel-placeholder strong{color:#cccac5;font-size:13px}.chess-panel-placeholder p{margin:0;font-size:10px}.chess-chat{display:flex;min-height:0;flex:1;flex-direction:column}.chess-chat-messages{display:flex;min-height:0;flex:1;flex-direction:column;gap:8px;padding:14px;overflow:auto}.chess-chat-empty{margin:auto;color:#85827d;font-size:11px}.chess-chat-message{max-width:85%;padding:8px 10px;border-radius:10px 10px 10px 3px;background:#45413d;color:#eee;font-size:12px;line-height:1.35}.chess-chat-message.mine{align-self:flex-end;border-radius:10px 10px 3px 10px;background:#668a43}.chess-chat-message strong{display:block;margin-bottom:2px;font-size:9px;opacity:.7}.chess-chat-form{display:grid;grid-template-columns:1fr 40px;gap:7px;padding:10px;border-top:1px solid var(--chess-line)}.chess-chat-form input{min-width:0;height:40px;padding:0 12px;border:1px solid #ffffff18;border-radius:7px;background:#252321;color:#fff;font:inherit;font-size:12px;outline:none}.chess-chat-form input:focus{border-color:#83a95b}.chess-chat-form button{border:0;border-radius:7px;background:#779556;color:#fff;font-size:17px;cursor:pointer}
.chess-info-list{margin:0;padding:8px 14px}.chess-info-list>div{display:flex;justify-content:space-between;gap:12px;padding:11px 2px;border-bottom:1px solid var(--chess-line);font-size:11px}.chess-info-list dt{color:#8f8d89}.chess-info-list dd{margin:0;max-width:64%;overflow:hidden;color:#e3e1dd;font-weight:750;text-align:right;text-overflow:ellipsis;white-space:nowrap}.chess-code-block{margin:6px 14px;padding:10px;border-radius:7px;background:#252321}.chess-code-block>div{display:flex;align-items:center;justify-content:space-between;margin-bottom:7px}.chess-code-block strong{font-size:10px}.chess-code-block button{border:0;background:transparent;color:#91b56c;font:inherit;font-size:9px;font-weight:800;cursor:pointer}.chess-code-block code{display:block;max-height:84px;overflow:auto;color:#aaa8a4;font-size:9px;line-height:1.45;overflow-wrap:anywhere;white-space:pre-wrap}
.chess-room-bar{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:34px;padding:0 12px;border-top:1px solid var(--chess-line);background:#2a2825;color:#aaa8a4;font-size:10px}.chess-room-bar[hidden]{display:none}.chess-connection{display:flex;align-items:center;gap:6px}.chess-connection>span:first-child{width:7px;height:7px;border-radius:50%;background:#c49b48}.chess-connection>span:first-child.online{background:#82ad58;box-shadow:0 0 0 3px #82ad5820}
.chess-controls{display:flex;flex:0 0 auto;align-items:center;gap:5px;min-height:54px;padding:7px 9px;border-top:1px solid var(--chess-line);background:#292724}.chess-control-group{display:flex;gap:5px}.chess-control-group[hidden]{display:none}.chess-control-spacer{flex:1}.chess-icon-button{display:grid;flex:0 0 auto;place-items:center;width:38px;height:38px;padding:0;border:0;border-radius:6px;background:transparent;color:#b9b7b2;font:inherit;font-size:18px;font-weight:800;cursor:pointer;transition:background .15s,color .15s,transform .15s}.chess-icon-button:hover,.chess-icon-button[aria-pressed="true"]{background:#45413d;color:#fff}.chess-icon-button:active{transform:translateY(1px)}.chess-icon-button:disabled{opacity:.35;cursor:not-allowed}.chess-icon-danger:hover{background:#6e3431;color:#ffb3ae}.chess-settings-panel{position:absolute;right:8px;bottom:60px;z-index:10;width:210px;padding:11px;border:1px solid #ffffff16;border-radius:8px;background:#211f1d;box-shadow:0 12px 35px #0008}.chess-settings-panel[hidden]{display:none}.chess-settings-panel label{display:grid;gap:5px;color:#aaa8a4;font-size:10px}.chess-settings-panel button{width:100%;height:36px;margin-top:8px;border:1px solid #ffffff16;border-radius:6px;background:#3b3834;color:#ddd;font:inherit;font-size:11px;font-weight:750;cursor:pointer}.chess-settings-panel button[aria-pressed="true"]{border-color:#81a957;background:#81a9572b;color:#e8f3df}
.chess-dialog{width:min(390px,calc(100% - 28px));padding:25px;border:1px solid #ffffff14;border-radius:13px;background:#312e2b;color:#f5f5f2;text-align:center;box-shadow:0 24px 80px #000a}.chess-dialog::backdrop{background:#111c;backdrop-filter:blur(3px)}.chess-dialog h2{margin:0;font-size:22px}.chess-dialog p{margin:8px 0 19px;color:#aaa8a4;font-size:12px}.promotion-options{display:grid;grid-template-columns:repeat(4,1fr);gap:8px}.promotion-option{display:grid;place-items:center;aspect-ratio:1;border:1px solid #ffffff16;border-radius:8px;background:#242220;color:#eee;font-family:Georgia,serif;font-size:44px;cursor:pointer}.promotion-option:hover,.promotion-option:focus-visible{border-color:#81a957;background:#3d4635;outline:none}.game-over-mark{margin-bottom:6px;color:#91b76c;font-family:Georgia,serif;font-size:52px}.game-over-actions{display:grid;grid-template-columns:1fr 1fr;gap:8px}.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}
.chess-history-empty>img{width:52px;height:52px;margin:auto;object-fit:contain;opacity:.55}.promotion-piece{display:block;width:92%;height:92%;object-fit:contain}.game-over-mark img{width:58px;height:58px;object-fit:contain}
@media(min-width:981px) and (max-height:800px){.chess-page{padding-top:8px}.chess-topbar{margin-bottom:6px}.chess-topbar h1{font-size:28px}.chess-game{grid-template-columns:470px minmax(310px,390px)}.chess-player{min-height:42px;padding-top:4px;padding-bottom:4px}.chess-avatar{width:34px;height:34px}.chess-panel{height:570px;min-height:500px}}
@media(max-width:980px){.chess-page{width:min(100% - 24px,760px)}.chess-game{grid-template-columns:1fr}.chess-panel{height:500px;min-height:420px}.chess-piece{font-size:clamp(32px,11.6vw,82px)}}
@media(max-width:560px){body[data-page="chess"] .site-header{min-height:52px;padding:6px 10px}.chess-page{width:100%;padding:10px 0 20px;overflow-x:hidden}.chess-topbar,.chess-online-setup,.chess-error{margin-left:10px;margin-right:10px}.chess-topbar{align-items:flex-start}.chess-topbar h1{font-size:23px}.chess-mode-switch{grid-template-columns:1fr}.chess-mode-switch button{height:30px;padding:0 9px;font-size:9px}.chess-online-setup{grid-template-columns:1fr}.chess-online-setup .chess-button{width:100%}.chess-game{gap:8px}.chess-player{padding-left:10px;padding-right:10px}.chess-avatar{width:34px;height:34px}.chess-clock{min-width:78px;font-size:20px!important}.chess-board{border-radius:0}.chess-panel{height:440px;min-height:380px;margin:0 10px;border-radius:8px}.chess-tabs button{height:44px;font-size:11px}.chess-piece{font-size:clamp(30px,12.6vw,68px)}.chess-square.legal.occupied::after{border-width:4px}.chess-coordinate{font-size:8px}.chess-controls{position:sticky;bottom:0}.chess-icon-button{width:36px;height:40px}.chess-dialog{padding:22px}}
@media(prefers-reduced-motion:reduce){.chess-piece,.chess-square::after,.chess-button,.chess-icon-button,.chess-tab-panel,.chess-drag-ghost{animation-duration:.01ms!important;transition-duration:.01ms!important}}
