/* Theme colors never change safe-area geometry, item density or hit targets. */
:root {
  --theme-ink: #eee4ce;
  --theme-muted: #bdc9cc;
  --theme-gold: #edca7c;
  --theme-edge: #6b7d80;
  --theme-surface: #14232b;
  --theme-raised: #20323a;
  --theme-panel-image: none;
  --theme-button-image: none;
  --theme-primary-image: none;
  --theme-slot-image: none;
  --theme-scene-image: none;
}

/* Public/default colors remain exactly those of the current production stylesheets. */
.theme-account-toggle { min-height: 44px; padding: 6px 10px; color: #d7e6ea; background: #1a303b; border: 1px solid #577783; border-radius: 4px; font: inherit; font-size: 12px; cursor: pointer; }
.theme-account-toggle[hidden], body.mobile-layout #theme-desktop-toggle { display: none !important; }
.theme-account-toggle:focus-visible { outline: 2px solid #80d7ff; outline-offset: 2px; }
.theme-account-toggle:disabled { opacity: .6; cursor: wait; }
:root[data-ui-theme='black-gold'] .theme-account-toggle { color: #f1e5c9; background: #252b30; border-color: #a3864e; }

.theme-intro { margin: 0 0 14px; color: var(--theme-muted); line-height: 1.6; }
.theme-options { display: flex; flex-direction: column; gap: 14px; }
.theme-option { display: grid; grid-template-columns: 108px minmax(0, 1fr) 178px; gap: 16px; align-items: center; padding: 14px; border: 1px solid var(--theme-edge); border-radius: 6px; background: var(--theme-surface); }
.theme-option[data-selected='true'] { border-color: var(--theme-gold); }
.theme-copy { min-width: 0; }
.theme-copy h3 { margin: 0 0 6px; font-size: 16px; color: var(--theme-ink); }
.theme-copy p { margin: 4px 0; line-height: 1.5; }
.theme-copy [data-theme-status] { color: var(--theme-gold); font-variant-numeric: tabular-nums; }
.theme-copy .theme-art-status { font-size: 11px; color: var(--theme-muted); }
.theme-actions { display: flex; flex-direction: column; gap: 8px; }
.theme-actions button { min-height: 44px; padding: 8px; font: inherit; font-size: 12px; border: 1px solid var(--theme-edge); border-radius: 4px; background: var(--theme-raised); color: var(--theme-ink); cursor: pointer; }
.theme-actions button[hidden] { display: none; }
.theme-actions button:disabled { opacity: .6; cursor: default; }
.theme-actions button:focus-visible { outline: 2px solid #7fdcff; outline-offset: 2px; }
.theme-message { margin: 12px 0 0; min-height: 20px; color: var(--theme-gold); line-height: 1.5; }
.theme-message.error { color: #ffc1ac; }
.theme-swatch { height: 78px; padding: 12px; display: flex; gap: 6px; align-items: end; border: 1px solid #617c81; background: #14232b; border-radius: 4px; }
.theme-swatch i { display: block; flex: 1; height: 30px; background: #28494f; border: 1px solid #89987b; }
.theme-swatch i:last-child { background: #36769a; }
.theme-swatch-black-gold { border-color: #b99651; background: #10161c; box-shadow: inset 0 0 0 3px #29343c; }
.theme-swatch-black-gold i { background: #262b2c; border-color: #bd9652; }
.theme-swatch-black-gold i:last-child { background: #235b7c; border-color: #88c8e4; }

#theme-preview-bar { position: fixed; z-index: 3100; top: calc(var(--rd-safe-area-top, 0px) + 54px); left: calc(50% + (var(--rd-safe-area-left, 0px) - var(--rd-safe-area-right, 0px)) / 2); transform: translateX(-50%); max-width: calc(100vw - var(--rd-safe-area-left, 0px) - var(--rd-safe-area-right, 0px) - 24px); box-sizing: border-box; display: flex; gap: 8px; align-items: center; padding: 4px 8px; border: 1px solid var(--theme-gold); border-radius: 4px; background: #101820f5; color: #f5e5c0; font: 12px/1.4 'Microsoft YaHei', sans-serif; box-shadow: 0 4px 16px #0008; }
#theme-preview-bar[hidden], body.progression-open #theme-preview-bar, body:has(#game-session-frame) #theme-preview-bar { display: none; }
#theme-preview-bar span { white-space: nowrap; }
#theme-preview-bar button { min-height: 44px; white-space: nowrap; border: 1px solid #8e7849; border-radius: 3px; padding: 6px 10px; background: #28333b; color: #f5e5c0; font: inherit; cursor: pointer; }
#theme-preview-bar button:focus-visible { outline: 2px solid #7fdcff; outline-offset: 2px; }
body.preparation-dashboard #theme-preview-bar { top: calc(var(--rd-safe-area-top, 0px) + 166px); right: calc(var(--rd-safe-area-right, 0px) + 16px); left: auto; transform: none; padding: 3px 6px; gap: 6px; font-size: 11px; }

/* Black-gold material fallback. Raster slots above stay empty until art arrives. */
:root[data-ui-theme='black-gold'] {
  --theme-ink: #f1e5c9;
  --theme-muted: #c0c8cc;
  --theme-gold: #f0cd7d;
  --theme-edge: #a3864e;
  --theme-surface: #111820;
  --theme-raised: #252b30;
  --game-border: #a3864e;
  --hud-control-surface: #131a20ee;
  --hud-control-edge: #b89b60;
}
:root[data-ui-theme='black-gold'] body { color: var(--theme-ink); }
:root[data-ui-theme='black-gold'] body::after { content: ''; position: fixed; inset: 0; z-index: 2500; pointer-events: none; border: 3px ridge #6c777c; box-shadow: inset 0 0 0 1px #ad8947; }
:root[data-ui-theme='black-gold'] ::selection { background: #29576b; color: #fff1cf; }
:root[data-ui-theme='black-gold'] :is(button, input, textarea, select):focus-visible { outline: 2px solid #80d7ff; outline-offset: 2px; }
:root[data-ui-theme='black-gold'] :is(input, textarea, select) { accent-color: #d7b56b; caret-color: #8bdbff; }
:root[data-ui-theme='black-gold'] * { scrollbar-color: #8b784d #111820; scrollbar-width: thin; }
:root[data-ui-theme='black-gold'] :is(#prep-dashboard, #shop-modal.shop-sheet) {
  color: var(--theme-ink); background-color: #111820;
  background-image: var(--theme-scene-image), linear-gradient(115deg, #141b21 20%, #0c1319 64%, #172a39);
  background-size: cover; background-position: center; border-color: #9b804c;
}
:root[data-ui-theme='black-gold'] :is(.prep-dashboard-header, .prep-shortcuts, #shop-modal.shop-sheet .shop-header, #shop-modal.shop-sheet .shop-footer) { background-color: #13191f; border-color: #736342; color: var(--theme-ink); }
:root[data-ui-theme='black-gold'] :is(#prep-inventory-host .console-center, #shop-modal.shop-sheet .shop-detail, #mobile-drawer, #progression-dialog, #skill-modal, #talent-modal, #attribute-panel, #run-reward-dialog, #player-commands-dialog, #hero-selection-modal) {
  color: var(--theme-ink); background-color: #111820; background-image: var(--theme-panel-image), linear-gradient(135deg, #1d252c, #0c1319);
  border-color: #a3864e; box-shadow: inset 0 0 0 2px #29343d, inset 0 0 0 3px #716142, 0 6px 18px #0007;
}
:root[data-ui-theme='black-gold'] :is(#mobile-drawer > header, .progression-header, .progression-footer, .progression-tabs) { background: #151e25; border-color: #716142; }
:root[data-ui-theme='black-gold'] :is(.progression-card, .mobile-menu-section, #mobile-battle-summary) { background-color: #19232b; border-color: #776744; }
:root[data-ui-theme='black-gold'] :is(#prep-dashboard, #shop-modal.shop-sheet, #mobile-drawer, #progression-dialog, #hero-selection-modal, #combat-quick-access, #skill-modal, #talent-modal, #attribute-panel, #run-reward-dialog, #player-commands-dialog) button {
  color: var(--theme-ink); border-color: #ab8b4c; border-radius: 3px; background-color: #272a29;
  background-image: var(--theme-button-image), linear-gradient(#363a38, #1a1e20);
  box-shadow: inset 0 1px #a38b5870, inset 0 -2px #080c10;
}
:root[data-ui-theme='black-gold'] :is(#prep-dashboard, #shop-modal.shop-sheet, #mobile-drawer, #progression-dialog, #combat-quick-access) button:hover:not(:disabled) { filter: brightness(1.15); }
:root[data-ui-theme='black-gold'] :is(#prep-dashboard, #shop-modal.shop-sheet, #mobile-drawer, #progression-dialog, #combat-quick-access) button:active:not(:disabled) { background-color: #10171d; background-image: linear-gradient(#141b20, #292d2d); box-shadow: inset 0 2px 4px #0009; }
:root[data-ui-theme='black-gold'] :is(#prep-dashboard, #shop-modal.shop-sheet, #mobile-drawer, #progression-dialog) button:disabled { filter: saturate(.25); opacity: .55; }
:root[data-ui-theme='black-gold'] #prep-dashboard #btn-banner-start-wave,
:root[data-ui-theme='black-gold'] #shop-modal.shop-sheet #shop-reroll-btn { background-color: #22462d; background-image: var(--theme-primary-image), linear-gradient(#355d30, #183522); border-color: #c8ac64; color: #fff0ca; }
:root[data-ui-theme='black-gold'] :is(#prep-skills-grid .cmd-slot, #prep-inventory-host .inv-slot, #shop-modal.shop-sheet .shop-item, #shop-modal.shop-sheet .inv-slot) {
  background-color: #10171c; background-image: var(--theme-slot-image); border-color: #a88a4c; border-radius: 3px;
  box-shadow: inset 0 0 0 2px #2d363a;
}
:root[data-ui-theme='black-gold'] #shop-modal.shop-sheet .shop-item.selected { border-color: #f6cf72; box-shadow: inset 0 0 0 1px #f6cf72; }
:root[data-ui-theme='black-gold'] #shop-modal.shop-sheet :is(.shop-item-name, .shop-catalog-heading, .shop-bag-heading, #shop-detail-name) { color: #f3d68e; }
:root[data-ui-theme='black-gold'] #shop-modal.shop-sheet :is(.shop-item-price, .shop-gold, #shop-gold) { color: #ffe296; }
:root[data-ui-theme='black-gold'] #shop-modal.shop-sheet :is(.shop-hint, .shop-item-type) { color: #bac8ce; }
:root[data-ui-theme='black-gold'] #prep-skills-grid .prep-skill-name { color: #f2dfb6; }
:root[data-ui-theme='black-gold'] .prep-vitals > div { outline: 1px solid #817144; background: #0c1216; }
:root[data-ui-theme='black-gold'] .prep-vitals span { background: linear-gradient(#5d9d40, #2f651e); }
:root[data-ui-theme='black-gold'] .prep-vitals > div + div span { background: linear-gradient(#488db5, #234b7e); }
:root[data-ui-theme='black-gold'] :is(.prep-core-stats dt, .progression-note) { color: #c3cbd0; }
:root[data-ui-theme='black-gold'] :is(.prep-identity strong, .prep-economy b, #prep-dashboard #prep-next-boss) { color: #f3d68e; }
:root[data-ui-theme='black-gold'] :is(#minimap-dock, #top-bar, #mobile-toolbar button) { border-color: #a3864e; background-color: #121a21e8; color: #f3d68e; box-shadow: inset 0 0 0 2px #35414a; }
:root[data-ui-theme='black-gold'] :is(#mobile-joystick, #mobile-attack, #mobile-attack-minion, #mobile-attack-boss, .command-grid > .cmd-slot, #item-active-dock .item-active-slot) { border-color: #c0a05b; background-color: #12191fe0; box-shadow: inset 0 0 0 2px #3c4850; }
:root[data-ui-theme='black-gold'] #mobile-joystick { background-color: #18232b88; }
:root[data-ui-theme='black-gold'] #mobile-joystick-knob { background-color: #758490; border-color: #afb9b9; }
:root[data-ui-theme='black-gold'] :is(#mobile-attack, #mobile-attack-minion, #mobile-attack-boss) { color: #f2d590; }
:root[data-ui-theme='black-gold'] #shop-modal.shop-sheet .shop-quick-controls button[aria-pressed='true'] { background-color: #2b4737; color: #ebefc9; }

@media (max-width: 720px) and (orientation: landscape) {
  .theme-option { grid-template-columns: 68px minmax(0, 1fr) 154px; gap: 10px; padding: 10px; }
  .theme-swatch { height: 60px; padding: 8px; gap: 3px; }
  .theme-copy h3 { font-size: 14px; }
  .theme-copy p { font-size: 12px; }
  #theme-preview-bar { gap: 6px; padding: 3px 6px; font-size: 11px; }
}

@media (prefers-reduced-motion: no-preference) {
  #theme-preview-bar { animation: theme-preview-appear 160ms ease-out; }
  @keyframes theme-preview-appear { from { opacity: .75; } to { opacity: 1; } }
}
