/* Shared structural colours. Game verdicts, warning signals, chess pieces and
   supplied artwork retain their semantic/original colours. */
html[data-theme=warm]{--ui-text:#5b4532;--ui-muted:#91775b;--ui-surface:#fff3df;--ui-raised:#fff9ed;--ui-soft:#f4e5ca;--ui-line:#cbb18c66;--ui-accent:#a67a3d;--ui-focus:#a67a3d66;--ui-on:#fffaf2;--ui-shadow:#8a5e3020}
html[data-theme=paper]{--ui-text:#38403a;--ui-muted:#7c857b;--ui-surface:#f6f5ee;--ui-raised:#fcfcf6;--ui-soft:#e8ebe2;--ui-line:#a7b2a466;--ui-accent:#596d5e;--ui-focus:#596d5e66;--ui-on:#fafcf8;--ui-shadow:#35463718}
html[data-theme=cyan]{--ui-text:#e2faf6;--ui-muted:#a9d3cd;--ui-surface:#1b515a;--ui-raised:#245f67;--ui-soft:#2c6a70;--ui-line:#70cfc55c;--ui-accent:#64e8d6;--ui-focus:#64e8d677;--ui-on:#104349;--ui-shadow:#052f3830}
html[data-theme=quartz]{--ui-text:#384754;--ui-muted:#788b9a;--ui-surface:#f5f7f9;--ui-raised:#fff;--ui-soft:#e8eef2;--ui-line:#a6b8c666;--ui-accent:#657f91;--ui-focus:#657f9166;--ui-on:#fff;--ui-shadow:#334c6118}
html[data-theme] body :is(.puzzle-island,.opening-island,.settings-preview){position:relative}
/* The board island keeps its original absolute centre anchor. */
html[data-theme] body .island-stage>.island{position:absolute;left:50%;transform:translateX(-50%);margin-left:0;margin-right:0}
html[data-theme] body :is(.sheet-heading,.import-actions,.settings-heading,.panel-title,.workspace-heading,.theme-heading,.records-footer,.storage-summary,.library-heading,.opening-header){background:transparent!important;background-image:none!important;box-shadow:none!important}
html[data-theme] body :is(dialog,#themeSettings,#newGameDialog,#importDialog,#promotion,#setupDialog,#versionsDialog,#storageDialog,#storageConfirm){background:var(--ui-raised);color:var(--ui-text);border-color:var(--ui-line);box-shadow:0 16px 45px var(--ui-shadow)}
html[data-theme] body :is(.import-dialog label,.import-dialog p,.theme-save,.theme-intro,.puzzle-caption,.records-caption,.records-count,.clear-detail,fieldset,legend,.settings-nav,.settings-eyebrow,.settings-status){color:var(--ui-muted)}
html[data-theme] body :is(input,textarea,select){background:var(--ui-raised);color:var(--ui-text);border-color:var(--ui-line);box-shadow:none;caret-color:var(--ui-accent)}
html[data-theme] body :is(input,textarea,select):focus{outline:2px solid var(--ui-focus);outline-offset:2px;border-color:var(--ui-accent)}
html[data-theme] body :is(button,a,input,textarea,select):focus-visible{outline-color:var(--ui-accent)}
html[data-theme] body :is(.sheet-close,.theme-close){background:transparent;color:var(--ui-muted);border-color:var(--ui-line);box-shadow:none}
html[data-theme] body :is(.edition,.badge,.coach-move,.premove-toggle,.theme-settings-trigger,.library-back,.library-count,.game-year,.game-enter,.hint-icon-arrow,.hint-glyph,#soundToggle,#puzzleHint,#reviewBack,#reviewForward){color:var(--ui-accent);border-color:var(--ui-line)}
html[data-theme] body :is(.badge,.coach-move,.edition,.library-count){background:var(--ui-soft);box-shadow:none}
html[data-theme] body .edition i{background:var(--ui-accent);box-shadow:none}
html[data-theme] body :is(.brand-avatar,.player-avatar,.coach-avatar){background-color:var(--ui-soft);border-color:var(--ui-line)}
html[data-theme] body :is(#opponent,#you,.player b,.desk-brand,.brand,.move-san,.workspace-opening-name,.workspace-book-toggle,.guidance-toggle b,.classic-card h3,.game-players){color:var(--ui-text)}
html[data-theme] body :is(.premove-bar,.premove-bar span,.play-mode-label,.inventory-caption,.puzzle-tags,.puzzle-id,.puzzle-help,.catalogue-meta,.entry-topline,.entry-pgn,.branch-count,.classic-intro,.desk-note,.desk-note p,.desk-note small,.eyebrow,.index,.section-label,.opening-statistics,.outcome-labels,.workspace-engine-heading,.workspace-opening-detail,.workspace-book-state,.workspace-book-note,.analysis-note,.analysis-status,.settings-subtitle,.engine-note,.engine-elo,.desk-engine p,.desk-duration p,.desk-field>span,.desk-field>label,.settings-content label,.settings-content legend){color:var(--ui-muted)}
html[data-theme] body :is(footer,footer span,footer a,.about,.about summary,.about a,.library-foot){color:var(--ui-muted);border-color:var(--ui-line)}
html[data-theme] body :is(.desk-engine,.mode,.duration-choices,.desk-segment,.side-options,.time-control,.turn-track,.workspace-engine,.guidance-toggle,.review-navigation,.opening-search,.opening-controls,.board-tools,.puzzle-inventory,.match-record,.settings-module,.storage-option){background:var(--ui-surface);border-color:var(--ui-line);color:var(--ui-text);box-shadow:none}
html[data-theme] body :is(.desk-engine.active,.mode.active,.theme-option[aria-pressed=true]){background:var(--ui-soft);border-color:var(--ui-accent);box-shadow:inset 0 0 0 1px var(--ui-line)}
html[data-theme] body :is(.desk-engine-select,.duration-thumb,.side-thumb,.desk-segment i,.mode-track){background:var(--ui-soft);border-color:var(--ui-line);color:var(--ui-text);box-shadow:none}
html[data-theme] body :is(.desk-segment button,.duration-choices button){color:var(--ui-muted)}
html[data-theme] body :is(.desk-segment button[aria-pressed=true],.duration-choices button[aria-pressed=true]){color:var(--ui-text)}
html[data-theme] body :is(.import-actions button,.setup-board-actions button,.setup-tools button,.workspace-utilities button,.classic-filters button,.library-more,.board-tools button){background:var(--ui-soft);border-color:var(--ui-line);color:var(--ui-text);box-shadow:none}
html[data-theme] body :is(button.primary,.import-actions .primary,.analyze-button){background:var(--ui-accent)!important;border-color:var(--ui-accent)!important;color:var(--ui-on)!important}
html[data-theme] body :is(.workspace-engine-list button,.workspace-book-moves button,.opening-entry[aria-current=true],.continuation-row:hover){background:var(--ui-soft);color:var(--ui-text)}
html[data-theme] body :is(.workspace-engine-list small,.workspace-engine-list b,.workspace-book-moves b,.workspace-book-moves small,.review-navigation>span){color:var(--ui-muted)}
html[data-theme] body .guidance-toggle>i{background:var(--ui-muted)}
html[data-theme] body .guidance-toggle[aria-checked=true]>i{background:var(--ui-accent)}
html[data-theme] body .guidance-toggle em{background:var(--ui-raised);box-shadow:none}
html[data-theme] body .history-head{background:transparent;color:var(--ui-muted)}
html[data-theme] body .history-row:nth-child(even){background:var(--ui-soft)}
html[data-theme] body .history-move{color:var(--ui-text)}
html[data-theme] body .outcome-bar{box-shadow:inset 0 0 0 1px var(--ui-line)}
html[data-theme] body .outcome-bar .white{background:var(--room-board-light)}
html[data-theme] body .outcome-bar .draw{background:var(--room-board-dark)}
html[data-theme] body .outcome-bar .black{background:var(--ui-accent)}
html[data-theme] body .puzzle-island:not([data-tone=correct]):not([data-tone=retry]):not([data-tone=solved]) .puzzle-island-icon{color:var(--room-island-muted)}
html[data-theme] body .puzzle-island-track{background:var(--ui-line)}
html[data-theme] body .island-rim-pulse{border-color:var(--room-edge-tail);box-shadow:inset 0 0 0 1px var(--room-edge)}
html[data-theme] body :is(.setup-tools,.setup-castling,.setup-options,.setup-board-actions){background:transparent;color:var(--ui-text)}
html[data-theme] body .setup-palette button{background:var(--ui-soft);border-color:var(--ui-line)}
html[data-theme] body .setup-palette button[aria-pressed=true]{border-color:var(--ui-accent)}
html[data-theme] body :is(.import-error,.storage-option[data-clear-scope=all] b){color:#b56b60}
html[data-theme] body .storage-confirm .danger{background:#a66556;color:#fff;border-color:#a66556}
html[data-theme] body :is(h1,h2,h3,h4,.panel-title h2,.workspace-heading h2){color:var(--ui-text)}
html[data-theme] body :is(h1 span,h2 span,.opening-search>span,.opening-search kbd,.library-search>span){color:var(--ui-accent)}
html[data-theme] body :is(p,label,legend,small){color:var(--ui-muted)}
html[data-theme] body .desk-note>span{background:var(--ui-line)}
html[data-theme] body .new-game-dialog .desk-engine.active .desk-engine-select{background:var(--ui-soft);color:var(--ui-text)}
html[data-theme] body :is(.desk-engine.unavailable>span,.new-game-dialog .desk-duration>p,#puzzleTotal){color:var(--ui-muted)}
html[data-theme] body :is(.analysis-choice-grid button,.version-item,.engine-principle-card){background:var(--ui-surface);color:var(--ui-text);border-color:var(--ui-line)}
html[data-theme] body :is(.analysis-choice-grid small,.version-tag,.version-item p,.version-item li,.version-item time,.principle-link,.engine-principle p,.engine-principle small){color:var(--ui-muted)}
html[data-theme] body .version-item[data-current=true]{background:var(--ui-soft);border-color:var(--ui-accent)}
html[data-theme] body .setup-board{border-color:var(--room-board-dark)}
html[data-theme] body .setup-square{background:var(--room-board-light);color:var(--ui-text)}
html[data-theme] body .setup-square.dark{background:var(--room-board-dark)}
html[data-theme] body .setup-coord{color:#354751}
html[data-theme] body .setup-square.selected{box-shadow:inset 0 0 0 3px var(--ui-accent)}
html[data-theme] body .position-editor button:not(.setup-square):not(.sheet-close){background:var(--ui-soft);border-color:var(--ui-line);color:var(--ui-text)}
html[data-theme] body .position-editor button[aria-pressed=true]{background:var(--ui-soft)!important;box-shadow:inset 0 0 0 1px var(--ui-accent)}
html[data-theme] body .position-editor .import-actions .primary{background:var(--ui-accent)!important;color:var(--ui-on)!important}
html[data-theme] body .position-editor :is(select,textarea,.setup-castling){border-color:var(--ui-line);color:var(--ui-text)}
html[data-theme] body .position-editor :is(input[type=checkbox],input[type=radio]){accent-color:var(--ui-accent)}
/* Status text inside a themed island must retain its own contrast. */
html[data-theme] body :is(.island-copy small,.puzzle-island-subtitle,.opening-island small,.settings-preview small){color:var(--room-island-muted)}
html[data-theme] body .island-copy b{color:var(--room-island-ink)}
html[data-theme] body .desk-duration>p{color:var(--ui-muted)!important}
html[data-theme] body :is(.version-item ul,.archived-versions,.archived-versions summary,.archived-versions summary #archivedCount){color:var(--ui-muted);border-color:var(--ui-line)}
html[data-theme] body .archived-grid span{background:var(--ui-soft);color:var(--ui-muted)}
html[data-theme] body .version-list{border-color:var(--ui-line)}
html[data-theme] body .version-item::before{background:var(--ui-accent);box-shadow:0 0 0 4px var(--ui-raised)}
html[data-theme] body :is(.engine-principle,.engine-info a,.engine-info-source,.engine-eas){color:var(--ui-accent)}
html[data-theme] body :is(.panel,.position-card,.statistics-card,.continuation-card,.idea-card,.puzzle-card,.opening-catalogue,.opening-detail,.classic-card,.settings-surface),html[data-theme][data-effects] body .panel{background:var(--ui-surface);color:var(--ui-text);border-color:var(--ui-line);box-shadow:0 8px 24px var(--ui-shadow)}
html[data-theme] body :is(.puzzle-stats b,.inventory-number b,.stats b,.continuation-row b,.game-title,.game-result,.workspace-heading h2){color:var(--ui-accent)}
html[data-theme] body .desk-engine.unavailable :is(span,small){color:var(--ui-muted)}
html[data-theme] body :is(#settingsTitle,.setting-title,.settings-content b,.mode b){color:var(--ui-text)}
html[data-theme] body :is(.settings-heading>span,.settings-content .panel-title>span,.time-chevron,.side-thumb-label,.side-thumb-label span,.engine-extra-rating,.classic-caption){color:var(--ui-muted)}
html[data-theme] body :is(.side-control,.time-picker,.time-menu,.time-option,.review-branches button){background:var(--ui-surface);border-color:var(--ui-line);color:var(--ui-text)}
html[data-theme] body :is(.time-option[aria-selected=true],.side-control button[aria-checked=true],.review-branches button[aria-pressed=true],.history-move[aria-current=true]){background:var(--ui-soft);border-color:var(--ui-accent);color:var(--ui-text);box-shadow:none}
html[data-theme] body .settings-shade{background:#24384533!important}
html[data-theme] body .eval-track{box-shadow:none;border-color:var(--room-edge-tail);background:var(--room-board-dark)}
html[data-theme] body #evalWhite{background:var(--room-board-light)}
html[data-theme] body .eval-mid{background:var(--room-edge-tail)}
html[data-theme] body :is(.eval-heading,.eval-detail,#evalScore){color:var(--room-island-ink)}
html[data-theme] body :is(.promotion-eyebrow,#promotionCancel,.promotion-flow,#promotionPreviewName,#promotionHelp,#promotionHelp span,#promotionTitle span){color:var(--ui-muted)}
html[data-theme] body .promotion-preview-wrap{background:var(--ui-soft);border-color:var(--ui-line);box-shadow:0 8px 20px var(--ui-shadow)}
html[data-theme] body #promotionOptions button{background:var(--ui-soft);color:var(--ui-text);border-color:var(--ui-line);box-shadow:none}
html[data-theme] body #promotionOptions button:hover{background:var(--ui-surface);border-color:var(--ui-accent)}
html[data-theme] body :is(.search-progress,.puzzle-progress){background:var(--ui-line)}
html[data-theme] body :is(.search-progress-fill,.inventory-fill,.puzzle-progress-fill){background:var(--ui-accent)}
html[data-theme] body .search-progress-sheen{background:linear-gradient(100deg,transparent 10%,var(--room-edge) 50%,transparent 90%);opacity:.4}
html[data-theme] body .dot{background:var(--ui-accent);border-color:var(--ui-line)}
html[data-theme] body .capture{border-color:var(--ui-accent);box-shadow:none}
html[data-theme] body .hint-arrow-line{stroke:var(--ui-accent)}
html[data-theme] body .hint-arrow-head{fill:var(--ui-accent)}
html[data-theme] body .hint-arrow-tail{fill:var(--room-edge)}
html[data-theme] body :is(.game-meta,.promotion-caption){color:var(--ui-muted)}
html[data-theme] body .settings-actions{border-color:var(--ui-line);background:transparent}
html[data-theme] body #board .square.last{box-shadow:inset 0 0 0 40px var(--ui-focus)}
html[data-theme] body #board .square.hint{outline-color:var(--ui-accent)}
html[data-theme] body :is(.match-result:not(.win):not(.loss):not(.draw),.puzzle-promotion-choices button){background:var(--ui-soft);color:var(--ui-text);border-color:var(--ui-line)}
html[data-theme] body #board :is(.square.selected,.square.hint-from,.square.hint-to){box-shadow:inset 0 0 0 3px var(--ui-accent)}
html[data-theme] body #settingsPanel .settings-actions{border-color:var(--ui-line)}
html[data-theme] body :is(dialog,#themeSettings)::backdrop{background:#24384555}
html[data-theme] body #promotion :is(#promotionCancel,#promotionHelp){color:var(--ui-muted);border-color:var(--ui-line)}
html[data-theme] body .side-control input:checked+span{color:var(--ui-text)}
html[data-theme] body .side-control[data-side=b] .side-thumb{background:var(--ui-accent);border-color:var(--ui-accent)}
html[data-theme] body .side-control[data-side=b] :is(.side-thumb-label,input:checked+span){color:var(--ui-on)}

html[data-theme] body #puzzleHint{background:var(--ui-soft);border-color:var(--ui-line);color:var(--ui-accent)}
html[data-theme] body #coachAvatar{background:var(--ui-soft);border-color:var(--ui-line)}

html[data-theme] body .actions #hint{background:var(--ui-soft)!important;border-color:var(--ui-line)!important;color:var(--ui-text)!important;box-shadow:none}
html[data-theme] body[data-started=false] #hint{background:var(--ui-soft)!important;border-color:var(--ui-line)!important;color:var(--ui-muted)!important}
html[data-theme] body #board .hint-halo{background:var(--ui-focus);border-color:var(--ui-accent);box-shadow:none}

/* Shared controls used by the paper theme also inherit the selected palette. */
html[data-theme] body :is(.room-home,.creator-footer button,.creator-footer button span,.puzzle-promotion-cancel,.time-value,.workspace-mark,.text-btn,.opening-more,#settingsCancel,.theme-eyebrow){color:var(--ui-muted)}
html[data-theme] body :is(.room-home,.opening-nav button,.opening-filters button,.continuation-more,.time-trigger,#settingsImport){background:var(--ui-soft);color:var(--ui-text);border-color:var(--ui-line);box-shadow:none}
html[data-theme] body .opening-filters button[aria-pressed=true]{background:var(--ui-accent);color:var(--ui-on)}
html[data-theme] body :is(.import-actions,.principle-link,.theme-option){border-color:var(--ui-line)}
html[data-theme] body :is(.match-record time,.match-record small){color:var(--ui-muted)}
html[data-theme] body :is(.entry-card,.analyze-button){box-shadow:0 8px 24px var(--ui-shadow)}
html[data-theme] body .square{background:var(--room-board-light)}
html[data-theme] body .square.dark-square{background:var(--room-board-dark)}
html[data-theme] body .square.last{box-shadow:inset 0 0 0 40px var(--ui-focus)}
html[data-theme] body .square .coord{color:#46565b}
html[data-theme] body .square.dark-square .coord{color:#f4f7f5}

@media(max-width:680px) and (orientation:portrait){html[data-theme] body .opening-header{flex-wrap:wrap;height:auto;min-height:44px;gap:6px 10px}html[data-theme] body .opening-header-meta{margin-left:auto}html[data-theme] body .opening-header .theme-settings-trigger{margin-left:0;flex-shrink:0}}

html[data-theme] body :is(.puzzle-room,.opening-room) .capture.move-marker{border:0;box-shadow:inset 0 0 0 6cqw var(--ui-accent);background:transparent}

html[data-theme] body #hintSettings .hint-mode-switch button{background:transparent;color:var(--ui-muted);border-color:transparent;box-shadow:none}
html[data-theme] body #hintSettings .hint-mode-switch button[aria-pressed=true]{background:var(--ui-accent);color:var(--ui-on);border-color:var(--ui-accent)}
