/* Global visual-only theme tokens. Never recolor game sprites or calculate game state. */
html[data-theme="light"] {
  color-scheme:light;
  --bg-primary:#f7f9ff;--bg-secondary:#edf2fa;--bg-surface:#fff;
  --text-primary:#25344e;--text-secondary:#53647b;--border-color:#cbd5e7;
  --accent-color:#315de1;--button-bg:#edf2ff;--modal-bg:#fff;
  --input-bg:#fff;--game-panel-bg:#fff;--game-overlay-bg:#f0f5faef;
  --ui-text-on-dark:#eef3e7;--ui-muted-on-dark:#d4e3d9;
}
html[data-theme="dark"] {
  color-scheme:dark;
  --bg-primary:#101d24;--bg-secondary:#172b32;--bg-surface:#20353b;
  --text-primary:#eef3e7;--text-secondary:#bdcdc6;--border-color:#50676b;
  --accent-color:#e7d196;--button-bg:#274740;--modal-bg:#1b3239;
  --input-bg:#233a41;--game-panel-bg:#20363a;--game-overlay-bg:#13282feF;
  --ui-text-on-dark:#eef3e7;--ui-muted-on-dark:#c8d8cf;
}
/* Reserve the real page scrollbar while a full-screen game menu locks scrolling.
 * Home/race scroll in body; standalone games scroll at the document root. */
html {scrollbar-gutter:stable;}
/* Home/race and QuickBet maintain their own body scrollbars. */
html:has(> body:is(.game-portal,.standalone-quickbet)) {scrollbar-gutter:auto;}
body:is(.game-portal,.standalone-quickbet) {scrollbar-gutter:stable;}
html[data-theme] {background:var(--bg-primary);}
html[data-theme] body {--theme-bg:var(--bg-primary);--theme-surface:var(--bg-surface);}
html[data-theme] :is(button,a,input,select,textarea,summary):focus-visible {
  outline:3px solid var(--accent-color);outline-offset:3px;
}
.site-theme-toggle {
  box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;
  flex:0 0 44px;min-width:44px;width:44px;height:44px;margin:0;padding:0;
  border:1px solid var(--header-line,var(--border-color));
  background:var(--header-control,var(--button-bg));
  color:var(--header-text,var(--text-primary));border-radius:11px;
  font:700 25px/1 system-ui,sans-serif;cursor:pointer;
}
.site-theme-toggle:hover {background:var(--header-control-hover,var(--bg-secondary));}
.site-theme-toggle:focus-visible {outline:3px solid var(--accent-color);outline-offset:2px;}
.site-theme-glyph {display:block;line-height:1;}
/* Browser-native controls stay legible in either palette. */
html[data-theme] :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),select,textarea) {
  accent-color:var(--accent-color);
}
html[data-theme] input[type="range"],html[data-theme] input[type="checkbox"] {accent-color:var(--accent-color);}
html[data-theme] ::selection {background:var(--accent-color);color:var(--bg-primary);}

/* Home and racing landing screens preserve their original layout and artwork. */
html[data-theme="dark"] body.game-portal {
  --home-paper:#111e28;--home-ink:#edf3ee;--home-muted:#bdcdc6;
  background:var(--bg-primary);color:var(--text-primary);
}
html[data-theme="dark"] body.game-portal :is(.hero.game-home,.features.home-guide,.home-welcome) {
  background:var(--bg-secondary);color:var(--text-primary);
}
html[data-theme="dark"] body.game-portal :is(.home-featured,.home-tile,.home-search-field,.home-motion-toggle,.home-footer,.race-page-features article,.home-guide .feature-card) {
  background:var(--bg-surface);color:var(--text-primary);border-color:var(--border-color);
}
html[data-theme="dark"] body.game-portal .home-guide .feature-number {
  background:#243746;color:#bcd0ff;
}
html[data-theme="dark"] body.game-portal :is(.home-featured h2,.home-category-heading h3,.home-tile-title,.home-directory-heading h2,.home-guide h2,.home-guide h3,.race-page-features h2) {color:var(--text-primary);}
html[data-theme="dark"] body.game-portal :is(.home-featured-copy>p,.home-tile-desc,.home-tile-meta,.home-category-heading p,.home-directory-heading p,.home-discovery label,.home-guide p,.home-footer,.race-page-features p) {color:var(--text-secondary);}
html[data-theme="dark"] body.game-portal :is(.home-tile-meta,.home-filter-row,.home-guide .feature-container) {border-color:var(--border-color);}
html[data-theme="dark"] body.game-portal :is(.home-search-field,#home-play-mode,.home-motion-toggle,.home-help-button) {
  background-color:var(--input-bg);color:var(--text-primary);border-color:var(--border-color);
}
html[data-theme="dark"] body.game-portal :is(#home-search,.home-filters button,#home-catalog-status,#home-search-clear,.home-featured-label) {color:var(--text-primary);}
html[data-theme="dark"] body.game-portal .home-filters button[aria-pressed="true"] {background:var(--accent-color);color:#16282b;}
html[data-theme="dark"] body.game-portal .home-filters button:hover {background:var(--button-bg);}
/* Small navigation arrows are functional iconography, not faded decoration. */
html[data-theme="light"] body.game-portal .home-tile-open {color:#465c85;}
html[data-theme="dark"] body.game-portal .home-tile-open {color:#bfd0e8;}
html[data-theme="dark"] body.game-portal .home-footer a {color:#e6d498;}
html[data-theme="dark"] body.game-portal .race-page-hero {background:linear-gradient(120deg,#0b292b,#204743);border-color:#4b6d64;}

/* In the racing engine only panels and track UI change; scenery/horse art remain intact. */
html[data-theme="light"] body.game-portal #raceTrack {
  background:#eef4f0;color:#1e3838;--color-text:#243b3d;--color-text-muted:#536c69;
  --color-dark:#e4ede8;--color-darker:#d5e5dd;
}
html[data-theme="light"] body.game-portal #raceTrack .track {
  background-color:#dcece1;background-image:linear-gradient(0deg,#cbded080,#e1f0e078);
  border-color:#9bbcb0;box-shadow:inset 0 0 12px #335d4b19;
}
html[data-theme="light"] body.game-portal #raceTrack .lane,
html[data-theme="light"] body.game-portal #raceTrack .lane:nth-child(odd) {
  background:linear-gradient(90deg,#cde2d3dd,#e5f4e4dd);
  border-color:#a4c3b2;
}
html[data-theme="light"] body.game-portal #raceTrack .timer {
  background:linear-gradient(90deg,#d4e5da,#eff7ee,#d4e5da);
  color:#245c57;border:1px solid #9dbdad;text-shadow:none;box-shadow:0 2px 8px #2e58401c;
}
html[data-theme="dark"] body.game-portal #raceTrack {background:#0e2024;color:#eef3e7;}
html[data-theme="light"] body.game-portal .countdown-overlay {background-color:#e7f0e6e8;color:#204a41;}
/* Results are independent of whether the underlying game uses Canvas or DOM. */
html[data-theme="light"] body.game-portal #raceResults {
  background:#fff;color:#223a3d;border-color:#bed2cd;box-shadow:0 20px 60px #17332b33;
}
html[data-theme="light"] body.game-portal #raceResults :is(h2,.result-winner-name,.race-results-list) {color:#223a3d;}
html[data-theme="light"] body.game-portal #raceResults .result-winner {
  background:#eaf2e8;border-color:#a5c1b2;
}
html[data-theme="light"] body.game-portal #raceResults .result-winner-icon {background:#dcebcf;}
html[data-theme="light"] body.game-portal #raceResults :is(.result-winner-time,.result-finish-count) {color:#50655f;}
html[data-theme="light"] body.game-portal #raceResults .result-winner-label {color:#70520b;}
html[data-theme="light"] body.game-portal .modal-content {background:var(--modal-bg);color:var(--text-primary);border-color:var(--border-color);box-shadow:0 12px 50px #1b3d4533;}
html[data-theme="light"] body.game-portal :is(.modal-content input,.modal-content select,.modal-content textarea) {background:var(--input-bg);color:var(--text-primary);border-color:var(--border-color);}
html[data-theme="light"] body.game-portal :is(.modal-header h2,.info-tab-content h3) {color:#234b72;text-shadow:none;}

/* A modal or start countdown must cover the unified sticky header (z=1200).
   Otherwise the mobile header obscures the race setup title and close button. */
body.game-portal :is(.modal,.main-menu-modal,.game-help-modal,.credits-modal) {z-index:1400;}
body.game-portal .countdown-overlay {z-index:1300;}

/* The results sheet is a dialog, not HUD scenery. Keep it above the
   two-row mobile header and dim the entire header behind it. */
body.game-portal.results-open::after {z-index:1220;}
body.game-portal #raceResults {z-index:1221;}
@media(max-width:480px){
  body.game-portal #raceResults {
    top:max(12px,env(safe-area-inset-top,0px));
    max-height:calc(100dvh - 24px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));
  }
}

/* Racing setup: the original setup widgets have hard-coded dark colors.
   Keep the game scenery untouched, but give every setup control a light palette. */
html[data-theme="light"] body.game-portal #settingsModal {color-scheme:light;}
html[data-theme="light"] body.game-portal #settingsModal .modal-content {background:#fff;color:#243b3d;border-color:#bed2d0;}
html[data-theme="light"] body.game-portal #settingsModal .modal-header {
  background:#edf4f0;border-color:#c5d7cd;color:#243b3d;
}
html[data-theme="light"] body.game-portal #settingsModal .modal-header h2 {color:#234439;}
html[data-theme="light"] body.game-portal #settingsModal .close-modal {
  background:#fff;color:#38554f;border-color:#a6bdb5;
}
html[data-theme="light"] body.game-portal #settingsModal .close-modal:hover {
  background:#dbece2;color:#1d4133;
}
html[data-theme="light"] body.game-portal #settingsModal :is(.settings-intro,.field-hint,.device-performance,.bet-description) {color:#526b67;}
html[data-theme="light"] body.game-portal #settingsModal .form-group label,
html[data-theme="light"] body.game-portal #settingsModal :is(.settings-disclosure summary,.music-credits h3) {color:#253e3a;}
html[data-theme="light"] body.game-portal #settingsModal .settings-disclosure {border-color:#c8d9d1;}
html[data-theme="light"] body.game-portal #settingsModal .disclosure-chevron {color:#416d5b;}
html[data-theme="light"] body.game-portal #settingsModal .settings-actions {background:#edf4f0;border-color:#c5d7cd;}
html[data-theme="light"] body.game-portal #settingsModal .range-value {background:#edf5f0;color:#24473b;}
html[data-theme="light"] body.game-portal #settingsModal :is(.count-step,.count-presets button:not([aria-pressed="true"])) {
  background:#f1f6f2;color:#294b40;border-color:#a9c2b5;
}
html[data-theme="light"] body.game-portal #settingsModal .count-presets button[aria-pressed="true"] {
  background:#32674f;color:#fff;border-color:#32674f;
}
html[data-theme="light"] body.game-portal #settingsModal input[type="range"]::-webkit-slider-runnable-track {background:#a9c8bb;}
html[data-theme="light"] body.game-portal #settingsModal input[type="range"]::-moz-range-track {background:#a9c8bb;}
html[data-theme="light"] body.game-portal #settingsModal input[type="range"]::-webkit-slider-thumb {
  background:#2e775c;border-color:#fff;box-shadow:0 0 0 1px #2e775c;
}
html[data-theme="light"] body.game-portal #settingsModal input[type="range"]::-moz-range-thumb {
  background:#2e775c;border-color:#fff;
}
html[data-theme="light"] body.game-portal #settingsModal :is(.track-option,.performance-option,.theme-choice,.bet-tab,.quick-amount-btn) {
  background:#f1f6f3;color:#284b3e;border-color:#b3cbc0;box-shadow:none;
}
html[data-theme="light"] body.game-portal #settingsModal :is(.track-option,.performance-option,.theme-choice,.bet-tab,.quick-amount-btn):hover {
  background:#e0eee5;border-color:#468268;
}
html[data-theme="light"] body.game-portal #settingsModal :is(.track-option.active,.performance-option.active,.bet-tab.active) {
  background:#32674f;color:#fff;border-color:#32674f;
}
html[data-theme="light"] body.game-portal #settingsModal .theme-choice[aria-pressed="true"] {
  background:#e0f0e6;color:#204634;border-color:#397a5c;box-shadow:inset 0 0 0 1px #397a5c;
}
html[data-theme="light"] body.game-portal #settingsModal .theme-choice-name {color:#284b3e;}
html[data-theme="light"] body.game-portal #settingsModal .theme-choice[aria-pressed="true"] .theme-choice-name {color:#20523a;}
html[data-theme="light"] body.game-portal #settingsModal .theme-choice-mood,
html[data-theme="light"] body.game-portal #settingsModal .theme-track-title {color:#516c63;}
html[data-theme="light"] body.game-portal #settingsModal .theme-random > span:first-child {color:#32674f;}
html[data-theme="light"] body.game-portal #settingsModal :is(select,.weather-select,.bet-horse-select,.bet-amount,#raceFavorite) {
  background-color:#fff;color:#253f3a;border-color:#a9c0b4;color-scheme:light;
}
html[data-theme="light"] body.game-portal #settingsModal .race-favorite-setting {
  background:radial-gradient(circle at 100% 0%,rgba(235,194,77,.16),transparent 55%),linear-gradient(155deg,#f8fcf9,#eef6f1);
  border-color:#bdd3c8;
  box-shadow:0 2px 8px rgba(32,68,52,.06),inset 0 1px 0 rgba(255,255,255,.9);
}
html[data-theme="light"] body.game-portal #settingsModal .form-group.race-favorite-setting > label,
html[data-theme="light"] body.game-portal #settingsModal .race-favorite-setting > label {color:#214939;}
html[data-theme="light"] body.game-portal #settingsModal .favorite-chip {
  background:#fff;color:#243f36;border-color:#bfd4c9;border-left:3.5px solid var(--chip-color,#4a7c66);
  box-shadow:0 1px 3px rgba(28,58,45,.05);
}
html[data-theme="light"] body.game-portal #settingsModal .favorite-chip-all {
  background:#edf5f0;color:#274b3e;border-left-width:1px;
}
html[data-theme="light"] body.game-portal #settingsModal .favorite-chip:hover {
  background:#e6f3ec;border-color:#4b896c;border-left-color:var(--chip-color,#32674f);
}
html[data-theme="light"] body.game-portal #settingsModal .favorite-chip[aria-pressed="true"],
html[data-theme="light"] body.game-portal #settingsModal .favorite-chip.is-selected {
  background:linear-gradient(135deg,#fffbeb,#e6f4ec);border-color:#d4a017;border-left-color:var(--chip-color,#d4a017);
  box-shadow:0 3px 10px rgba(180,134,18,.16),inset 0 0 0 1px rgba(212,160,23,.38);color:#1b3a2e;
}
html[data-theme="light"] body.game-portal #settingsModal .favorite-chip-all .favorite-chip-badge {
  background:rgba(50,103,79,.14);color:#23493a;
}
html[data-theme="light"] body.game-portal #settingsModal .favorite-chip-star {color:#d99b00;}
html[data-theme="light"] body.game-portal #settingsModal :is(.horse-name-input,.bet-content,.balance-display,.odds-display-container) {
  background:#f1f6f3;color:#24443b;border-color:#b5cdc1;
}
html[data-theme="light"] body.game-portal #settingsModal .horse-name-input .horse-number {color:#506b61;}
html[data-theme="light"] body.game-portal #settingsModal .horse-name-input input {background:transparent;color:#243b3d;}
html[data-theme="light"] body.game-portal #settingsModal .horse-name-input input::placeholder {color:#687f78;}
html[data-theme="light"] body.game-portal #settingsModal .horse-name-input:focus-within {border-color:#2b7454;outline-color:#2b7454;}
html[data-theme="light"] body.game-portal #settingsModal .shuffle-btn,
html[data-theme="light"] body.game-portal #settingsModal .music-toggle-inline {
  background:#e9f3ec;color:#275a41;border-color:#a9c5b5;
}
html[data-theme="light"] body.game-portal #settingsModal :is(.music-credits,.betting-section) {border-color:#c8d9d1;color:#536b65;}
html[data-theme="light"] body.game-portal #settingsModal .music-credits a {color:#215e42;}
html[data-theme="light"] body.game-portal #settingsModal .music-settings output {color:#3c6154;}
html[data-theme="light"] body.game-portal #settingsModal :is(.bet-tabs,.bet-type-tabs) {
  background:#eaf2ee;border-color:#bdd3c8;
}
html[data-theme="light"] body.game-portal #settingsModal .bet-tab:not(.active) {color:#345c4d;}
html[data-theme="light"] body.game-portal #settingsModal .betting-title {color:#28543d;text-shadow:none;}

/* Match the dark-mode countdown's transparent dimming stage. The previous
   almost-opaque pale gradient hid the race scene instead of dimming it. */
html[data-theme="light"] body.game-portal .countdown-overlay {
  background:linear-gradient(180deg,rgba(9,24,24,.64),rgba(7,19,22,.70));
  color:#fff;
}
html[data-theme="light"] body.game-portal .countdown-text {
  color:#fff;
  text-shadow:0 3px 22px rgba(0,0,0,.75),0 0 3px rgba(0,0,0,.45);
}

/* The spectator dashboard is DOM UI on top of the game, not scene artwork. */
html[data-theme="light"] body.game-portal #raceTrack .broadcast-heading h2 {color:#223e39;}
html[data-theme="light"] body.game-portal #raceTrack .broadcast-live {
  color:#256045;border-color:#87b29e;background:#e4f3e9;
}
html[data-theme="light"] body.game-portal #raceTrack .broadcast-status {color:#4e665e;}
html[data-theme="light"] body.game-portal #raceTrack .broadcast-status.is-announcing {
  max-width:min(45%,420px);
  padding:6px 10px;
  border:1px solid #96bba8;
  border-radius:8px;
  background:#e3f2e8;
  color:#20543c;
  font-weight:750;
  line-height:1.5;
  white-space:normal;
  overflow-wrap:anywhere;
  text-overflow:clip;
}
@media(max-width:680px){
  html[data-theme="light"] body.game-portal #raceTrack .broadcast-status.is-announcing {
    max-width:100%;
    width:100%;
  }
}
html[data-theme="light"] body.game-portal #raceTrack :is(.camera-options,.character-options,.zoom-options) {
  background:#e5efea;border-color:#b6cec1;
}
html[data-theme="light"] body.game-portal #raceTrack .broadcast-controls button:not([aria-pressed="true"]) {color:#345b4d;}
html[data-theme="light"] body.game-portal #raceTrack .broadcast-controls button:hover {background:#d1e6d9;color:#244839;}
html[data-theme="light"] body.game-portal #raceTrack .broadcast-controls button[aria-pressed="true"] {
  background:#326c52;color:#fff;
}
html[data-theme="light"] body.game-portal #raceTrack .broadcast-controls .broadcast-tools-toggle {
  background:#e5efea;color:#244c3d;border-color:#b6cec1;
}
html[data-theme="light"] body.game-portal #raceTrack .positions-heading :is(h3,p) {color:#36584c;}
html[data-theme="light"] body.game-portal #raceTrack .position-card {
  background:#fff;color:#263e38;border-color:#bad0c4;border-left:4px solid var(--runner-color);
  box-shadow:0 2px 6px rgba(24,52,42,.05);
}
html[data-theme="light"] body.game-portal #raceTrack .position-card[style*="order: 0"],
html[data-theme="light"] body.game-portal #raceTrack .position-card[style*="order:0"] {
  background:linear-gradient(145deg,#fffdf4,#f8f3dc);border-color:#d4b459;border-left:4px solid #e0a82e;
}
html[data-theme="light"] body.game-portal #raceTrack .position-card:hover,
html[data-theme="light"] body.game-portal #raceTrack .position-card[aria-pressed="true"] {background:#edf6ef;border-color:#588b73;}
html[data-theme="light"] body.game-portal #raceTrack .position-name {color:#213c34;}
html[data-theme="light"] body.game-portal #raceTrack .position-detail {color:#4d6c60;}
html[data-theme="light"] body.game-portal #raceTrack .position-percent {color:#265d42;}
html[data-theme="light"] body.game-portal #raceTrack .position-rank {background:#eaf3ed;color:#22583f;}
html[data-theme="light"] body.game-portal #raceTrack .position-card[style*="order: 0"] .position-rank,
html[data-theme="light"] body.game-portal #raceTrack .position-card[style*="order:0"] .position-rank {background:#ffe999;color:#7a4f00;}
html[data-theme="light"] body.game-portal #raceTrack .position-meter {background:#d1e2d8;}
html[data-theme="light"] body.game-portal #raceTrack .position-card.is-favorite {
  background:linear-gradient(145deg,#fffdf4,#eef7f1);border-color:#d4b459;
  box-shadow:inset 3px 0 #e0a82e,0 2px 6px rgba(24,52,42,.06);
}
html[data-theme="light"] body.game-portal #raceTrack .race-favorite {
  background:radial-gradient(circle at 0% 50%,rgba(235,194,77,.18),transparent 55%),linear-gradient(135deg,#fdfcf5,#eef6f0);
  border-color:#d1b866;border-left:5px solid var(--favorite-color,#d4a017);
  box-shadow:0 4px 14px rgba(32,62,48,.08),inset 0 1px 0 rgba(255,255,255,.9);
}
html[data-theme="light"] body.game-portal #raceTrack .race-favorite-name {color:#1f3b31;}
html[data-theme="light"] body.game-portal #raceTrack .race-favorite-rank {
  background:#e6f2eb;border-color:#a9c7b7;color:#214d3a;
}
html[data-theme="light"] body.game-portal #raceTrack .race-favorite-label {
  background:#fff4cc;border-color:#dfb94b;color:#6e510b;
}
html[data-theme="light"] body.game-portal #raceTrack .race-favorite-label::before {color:#d49500;}
html[data-theme="light"] body.game-portal #raceTrack .race-favorite-movement {color:#2f6849;}
html[data-theme="light"] body.game-portal #raceTrack .race-favorite-follow {
  background:#e4f1e9;color:#234d3a;border-color:#9ec0ae;
}
html[data-theme="light"] body.game-portal #raceTrack .race-favorite-follow:hover {background:#d3e8dc;}
html[data-theme="light"] body.game-portal #raceTrack .race-favorite-follow[aria-pressed="true"] {
  background:linear-gradient(135deg,#32674f,#26533e);color:#fff;border-color:#26533e;
  box-shadow:0 2px 8px rgba(38,83,62,.25);
}
/* Results stories and disclosure panels must not remain dark on white results. */
html[data-theme="light"] body.game-portal #raceResults .result-story {border-color:#ccdcd2;}
html[data-theme="light"] body.game-portal #raceResults :is(.result-favorite,.result-comeback) {
  background:#eaf4ee;border-color:#bdd4c4;
}
html[data-theme="light"] body.game-portal #raceResults :is(.result-story-name,.result-story-title) {color:#24453a;}
html[data-theme="light"] body.game-portal #raceResults :is(.result-story-detail,.result-lead-count,.result-story-hint) {color:#526c60;}
html[data-theme="light"] body.game-portal #raceResults .result-story-label {color:#725c21;}
html[data-theme="light"] body.game-portal #raceResults .result-highlight-details {
  background:#f1f7f3;border-color:#c4d8cb;
}
html[data-theme="light"] body.game-portal #raceResults .result-highlight-details summary {color:#244d3c;}
html[data-theme="light"] body.game-portal #raceResults .result-highlight-list li {
  color:#3a5b4c;border-color:#c8d9cf;
}
html[data-theme="light"] body.game-portal #raceResults .result-highlight-time {color:#785c21;}

/* Finish dialog: race-results-list is an actual table inside #results.results-list.
   The original table cell, footer and bet styles use dark-mode foregrounds even
   when the containing results panel has switched to white. */
html[data-theme="light"] body.game-portal #raceResults #results {
  background:#fff;
  color:#243b3d;
  scrollbar-color:#a2bdb1 transparent;
}
html[data-theme="light"] body.game-portal #raceResults .race-results-list th {
  background:#e9f1eb;
  color:#3e5a50;
  border-color:#cbded1;
}
html[data-theme="light"] body.game-portal #raceResults .race-results-list td {
  background:#fff;
  color:#243d35;
  border-color:#cbded1;
}
html[data-theme="light"] body.game-portal #raceResults .race-results-list td.result-participant {
  color:#243d35;
}
html[data-theme="light"] body.game-portal #raceResults .result-position,
html[data-theme="light"] body.game-portal #raceResults .result-time {color:#405f51;}
html[data-theme="light"] body.game-portal #raceResults .gold-medal .result-position {color:#80570b;}
html[data-theme="light"] body.game-portal #raceResults .silver-medal .result-position {color:#53677a;}
html[data-theme="light"] body.game-portal #raceResults .bronze-medal .result-position {color:#824b2d;}
html[data-theme="light"] body.game-portal #raceResults .betting-results-header {color:#253f36;}
html[data-theme="light"] body.game-portal #raceResults #results .betting-results-container {
  background:#f0f6f1;
  color:#304c40;
  border-color:#c1d6c9;
}
html[data-theme="light"] body.game-portal #raceResults #results .bet-result {border-color:#c7d9ce;}
html[data-theme="light"] body.game-portal #raceResults #results :is(.bet-result.win,.bet-total) {color:#205e3f;}
html[data-theme="light"] body.game-portal #raceResults #results :is(.bet-result.loss,.bet-total.loss,.balance-display) {color:#506a5b;}
html[data-theme="light"] body.game-portal #raceResults .result-finish-note {
  background:#edf6ed;
  color:#32563f;
  border-color:#39775b;
}
html[data-theme="light"] body.game-portal #raceResults :is(.result-copy-btn,.result-copy-text) {
  background:#f3f8f4;
  color:#2b4f3e;
  border-color:#a9c5b4;
}
html[data-theme="light"] body.game-portal #raceResults .result-copy-status {color:#4f6a5b;}
html[data-theme="light"] body.game-portal #raceResults #newRaceBtn {
  background:#32674f;
  color:#fff;
  box-shadow:0 0 0 8px #fff;
}
html[data-theme="light"] body.game-portal #raceResults #newRaceBtn:hover {background:#25563f;}

/* Home's legacy All Games directory uses the same tokens as standalone games. */
html[data-theme="dark"] body.game-portal #main-menu {color:var(--menu-text);color-scheme:dark;}
html[data-theme="dark"] body.game-portal #main-menu :is(.game-hub-shell,.game-hub-heading,.game-hub-search-wrap,.game-hub-results,.game-hub-utilities) {
  background:var(--menu-bg);color:var(--menu-text);border-color:var(--menu-line);
}
html[data-theme="dark"] body.game-portal #main-menu .game-hub-categories {background:var(--menu-sidebar);border-color:var(--menu-line);}
html[data-theme="dark"] body.game-portal #main-menu :is(.game-hub-title,.game-hub-game-title,.game-hub-results-heading h3,#game-hub-title) {color:var(--menu-text);}
html[data-theme="dark"] body.game-portal #main-menu :is(.game-hub-brand,#game-hub-intro,#game-hub-count,.game-hub-game-desc,.game-hub-utilities h3,.game-hub-game-tail) {color:var(--menu-muted);}
html[data-theme="dark"] body.game-portal #main-menu .game-hub-search,
html[data-theme="dark"] body.game-portal #main-menu .game-hub-utilities .menu-button {
  background:var(--menu-surface);color:var(--menu-text);border-color:var(--menu-line);
}
html[data-theme="dark"] body.game-portal #main-menu .game-hub-search input {background:transparent;color:var(--menu-text);}
html[data-theme="dark"] body.game-portal #main-menu .game-hub-game {background:transparent;color:var(--menu-text);border-color:var(--menu-line);}
html[data-theme="dark"] body.game-portal #main-menu .game-hub-game:hover {background:var(--menu-surface-hover);}
html[data-theme="dark"] body.game-portal #main-menu .game-hub-game-icon {background:var(--menu-surface);color:var(--menu-accent);border-color:var(--menu-line);}
html[data-theme="dark"] body.game-portal #main-menu .game-hub-category {background:transparent;color:var(--menu-muted);}
html[data-theme="dark"] body.game-portal #main-menu .game-hub-category[aria-pressed="true"] {background:var(--menu-selected);color:var(--menu-text);border-color:var(--menu-accent);}
html[data-theme="dark"] body.game-portal #main-menu :is(.close-modal-button,.game-hub-search kbd) {background:var(--menu-surface);color:var(--menu-text);border-color:var(--menu-line);}

/* Legacy Help / Language / Supporter / Contact dialogs on home + racing pages. */
html[data-theme="dark"] body.game-portal :is(#game-help-modal,#language-setting-modal,#supporter-modal,#contact-modal) {
  color:var(--menu-text);color-scheme:dark;
}
html[data-theme="dark"] body.game-portal :is(#game-help-modal,#language-setting-modal,#supporter-modal,#contact-modal) .help-modal-content {
  background:var(--menu-bg);color:var(--menu-text);border-color:var(--menu-line);
}
html[data-theme="dark"] body.game-portal :is(#game-help-modal,#language-setting-modal,#supporter-modal,#contact-modal) :is(
  .help-modal-header,.help-modal-footer,.help-overview,.help-category-content,.help-game-list,.help-guide-content) {
  background:var(--menu-bg);color:var(--menu-text);border-color:var(--menu-line);
}
html[data-theme="dark"] body.game-portal :is(#game-help-modal,#language-setting-modal,#supporter-modal,#contact-modal) :is(
  h2,h3,strong,.help-question summary,.help-game-copy strong) {color:var(--menu-text);}
html[data-theme="dark"] body.game-portal :is(#game-help-modal,#language-setting-modal,#supporter-modal,#contact-modal) :is(
  p,.help-game-meta,.help-game-summary,.help-game-copy>span) {color:var(--menu-muted);}
html[data-theme="dark"] body.game-portal :is(#game-help-modal,#language-setting-modal,#supporter-modal,#contact-modal) :is(
  .help-game-button,.help-category-button,.language-option-large,.back-button,.close-modal-button,.help-question,.home-game-guide-step,.menu-button) {
  background:var(--menu-surface);color:var(--menu-text);border-color:var(--menu-line);box-shadow:none;
}
html[data-theme="dark"] body.game-portal :is(#game-help-modal,#language-setting-modal,#supporter-modal,#contact-modal) :is(
  input,select,textarea) {background:var(--input-bg);color:var(--menu-text);border-color:var(--menu-line);}

/* Independent game pages: theme control and UI, without tinting WebGL or sprites. */
html[data-theme="light"] body:not(.game-portal) {
  background-color:var(--bg-primary);color:var(--text-primary);
}
html[data-theme="dark"] body:not(.game-portal) {background-color:var(--bg-primary);}
html[data-theme="light"] body:not(.game-portal) :is(.ug-header,.site-header,.standalone-hub-header) {color:var(--header-text);}
html[data-theme="light"] body:not(.game-portal) :is(
  .ug-audio-panel,.audio-panel,.ug-result-surface,.game-hub-shell,.standalone-hub-subview,
  .ug-audio-option,.ug-common-result-action) {
  color:var(--text-primary);border-color:var(--border-color);
}
html[data-theme="light"] body:not(.game-portal) :is(
  .ug-audio-panel,.audio-panel,.ug-result-surface,.ug-audio-option,.ug-common-result-action) {
  background:var(--game-panel-bg);
}
html[data-theme="dark"] body:not(.game-portal) :is(.ug-result-surface,.ug-audio-panel) {
  background:var(--game-panel-bg);color:var(--text-primary);border-color:var(--border-color);
}
html[data-theme="light"] body:not(.game-portal) :is(
  .ug-result-surface input,.ug-result-surface select,.ug-audio-panel input,
  .game-hub-shell input,.game-hub-shell select) {color:var(--text-primary);background:var(--input-bg);}
@media(max-width:680px){
  .site-theme-toggle {min-width:40px;width:40px;height:42px;flex-basis:40px;font-size:22px;}
}


/* P2 — quick-bet engines: retain their SVG/Canvas effects but theme the containers. */
html[data-theme="light"] body.standalone-quickbet {
  background:radial-gradient(ellipse at 50% -6%,#d7e9dd 0,transparent 58%),#f7f9ff;
  color:var(--text-primary);
}
html[data-theme="light"] body.standalone-quickbet :is(.qb-hero h1,.quickbet-names-title,#quickbet-result-title,
  #quickBetModal .modal-header h2,.qb-refreshed .quickbet-names-title) {
  color:var(--text-primary);text-shadow:none;
}
html[data-theme="light"] body.standalone-quickbet :is(.qb-eyebrow,.qb-hero p:last-child,.qb-fairness,
 .quickbet-intro,.quickbet-hint,.quickbet-mode-description,.quickbet-setup,
 .qb-modal-subtitle,#quickbet-round,#quickbet-status) {color:var(--text-secondary);}
html[data-theme="light"] body.standalone-quickbet .qb-game-nav a {
  background:#edf3f0;border-color:#bed1c6;color:#23433c;
}
html[data-theme="light"] body.standalone-quickbet .qb-game-nav a[aria-current="page"] {
  background:#355c4f;color:#fff;border-color:#355c4f;
}
html[data-theme="light"] body.standalone-quickbet #quickBetModal .quickbet-panel,
html[data-theme="light"] body.qb-refreshed #quickBetModal .quickbet-panel {
  background:#fff;color:var(--text-primary);border-color:var(--border-color);
  box-shadow:0 18px 42px #1d393223;
}
html[data-theme="light"] body.standalone-quickbet #quickBetModal .modal-header {
  background:#edf4f0;border-color:#c4d4c9;
}
html[data-theme="light"] body.standalone-quickbet .qb-setting-grid>.quickbet-field {
  background:#f2f7f2;border-color:#bccfc5;
}
html[data-theme="light"] body.standalone-quickbet :is(.quickbet-field label,
 .qb-refreshed .qb-setting-grid .quickbet-field label,
 .qb-refreshed #quickbet-setup .quickbet-intro) {
  color:var(--text-primary);
}
html[data-theme="light"] body.standalone-quickbet #quickBetModal :is(input,select),
html[data-theme="light"] body.standalone-quickbet #quickBetModal .qb-setting-grid select,
html[data-theme="light"] body.standalone-quickbet #quickBetModal .qb-player-field input {
  background:var(--input-bg);color:var(--text-primary);border-color:var(--border-color);
  color-scheme:light;
}
html[data-theme="light"] body.standalone-quickbet :is(.quickbet-name-field,
 .qb-refreshed #quickBetModal .quickbet-name-field.qb-player-field) {
  background:#f4f7f4;border-color:#bdcfc9;
}
html[data-theme="light"] body.standalone-quickbet :is(.quickbet-name-number,.qb-refreshed .quickbet-name-number) {color:#47645b;}
html[data-theme="light"] body.standalone-quickbet :is(.quickbet-tabs,.quickbet-actions) {
  background:#eaf2ed;border-color:#c2d2c9;
}
html[data-theme="light"] body.standalone-quickbet .quickbet-tab:not(.active) {color:#36514c;}
html[data-theme="light"] body.standalone-quickbet .quickbet-tab:not(.active):hover {background:#d5e7dd;}
html[data-theme="light"] body.standalone-quickbet .quickbet-visual,
html[data-theme="light"] body.standalone-quickbet .qb-refreshed .quickbet-visual {
  background:radial-gradient(circle at 50% 35%,#f5faf0 0,#dbece2 55%,#cbded8 100%);
  border-color:#b5cec1;
}
html[data-theme="light"] body.standalone-quickbet .quickbet-ladder-odds {
  background:#ebf5e9;color:#254940;border-color:#bbd1c0;
}
html[data-theme="light"] body.standalone-quickbet .quickbet-ladder-odds strong {color:#28604e;}
html[data-theme="light"] body.standalone-quickbet .quickbet-ladder-odds>span {color:#355b49;}
html[data-theme="light"] body.standalone-quickbet .qb-soundbar {
  background:#e6f0ea;color:var(--text-primary);border-color:#b8cec3;
}
/* Quick-bet result displays are generated dynamically and keep the same palette. */
html[data-theme="light"] body.standalone-quickbet :is(.ug-results-shell,.quickbet-outcome,#quickbet-outcome) {
  background:var(--game-panel-bg);color:var(--text-primary);border-color:var(--border-color);
}
html[data-theme="dark"] body.standalone-quickbet :is(.ug-results-shell,.ug-result-surface) {
  background:#1e3539;color:#edf4ec;border-color:#53716d;
}

/* Quick-bet result hints are UI on pale result cards, not game sprites. */
html[data-theme="light"] body.standalone-quickbet #quickbet-outcome :is(.quickbet-probability-label,.quickbet-odds-label) {color:#365b49;}
html[data-theme="light"] body.standalone-hub-page-roulette :is(#rt-selected-heading,.rt-empty-result) {color:#335448;}
/* P2 — casino table felt, board textures, and game sprites deliberately stay intact. */
html[data-theme="light"] body:is(.standalone-hub-page-dice,.standalone-hub-page-hwatu) :is(
 .local-play,.local-setup,.local-panel,.local-result,.dice-results,.dice-setup) {
  background-color:#eaf2ed;color:#254039;border-color:#bbd0c6;
}
html[data-theme="light"] body:is(.standalone-hub-page-dice,.standalone-hub-page-hwatu) :is(
 .local-hero h1,.local-hero p,.local-play h2,.local-play h3) {color:#254039;}
html[data-theme="light"] body.standalone-hub-page-sticky .control-panel {
  background:#e3ede4;color:#24483e;border-color:#b5cbbf;
}
html[data-theme="light"] body.standalone-hub-page-bomb :is(.card,.setup,.result-panel) {
  background:#e5f1e8;color:#23473c;border-color:#b6cfbd;
}
html[data-theme="light"] body.standalone-hub-page-reaction :is(.panel.setup,.score-panel,.panel) {
  background:#e6f0ed;color:#22483f;border-color:#b7cdc3;
}
html[data-theme="light"] body.standalone-hub-page-timer .setup {
  background:#e7f0e9;color:#254039;border-color:#bbd0c6;
}
html[data-theme="dark"] body.standalone-hub-page-payment-card :is(.pc-panel,.pc-setup) {
  background:#22383b;color:#f0f4ec;border-color:#4e6764;
}
html[data-theme="dark"] body.standalone-hub-page-yut :is(.setup,.control-panel) {
  background:#273d36;color:#eff3e9;border-color:#576d5e;
}
/* The original Yut setup uses dark ink on parchment; recolor its editable
   settings when the same setup surface is forest-green at night. */
html[data-theme="dark"] body.standalone-hub-page-yut :is(.setup .player-count-label,.setup .name-field>span) {
  color:var(--ui-text-on-dark);
}
/* Art surfaces such as 3-D chess boards, races, felt poker tables and sticky
   backgrounds do not receive grayscale/invert filters: that would corrupt sprites. */
html[data-theme="light"] body:not(.game-portal) :is(
 .setup.panel,.settings-panel,.audio-panel,.control-panel,.result-panel) :is(input,select,textarea) {
  color:var(--text-primary);background:var(--input-bg);border-color:var(--border-color);
}
html[data-theme="dark"] body:not(.game-portal) :is(
 .setup.panel,.settings-panel,.audio-panel,.control-panel,.result-panel) :is(input,select,textarea) {
  color:var(--text-primary);background:var(--input-bg);border-color:var(--border-color);
}

/* P2/P3 game-specific scene-safe theme finishing (2026-10-30).
   Scope every override to a named game. Canvas/WebGL, boards, sprites,
   collisions, timing and match state are deliberately not modified. */

/* Marble race: bright futuristic arcade HUD without recoloring the marbles. */
html[data-theme="light"] body.standalone-hub-page-marble {
  background:radial-gradient(ellipse at 14% 10%,#e0ddfa 0,transparent 54%),
             radial-gradient(ellipse at 85% 80%,#d6f0f1 0,transparent 54%),#f5f7ff;
  color:#25344e;
}
html[data-theme="light"] body.standalone-hub-page-marble :is(.intro h1,.arena-bar h2) {
  color:#1e3459;text-shadow:none;
}
/* The arcade badge needs dark lettering on the light page, not neon yellow. */
html[data-theme="light"] body.standalone-hub-page-marble .intro h1 span {
  color:#704112;
  background:#fff0cd;
  border-color:#c79244;
  box-shadow:inset 0 1px #fff9ec,0 2px 8px #7956221a;
  text-shadow:none;
}
/* The lobby heading sits on a white card: use dedicated high-contrast ink. */
html[data-theme="light"] body.standalone-hub-page-marble #marble-lobby-title {
  color:#17385d;
  font-weight:850;
  text-shadow:none;
}
html[data-theme="light"] body.standalone-hub-page-marble .marble-lobby-eyebrow {
  color:#126471;
}
html[data-theme="light"] body.standalone-hub-page-marble :is(.intro p,.intro-kicker,.marble-lobby-count) {color:#4c6077;}
html[data-theme="light"] body.standalone-hub-page-marble :is(.intro-badges span,.marble-lobby,.arena-card,.controls) {
  background:#fff;color:#263d56;border-color:#bdcee2;
}
html[data-theme="light"] body.standalone-hub-page-marble :is(.marble-lobby input,.marble-lobby select,.controls select) {
  color:#263d56;background:#f7faff;border-color:#bdcee2;
}
html[data-theme="light"] body.standalone-hub-page-marble .arena {
  background-color:#e8f0f8;border-color:#9fbad0;
}
/* Sticky dinosaur: natural light surroundings; the scenic glass backdrop stays untouched. */
html[data-theme="light"] body.standalone-hub-page-sticky {
  background:radial-gradient(ellipse at 15% 5%,#e2eedf 0,transparent 52%),#f4f8f0;
  color:#284437;
}
html[data-theme="light"] body.standalone-hub-page-sticky :is(.intro h1,.section-head h2,.ranking-heading h2,.selection legend,.control-label) {color:#244536;}
html[data-theme="light"] body.standalone-hub-page-sticky :is(.intro p,.field-note,.section-caption,.ranking-progress) {color:#49695b;}
html[data-theme="light"] body.standalone-hub-page-sticky :is(.intro-chips span,.ranking-list li,.selection button:not(.active),.player-name-field) {
  color:#264b3e;background:#f8fcf7;border-color:#b9d0be;
}
html[data-theme="light"] body.standalone-hub-page-sticky :is(.ranking-height,.player-name-number) {color:#496b5c;}
html[data-theme="light"] body.standalone-hub-page-sticky .control-panel :is(input,textarea,select) {
  color:#244536;background:#fff;border-color:#b9d0be;
}
html[data-theme="light"] body.standalone-hub-page-sticky .control-label #player-count {
  color:#28533d;
}
html[data-theme="light"] body.standalone-hub-page-sticky .selection button.active {color:#174634;background:#d1efde;border-color:#5b9c7a;}
html[data-theme="light"] body.standalone-hub-page-sticky .outcome {color:#f6fff4;}

/* Diecast: pale automotive-metal dashboard, unchanged 2D/3D track art. */
html[data-theme="light"] body.standalone-hub-page-diecast {
  --ink:#24354d;--muted:#4f637c;--line:#bdcede;
  background:radial-gradient(circle at 85% 0%,#dce9f4 0,transparent 45%),#f3f7fb;
  color:var(--ink);
}
html[data-theme="light"] body.standalone-hub-page-diecast :is(.intro h1,.intro p,.section-head h2,.lobby h2) {color:var(--ink);}
html[data-theme="light"] body.standalone-hub-page-diecast :is(.player-slot,.race-panel,.course-overview,.player-editor .player-name-field) {
  background:#fff;color:var(--ink);border-color:var(--line);
}
html[data-theme="light"] body.standalone-hub-page-diecast :is(.player-slot input,.player-editor input,select) {
  color:var(--ink);background:#fff;border-color:var(--line);
}
html[data-theme="light"] body.standalone-hub-page-diecast :is(.slot-number,.small-hint,.section-head p) {color:#52657a;}
html[data-theme="light"] body.standalone-hub-page-diecast :is(.btn:not(.primary),.btn.ghost,.btn.subtle) {
  color:#27415b;background:#e7eef7;border-color:#b7c9d9;
}
html[data-theme="light"] body.standalone-hub-page-diecast .btn.primary {color:#1d2e3d;}

/* Chess: 3D wood pieces/board remain unaltered, surrounding forest UI follows theme. */
html[data-theme="light"] body.standalone-hub-page-chess {
  --ink:#243b32;--sub:#476357;--muted:#587366;--stroke:#b1cbb8;
  background:radial-gradient(ellipse at 50% 0%,#dceadd 0,transparent 62%),#f4f7f0;color:var(--ink);
}
html[data-theme="light"] body.standalone-hub-page-chess :is(.hero h1,.lead,.eyebrow,.hero-meta,.panel h2,.panel-description,.player-status) {color:var(--ink);text-shadow:none;}
html[data-theme="light"] body.standalone-hub-page-chess :is(.panel,.settings-panel,.game-panel,.audio-panel) {
  background:linear-gradient(145deg,#fff,#eaf1e9);color:var(--ink);border-color:var(--stroke);
  box-shadow:0 9px 24px #22453015;
}
html[data-theme="light"] body.standalone-hub-page-chess :is(.panel-description,.panel small,.audio-volume-row label) {color:var(--sub);}
html[data-theme="light"] body.standalone-hub-page-chess :is(.mode-choice:not(.active),.audio-switch) {
  background:#e6f0e8;color:#28463a;border-color:#acc5b2;
}
/* Janggi: the wooden board is preserved; change surrounding surfaces only. */
html[data-theme="dark"] body.standalone-hub-page-janggi {
  --ink:#eeeadd;--muted:#bac9bd;--line:#536b60;
  background:radial-gradient(ellipse at 50% 0%,#304a3b 0,transparent 56%),#142721;
  color:var(--ink);
}
html[data-theme="dark"] body.standalone-hub-page-janggi :is(.intro h1,.intro-main>p:last-child,.kicker,.intro-mark,.under-board,.panel-note) {
  color:var(--ink);
}
html[data-theme="dark"] body.standalone-hub-page-janggi :is(.panel,.player-bar) {
  background:#243c32;color:var(--ink);border-color:var(--line);
}
html[data-theme="dark"] body.standalone-hub-page-janggi :is(.panel h2,.player-bar strong,.settings label,.formation,.notice,.material,.player-bar small) {color:var(--ink);}
html[data-theme="dark"] body.standalone-hub-page-janggi :is(.mode-switch,.history) {background:#1b3128;color:#c7d4c8;border-color:#536b60;}
html[data-theme="dark"] body.standalone-hub-page-janggi .mode:not(.active) {color:#e0e9df;}
html[data-theme="dark"] body.standalone-hub-page-janggi :is(.settings select,.formation select,.actions button) {
  background:#2b493c;color:#f0f4e7;border-color:#688276;
}
html[data-theme="dark"] body.standalone-hub-page-janggi .turn-label {background:#294f41;color:#eef5ea;border-color:#638e79;}
html[data-theme="dark"] body.standalone-hub-page-janggi .turn-label.check {background:#49322e;color:#ffdfcb;border-color:#a16658;}
html[data-theme="dark"] body.standalone-hub-page-janggi .turn-label.end {background:#50422b;color:#f4e0ae;border-color:#94754c;}
/* Omok: keep the wood board and stone contrast; theme the card variables. */
html[data-theme="light"] body.standalone-hub-page-omok {
  --bg:#f5f8f5;--surface:#fff;--text:#263f37;--muted:#506961;--line:#b9cdc4;--lime:#365e49;
  background:#f5f8f5;color:var(--text);
}
/* Yut: maintain the traditional wooden board with pale parchment surroundings. */
html[data-theme="light"] body.standalone-hub-page-yut {
  background:radial-gradient(ellipse at 25% 2%,#e6eddf 0,transparent 50%),#f6f3e9;
  color:#2c4534;
}
html[data-theme="light"] body.standalone-hub-page-yut :is(.intro h1,.intro-description,.eyebrow,.section-caption,.setup h2) {color:#244335;}
html[data-theme="light"] body.standalone-hub-page-yut :is(.scorebar,.setup,.control-panel) {
  border-color:#c3d2ba;
}
html[data-theme="light"] body.standalone-hub-page-yut :is(.game,.board-panel) {color:#2c4534;}
/* Dice/Hwatu: light surrounding panels, preserve dice faces and card ink. */
html[data-theme="light"] body.dice-standalone {
  background:radial-gradient(ellipse at 75% -10%,#d0e5e8 0,#e9f1ed 38%,#f7f9f6 95%);
  color:#283f40;
}
html[data-theme="light"] body.dice-standalone :is(.local-hero h1,.local-hero p,.local-overline,.local-play-heading h2,.dice-names-title,.local-guide h2) {color:#284743;}
html[data-theme="light"] body.dice-standalone :is(.local-tags span,.local-guide,.local-game-nav a:not([aria-current="page"])) {
  background:#eff6f1;color:#345a54;border-color:#b6cfc7;
}
html[data-theme="light"] body.dice-standalone #diceModal.local-play {
  background:#fff;color:#284743;border-color:#b4d0c8;box-shadow:0 14px 42px #284d3d22;
}
html[data-theme="light"] body.dice-standalone .local-play-heading {
  background:#e4f1eb;color:#264a40;border-color:#bad1c8;
}
html[data-theme="light"] body.dice-standalone #diceModal :is(.dice-content,.dice-settings,.dice-names,.dice-roll-stage) {color:#284743;}
html[data-theme="light"] body.dice-standalone #diceModal :is(input,select,.dice-field) {
  background:#f6faf8;color:#294a40;border-color:#b4d0c8;color-scheme:light;
}
html[data-theme="light"] body.dice-standalone :is(.dice-play-modes a:not(.is-current),.dice-name-field,.dice-result,.dice-card-guide) {
  background:#f1f7f3;color:#305548;border-color:#bfd2c8;
}
html[data-theme="light"] body.dice-standalone :is(.local-guide p,.local-footer,.hwatu-audio-credits) {color:#4e695e;}
html[data-theme="light"] body.dice-standalone .dice-actions .btn-secondary {
  color:#275349!important;background:#e1eee8!important;border-color:#adc8bd!important;
}
/* The actual Dice and Hwatu result rows become pale in light mode. */
html[data-theme="light"] body.dice-standalone #dice-outcome .dice-result-name {color:#264d41;}
/* Pirate: sunny shore outside, unchanged pirate character and island. */
html[data-theme="light"] body.standalone-hub-page-pirate {
  background:radial-gradient(ellipse at 50% -18%,#d9e8e9 0,transparent 60%),#f5f1e5;
  color:#254754;
}
html[data-theme="light"] body.standalone-hub-page-pirate :is(.intro h1,.intro p,.intro-eyebrow) {
  color:#254754;text-shadow:none;
}
html[data-theme="light"] body.standalone-hub-page-pirate :is(.intro-tags span,.setup.panel,.sidebar.panel) {
  border-color:#c5d3cb;
}
/* Pirate turn instructions sit on a pale parchment ribbon in both modes. */
html[data-theme] body.standalone-hub-page-pirate :is(#turn-suffix,#turn-help) {color:#47574d;}
/* Reaction/bomb/timer: the timing colors, stage lights and bomb art stay recognizable. */
html[data-theme="light"] body.standalone-hub-page-bomb {background:radial-gradient(ellipse at 80% 0%,#d5e9da 0,transparent 60%),#f6f9f4;}
html[data-theme="light"] body.standalone-hub-page-reaction {background:#f5f9f6;color:#274438;}
/* Reaction UI keeps game traffic-light hues, but explanatory copy and player
   controls need readable ink on the pale setup and page backgrounds. */
html[data-theme="light"] body.standalone-hub-page-reaction :is(
  .intro-copy>p:not(.eyebrow),.feature-pills span,.section-heading p,
  .count-select,.setup-bottom p,.player-input label
) {color:var(--text-secondary);}
html[data-theme="light"] body.standalone-hub-page-reaction .signal-flash {
  color:#315e48;
}
html[data-theme="light"] body.standalone-hub-page-timer {background:#f6f8f1;color:#25443d;}
/* The decorative watch retains its dark dial; its numerals must not inherit
   the light page's dark text color. */
html[data-theme="light"] body.standalone-hub-page-timer .intro-watch > span {
  color:#f8f5e9;
}
html[data-theme="light"] body.standalone-hub-page-timer :is(.game,.stopwatch-panel,.game-heading) {color:#25443d;}

/* Dynamic turn HUD is not part of the color-coded timing lights. */
html[data-theme="light"] body.standalone-hub-page-reaction :is(
  #round-label,#turn-counter,#turn-description,#pad-hint,#completed-count,.score-panel .step
) {color:#315746;}
html[data-theme="light"] body.standalone-hub-page-reaction .rank-name {color:#eef5eb;}
html[data-theme] body.standalone-hub-page-reaction .turn-member .turn-score {color:#bdd9ce;}
/* The timer watchface stays parchment in both modes; its status labels must
   remain distinguishable as game time and player status changes. */
html[data-theme] body.standalone-hub-page-timer :is(
  #watch-label,#timer-overline,.timer-unit,#timer-hint,.keyboard-note,#progress-label,.progress-score
) {color:#405b4b;}
html[data-theme="light"] body.standalone-hub-page-timer #turn-title {color:#edf7ed;}
html[data-theme] body.standalone-hub-page-timer .watch-top>span {color:#405b4b;}
/* Payment cards: coffee-brown night mode without altering the card draw animation. */
html[data-theme="dark"] body.standalone-hub-page-payment-card {
  --pc-ink:#f1f3e6;--pc-muted:#bdccc4;--pc-line:#557168;
  background:radial-gradient(ellipse at 90% 8%,#354f45 0,transparent 46%),#142a27;
  color:var(--pc-ink);
}
html[data-theme="dark"] body.standalone-hub-page-payment-card :is(.pc-intro h1,.pc-intro p,.pc-eyebrow,.pc-section-heading,.pc-step) {color:#f1f3e6;}
html[data-theme="dark"] body.standalone-hub-page-payment-card :is(.pc-panel,.pc-table-area,.pc-setup,.pc-table-header) {
  background:#263d38;color:#f1f3e6;border-color:#527267;
}
html[data-theme="dark"] body.standalone-hub-page-payment-card :is(.pc-player-preview,.pc-field-hint,.pc-fairness) {color:#d4e1d6;}
html[data-theme="dark"] body.standalone-hub-page-payment-card :is(.pc-player-controls input,.pc-player-preview input,.pc-setup input,.pc-setup select) {
  background:#304f45;color:#f1f3e6;border-color:#638474;
}
html[data-theme="dark"] body.standalone-hub-page-payment-card :is(.pc-quiet-button,.pc-reset-names) {
  color:#e3eddf;background:#2c4d40;border-color:#708e7e;
}
/* Casino: keep the green felt table in both themes, style only the lobby surfaces. */
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) {
  --ink:#253e32;--muted:#53665a;--line:#c0d1c5;--bg:#f4f7f1;
  background:#f4f7f1;color:#253e32;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) :is(.intro h1,.entry h1,.entry p,.entry .eyebrow,.card-copy,.section-number) {
  color:#294838;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) :is(.entry-card,.setup-card,.entry .card,.room-card) {
  background:#fff;color:#294838;border-color:#bdcec3;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) :is(.entry-card input,.entry-card select,.setup-card input,.setup-card select) {
  background:#f7faf7;color:#274537;border-color:#bdcec3;
}
/* Shared casino navigation and information UI. Felt, cards and chips remain
   game art; header popovers and nickname fields are ordinary UI controls. */
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .audio-panel :is(
  #audio-mute,#audio-status,.audio-note,.audio-note a,.audio-channel output
) {color:var(--text-secondary);}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .audio-panel #audio-mute {
  background:var(--button-bg);border-color:var(--border-color);
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .intro-facts span {
  color:#365747;
}
/* Poker lobbies use a bright, quiet paper surface in light theme.
   Only the entry UI is recolored; felt, chips, cards and dark mode stay intact. */
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel {
  background:#ffffff;
  color:#264636;
  border-color:#b9cdbd;
  box-shadow:0 14px 34px rgb(35 77 51 / 7%);
  color-scheme:light;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel .entry-card {
  background:transparent;
  color:#264636;
  border-color:#cbd9ce;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel :is(.nickname-field,.entry-card + form) {
  border-color:#d4e1d7;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel :is(
  .nickname-field p,.card-copy,.input-hint,.table-settings summary>span
) {color:#506c59;}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel :is(
  .section-number,.entry-card h2,.table-settings summary,.online-connection-gate h2
) {color:#234a34;}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel :is(
  #entry-name,#room-code,.settings-grid select
) {
  color:#203e2d;
  background:#f5f9f5;
  border-color:#b7cbb9;
  color-scheme:light;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel :is(#entry-name,#room-code)::placeholder {
  color:#647d6c;
  opacity:1;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel .table-settings {
  border-color:#d4e1d7;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel .button-primary {
  background:#265a3f;
  border-color:#265a3f;
  color:#ffffff;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel .button-primary:hover {
  background:#1e4933;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel .button-secondary {
  background:#e8f1e9;
  border-color:#a9c5b0;
  color:#234b34;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel .button-secondary:hover {
  background:#d8e9db;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel .error-message:not(:empty) {
  color:#833e2d;
  border-color:#e6b5a6;
  background:#fff0e9;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .table-view {
  /* Do not recolor felt, playing-card faces, or player position semantics. */
  --ink:#f1efdf;--muted:#c7d4c8;
}
/* Keep an input's native pop-up consistent with the saved choice. */
html[data-theme] body :is(input,select,textarea) {color-scheme:inherit;}
/* Controls should not collapse below the minimum visual target in small viewports. */
@media(max-width:420px){
  .site-theme-toggle{flex-shrink:0;}
  body.standalone-hub-page-diecast .player-slot {min-width:0;}
}

/* P4 contrast corrections from real Chromium computed-style audit.
   Text tokens change only; semantic colors for traffic lights, dice and game pieces stay intact. */
html[data-theme="light"] body.standalone-hub-page-marble :is(
 .marble-lobby-heading p,.marble-lobby-roster-head strong,.marble-lobby-roster-head span,
 .marble-lobby-names p,.marble-lobby-toolbar span,.marble-lobby-toolbar .btn-quiet,
 .controls .btn-quiet,.arena-bar,.course-length,.arena-counter) {color:#314e68;}
/* Keep the remove/avatar glyph ink on their dark participant badges. */
html[data-theme="light"] body.standalone-hub-page-marble .marble-lobby :is(input,button:not(.marble-lobby-remove):not(.marble-lobby-avatar)) {color:#294968;}
html[data-theme="light"] body.standalone-hub-page-marble .marble-lobby input::placeholder {color:#60768d;}
html[data-theme="light"] body.standalone-hub-page-marble .marble-lobby-roster-head :is(strong,small) {color:#27425c;}
body.standalone-hub-page-marble .controls .btn-start {color:#23323d;background:#ed946f;}
html[data-theme="light"] body.standalone-hub-page-sticky :is(
 .control-panel .section-head>span,.control-panel .player-roster-heading h3,
 .control-panel .player-roster-heading span,.control-panel .player-count-row,
 .control-panel .player-name-number) {color:#2b5646;}
html[data-theme="light"] body.standalone-hub-page-sticky :is(
 .control-panel .player-remove,.control-panel .ug-participant-remove) {
 color:#285143;background:#e2ece3;border-color:#9fbca9;
}
html[data-theme="light"] body.standalone-hub-page-sticky :is(.play-guide,.guide-grid>div) {
 background:#e0ebde;color:#28483b;border-color:#b8d0bb;
}
html[data-theme="light"] body.standalone-hub-page-sticky :is(.play-guide h2,.play-guide h3,.guide-grid strong,.guide-grid small,.guide-grid p,.guide-grid .hand) {color:#244636;}
/* The same guide is a pale card in dark mode: make its label ink legible there too. */
html[data-theme="dark"] body.standalone-hub-page-sticky .guide-grid > div {color:#304c3a;}
html[data-theme="dark"] body.standalone-hub-page-sticky .guide-grid :is(strong,.hand,small) {color:#304c3a;}
html[data-theme="light"] body.standalone-hub-page-diecast :is(.standings,.rank-list) {background:#e8eff8;color:#293f57;border-color:#b7c9d9;}
html[data-theme="light"] body.standalone-hub-page-diecast :is(.rank-item,.rank-item:first-child) {background:#fff;color:#273e55;border-color:#becfdd;}
html[data-theme="light"] body.standalone-hub-page-diecast :is(.standings h2,.rank-item .rank-name,.rank-item .rank-time,.course-overview-title) {color:#27445f;}
html[data-theme="light"] body.standalone-hub-page-diecast .rank-item:first-child {background:#faf1db;}
html[data-theme="light"] body.standalone-hub-page-chess .mode-icon {color:#5a6743;}
html[data-theme="light"] body.standalone-hub-page-omok .intro :is(.eyebrow,p,.title-mark) {color:#3e5a49;}
html[data-theme="light"] body.dice-standalone #diceModal :is(
 .dice-field label,.dice-intro,.dice-member-count,.dice-name-number,
 .dice-hint,.dice-names-title,.dice-result-heading,.dice-result-top) {color:#34564a;}
html[data-theme="light"] body.dice-standalone #diceModal :is(
 .dice-play-modes a:not(.is-current),.dice-card-guide,.dice-results-title) {color:#34564a;}
html[data-theme="light"] body.standalone-hub-page-reaction :is(
 .intro .eyebrow,.intro strong,.setup .step,.section-heading .step,.intro .feature-pills) {color:#305c48;}
html[data-theme="light"] body.standalone-hub-page-timer :is(
 .intro .eyebrow,.intro-description,.intro-description strong,.intro h1 span,
 .setup .section-index,.setup p,.setup .player-count,.setup .limit-note,
 .setup .section-heading,.section-heading .section-index) {color:#31594b;}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) :is(
 .entry-steps,.entry-steps strong,.entry-meta,.entry-meta span,.entry .card-copy) {color:#3d574a;}
/* Labels belong to the light lobby surface, not the dark poker felt. */
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel :is(label,.nickname-field label) {color:#294c38;}
html[data-theme="light"] body.standalone-quickbet :is(.qb-member-count,.qb-player-remove,.ug-participant-remove) {color:#335e4c;}
html[data-theme="light"] body.standalone-quickbet :is(.qb-player-remove,.ug-participant-remove) {background:#e4ede6;border-color:#b5cabe;}
html[data-theme="dark"] body.standalone-hub-page-janggi :is(.formation-help,.sound-footnote,.status-heading>span) {color:#c5d2c5;}
html[data-theme="dark"] body.standalone-hub-page-yut :is(.setup p,.yut-mode-hint,.intro p) {color:#d4e2d1;}
html[data-theme="dark"] body.standalone-hub-page-payment-card :is(
 .pc-section-heading p,.pc-player-preview-head strong,.pc-member-count,
 .pc-player-preview-head span,.pc-setup .pc-field-hint,.pc-setup label) {color:#e0ecdf;}
html[data-theme="dark"] body.standalone-hub-page-payment-card #pc-count,
html[data-theme="dark"] body.standalone-hub-page-payment-card .pc-setup select {
 color:#f1f3e6;background:#304f45;border-color:#718b78;color-scheme:dark;
}
html[data-theme="light"] body.standalone-hub-page-payment-card .pc-fairness {color:#596e63;}
/* Fitted light backgrounds on video-game score badges must keep light foreground legible. */
html[data-theme="light"] body.standalone-hub-page-bomb .rule-number {color:#6f4d1d;}

/* P4 verified selector specificity fixes. */
html[data-theme="light"] body.standalone-hub-page-marble .marble-lobby-toolbar #marble-lobby-hint {color:#385873;}
html[data-theme="light"] body.standalone-hub-page-omok .intro .eyebrow {color:#365842!important;}
html[data-theme="light"] body.standalone-hub-page-omok .intro p:not(.eyebrow) {color:#435e50;}
html[data-theme="light"] body.standalone-hub-page-omok .intro .title-mark {color:#6d553b;}
html[data-theme="dark"] body.standalone-hub-page-payment-card .pc-setup #pc-player-count,
html[data-theme="dark"] body.standalone-hub-page-payment-card .pc-setup #pc-purpose {
  background:#304f45;color:#f1f3e6;border-color:#718b78;color-scheme:dark;
}
/* The chess page originally locked the root viewport to 320px. On a
   narrow foldable cover display let the responsive board shell shrink. */
@media (max-width:319px) {
  html:has(body.standalone-hub-page-chess) {min-width:0;}
  body.standalone-hub-page-chess .wrap {min-width:0;max-width:100%;}
  body.standalone-hub-page-chess .play-area,
  body.standalone-hub-page-chess .game-layout,
  body.standalone-hub-page-chess .game-panel {min-width:0;}
}
/* Marble race scrolls to the track when started. Keep the common theme
   control reachable without interrupting the current Canvas simulation. */
body.standalone-hub-page-marble.ug-unified-page > header.ug-header {
  position:sticky;top:0;z-index:1002;
}
body.standalone-hub-page-marble #arena {scroll-margin-top:calc(84px + env(safe-area-inset-top,0px) + 12px);}
@media(max-width:680px){
 body.standalone-hub-page-marble #arena {scroll-margin-top:calc(72px + env(safe-area-inset-top,0px) + 12px);}
}

/* P4 browser-verified semantic contrast fixes, pass 2.
   Maintain the actual game art and signal colors; text and control surfaces only. */

/* Home: the welcome headline and featured label used light-theme paint in dark mode. */
html[data-theme="dark"] body.game-portal .home-welcome :is(h1,.hero-eyebrow,.hero-description,.home-welcome-copy p) {
  color:#edf3ec;text-shadow:none;
}
html[data-theme="dark"] body.game-portal .home-welcome .hero-eyebrow {color:#c4d5ed;}
html[data-theme="dark"] body.game-portal .home-featured-label {
  color:#243d55;background:#e9efff;border-color:#ccd9ec;
}
html[data-theme="dark"] body.game-portal .home-filters button[aria-pressed="true"] {
  color:#203332;background:#e7d196;
}

/* Omok: the original mode buttons, players and current-turn badge are intentionally dark. */
html[data-theme="light"] body.standalone-hub-page-omok :is(
  .mode-option,.mode-option.selected,.player,.player.active,.turn-message,
  .move-history li,.action-button.secondary,.difficulty-row select,.board-toolbar
) {color:#f1f5e9;}
html[data-theme="light"] body.standalone-hub-page-omok :is(
  .mode-option strong,.player strong,.turn-message strong,.mode-option .mode-icon,
  .board-toolbar span,.action-button.secondary
) {color:#f1f5e9;}
html[data-theme="light"] body.standalone-hub-page-omok :is(
  .mode-option small,.player small,.turn-message p,.move-history li,.board-toolbar span:last-child
) {color:#d2e4d9;}
html[data-theme="light"] body.standalone-hub-page-omok .player b {color:#deefaf;}

/* Yut board's help copy remains on pale parchment. */
html[data-theme="light"] body.standalone-hub-page-yut :is(.yut-mode-hint,.setup p:not(.eyebrow)) {color:#425b46;}

/* Diecast: lift the score typography off light scoreboard cards.
   The duration configuration stays a dark instrument panel. */
html[data-theme="light"] body.standalone-hub-page-diecast :is(
  .standings .mini-label,.rank-item .rank-progress,.rank-item .rank-meta,
  .rank-item .rank-time,.standings .mini-label
) {color:#38556e;}
html[data-theme="light"] body.standalone-hub-page-diecast :is(
  .duration-config,.duration-config label,.duration-config .duration-head,
  .duration-config .duration-note,.race-main .mini-label
) {color:#e9f1fb;}
html[data-theme="light"] body.standalone-hub-page-diecast :is(
  .course-overview .overview-percent,.course-overview .course-stage
) {color:#294a65;}
html[data-theme="light"] body.standalone-hub-page-diecast :is(
  .rank-item,.rank-item:first-child
) {color:#24425c;}

/* Marble: keep stadium counters on dark navy, use dark text on orange buttons. */
html[data-theme="light"] body.standalone-hub-page-marble :is(
  .arena-counter,.arena-counter span,.arena-counter strong
) {color:#eaf4ff;}
html[data-theme] body.standalone-hub-page-marble :is(
  #marble-lobby-start,#start-btn,.modal-footer .btn-start
) {color:#222f3e;background:#f3a17d;}
html[data-theme] body.standalone-hub-page-marble :is(
  #marble-lobby-start,#start-btn,.modal-footer .btn-start
):hover:not(:disabled) {background:#ffb998;}
html[data-theme="light"] body.standalone-hub-page-marble .marble-lobby-roster :is(
  .ug-participant-avatar,.marble-lobby-avatar
) {color:#fff;}

/* Sticky: dark scene uses mint, but light control panels require forest-green ink. */
html[data-theme="light"] body.standalone-hub-page-sticky :is(
  .control-panel .ranking-heading span,.control-panel .ranking-heading strong,
  .control-panel .player-roster-actions span,.control-panel .player-roster-actions strong,
  .control-panel .people-count,.control-panel .player-total
) {color:#315747;}
html[data-theme="dark"] body.standalone-hub-page-sticky .guide-grid > div :is(strong,h3,p,small) {
  color:#e4f0e8;
}
html[data-theme="dark"] body.standalone-hub-page-sticky .stage-hint :is(strong,small) {
  color:#fff2d8;
}

/* Dice and Hwatu: inset roster rows stay dark even when their outer modal becomes light. */
html[data-theme="light"] body.dice-standalone #diceModal :is(
  .dice-name-field .dice-name-number,.dice-name-field .dice-player-number,
  .dice-actions .dice-hint,.dice-actions .dice-intro
) {color:#e0f2e8;}
html[data-theme="light"] body.dice-standalone #diceModal :is(
  .dice-name-field input.ug-participant-name
) {color:#f2f9f2;}
html[data-theme="light"] body.dice-standalone #diceModal :is(
  .dice-name-field input.ug-participant-name
)::placeholder {color:#b8d2c8;}

/* Bomb instructions are light parchment cards, separate from the dark hero illustration. */
html[data-theme="light"] body.standalone-hub-page-bomb :is(
  .card,.setup.card,.rules.card,.rules.card p,.section-heading h2,
  .section-heading p,.rules .rule-grid p,.rules .rule-grid h3
) {color:#294839;}
html[data-theme="light"] body.standalone-hub-page-bomb :is(
  .card .section-label,.card .people-count,.rules .rule-number,
  .card .eyebrow
) {color:#34674e;}
html[data-theme="light"] body.standalone-hub-page-bomb :is(
  .setup .helper,.setup .range-caption
) {color:#425d4d;}
/* Retain dark gaming boards, range buttons and their light-on-dark text. */
html[data-theme="light"] body.standalone-hub-page-bomb :is(
  .person input,.range-option span,.name-add input,.outline-button,.number-button,
  .direction,.range-display,.turn-players span
) {color:#eef6e8;}
html[data-theme="light"] body.standalone-hub-page-bomb .range-option input:checked+span {
  color:#ffe8b4;
}

/* Reaction and ten-second timer: both have original bright lime labels
   designed for dark screens; use darker captions on light paper. */
html[data-theme="light"] body.standalone-hub-page-reaction :is(
  .rules-grid .step,.rules-grid article span,.rules .step,.guide .step,
  .intro .eyebrow,.section-heading .step,.rules-grid p
) {color:#315d47;}
html[data-theme="light"] body.standalone-hub-page-reaction :is(
  .rules-grid h3,.rules-grid article strong,.rules h2,.guide h2
) {color:#234c3c;}
html[data-theme="light"] body.standalone-hub-page-timer :is(
  .rules-heading p,.rules p,.rules-grid p,.rules-grid article p,
  .intro-copy>p:not(.eyebrow),.how-it-works p,.guide p
) {color:#425d4e;}
html[data-theme="light"] body.standalone-hub-page-timer :is(
  .rules-heading .eyebrow,.rules .eyebrow,.rules .step,.intro strong
) {color:#365e48;}

/* A pale active game panel needs dark ink, unlike the original neon dark HUD. */
html[data-theme="light"] body.standalone-hub-page-bomb :is(
  #range-heading,#range-display,#remaining-text,.board-note,#turn-helper,#turn-label,#chance-label,
  .turn-players span
) {color:#2a5040;}
/* The board's green player badges are dark in either theme. */
html[data-theme] body.standalone-hub-page-yut .score-card .score-line strong {color:#eff5ec;}
html[data-theme="light"] body.standalone-hub-page-yut :is(#turn-number,#result-guidance,.empty-text) {color:#435c47;}
html[data-theme="dark"] body.standalone-hub-page-yut :is(
  .section-caption,#turn-number,#turn-hint,#result-guidance,.empty-text
) {color:#d7e7d9;}
html[data-theme="dark"] body.standalone-hub-page-yut #turn-name {color:#f0d5a4;}
/* Card-draw rosters are intentionally pale in both modes. */
html[data-theme] body.standalone-hub-page-payment-card .pc-player-number {
  color:#365b4b!important;
}
html[data-theme="light"] body.standalone-hub-page-payment-card :is(
  .pc-setup .pc-section-heading p,.pc-setup .pc-field-hint,.pc-setup .pc-count,
  .pc-setup .pc-player-preview p,.pc-setup .pc-player-preview span
) {color:#456353;}

/* Poker lobby and instructions: keep original dark green table felt unchanged,
   but use dark type on white entry cards and pale rules sections. */
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) :is(
  .entry-card label,.entry-card strong,.entry-card h2,
  .table-settings label,.settings-grid label,.entry-card p,
  .rules-basics h2,.rules-basics p,.rules-content h2,.rules-content h3,
  .rules-content strong,.rules-content p,
  .stud-start-steps strong,.stud-start-steps p,.stud-start-steps li,
  .rules-section h2,.rules-section p,.rules-section strong,
  .entry-intro h2,.entry-intro p
) {color:#294b3b;}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .table-settings :is(
  input,select
) {color:#294b3b;background:#f5faf6;border-color:#b6cfc0;}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .rules-content :is(
  .rules-basics,.rules-section,.stud-start-steps
) {color:#294b3b;}
/* Poker's related-game navigation is a light card in light mode, not a dark
   felt panel. Scope this to the two poker pages; preserve dark mode as-is. */
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .seo-related-games {
  background:linear-gradient(145deg,#fff,#eef6f0);
  border-color:#b9d2c2;
  color:#234536;
  box-shadow:0 10px 24px #163d2a12;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .seo-related-copy h2 {
  color:#1e4935;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .seo-related-copy p {
  color:#506b59;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .seo-related-links a {
  background:#fff;
  border-color:#c4d8ca;
  color:#213e31!important;
  box-shadow:0 2px 8px #163d2a0b;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .seo-related-links a:hover {
  background:#e7f4ea;
  border-color:#6c9e7d;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .seo-related-links a:focus-visible {
  outline-color:#236846;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .seo-related-icon {
  background:#e5f2e8;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .seo-related-links strong {
  color:#214736;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .seo-related-links small {
  color:#557263;
}
/* Keep dark felt and the multiplayer seat UI legible regardless of theme. */
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .table-view :is(
  .seat,.table-felt,.playing-card
) {color:#f1efdf;}
html[data-theme="dark"] body.standalone-hub-page-janggi .panel.rules p {color:#d6e3d7;}

/* The sticky-game status appears over a mint glass panel at night. */
/* The survival banner is dark translucent glass, so retain its light text.
   Never color it from the mint-colored stage behind it. */
/* Card shuffle status appears on the dark brown-green tabletop. */
html[data-theme="dark"] body.standalone-hub-page-payment-card #pc-status {color:#e4f2e7;}
/* Mini-car results use pale scoreboard cards in light mode. */
html[data-theme="light"] body.standalone-hub-page-diecast .board-metrics {color:#36576f;}
html[data-theme="light"] body.standalone-hub-page-diecast .board-metrics b {color:#2d4c64;}
/* P4 targeted specificity/contrast follow-through (pass 3).
   Strengthen only scoped semantics after computed-style verification. */
html[data-theme="dark"] body.game-portal .home-featured-label {
  color:#284563!important;
}
html[data-theme="dark"] body.game-portal .home-filters button[aria-pressed="true"] :is(span,strong) {
  color:#203a38!important;
}
html[data-theme="dark"] body.game-portal .home-welcome :is(.hero-badge span,.home-welcome-facts span,.welcome-badges span,.home-hero-tags span) {
  color:#d9e7f3;
}
html[data-theme="dark"] body.game-portal :is(.features .feature-number,.home-guide .feature-number) {
  color:#bcd0ff;
}

/* Dark inset Omok boards, with a light parchment settings shell. */
html[data-theme="light"] body.standalone-hub-page-omok .rules :is(h3,article>span) {
  color:#eaf5ea;
}
html[data-theme="light"] body.standalone-hub-page-omok .rules article p {color:#d3e2d8;}
html[data-theme="light"] body.standalone-hub-page-omok .difficulty-row :is(label,span) {color:#36574a;}
html[data-theme="light"] body.standalone-hub-page-omok .action-button.primary {
  color:#243d31;background:#d1e99e;border-color:#9eae76;
}
html[data-theme="light"] body.standalone-hub-page-janggi .mode-switch .mode:not(.active) {color:#435c4c;}

/* Marble participant emojis are pictograms, not ordinary typographic contrast. */
html[data-theme="light"] body.standalone-hub-page-marble .marble-lobby :is(.ug-participant-avatar,.marble-lobby-avatar) {
 color:#f3faff;
}

/* Sticky light roster is pastel, not neon on pastel. */
html[data-theme="light"] body.standalone-hub-page-sticky .control-panel :is(
 .player-roster-heading span,.player-roster-actions span,.player-roster-actions p,
 .player-roster-heading p,.ranking-heading span,.ranking-heading strong,
 .ranking-subheading,.ranking-progress,.player-inputs p,.control-subtitle
) {color:#315a48;}
html[data-theme="dark"] body.standalone-hub-page-sticky .play-guide .guide-grid>div strong {
  color:#e7f0eb;
}

/* Dashboard text must not override contrast-aware participant marker numbers. */
html[data-theme="light"] body.standalone-hub-page-diecast .course-overview :is(
 span:not(.overview-car),.course-stage,.course-marker,.course-overview-title,.course-overview-subtitle,
 .overview-percent,.overview-progress,.course-label,.course-overview-note
) {color:#2d4b64;}
html[data-theme="light"] body.standalone-hub-page-diecast .course-overview .course-stage.is-active {
  color:#315e4b;
}

/* Both dice implementations now use a light participant roster. */
html[data-theme="light"] body.dice-standalone #diceModal .dice-name-field :is(
 .dice-name-number,.dice-player-number,.ug-participant-number
) {color:#315f4d;}
html[data-theme="light"] body.dice-standalone #diceModal .dice-name-field input.ug-participant-name {
  color:#264c3f!important;background:#f6faf8;
}
html[data-theme="light"] body.dice-standalone #diceModal .dice-name-field input.ug-participant-name::placeholder {color:#5e7569;}
html[data-theme="light"] body.dice-standalone #diceModal .dice-actions .dice-hint {color:#eaf4ea;}

/* Reaction uses a pale scoreboard in light mode. */
html[data-theme="light"] body.standalone-hub-page-reaction :is(
 .intro h1 span,.intro .lead span,.setup .player-input label.ug-participant-number,
 .setup .player-inputs label,.setup .ug-participant-number,.rules-grid article .step,
 .rules-grid article .number,.rules-heading .step
) {color:#315b46;}
html[data-theme="light"] body.standalone-hub-page-reaction .intro :is(.eyebrow,.intro-chip) {color:#315b46;}

/* Payment roster notes on white panel. */
html[data-theme="light"] body.standalone-hub-page-payment-card .pc-setup :is(
 .pc-member-count,.pc-player-preview-head span,.pc-roster-note,.pc-field-hint
) {color:#47604f;}

/* Poker: an older blanket dark-panel rule won in entry-card fields.
   The entry cards themselves are white in light mode. */
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .entry-panel .entry-card :is(
 label,strong,p,h2,h3
) {color:#254837!important;}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) :is(
 .entry-card label,.table-settings .settings-grid label
) {color:#254837!important;}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .intro :is(
 .intro-meta span,.intro-stat span,.hero-meta span,.intro-badges span,.intro-features span
) {color:#325746;}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .stud-rule-tip {
  color:#e0f2e5;background:#23472f;border-color:#39644d;
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) :is(
 .stud-start-steps strong,.stud-start-steps span,.stud-start-steps li,
 .rules-basics h2,.rules-basics h3,.rules-content h2,.rules-content h3
) {color:#294b3b;}
/* Final explicit text colors for surfaces whose backgrounds differ by game. */
html[data-theme="light"] body.standalone-hub-page-dice #diceModal .dice-name-field .dice-name-number {
  color:#e4f0ea;
}
html[data-theme="light"] body.standalone-hub-page-seven-poker .stud-rule-tip {
  color:#eef6e9!important;
}
/* Poker result cards follow the page theme without recoloring the playing felt. */
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) #hand-summary {
  background:#f1f6ee;
  color:#254635;
  border-color:#a9c3a8;
  box-shadow:0 8px 24px rgb(33 75 47 / 8%);
}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) #hand-summary :is(.summary-title,.result-name,.summary-note) {color:#254635;}
html[data-theme="light"] body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) #hand-summary .result-amount {color:#525e25;}


/* Shared light participant name editor: visual contract across game lobbies.
   Keep all game-specific layout, avatars, identity colors, and gameplay intact. */
html[data-theme="light"] body :is(.ug-participant-row, .horse-name-input) {
  box-sizing:border-box; min-width:0;
  background:#f3f8f4!important; color:#294c3e!important;
  border:1px solid #bdd2c4!important; border-radius:12px; box-shadow:none;
}
html[data-theme="light"] body :is(.ug-participant-row, .horse-name-input):focus-within {
  border-color:#568771!important; background:#f9fcfa!important; box-shadow:0 0 0 2px #56877129;
}
html[data-theme="light"] body .ug-participant-row input.ug-participant-name,
html[data-theme="light"] body.game-portal .horse-name-input input {
  box-sizing:border-box; min-width:0; max-width:100%;
  background:transparent!important; color:#244738!important; border:0!important;
  box-shadow:none; font-size:14px!important; line-height:1.45;
  color-scheme:light; -webkit-text-fill-color:currentColor;
}
html[data-theme="light"] body .ug-participant-row input.ug-participant-name::placeholder,
html[data-theme="light"] body.game-portal .horse-name-input input::placeholder {
  color:#607c6b!important; opacity:1; -webkit-text-fill-color:#607c6b;
}
html[data-theme="light"] body .ug-participant-row :is(
  .ug-participant-number,.quickbet-name-number,.dice-name-number,
  .dice-player-number,.player-name-number,.slot-number,.rt-player-number,.horse-number
),
html[data-theme="light"] body.game-portal .horse-name-input .horse-number {
  color:#426854!important;
}
html[data-theme="light"] body .ug-participant-row :is(
  .ug-participant-remove,.qb-player-remove,.player-remove,.rt-remove
) {
  color:#315c47!important; background:#e5efe8; border-color:#b8cfbe;
}
html[data-theme="light"] body .ug-participant-row :is(
  .ug-participant-remove,.qb-player-remove,.player-remove,.rt-remove
):hover:not(:disabled) {background:#d5e7da;color:#244a35;}
@media (max-width:600px) {
  /* Prevent automatic browser zoom when editing participant names on phones. */
  html[data-theme="light"] body .ug-participant-row input.ug-participant-name,
  html[data-theme="light"] body.game-portal .horse-name-input input {font-size:16px!important;}
}

/* Yut setup uses legacy labels rather than ParticipantEditor rows.
   Present them as the same pale name cards without modifying the Yut board. */
html[data-theme="light"] body.standalone-hub-page-yut .setup .name-field {
  padding:9px 10px; border:1px solid #bdd2c4; border-radius:12px; background:#f3f8f4;
}
html[data-theme="light"] body.standalone-hub-page-yut .setup .name-field:focus-within {
  border-color:#568771; background:#f9fcfa; box-shadow:0 0 0 2px #56877129;
}
html[data-theme="light"] body.standalone-hub-page-yut .setup .name-field>span {color:#426854;}
html[data-theme="light"] body.standalone-hub-page-yut .setup .name-field input {
  min-width:0; max-width:100%; color:#244738; background:transparent;
  border:0; box-shadow:none; border-radius:6px; font-size:14px; line-height:1.45;
}
html[data-theme="light"] body.standalone-hub-page-yut .setup .name-field input::placeholder {color:#607c6b;opacity:1;}
@media(max-width:600px){
 html[data-theme="light"] body.standalone-hub-page-yut .setup .name-field input {font-size:16px;}
}

/* Mobile viewport sizing & layout normalization across home, race, and standalone games. */
@media (max-width: 600px) {
  html[data-theme="dark"] body.game-portal .home-filters button:not([aria-pressed="true"]) {
    background:var(--bg-surface);
    border-color:var(--border-color);
    color:var(--text-primary);
  }
  body.standalone-quickbet .quickbet-names,
  body.qb-refreshed .quickbet-names,
  #quickbet-names.quickbet-names {
    grid-template-columns:1fr!important;
    gap:8px;
  }
  body.standalone-quickbet .qb-setting-grid,
  body.qb-refreshed .qb-setting-grid {
    grid-template-columns:1fr!important;
    gap:10px;
  }
  body.standalone-quickbet .qb-hero {
    padding:18px 16px 12px;
  }
  body.standalone-quickbet .qb-hero h1 {
    font-size:clamp(22px,6.2vw,27px)!important;
    line-height:1.25;
  }
  body.standalone-hub-page-sticky .control-panel {
    grid-template-columns:1fr!important;
    padding:16px 14px;
    gap:14px;
  }
  body.standalone-hub-page-sticky .scene-buttons {
    grid-template-columns:repeat(3,minmax(0,1fr))!important;
    width:100%;
    gap:6px;
  }
  body.standalone-hub-page-sticky .scene-choice {
    min-height:42px;
    padding:8px 6px;
    font-size:12px;
    white-space:nowrap;
  }
  body.standalone-hub-page-diecast #player-editor.player-editor,
  body.standalone-hub-page-diecast #rank-list.rank-list {
    grid-template-columns:1fr!important;
    gap:8px;
  }
  body.standalone-hub-page-yut #player-names.name-grid,
  body.standalone-hub-page-yut .rules-grid {
    grid-template-columns:1fr!important;
    gap:8px;
  }
  body.standalone-hub-page-yut .setup .name-field {
    display:flex;
    align-items:center;
    gap:10px;
    min-height:46px;
    padding:8px 12px;
  }
  body.standalone-hub-page-yut .setup .name-field > span {
    flex:0 0 auto;
    margin:0;
  }
  body.standalone-hub-page-yut .setup .name-field input {
    flex:1 1 auto;
    width:auto;
  }
  body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) #entry-title {
    font-size:clamp(24px,6.5vw,30px)!important;
    line-height:1.24;
  }
  body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .settings-grid {
    grid-template-columns:1fr!important;
    gap:10px;
  }
  body:is(.standalone-hub-page-holdem,.standalone-hub-page-seven-poker,.standalone-hub-page-omaha,.standalone-hub-page-draw-poker) .audio-panel {
    position:absolute!important;
    right:-110px!important;
    left:auto!important;
    width:min(296px,calc(100vw - 24px))!important;
    max-width:calc(100vw - 24px)!important;
  }
  body.race-standalone .race-page-hero {
    margin:12px 12px 18px;
    padding:24px 18px;
    border-radius:18px;
  }
  body.race-standalone .race-page-hero h1 {
    font-size:clamp(24px,6.5vw,30px);
    margin:10px 0;
  }
  body.race-standalone .race-page-hero p {
    font-size:13.5px;
    line-height:1.6;
  }
  body.race-standalone .race-page-actions {
    gap:8px;
    margin-top:16px;
  }
  body.race-standalone .race-page-actions :is(a,button) {
    min-height:44px;
    padding:10px 14px;
    font-size:13.5px;
  }
  body:not(.game-portal) :is(.intro h1,.local-hero h1,.hero h1,.pc-intro h1,#page-title,#game-title) {
    font-size:clamp(23px,6.4vw,28px)!important;
    line-height:1.24;
  }
  body:is(.standalone-hub-page-dice,.standalone-hub-page-hwatu) .dice-settings,
  body.standalone-hub-page-timer .rules-grid,
  body.standalone-hub-page-janggi :is(#cpu-settings.settings,.formation-grid),
  body.standalone-hub-page-chess #cpu-options.field-row,
  body .seo-related-links {
    grid-template-columns:1fr!important;
    gap:8px;
  }
}
