:root { color-scheme: dark; --ui-surface:#1e293b; --ui-text:#e2e8f0; --ui-border:#475569; }
.preference-controls { display:flex; justify-content:center; gap:8px; flex-shrink:0; }
#page-content > .preference-controls, body > .preference-controls { margin:0 0 16px; position:relative; z-index:2; }
.preference-controls button { display:flex; align-items:center; justify-content:center; gap:7px; min-height:44px; min-width:44px; padding:8px 12px; border:1px solid var(--ui-border); border-radius:10px; background:var(--ui-surface); color:var(--ui-text); font:600 13px/1.2 sans-serif; cursor:pointer; touch-action:manipulation; }
.preference-icon { font:20px/1 sans-serif; }
.preference-controls button:focus-visible { outline:3px solid #3b82f6; outline-offset:2px; }
#match-toolbar { gap:8px; }
#match-toolbar .match-mode-name { margin-right:auto; }
#match-toolbar .preference-controls { gap:6px; }
#match-toolbar .preference-controls button { min-height:44px; min-width:44px; gap:6px; }
#match-toolbar .preference-icon { font-size:20px; color:inherit; }
#match-toolbar .preference-label { color:inherit; font-size:12px; }
/* Keep settings accessible while the game itself is paused. */
#game-pause { top:44px; }
@media(max-width:700px) {
    #match-toolbar .preference-label { display:none; }
    #match-toolbar .preference-controls { margin-left:auto; }
    #match-toolbar .match-mode-name { overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
}
@media(max-width:420px) { #match-toolbar .match-mode-name { display:none; } }

/* Light palette: keep player colours and the original game illustrations. */
html[data-color-theme="light"] {
    color-scheme:light; --bg:#f3f6fc; --accent:#0369a1; --boss:#be123c;
    --ui-surface:#ffffff; --ui-text:#172b4d; --ui-border:#b5c5da; --muted:#526580;
}
html[data-color-theme="light"], html[data-color-theme="light"] body {
    background:#f3f6fc !important; color:#172b4d;
}
html[data-color-theme="light"] .ambient-background { display:none; }
html[data-color-theme="light"] #game { background:linear-gradient(135deg,#f7faff,#edf2fa); }
html[data-color-theme="light"] .menu-section,
html[data-color-theme="light"] .rules-box { background:#fff; color:#172b4d; border-color:#c4d2e5; box-shadow:0 6px 24px #25497612; }
html[data-color-theme="light"] #page-content > h1 { background-image:linear-gradient(90deg,#1d4ed8,#7e22ce,#be185d); filter:none; }
html[data-color-theme="light"] select,
html[data-color-theme="light"] input[type="number"] { background:#fff; color:#172b4d; border-color:#9aadc7; }
html[data-color-theme="light"] .slider { background:#a2b1c5; }
html[data-color-theme="light"] input:checked + .slider { background:#0369a1; }
html[data-color-theme="light"] .help-btn,
html[data-color-theme="light"] .rules-close,
html[data-color-theme="light"] .social-link { background:#e8eff9; color:#174980; border-color:#a8bdd8; }
html[data-color-theme="light"] .rules-overlay { background:#142d5059; }
html[data-color-theme="light"] #offline-music { background:#e8eff9 !important; color:#174980 !important; }
html[data-color-theme="light"] #match-toolbar { background:#fff; border-color:#c4d2e5; }
html[data-color-theme="light"] #match-toolbar a,
html[data-color-theme="light"] #match-toolbar button { background:#e8eff9; color:#172b4d; }
html[data-color-theme="light"] #match-toolbar span { color:#425672; }
html[data-color-theme="light"] #match-setup,
html[data-color-theme="light"] #game-pause,
html[data-color-theme="light"] #finish-screen,
html[data-color-theme="light"] #error-review { background:#f3f6fcf5 !important; color:#172b4d; }
html[data-color-theme="light"] .match-card,
html[data-color-theme="light"] .game-pause-card,
html[data-color-theme="light"] #match-statistics { color:#172b4d; }
html[data-color-theme="light"] :is(.match-intro,.match-back,.game-pause-card p,.match-fields-grid label,#match-readiness,#match-fields legend,#setup-op-note,.tutorial-content p,.results-grid dt,.stats-note,#final-score) { color:#526580 !important; }
html[data-color-theme="light"] #match-fields { border-color:#bacbe0; }
html[data-color-theme="light"] #match-summary { color:#334e70; background:#e6eef9; }
html[data-color-theme="light"] #mode-tutorial,
html[data-color-theme="light"] .results-grid article,
html[data-color-theme="light"] .error-item { background:#fff; border-color:#b3c8e2; }
html[data-color-theme="light"] :is(#mode-tutorial summary,.results-grid summary) { color:#1d4ed8; }
html[data-color-theme="light"] :is(.tutorial-content button,.match-finish-actions button,.review-button,.rho-btn) { background:#e4edf9; color:#172b4d; border-color:#9ab4d6; }
html[data-color-theme="light"] #p1-ready { background:#dbeafe; color:#1e40af; border-color:#7198d4; }
html[data-color-theme="light"] #p2-ready { background:#fce7f3; color:#9d174d; border-color:#d08baa; }
html[data-color-theme="light"] :is(#p1-ready,#p2-ready)[aria-pressed="true"] { background:#d1fae5; color:#065f46; border-color:#059669; }
html[data-color-theme="light"] #match-countdown { background:#f3f6fcf5; color:#047857; }
html[data-color-theme="light"] .start-btn { background:#1d4ed8; color:#fff; border-color:#1d4ed8; box-shadow:0 4px 16px #1d4ed825; }
html[data-color-theme="light"] #match-replay { background:#1d4ed8; color:#fff; }
html[data-color-theme="light"] #game #p1-zone { background:linear-gradient(145deg,#eaf2ff,#f7faff); border-color:#acc5e7; }
html[data-color-theme="light"] #game #p2-zone { background:linear-gradient(145deg,#fff0f6,#faf6ff); border-color:#dcafc5; }
html[data-color-theme="light"] #game .equation { color:#102744; text-shadow:none; }
html[data-color-theme="light"] #game .btn { color:#172b4d; background:#fff; border-color:#a5bddb; box-shadow:0 2px 5px #2740600c; }
html[data-color-theme="light"] #game #p2-zone .btn { border-color:#cfabc1; }
html[data-color-theme="light"] #game .btn.correct { background:#d1fae5 !important; color:#065f46; border-color:#059669 !important; box-shadow:none !important; }
html[data-color-theme="light"] #game .btn.wrong { background:#ffe4e6 !important; color:#9f1239; border-color:#e11d48 !important; box-shadow:none !important; }
html[data-color-theme="light"] #game #p1-zone :is(.player-label,.team-symbol) { color:#1d4ed8; }
html[data-color-theme="light"] #game #p2-zone :is(.player-label,.team-symbol) { color:#be185d; }
html[data-color-theme="light"] :is(.player-score,.player-feedback,.learning-progress,#rope-status,.arena-caption p,.arena-footnote) { color:#526580; }
html[data-color-theme="light"] .player-score b { color:#172b4d; }
html[data-color-theme="light"] .play-status { color:#334e70 !important; }
html[data-color-theme="light"] .play-status[data-status="wrong"] { color:#9f1239 !important; }
html[data-color-theme="light"] .play-status[data-status="correct"] { color:#047857 !important; }
html[data-color-theme="light"] .play-status[data-status="blocked"] { color:#92400e !important; }
html[data-color-theme="light"] .result-awards { color:#92400e; }
html[data-color-theme="light"] :is(.hp-bar,.boss-bar,.castle-hp-bar,.tower-hp-bar) { background:#cbd5e1; border-color:#64748b; }
html[data-color-theme="light"] #racing-tracks { background:#dce6f2; border-color:#95aac6; }
html[data-color-theme="light"] .track { background:#e2eaf5; border-color:#94a3b8; }
html[data-color-theme="light"] #game .track::before { color:#1e40af; }
html[data-color-theme="light"] #game .track + .track::before { color:#9d174d; }
html[data-color-theme="light"] #battlefield { background:linear-gradient(#dceef2,#e4f1df 65%,#c8dab5) !important; }
html[data-color-theme="light"] .castle-hp-label { color:#172b4d; text-shadow:none; }
html[data-color-theme="light"] #game .side-panel { border-color:#c4d2e5; }
html[data-color-theme="light"] #game :is(.action-btn,.shop-tab) { background:#fff; color:#172b4d; border-color:#a8bdd8; }
html[data-color-theme="light"] #game :is(.action-label,.action-status) { color:#334e70; }
html[data-color-theme="light"] #game :is(.action-cost,.coins-val,.diff-btn small) { color:#854d0e; }
html[data-color-theme="light"] #game :is(.diff-btn.active,.shop-tab[aria-selected="true"]) { background:#dbeafe; color:#1e40af; border-color:#3b82f6; }
html[data-color-theme="light"] #game #p2-zone .shop-tab[aria-selected="true"] { background:#fce7f3; color:#9d174d; border-color:#db2777; }
html[data-color-theme="light"] #game .shop-grid .action-btn:disabled { background:#e8edf5; border-color:#c3cedd; }
html[data-color-theme="light"] #game .shop-grid .action-btn:disabled .action-label { color:#5c6e85; }
html[data-color-theme="light"] #game .shop-grid .action-btn.active-effect { background:#ede9fe; border-color:#8b5cf6; }
html[data-color-theme="light"] #game .shop-grid .action-btn.active-effect .action-label { color:#5b21b6; }
html[data-color-theme="light"] .shop-scroll-hint { background:linear-gradient(transparent,#edf2fa 35%); color:#526580; }
html[data-color-theme="light"] .tension-labels span:last-child { color:#be185d; }
html[data-color-theme="light"] #rope-marker { background:#475569; box-shadow:none; }
