/* Shared controls use the same preference on the game and the guide. */
:root { --theme-control-bg: #fffdf8; --theme-control-text: #254f79; --theme-control-border: #b7d0e3; }
.theme-controls { display: flex; align-items: center; justify-content: flex-end; margin-bottom: 14px; }
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 40px; padding: 7px 12px; border: 1px solid var(--theme-control-border); border-radius: 100px; color: var(--theme-control-text); background: var(--theme-control-bg); font: inherit; font-size: .73rem; font-weight: 750; white-space: nowrap; cursor: pointer; }
.theme-toggle:hover { border-color: #f4a638; }
.theme-toggle:focus-visible { outline: 3px solid #f4a638; outline-offset: 3px; }
.theme-icon { font-size: 1.2rem; line-height: 1; }
.theme-toggle-track { display: block; width: 27px; height: 15px; padding: 2px; border-radius: 30px; background: #b6d0e3; }
.theme-toggle-track i { display: block; width: 11px; height: 11px; border-radius: 50%; background: #fff; transition: transform .18s ease; }
.theme-toggle[aria-pressed="true"] .theme-toggle-track { background: #d5a743; }
.theme-toggle[aria-pressed="true"] .theme-toggle-track i { transform: translateX(12px); }
.splash-theme-controls { position: absolute; top: max(16px,env(safe-area-inset-top)); right: max(16px,env(safe-area-inset-right)); z-index: 10; }
.room-setup-heading { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 24px; }
.room-setup-heading #btn-back-to-menu { margin: -6px 0 -6px -8px; }
.top-bar [data-theme-control] { margin-left: auto; }
#screen-demand_reveal .theme-controls { position: absolute; top: 10px; right: 12px; margin: 0; }
#screen-demand_reveal .card-panel > h2 { padding-inline: 46px; }
.guide-header-actions { display: flex; align-items: center; gap: 12px; }

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a1423; --surface: #15263d; --surface2: #203752; --surface3: #31506d;
  --text: #edf4ff; --muted: #b0c3dc; --accent: #ffb65c; --accent-hover: #ffce8f;
  --success: #81d6a2; --danger: #ff9baa; --warn: #ffd271; --info: #8bcaff;
  --theme-control-bg: #1c324d; --theme-control-text: #e1edff; --theme-control-border: #4b6888;
  --ink: #e4efff; --paper: #15263d;
}
html[data-theme="dark"] body { color: var(--text); background: radial-gradient(circle at 88% 5%,#193658 0,transparent 29rem),#0a1423; }
html[data-theme="dark"] body::before { background-image: radial-gradient(#87bdf022 1px,transparent 1px); }
html[data-theme="dark"] .card-panel,
html[data-theme="dark"] #screen-home .card-panel,
html[data-theme="dark"] #screen-rooms .room-setup-panel { color: var(--text); background: #15263df5; border-color: #405c7b; box-shadow: 0 18px 45px #030a1755; }
html[data-theme="dark"] #screen-home .subtitle,
html[data-theme="dark"] #screen-rooms .subtitle,
html[data-theme="dark"] .start-menu-note { color: #b4c9e2; }
html[data-theme="dark"] #screen-home .game-owners { background: #fffdf8; border-color: #557da2; }
html[data-theme="dark"] .how-to-play-link { color: #c9e6ff; background: #203d5d; border-color: #50759b; }
html[data-theme="dark"] .how-to-play-link:hover { background: #2c5275; }
html[data-theme="dark"] #btn-back-to-menu { color: #bbd5f3; }
html[data-theme="dark"] .top-bar { color: var(--text); background: #13243cf5; border-color: #405c7b; }
html[data-theme="dark"] #screen-production .top-bar,
html[data-theme="dark"] #screen-action_cards .top-bar,
html[data-theme="dark"] #screen-offering .top-bar { color: var(--text); background: #13243cf5; border-color: #405c7b; }
html[data-theme="dark"] .round-label { color: #edf4ff; }
html[data-theme="dark"] .room-chip,
html[data-theme="dark"] .money-chip { color: #e3efff; background: #213b59; border-color: #4a6989; }
html[data-theme="dark"] input[type="text"],
html[data-theme="dark"] input[type="number"],
html[data-theme="dark"] select { color: #eef5ff; background: #102139; border-color: #6484a6; }
html[data-theme="dark"] input::placeholder { color: #a6bcd5; }
html[data-theme="dark"] select option { color: #eef5ff; background: #102139; }
html[data-theme="dark"] .btn-secondary,
html[data-theme="dark"] .btn-num { color: #e7f1ff; background: #284766; border-color: #6484a6; }
html[data-theme="dark"] .btn-secondary:hover,
html[data-theme="dark"] .btn-num:hover { background: #365e83; }
html[data-theme="dark"] .btn-ghost { color: #bed1e8; border-color: #6582a2; }
html[data-theme="dark"] .btn-ghost:hover { color: #fff; background: #284766; }
html[data-theme="dark"] .player-row,
html[data-theme="dark"] .room-list-item,
html[data-theme="dark"] .score-row,
html[data-theme="dark"] .cost-preview,
html[data-theme="dark"] .turn-indicator { color: #d2e3f7; background: #203752; border-color: #4a6785; }
html[data-theme="dark"] .player-row .pname,
html[data-theme="dark"] .score-name { color: #f1f6ff; }
html[data-theme="dark"] .room-code-display,
html[data-theme="dark"] .production-warehouse { color: #dfedff; background: #102139; border-color: #6484a6; }
html[data-theme="dark"] .event-stage { background: radial-gradient(circle at 50% 25%,#2c5578,#152b47 72%); border-color: #557ba0; }
html[data-theme="dark"] .event-kicker { color: #b4d9ff; }
html[data-theme="dark"] .event-rule-chip { color: #ffdcaf; background: #4a3025; border-color: #bd8252; }
html[data-theme="dark"] .main-layout > .card-panel { color: #edf4ff; background: #15263d; border-color: #405c7b; }
html[data-theme="dark"] .main-layout > .card-panel h2,
html[data-theme="dark"] .main-layout > .card-panel > p,
html[data-theme="dark"] .main-layout > .card-panel label { color: #d9e9ff; }
html[data-theme="dark"] #screen-production,
html[data-theme="dark"] #screen-action_cards,
html[data-theme="dark"] #screen-offering { color: var(--text); }
html[data-theme="dark"] .mobile-game-nav button { color: #c7ddf6; background: #17334e; border-color: #54799e; }
html[data-theme="dark"] .mobile-game-nav button[aria-pressed="true"] { color: #102b55; background: #f7c928; border-color: #e1aa16; }
html[data-theme="dark"] .kppu-banner { color: #ffe4a4; background: #44381e; border-color: #ab8d40; }
html[data-theme="dark"] th { color: #b0c8e6; border-color: #3c5774; }
html[data-theme="dark"] td { border-color: #3c5774; }
html[data-theme="dark"] .btn-kick-player { color: #ffbcc6; background: #512b3a; border-color: #a85a6c; }
html[data-theme="dark"] .btn-kick-player:hover { background: #87394c; }
html[data-theme="dark"] .action-card-modal-shell { color: #edf4ff; background: #15263d; border-color: #537798; }
html[data-theme="dark"] .action-card-modal-controls label { color: #d9e9ff; }

/* The language chooser also follows the saved preference. */
html[data-theme="dark"] .language-screen { background: radial-gradient(ellipse at 15% 20%,#233e60 0,transparent 50%),#091524; }
html[data-theme="dark"] .language-panel { color: #edf4ff; background: #15263d; border-color: #5b7898; }
html[data-theme="dark"] .language-kicker { color: #ffd18c; }
html[data-theme="dark"] .language-panel h1 > span,
html[data-theme="dark"] .language-subtitle,
html[data-theme="dark"] .language-option-copy > span,
html[data-theme="dark"] .language-footer { color: #bbcee6; }
html[data-theme="dark"] .language-option { color: #edf4ff; background: #213751; border-color: #526e8d; box-shadow: 0 5px 0 #0c1c30; }
html[data-theme="dark"] .language-option[aria-pressed="true"] { color: #fff; background: #423c32; border-color: #ffb35e; }
html[data-theme="dark"] .language-arrow { background: #15263d; border-color: #526e8d; }
html[data-theme="dark"] .language-submit:disabled { color: #9aaec6; background: #2a3d53; }
html[data-theme="dark"] .splash-screen { background: radial-gradient(ellipse at 50% 25%,#214668,#0a1423 75%); }
html[data-theme="dark"] .splash-skip { color: #e3efff; background: #1e3a58; border-color: #6d8eae; }

/* Standalone how-to-play page. Printed screenshots retain their original colors. */
html[data-theme="dark"] .guide-header { color: #e5efff; background: #101f34f5; border-color: #3b5473; }
html[data-theme="dark"] .guide-brand span { color: #b0c3dc; border-color: #405c7b; }
html[data-theme="dark"] .guide-close { color: #e5efff; background: #1c324d; border-color: #4b6888; }
html[data-theme="dark"] .guide-close:hover { background: #34415a; }
html[data-theme="dark"] .close-icon { color: #e5efff; background: #2b4462; }
html[data-theme="dark"] .guide-nav-link { color: #bbcee6; }
html[data-theme="dark"] .guide-nav-link:hover,
html[data-theme="dark"] .guide-nav-link[aria-current="location"] { color: #fff; background: #294563; }
html[data-theme="dark"] .guide-nav-link[aria-current="location"] span { color: #ffcd7b; }
html[data-theme="dark"] .sidebar-note { color: #efdab7; background: #3b3226; border-color: #8a7045; }
html[data-theme="dark"] .guide-step { background: #15263d; border-color: #405c7b; }
html[data-theme="dark"] .step-description,
html[data-theme="dark"] .section-heading p { color: #bed0e8; }
html[data-theme="dark"] .step-label { color: #ffc27d; }
html[data-theme="dark"] .step-note { color: #efdab7; background: #3b3226; }
html[data-theme="dark"] .section-number { color: #c9e4ff; background: #284766; }
html[data-theme="dark"] .screenshot-button { background: #203752; border-color: #527497; }
html[data-theme="dark"] .step-figure figcaption,
html[data-theme="dark"] .guide-footer p,
html[data-theme="dark"] .contents-label { color: #adbfda; }
html[data-theme="dark"] .guide-step.no-image { background: #15362c; border-color: #467662; }
html[data-theme="dark"] .guide-step.no-image .step-label { color: #94dfb1; }
html[data-theme="dark"] .guide-finish { color: #fff0cb; background: #3b3226; border-color: #947543; }
html[data-theme="dark"] .guide-finish p:last-child { color: #e7d0a5; }
html[data-theme="dark"] .guide-finish .eyebrow { color: #ffd58f; }
html[data-theme="dark"] .footer-logos { padding: 10px 14px; border-radius: 12px; background: #fffdf8; }
html[data-theme="dark"] .screenshot-toolbar button { color: #edf4ff; background: #284766; border-color: #6484a6; }
@media (max-width: 680px) {
  .top-bar .theme-label, .top-bar .theme-toggle-track,
  #screen-demand_reveal .theme-label, #screen-demand_reveal .theme-toggle-track,
  .guide-header-actions .theme-label, .guide-header-actions .theme-toggle-track { display: none; }
  .top-bar .theme-toggle, #screen-demand_reveal .theme-toggle, .guide-header-actions .theme-toggle { width: 40px; padding: 7px; }
  .guide-header-actions { gap: 8px; }
  html[data-theme="dark"] .guide-sidebar { background: #101f34f5; border-color: #405c7b; }
  html[data-theme="dark"] .guide-sidebar .guide-nav-link { background: #203752; }
}
@media (prefers-reduced-motion: reduce) { .theme-toggle-track i { transition: none; } }
