#editor-dialog{width:min(1110px,calc(100vw - 40px));max-width:none;max-height:calc(100svh - 32px);padding:24px;overflow:auto;border-color:#aab89f;border-radius:10px}
.editor-header{display:flex;align-items:center;justify-content:space-between;gap:16px}
#editor-dialog h2{font-size:38px;margin:6px 0 0;line-height:1.1}
#editor-dialog button{font:500 12px 'DM Sans',sans-serif;color:#000;border:1px solid #b7c2ac;border-radius:5px;background:#f5f6ef;padding:9px 12px;cursor:pointer;min-height:35px}
#editor-dialog button:hover{background:#e1e8d8}
#editor-dialog button:disabled{opacity:.4;cursor:default}
#editor-dialog button:focus-visible,#editor-dialog input:focus-visible,#editor-dialog select:focus-visible,#editor-dialog textarea:focus-visible{outline:2px solid #425a48;outline-offset:2px}
#editor-dialog #editor-intro{font-size:12px;line-height:1.5;margin:12px 0 20px}
.editor-layout{display:grid;grid-template-columns:minmax(0,1fr) minmax(310px,.82fr);gap:28px;align-items:start}
.editor-canvas{position:sticky;top:0;min-width:0}
.editor-board-frame{background:#4b5848;padding:6px;border-radius:4px}
#editor-dialog .square{min-height:0;border-radius:0;padding:0;border:0;background:var(--light)}
#editor-dialog .square.dark{background:var(--dark)}
#editor-dialog .square.selected{background:#c5b56f;box-shadow:inset 0 0 0 3px #b88c3d}
.editor-board-actions{display:flex;gap:6px;margin-top:10px}.editor-board-actions button{flex:1;white-space:nowrap}
.editor-settings{min-width:0}
.editor-section-label{display:block;font-size:10px;line-height:1.4;letter-spacing:.08em;font-weight:700;margin-bottom:8px}
.editor-palette-row{display:grid;grid-template-columns:repeat(6,minmax(0,1fr));gap:5px;margin-bottom:5px}
#editor-dialog .editor-palette-row button{display:grid;place-items:center;padding:3px;aspect-ratio:1;min-height:0;max-height:60px;background:#e6eadf;border-color:#c4ccba}
.editor-palette-row .piece{width:90%;height:90%}
#editor-dialog [data-tool][aria-pressed=true]{background:#d0dbc3;border-color:#425a48;box-shadow:inset 0 0 0 1px #425a48}
.editor-tools,.editor-presets,.editor-fen-actions{display:flex;gap:6px}.editor-tools{margin-top:9px}.editor-tools button{flex:1}.editor-presets{padding:12px 0;border-block:1px solid #cbd2c1;margin:12px 0}.editor-presets button{flex:1;white-space:nowrap}
#editor-dialog .editor-hint{font-size:10px;line-height:1.6;margin:7px 0 12px}
#editor-tool-hint{min-height:32px}
.editor-turn{display:flex;align-items:center;justify-content:space-between;font-size:12px;font-weight:650;margin:12px 0}
#editor-dialog input:not([type=checkbox]),#editor-dialog select,#editor-dialog textarea{font:12px 'DM Sans',sans-serif;color:#000;background:#fafbf6;border:1px solid #b7c2ac;border-radius:4px;padding:8px;min-width:0}
.editor-turn select{width:130px}
.editor-castling{padding:10px 12px;border:1px solid #c3ccba;border-radius:5px;font-size:11px;margin:0 0 12px}
.editor-castling legend{font-weight:700;padding:0 4px}.editor-castling>div{display:grid;grid-template-columns:40px 1fr 1fr;gap:6px;align-items:center;margin:4px 0}.editor-castling label{display:flex;gap:5px;align-items:center}.editor-castling input{accent-color:#425a48}
.editor-counters{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:8px}
.editor-counters label{display:flex;flex-direction:column;gap:6px;font-size:10px;line-height:1.4}
.editor-counters input{width:100%}
#editor-dialog textarea{display:block;width:100%;font:11px/1.6 ui-monospace,monospace;resize:vertical;min-height:61px}
.editor-fen-actions{margin-top:6px}
.editor-bottom{display:flex;justify-content:space-between;align-items:center;gap:22px;border-top:1px solid #c3ccba;padding-top:15px;margin-top:20px}
#editor-dialog #editor-status{font-size:13px;font-weight:650;line-height:1.5;margin:0 0 4px}
#editor-status.invalid{color:#792c1e}
#editor-status.warning{color:#000;background:#f2e7cd;border-left:3px solid #a57b27;padding:7px 10px;border-radius:3px}
.editor-bottom>div>span{font-size:10px;line-height:1.6;display:block}
#editor-dialog .editor-primary{background:#d6e1cb;border-color:#81956e;font-weight:700;white-space:nowrap;padding:13px 18px}
.editor-ghost{z-index:10}
.editor-advanced{border-block:1px solid #cbd2c1;margin:10px 0 14px;padding:10px 0;font-size:11px}
.editor-advanced>summary{font-weight:650;cursor:pointer}
.editor-advanced[open]>summary{margin-bottom:13px}
.play-page:has(#editor-dialog[open]){overflow:clip}
@media(min-width:761px) and (max-height:800px){#editor-dialog{padding:18px}.editor-layout{grid-template-columns:minmax(0,1fr) minmax(310px,.9fr);gap:24px}#editor-dialog #editor-intro{margin-bottom:12px}.editor-palette-row{gap:4px}.editor-presets{padding:9px 0;margin:9px 0}.editor-turn{margin:9px 0}.editor-bottom{margin-top:15px}}
@media(min-width:761px) and (max-height:800px){
 #editor-dialog .editor-header .eyebrow{display:block;font-size:9px;line-height:12px}
 #editor-dialog h2{font-size:32px;margin-top:4px}
 .editor-board-frame{max-width:min(100%,calc(100svh - 300px));margin:auto}
 #editor-dialog .editor-palette-row button{max-height:44px}
 #editor-tool-hint{min-height:16px}
 .editor-presets{padding:8px 0;margin:6px 0}
}
@media(max-width:760px){
 #editor-dialog{width:calc(100vw - 16px);max-height:calc(100svh - 16px);padding:16px;border-radius:8px}
 #editor-dialog h2{font-size:31px}.editor-header .eyebrow{font-size:8px;letter-spacing:1px}
 #editor-dialog #editor-intro{font-size:11px;margin-bottom:14px}
 .editor-layout{grid-template-columns:minmax(0,1fr);gap:20px}.editor-canvas{position:static}
 .editor-layout{row-gap:10px}.editor-settings{display:contents}
 .editor-settings>.editor-section-label:not([for]){order:-5;margin:0}
 #editor-palette{order:-4}.editor-tools{order:-3;margin:0}
 #editor-dialog #editor-tool-hint{order:-2;margin:0;min-height:16px}
 .editor-canvas{order:-1}
 #editor-dialog .editor-board-actions button{padding:8px;font-size:10px}
 .editor-bottom{align-items:stretch;flex-direction:column;gap:12px;margin-top:16px}.editor-bottom .editor-primary{width:100%}
 .editor-palette-row{grid-template-columns:repeat(6,minmax(0,1fr))}
 #editor-dialog .editor-presets button{font-size:11px;padding:8px}
 .editor-castling>div{grid-template-columns:36px 1fr 1fr}
}

.editor-test-presets{border:1px solid #b7c2ac;border-radius:6px;padding:12px 14px;margin:0 0 18px;background:#edf1e5;color:#000}
.editor-preset-picker{display:flex;gap:8px;align-items:stretch}
#editor-dialog .editor-preset-picker select{flex:1;min-width:0;font-size:13px}
#editor-dialog .editor-test-presets p{font-size:12px;line-height:1.45;margin:8px 0 0}
#editor-dialog .editor-preset-mode{font-size:11px;font-weight:600}
#editor-dialog .editor-preset-mode:empty{display:none}
#editor-preset-answer{border-top:1px solid #c6cfba;margin-top:10px;padding-top:9px;font-size:12px}
#editor-preset-answer[hidden]{display:none}
#editor-preset-answer summary{font-weight:650;cursor:pointer}
#editor-dialog .editor-preset-reference-note{font-size:10px}
@media(max-width:760px){.editor-test-presets{padding:10px;margin-bottom:14px}#editor-dialog .editor-preset-picker select{font-size:12px}}

.editor-bottom{position:sticky;bottom:-24px;background:var(--paper,#f4f2ed);z-index:2;padding-bottom:12px}
@media(min-width:761px) and (max-height:800px){.editor-bottom{bottom:-18px}}
@media(max-width:760px){.editor-test-presets{order:-6}.editor-bottom{bottom:-16px}}

/* Keep setup choices and feedback readable, with the primary action in reach. */
#editor-dialog .editor-section-label{font-size:11px}
#editor-dialog .editor-hint{font-size:11px}
#editor-dialog button{font-size:13px;min-height:38px}
.editor-piece-count{font-size:12px;font-weight:650;margin:6px 0 12px}
.editor-play-settings{padding:12px;border:1px solid #bdc8b1;border-radius:6px;background:#edf1e5;margin:12px 0}
.editor-play-settings label{display:flex;align-items:center;justify-content:space-between;gap:10px;font-size:12px;margin-bottom:9px}
.editor-play-settings label:has(input){justify-content:flex-start;margin-bottom:0}
#editor-dialog #editor-player{width:130px}
#editor-dialog #editor-start-hint{font-size:11px;line-height:1.45;margin:8px 0 0}
#editor-dialog .editor-primary{min-height:44px}
#editor-dialog .square:focus-visible{outline:3px solid #72571e;outline-offset:-3px;z-index:1}
.editor-play-settings{display:grid;grid-template-columns:1fr 1fr;gap:9px 16px}
.editor-play-settings label,.editor-play-settings .editor-turn{margin:0;flex-direction:column;align-items:flex-start;gap:5px}
.editor-play-settings label:has(input),.editor-play-settings #editor-start-hint{grid-column:1/-1}
.editor-play-settings label:has(input){flex-direction:row;align-items:center}
#editor-dialog .editor-play-settings select,#editor-dialog #editor-player{width:100%}
#editor-dialog .editor-play-settings #editor-start-hint{margin:0}
@media(min-width:761px) and (max-height:800px){
 #editor-dialog{width:min(1240px,calc(100vw - 32px))}
 .editor-layout{grid-template-columns:minmax(0,1fr) minmax(310px,1fr)}
 .editor-test-presets{padding:10px;margin-bottom:10px}
 #editor-dialog .editor-test-presets p{font-size:11px;margin-top:6px}
 #editor-preset-answer{margin-top:7px;padding-top:7px}
 .editor-play-settings{padding:9px 10px;gap:7px 14px;margin:9px 0}
}
/* Put the editing surface directly below a compact title row. */
#editor-dialog.page-view{padding-top:12px}
#editor-dialog .editor-header{min-height:36px;gap:16px}
#editor-dialog .editor-header .eyebrow{display:none}
#editor-dialog .editor-header h2{font:700 27px/1.15 'DM Sans',sans-serif;letter-spacing:-.7px;margin:0}
#editor-dialog #editor-intro{font-size:13px;line-height:18px;margin:6px auto 12px}
#editor-dialog .editor-header button{min-height:32px;padding:6px 12px;font-size:13px}
#editor-dialog .editor-board-frame,#editor-dialog .editor-board-actions{max-width:min(100%,calc(100svh - 230px))}
@media(max-width:760px){#editor-dialog.page-view{padding-top:12px}#editor-dialog .editor-header h2{font-size:24px}#editor-dialog #editor-intro{font-size:12px;line-height:16px;margin:5px 0 10px}#editor-dialog .editor-board-frame,#editor-dialog .editor-board-actions{max-width:100%}}
