/* Shared interface palettes. Artwork and game-piece colors retain their meaning. */
:root[data-experience="history-tree"][data-theme]{--white:var(--lv-panel);--green:var(--lv-accent);--line-dark:var(--lv-line);--lime:var(--lv-soft)}
:root[data-experience="history-tree"][data-theme="dark"] :is(.era-node,.region-node,.toggle){background:var(--lv-soft);color:var(--lv-ink)}
:root[data-experience="history-tree"][data-theme] .hero h1{color:#fffef8!important}
:root[data-experience="history-tree"][data-theme] .jump{background:var(--lv-accent);color:var(--lv-on-accent)}
:root[data-experience="history-tree"][data-theme="dark"] :is(.era-links button:hover,#expand:hover,#clear:hover,.dialog-actions button:hover,.article-list a:hover,.related-list button:hover){background:var(--lv-control);color:var(--lv-ink)}
:root[data-theme="light"]{color-scheme:light;--lv-bg:#faf9f4;--lv-panel:#fffefa;--lv-soft:#eee9f5;--lv-ink:#29213b;--lv-muted:#6d647b;--lv-line:#ded7e7;--lv-accent:#6b4bc0;--lv-control:#f0ebf7;--lv-on-accent:#fff}
:root[data-theme="dark"]{color-scheme:dark;--lv-bg:#191622;--lv-panel:#252030;--lv-soft:#30283e;--lv-ink:#f1ecf8;--lv-muted:#bdb1cc;--lv-line:#4a3e5b;--lv-accent:#c4a7fa;--lv-control:#332a43;--lv-on-accent:#251936}
:root[data-theme]{--bg:var(--lv-bg);--base:var(--lv-bg);--page:var(--lv-bg);--panel:var(--lv-panel);--ink:var(--lv-ink);--muted:var(--lv-muted);--sub:var(--lv-muted);--line:var(--lv-line);--border:var(--lv-line);--night:var(--lv-bg);--ivory:var(--lv-ink);--lilac:var(--lv-accent);--board:var(--lv-soft);--arena:var(--lv-soft);background:var(--lv-bg)!important;color:var(--lv-ink)!important}
:root[data-theme] body{background:var(--lv-bg)!important;color:var(--lv-ink)!important}
:root[data-experience="color-trails"]{--paper:var(--lv-ink);--accent:var(--lv-accent)}
:root[data-experience="vesper-files"]{--gold:var(--lv-accent);--teal:var(--lv-accent)}
:root[data-experience]:not([data-experience="color-trails"]){--paper:var(--lv-bg)}
:root[data-theme] :is(header,.topbar,footer,.sidebar,.rail){background-color:var(--lv-bg)!important;border-color:var(--lv-line)!important;color:var(--lv-ink)}
:root[data-theme] :is(dialog,.modal-card,.panel,.library,.dialog-head,.arena,.game,.budget-panel,.board-panel){background:var(--lv-panel)!important;color:var(--lv-ink)!important;border-color:var(--lv-line)!important}
:root[data-theme] dialog::backdrop{background:#14101fb3}
:root[data-theme] :is(.small,.icon-button,.close,.tab,.action,.control,.blade,.level-tile,.level-pill,.palette,.tool,.search,.controls button,.settings-row select,.archive-controls input,.archive-controls select){background:var(--lv-control)!important;color:var(--lv-ink)!important;border-color:var(--lv-line)!important}
:root[data-theme] :is(.tab.active,.tabs button[aria-selected="true"],.action.primary,.cta,.primary,.btn.primary){background:var(--lv-accent)!important;color:var(--lv-on-accent)!important;border-color:var(--lv-accent)!important}
:root[data-theme] :is(.subtitle,.muted,.description,.hint-text,.side-caption,.small-label,.stats,.below,.how p,.game-bottom p,.intro p,.details p){color:var(--lv-muted)!important}
:root[data-theme] input,:root[data-theme] select{color:var(--lv-ink)}
:root[data-experience="color-trails"] :is(.board,.cell){background:var(--lv-soft)!important;border-color:var(--lv-line)!important}
:root[data-experience="color-trails"] .cell.alt{background:var(--lv-panel)!important}
:root[data-experience="color-trails"] :is(.puzzle-card,.mode-card,.menu-row,.summary-card,.personal-best,.stat-card,.challenge-card,.board-victory strong){background:var(--lv-panel)!important;color:var(--lv-ink)!important;border-color:var(--lv-line)!important}
:root[data-experience="color-trails"] :is(.card-footer,.home-stats){color:var(--lv-accent)!important;border-color:var(--lv-line)!important}
:root[data-experience="color-trails"][data-theme="light"] :is(.eyebrow,.brand small,.statbar small,.level-label){color:var(--lv-muted)!important}
:root[data-experience="elementarium"] :is(.board,.element,.discovery,.toast,.mark,.libtitle span){background:var(--lv-soft)!important;color:var(--lv-ink)!important;border-color:var(--lv-line)!important}
:root[data-experience="elementarium"] .element:hover{background:var(--lv-control)!important;border-color:var(--lv-accent)!important}
:root[data-experience="elementarium"][data-theme="light"] .underlay h2{color:var(--lv-ink)!important}
:root[data-experience="elementarium"][data-theme="light"] :is(.underlay p,.boardtip,.boardbar strong,.library-foot,.statusbar,.search input::placeholder,.dialog-body p,.row small,.recipe-list,.statline){color:var(--lv-muted)!important}
:root[data-experience="elementarium"][data-theme="light"] .sigil{color:var(--lv-accent);opacity:.55}
:root[data-experience="orchard-hit"] :is(.stage,.metric,#ammo,#tip,kbd){background:var(--lv-panel)!important;color:var(--lv-ink)!important;border-color:var(--lv-line)!important}
:root[data-experience="orchard-hit"][data-theme="light"] .overlay{background:linear-gradient(180deg,#faf9f400,#faf9f4b0 55%,#faf9f4f5)}
:root[data-experience="orchard-hit"][data-theme="light"] .overlay :is(h1,h2,p){color:var(--lv-ink)!important}
:root[data-experience="vesper-files"] :is(.card,.evidence,.feedback,.hint,.scene-art .caption){background:var(--lv-panel)!important;color:var(--lv-ink)!important;border-color:var(--lv-line)!important}
:root[data-experience="vesper-files"] .prose{color:var(--lv-ink)!important}
:root[data-experience="vesper-files"] .hero .tag{color:var(--lv-muted)!important}
:root[data-experience="vesper-files"][data-theme="light"] .hero:after{background:linear-gradient(90deg,#faf9f4 4%,#faf9f4f5 29%,#faf9f480 53%,#faf9f410 82%),linear-gradient(0deg,#faf9f4,transparent 32%)}
:root[data-experience="vesper-files"][data-theme="light"] .hero-location{background:#faf9f4c9;padding:12px;color:var(--lv-ink)}
:root[data-experience="vesper-files"][data-theme="light"] .hero-location b{color:var(--lv-ink)}
:root[data-theme="dark"] :is(.card,.receipt,.question,.result,.poll-card,.time-card,.day-card,.sound-card,.sound-channel,.channel,.daily-note,.personal-best,.win,.paper,.level-grid button,.product-card){background:var(--lv-panel)!important;color:var(--lv-ink)!important;border-color:var(--lv-line)!important}
:root[data-theme="dark"] :is(.game-top,.controls,.level-pill,.how,.panel-label,.drawing-toolbar,.budget-panel,.shop-search){background:var(--lv-panel)!important;color:var(--lv-ink)!important;border-color:var(--lv-line)!important}
:root[data-theme="dark"] :is(h1,h2,h3,.stats b,.how b,.win h2,.win p){color:var(--lv-ink)}
:root[data-theme="dark"] .board{background-color:var(--lv-soft)!important}
/* Explicit foreground/background pairs for controls from the supplied games. */
:root[data-theme="dark"] .primary-button{background:var(--lv-accent)!important;color:var(--lv-on-accent)!important}
:root[data-theme="dark"] .primary-button:hover{background:#d4bdf9!important;color:var(--lv-on-accent)!important}
:root[data-theme="dark"] :is(.btn:not(.primary):not(.cta),button.icon,.chapter-picker button){background:var(--lv-control)!important;color:var(--lv-ink)!important;border-color:var(--lv-line)!important}
:root[data-theme="dark"] :is(.btn:not(.primary):not(.cta),button.icon,.chapter-picker button):hover{background:#483859!important;color:var(--lv-ink)!important}
:root[data-experience="stack"][data-theme="dark"] .palette-state{color:var(--lv-muted)!important}
:root[data-experience="hue"][data-theme="dark"] #hint-count{background:var(--lv-soft)!important;color:var(--lv-ink)!important}
:root[data-experience="timberman"][data-theme="dark"] :is(.nav-link,#restartBtn){color:var(--lv-muted)!important}
:root[data-experience="timberman"][data-theme="dark"] .nav-link.active{color:var(--lv-ink)!important}
:root[data-experience="timberman"][data-theme="dark"] .nav-link span{background:var(--lv-control)!important;color:var(--lv-ink)!important}
:root[data-experience="timberman"][data-theme="dark"] .mode-switch{background:var(--lv-control)!important}
:root[data-experience="timberman"][data-theme="dark"] .mode-switch button{color:var(--lv-ink)!important}
:root[data-experience="timberman"][data-theme="dark"] .mode-switch button.selected{background:var(--lv-accent)!important;color:var(--lv-on-accent)!important}
:root[data-experience="ambient-sounds"][data-theme="dark"] .mixer-bar{background:var(--lv-bg)!important}
:root[data-experience="ambient-sounds"][data-theme="dark"] .filters button{background:transparent!important;color:var(--lv-ink)!important}
:root[data-experience="ambient-sounds"][data-theme="dark"] .filters button:hover{background:var(--lv-control)!important;color:var(--lv-ink)!important}
:root[data-experience="ambient-sounds"][data-theme="dark"] .filters button[aria-pressed="true"]{background:var(--lv-accent)!important;color:var(--lv-on-accent)!important}
:root[data-experience="day-atlas"][data-theme="dark"] #reset{color:var(--lv-accent)!important}
:root[data-experience="pick-a-side"][data-theme="dark"] .choice{color:#29213b!important}

/* Keep the glyph and its label readable on the same button surface. */
:root[data-experience="stack"][data-theme] .primary-button span,
:root[data-experience="water-sort"][data-theme] .controls button span { color: inherit; }
:root[data-experience="water-sort"][data-theme="dark"] :is(#sound,#symbols,#help),
:root[data-experience="timberman"][data-theme="dark"] #pauseBtn {
  background: var(--lv-control);
  color: var(--lv-ink);
}
:root[data-experience="stack"][data-theme="light"] :is(.text-button,.text-button span,.palette-state),
:root[data-experience="hue"][data-theme="light"] :is(.text-button,.nav-item,.nav-item span,#hint-count,#hint-button,#reset-button,#undo-button,#hint-button span,#reset-button span,#undo-button span),
:root[data-experience="timberman"][data-theme="light"] :is(.nav-link,.nav-link span,#restartBtn,.mode-switch button,.scenery) {
  color: #485b46;
}
:root[data-experience="color-trails"][data-theme="light"] .square-button {
  color: var(--lv-ink);
  background: var(--lv-control);
}
:root[data-experience="color-trails"][data-theme="light"] .tile-icon.mint { color: #246856; }
:root[data-experience="color-trails"][data-theme="light"] .tile-icon.gold { color: #754a0a; }
:root[data-experience="color-trails"][data-theme="light"] .tile-icon.lilac { color: #634191; }

:root[data-experience="bridgebound"][data-theme="dark"] .skin,
:root[data-experience="timberman"][data-theme="dark"] :is(.close-dialog,.character-card) {
  color: var(--lv-ink);
  background: var(--lv-control);
  border-color: var(--lv-line);
}
:root[data-experience="bridgebound"][data-theme="dark"] .skin[aria-pressed="true"],
:root[data-experience="timberman"][data-theme="dark"] .character-card.selected {
  border-color: var(--lv-accent);
}
:root[data-experience="timberman"][data-theme="dark"] .character-card small { color: var(--lv-muted); }
:root[data-experience="fold-beyond"][data-theme="dark"] #unfold { color: var(--lv-on-accent); }

/* Bridgebound paints a daylight landscape in both site themes. */
:root[data-experience="bridgebound"][data-theme] .center :is(h1,h2),
:root[data-experience="bridgebound"][data-theme] .hud .pill,
:root[data-experience="bridgebound"][data-theme] .controls kbd { color: #1d2e29; }

/* Match text to its painted surface, including panels that retain their artwork. */
:root[data-experience="stack"] .arena-corner { color:#25372c; background:#f4f5eb; border-radius:4px; padding:2px 4px; }
:root[data-experience="stack"] .mode-pill { color:#293b31; background:#f4f5eb; }
:root[data-experience="stack"][data-theme="light"] :is(.section-heading span,.note-star,.note-bottom) { color:#51604c; }
:root[data-experience="hue"][data-theme="light"] :is(.breadcrumb,.breadcrumb span,.breadcrumb b,.eyebrow,.little-star,#level-instruction,.difficulty,.board-caption,.board-caption span,.dialog-footnote,.move-count span,.under-puzzle span) { color:#525e4c; }
:root[data-experience="hue"][data-theme="light"] .primary-button { background:#4d6948; color:white; }
:root[data-experience="hue"][data-theme="dark"] #chapter-label { color:var(--lv-muted); }
:root[data-experience="bridgebound"] #balance,
:root[data-experience="water-sort"] :is(#message,#dialogbody p,.level-theme small),
:root[data-experience="ricochet"] .kicker,
:root[data-experience="orchard-hit"] :is(.metric span,.controls,#progress),
:root[data-experience="color-trails"] #footerProgress { color:var(--lv-muted); }
:root[data-experience="water-sort"] :is(.intro .eyebrow,.level-theme) { color:var(--lv-accent); }
:root[data-experience="timberman"] .start-card :is(h2,p,.little-label,.start-hint),
:root[data-experience="timberman"] kbd { color:#344530; }
:root[data-experience="timberman"] :is(.best-panel p,.best-bottom,.best-bottom b,.setup-panel label,.mode-description,.tip-panel p,dialog p,.best-value span,.game-footer,.tip-icon) { color:var(--lv-muted); }
:root[data-experience="timberman"] .snow-art { color:#405c62; }
:root[data-experience="timberman"][data-theme="light"] .character-card small { color:#495e40; }
:root[data-experience="ambient-sounds"] .masthead h1 { color:#312440; }
:root[data-experience="day-atlas"] :is(h1 em,.field output),
:root[data-experience="pick-a-side"] h1 em { color:var(--lv-accent); }
:root[data-experience="history-tree"] .hero :is(.kicker,h1 em) { color:#d5e9a9; }
:root[data-experience="elementarium"][data-theme="light"] .row { background:var(--lv-soft); color:var(--lv-ink); }
:root[data-experience="elementarium"] .tabs button:not([aria-selected="true"]) { background:var(--lv-control); color:var(--lv-ink); }
:root[data-experience="fold-beyond"] :is(.milestone,.milestone h2,.copy,.copy p) { color:#324431; }
:root[data-experience="fold-beyond"][data-theme="light"] #unfold { background:#6546a3; color:white; }
:root[data-experience="fold-beyond"][data-theme="light"] #unfold:hover:not(:disabled) { background:#523785; }
:root[data-experience="vesper-files"][data-theme="light"] .hero:after { background:linear-gradient(90deg,#faf9f4 4%,#faf9f4fa 36%,#faf9f4cc 55%,transparent 85%); }
@media(max-width:700px){
 :root[data-experience="vesper-files"][data-theme="light"] .hero:after { background:linear-gradient(to bottom,transparent 0,#faf9f4f7 220px,#faf9f4 100%); }
}
:root[data-experience="vesper-files"][data-theme="light"] .hero .btn:not(.primary) { background:var(--lv-panel); color:var(--lv-ink); }

:root[data-experience="orchard-hit"][data-theme="light"] :is(.overlay h1 span,.controls,dialog p) { color:#4c5344; }
:root[data-experience="water-sort"] .how div > span { color:#4e6248; }
:root[data-experience="timberman"] :is(.how-title .eyebrow,.instruction .step,.instruction p,.footer-brand) { color:var(--lv-muted); }
:root[data-experience="day-atlas"][data-theme="light"] .result { --muted:#504659; }
:root[data-experience="day-atlas"][data-theme="light"] :is(.result span,#result-note) { color:#51445e; }
:root[data-experience="day-atlas"][data-theme="dark"] :is(#out-home,#planned) { color:var(--lv-accent); }
:root[data-experience="fold-beyond"] :is(.milestone .progress-label,#comparison) { color:#324431; }

:root[data-experience="stack"] dialog .instruction,
:root[data-experience="hue"] :is(p.intro,.level-button small),
:root[data-experience="orchard-hit"] .blade small { color:var(--lv-muted); }
:root[data-experience="orchard-hit"][data-theme="light"] .controls > span { color:#404438; }
:root[data-experience="pack-it-in"] .stamp,
:root[data-experience="pack-it-in"] .stamp small { color:#40382c; }
:root[data-experience="day-atlas"][data-theme="dark"] #remaining { color:var(--lv-accent); }

:root[data-experience="ambient-sounds"][data-theme="dark"] .dial-icon { filter:brightness(0) invert(94%); opacity:1; }
:root[data-experience="ambient-sounds"] :is(.volume,.mobile-level) { color:var(--lv-muted); }

:root[data-experience="color-trails"][data-theme="light"] :is(.row-badge,.row-arrow),
:root[data-experience="elementarium"][data-theme="light"] .board .corner { color:#554367; }

:root[data-experience="ricochet"][data-theme="dark"] .win-card {
  background: var(--lv-panel);
  border-color: var(--lv-line);
}
:root[data-experience="ricochet"][data-theme="dark"] .win {
  background: #14101fb3 !important;
}
:root[data-experience="ricochet"][data-theme="dark"] .win-icon { color:var(--lv-accent); }
