/*
 * Final UI theme cascade.
 *
 * Every player-selectable skin implements the same component and state matrix.
 * Craft keeps its dedicated layout while its palette follows the active skin.
 */

body.game-page[data-ui-theme] {
    color-scheme: dark;
    --theme-duration: 160ms;
    --theme-ease: cubic-bezier(0.2, 0.75, 0.25, 1);
    --theme-success: #34d399;
    --theme-success-soft: rgba(52, 211, 153, 0.16);
    --theme-warning: #fbbf24;
    --theme-warning-soft: rgba(251, 191, 36, 0.16);
    --theme-danger: #f87171;
    --theme-danger-soft: rgba(248, 113, 113, 0.16);
    --theme-info: #60a5fa;
    --theme-info-soft: rgba(96, 165, 250, 0.16);
    --theme-selection: var(--theme-accent);
    --theme-selection-strong: var(--theme-accent-strong);
    --theme-selection-soft: var(--theme-accent-soft);
    --theme-panel-deep: color-mix(in srgb, var(--theme-surface-0) 92%, black 8%);
    --theme-panel: color-mix(in srgb, var(--theme-surface-1) 92%, transparent);
    --theme-panel-raised: color-mix(in srgb, var(--theme-surface-2) 94%, transparent);
    --theme-panel-soft: color-mix(in srgb, var(--theme-surface-2) 70%, transparent);
    --theme-control: linear-gradient(180deg, var(--theme-surface-2), var(--theme-surface-1));
    --theme-control-hover: linear-gradient(
        180deg,
        color-mix(in srgb, var(--theme-surface-3) 78%, var(--theme-accent) 22%),
        color-mix(in srgb, var(--theme-surface-2) 88%, var(--theme-accent) 12%)
    );
    --theme-control-active: linear-gradient(
        180deg,
        color-mix(in srgb, var(--theme-surface-1) 76%, var(--theme-accent) 24%),
        color-mix(in srgb, var(--theme-surface-2) 82%, black 18%)
    );
    --theme-control-selected: linear-gradient(
        180deg,
        color-mix(in srgb, var(--theme-surface-3) 66%, var(--theme-selection) 34%),
        color-mix(in srgb, var(--theme-surface-2) 78%, var(--theme-selection) 22%)
    );
    --theme-control-disabled: color-mix(in srgb, var(--theme-surface-1) 82%, black 18%);
    --theme-shadow: 0 18px 48px rgba(0, 0, 0, 0.42);
    --theme-glow: 0 0 24px var(--theme-accent-soft);
    --theme-focus-ring: 0 0 0 2px var(--theme-surface-0), 0 0 0 4px var(--theme-focus);
    --theme-overlay: rgba(0, 2, 7, 0.72);
    --theme-ui-text: var(--theme-text);
    --theme-muted-readable: color-mix(in srgb, var(--theme-muted) 84%, white 16%);
    --theme-ui-muted: var(--theme-muted-readable);

    --ui-theme-accent: var(--theme-accent);
    --ui-theme-accent-strong: var(--theme-accent-strong);
    --ui-theme-accent-soft: var(--theme-accent-soft);
    --ui-theme-line: var(--theme-border);
    --ui-theme-line-strong: var(--theme-border-strong);
    --ui-theme-panel: var(--theme-panel-deep);
    --ui-theme-panel-raised: var(--theme-panel-raised);
    --ui-theme-panel-soft: var(--theme-panel-soft);
    --ui-theme-text: var(--theme-text);
    --ui-theme-muted: var(--theme-muted-readable);
    --sf-icon-theme-glow: color-mix(in srgb, var(--theme-accent) 34%, transparent);
    --sf-icon-theme-glow-strong: color-mix(in srgb, var(--theme-accent) 52%, transparent);
    --sf-modal-polish-bg: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep));
    --sf-modal-frame-inner-bg: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep));
    --sf-modal-frame-underlay: linear-gradient(180deg, var(--theme-panel-deep), #010306);
    --sf-modal-polish-panel: var(--theme-panel-deep);
    --sf-modal-polish-panel-strong: var(--theme-panel-raised);
    --sf-modal-polish-line: var(--theme-border);
    --sf-modal-polish-line-strong: var(--theme-border-strong);
    --sf-modal-polish-text: var(--theme-text);
    --sf-modal-polish-muted: var(--theme-muted-readable);
    --sf-modal-polish-accent: var(--theme-accent-strong);

    color: var(--theme-text);
    transition: background-color var(--theme-duration) var(--theme-ease), color var(--theme-duration) var(--theme-ease);
}

body.game-page[data-ui-theme="command-interface"] {
    --theme-surface-0: #020b0d;
    --theme-surface-1: #051719;
    --theme-surface-2: #082824;
    --theme-surface-3: #0c3a31;
    --theme-text: #ecfdf5;
    --theme-text-soft: #d1fae5;
    --theme-muted: #85bda9;
    --theme-accent: #34d399;
    --theme-accent-strong: #a7f3d0;
    --theme-accent-soft: rgba(52, 211, 153, 0.17);
    --theme-selection: #34d399;
    --theme-selection-strong: #a7f3d0;
    --theme-selection-soft: rgba(52, 211, 153, 0.17);
    --theme-focus: rgba(110, 231, 183, 0.76);
    --theme-border: rgba(52, 211, 153, 0.24);
    --theme-border-strong: rgba(110, 231, 183, 0.5);
    --theme-page-glow: rgba(16, 185, 129, 0.2);
    --theme-page-glow-secondary: rgba(34, 211, 238, 0.08);
    --theme-page-top: #061618;
    --theme-page-bottom: #010608;
    --theme-scroll-track: #031012;
    --theme-scroll-thumb: #19705a;
    --theme-scroll-thumb-hover: #34d399;
}

body.game-page[data-ui-theme="deep-space"] {
    --theme-surface-0: #020914;
    --theme-surface-1: #061525;
    --theme-surface-2: #0a263d;
    --theme-surface-3: #103a58;
    --theme-text: #e8f7ff;
    --theme-text-soft: #d7f1ff;
    --theme-muted: #8ebbd1;
    --theme-accent: #38bdf8;
    --theme-accent-strong: #bae6fd;
    --theme-accent-soft: rgba(56, 189, 248, 0.18);
    --theme-selection: #2dd4bf;
    --theme-selection-strong: #ccfbf1;
    --theme-selection-soft: rgba(45, 212, 191, 0.2);
    --theme-structure: #6366f1;
    --theme-focus: rgba(125, 211, 252, 0.8);
    --theme-border: rgba(99, 102, 241, 0.34);
    --theme-border-strong: rgba(129, 140, 248, 0.62);
    --theme-page-glow: rgba(14, 165, 233, 0.22);
    --theme-page-glow-secondary: rgba(99, 102, 241, 0.13);
    --theme-page-top: #071a2a;
    --theme-page-bottom: #010510;
    --theme-scroll-track: #03101c;
    --theme-scroll-thumb: #146789;
    --theme-scroll-thumb-hover: #38bdf8;
}

body.game-page[data-ui-theme="martian-forge"] {
    --theme-surface-0: #100704;
    --theme-surface-1: #1d0e07;
    --theme-surface-2: #32190d;
    --theme-surface-3: #4a2918;
    --theme-text: #fff7ed;
    --theme-text-soft: #ffedd5;
    --theme-muted: #d6a579;
    --theme-accent: #fb923c;
    --theme-accent-strong: #ffedd5;
    --theme-accent-soft: rgba(249, 115, 22, 0.2);
    --theme-selection: #60a5fa;
    --theme-selection-strong: #dbeafe;
    --theme-selection-soft: rgba(96, 165, 250, 0.2);
    --theme-structure: #c26a3d;
    --theme-focus: rgba(253, 186, 116, 0.82);
    --theme-border: rgba(194, 106, 61, 0.36);
    --theme-border-strong: rgba(251, 146, 60, 0.62);
    --theme-page-glow: rgba(234, 88, 12, 0.23);
    --theme-page-glow-secondary: rgba(96, 165, 250, 0.12);
    --theme-page-top: #241108;
    --theme-page-bottom: #080302;
    --theme-scroll-track: #160903;
    --theme-scroll-thumb: #9a4217;
    --theme-scroll-thumb-hover: #fb923c;
}

body.game-page[data-ui-theme="void-protocol"] {
    --theme-surface-0: #05030b;
    --theme-surface-1: #120a1f;
    --theme-surface-2: #211236;
    --theme-surface-3: #34204f;
    --theme-text: #f8f4ff;
    --theme-text-soft: #e9e0f2;
    --theme-muted: #b8b2c7;
    --theme-accent: #22d3ee;
    --theme-accent-strong: #cffafe;
    --theme-accent-soft: rgba(34, 211, 238, 0.18);
    --theme-selection: #f472b6;
    --theme-selection-strong: #fce7f3;
    --theme-selection-soft: rgba(244, 114, 182, 0.2);
    --theme-structure: #9b5de5;
    --theme-focus: rgba(34, 211, 238, 0.86);
    --theme-border: rgba(155, 93, 229, 0.34);
    --theme-border-strong: rgba(192, 132, 252, 0.62);
    --theme-page-glow: rgba(155, 93, 229, 0.26);
    --theme-page-glow-secondary: rgba(244, 114, 182, 0.16);
    --theme-page-top: #120a1f;
    --theme-page-bottom: #05030b;
    --theme-scroll-track: #0b0612;
    --theme-scroll-thumb: #7c3aed;
    --theme-scroll-thumb-hover: #22d3ee;
    --theme-control-hover: linear-gradient(
        180deg,
        color-mix(in srgb, #34204f 70%, #22d3ee 30%),
        color-mix(in srgb, #211236 84%, #22d3ee 16%)
    );
    --theme-control-active: linear-gradient(180deg, #120a1f, color-mix(in srgb, #211236 78%, #22d3ee 22%));
    --theme-control-selected: linear-gradient(
        180deg,
        color-mix(in srgb, #34204f 62%, #f472b6 38%),
        color-mix(in srgb, #211236 76%, #f472b6 24%)
    );
    --theme-glow: 0 0 24px rgba(34, 211, 238, 0.18);
}

body.game-page[data-ui-theme="retro-terminal"] {
    --theme-surface-0: #010603;
    --theme-surface-1: #031008;
    --theme-surface-2: #062013;
    --theme-surface-3: #0a3520;
    --theme-text: #d8ffe2;
    --theme-text-soft: #baffc9;
    --theme-muted: #79b88a;
    --theme-accent: #67e8f9;
    --theme-accent-strong: #cffafe;
    --theme-accent-soft: rgba(103, 232, 249, 0.16);
    --theme-selection: #ffb000;
    --theme-selection-strong: #ffe2a3;
    --theme-selection-soft: rgba(255, 176, 0, 0.18);
    --theme-structure: #39ff6a;
    --theme-focus: rgba(103, 232, 249, 0.84);
    --theme-border: rgba(57, 255, 106, 0.24);
    --theme-border-strong: rgba(112, 255, 146, 0.58);
    --theme-page-glow: rgba(34, 197, 94, 0.2);
    --theme-page-glow-secondary: rgba(255, 176, 0, 0.09);
    --theme-page-top: #06150b;
    --theme-page-bottom: #010302;
    --theme-scroll-track: #020a05;
    --theme-scroll-thumb: #16843a;
    --theme-scroll-thumb-hover: #67e8f9;
}

body.game-page[data-ui-theme="high-contrast"] {
    --theme-surface-0: #000000;
    --theme-surface-1: #080808;
    --theme-surface-2: #141414;
    --theme-surface-3: #202020;
    --theme-text: #ffffff;
    --theme-text-soft: #ffffff;
    --theme-muted: #e5e5e5;
    --theme-accent: #ffd60a;
    --theme-accent-strong: #fff27a;
    --theme-accent-soft: rgba(255, 214, 10, 0.24);
    --theme-focus: #00e5ff;
    --theme-border: rgba(255, 255, 255, 0.72);
    --theme-border-strong: #ffffff;
    --theme-page-glow: transparent;
    --theme-page-glow-secondary: transparent;
    --theme-page-top: #000000;
    --theme-page-bottom: #000000;
    --theme-scroll-track: #000000;
    --theme-scroll-thumb: #ffffff;
    --theme-scroll-thumb-hover: #ffd60a;
    --theme-panel-deep: #000000;
    --theme-panel: #080808;
    --theme-panel-raised: #141414;
    --theme-panel-soft: #1c1c1c;
    --theme-control: #141414;
    --theme-control-hover: #252525;
    --theme-control-active: #080808;
    --theme-control-selected: #292300;
    --theme-control-disabled: #101010;
    --theme-shadow: none;
    --theme-glow: none;
    --theme-overlay: rgba(0, 0, 0, 0.9);
}

/* Keep the tactical board surround neutral: themes belong to the interface chrome. */
body.game-page[data-ui-theme] {
    background:
        radial-gradient(circle at 50% -18%, rgba(30, 52, 64, 0.18), transparent 44%),
        linear-gradient(180deg, #03080c, #010305) !important;
    background-attachment: fixed;
}

body.game-page[data-ui-theme="high-contrast"] {
    background: #000000 !important;
}

/* Global theme-aware utilities and document chrome. */
body.game-page[data-ui-theme] :is(
    .text-emerald-100, .text-emerald-200, .text-emerald-300,
    .text-emerald-400, .text-emerald-500
):not(.craft-shell *):not(:is(
    .event-log-item, .event-log-item *,
    [role="progressbar"], [role="progressbar"] *,
    .sf-timer-status__progress, .sf-timer-status__progress *,
    .mission-active-progress, .mission-active-progress *,
    .sector-access-handshake__progress, .sector-access-handshake__progress *,
    .skill-details__mastery-progression, .skill-details__mastery-progression *,
    .progress-bar-color, .progress-bar-color *,
    [class*="progress-track"], [class*="progress-track"] *,
    [class*="progress-fill"], [class*="progress-fill"] *,
    [id$="-progress-bar"], [id$="-progress-bar"] *,
    [role="alert"], [role="alert"] *,
    [class*="error"], [class*="error"] *,
    [class*="faction-accent"], [class*="faction-accent"] *,
    .chat-dialogue-author, .chat-dialogue-faction
)) {
    color: var(--theme-accent-strong) !important;
}

body.game-page[data-ui-theme] :is([class^="border-emerald-"], [class*=" border-emerald-"]):not(.craft-shell *):not(:is(
    .event-log-item, .event-log-item *,
    [role="progressbar"], [role="progressbar"] *,
    .sf-timer-status__progress, .sf-timer-status__progress *,
    .mission-active-progress, .mission-active-progress *,
    .sector-access-handshake__progress, .sector-access-handshake__progress *,
    .skill-details__mastery-progression, .skill-details__mastery-progression *,
    .progress-bar-color, .progress-bar-color *,
    [class*="progress-track"], [class*="progress-track"] *,
    [class*="progress-fill"], [class*="progress-fill"] *,
    [id$="-progress-bar"], [id$="-progress-bar"] *,
    [role="alert"], [role="alert"] *,
    [class*="error"], [class*="error"] *,
    [class*="faction-accent"], [class*="faction-accent"] *
)) {
    border-color: var(--theme-border) !important;
}

body.game-page[data-ui-theme] :is([class^="bg-emerald-"], [class*=" bg-emerald-"]):not(.craft-shell *):not(#mp-notification-container *):not(:is(
    .event-log-item, .event-log-item *,
    [role="progressbar"], [role="progressbar"] *,
    .sf-timer-status__progress, .sf-timer-status__progress *,
    .mission-active-progress, .mission-active-progress *,
    .sector-access-handshake__progress, .sector-access-handshake__progress *,
    .skill-details__mastery-progression, .skill-details__mastery-progression *,
    .progress-bar-color, .progress-bar-color *,
    [class*="progress-track"], [class*="progress-track"] *,
    [class*="progress-fill"], [class*="progress-fill"] *,
    [id$="-progress-bar"], [id$="-progress-bar"] *,
    [role="alert"], [role="alert"] *,
    [class*="error"], [class*="error"] *,
    [class*="faction-accent"], [class*="faction-accent"] *
)) {
    background-color: var(--theme-panel-soft) !important;
}

body.game-page[data-ui-theme] :is(
    [class^="bg-zinc-"], [class*=" bg-zinc-"],
    [class^="bg-slate-"], [class*=" bg-slate-"],
    [class^="bg-black"], [class*=" bg-black"]
):not(.craft-shell *):not(#mp-notification-container *):not(:is(
    .event-log-item, .event-log-item *,
    [role="progressbar"], [role="progressbar"] *,
    .sf-timer-status__progress, .sf-timer-status__progress *,
    .mission-active-progress, .mission-active-progress *,
    .sector-access-handshake__progress, .sector-access-handshake__progress *,
    .skill-details__mastery-progression, .skill-details__mastery-progression *,
    .progress-bar-color, .progress-bar-color *,
    [class*="progress-track"], [class*="progress-track"] *,
    [class*="progress-fill"], [class*="progress-fill"] *,
    [id$="-progress-bar"], [id$="-progress-bar"] *,
    [role="alert"], [role="alert"] *,
    [class*="error"], [class*="error"] *,
    [class*="faction-accent"], [class*="faction-accent"] *
)) {
    background-color: var(--theme-panel-deep) !important;
}

body.game-page[data-ui-theme] ::selection {
    color: var(--theme-text);
    background: color-mix(in srgb, var(--theme-accent) 52%, transparent);
}

body.game-page[data-ui-theme] *:not(.craft-shell *) {
    scrollbar-color: var(--theme-scroll-thumb) var(--theme-scroll-track);
}

body.game-page[data-ui-theme] *:not(.craft-shell *)::-webkit-scrollbar-track {
    background: var(--theme-scroll-track);
}

body.game-page[data-ui-theme] *:not(.craft-shell *)::-webkit-scrollbar-thumb {
    border-color: var(--theme-scroll-track);
    background: var(--theme-scroll-thumb);
}

body.game-page[data-ui-theme] *:not(.craft-shell *)::-webkit-scrollbar-thumb:hover {
    background: var(--theme-scroll-thumb-hover);
}

body.game-page[data-ui-theme] :is(.modal, [role="dialog"]) > .fixed.inset-0 {
    background: transparent !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

body.game-page[data-ui-theme] :is(.modal-backdrop, [modal-backdrop]) {
    display: none !important;
    background: transparent !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

body.game-page[data-ui-theme] .recorp-wordmark {
    background-image: linear-gradient(96deg, var(--theme-accent-strong), var(--theme-text), var(--theme-accent));
    color: var(--theme-accent-strong);
    text-shadow: 0 0 8px var(--theme-accent-soft), 0 0 20px var(--theme-page-glow-secondary);
    filter: drop-shadow(0 0 6px var(--theme-accent-soft));
}

body.game-page[data-ui-theme] .recorp-wordmark::before {
    color: var(--theme-accent-strong);
}

body.game-page[data-ui-theme] .recorp-wordmark::after {
    color: color-mix(in srgb, var(--theme-accent) 72%, var(--theme-warning) 28%);
}

body.game-page[data-ui-theme] #tooltip-hover {
    border-color: var(--theme-border-strong) !important;
    background: color-mix(in srgb, var(--theme-panel-deep) 92%, transparent) !important;
    color: var(--theme-accent-strong) !important;
    box-shadow: var(--theme-glow) !important;
}

body.game-page[data-ui-theme] [data-mission-count-badge] {
    border: 1px solid var(--theme-border-strong);
    background: var(--theme-accent) !important;
    color: var(--theme-surface-0) !important;
    box-shadow: 0 0 14px var(--theme-accent-soft) !important;
}

/* Top information bar, mobile information cards, scale controls and footer. */
body.game-page[data-ui-theme] :is(
    #info-container,
    #mobile-info-player-container,
    #info-sector-container-mobile,
    #game-ui-scale-controls
) {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at top, var(--theme-accent-soft), transparent 66%),
        linear-gradient(180deg, color-mix(in srgb, var(--theme-panel-raised) 94%, transparent), var(--theme-panel-deep)) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--theme-shadow), var(--theme-glow) !important;
}

body.game-page[data-ui-theme] #info-sector-container {
    background: transparent !important;
    border: 0 !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] :is(
    #player-avatar-frame,
    #info-coordinates-container,
    #info-credit-container,
    #mobile-info-player-container fieldset,
    #info-sector-container-mobile fieldset
) {
    border-color: var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel)) !important;
    color: var(--theme-text-soft) !important;
}

body.game-page[data-ui-theme] :is(
    #info-container legend,
    #mobile-info-player-container legend,
    #info-sector-container-mobile legend,
    #info-coordinates-container .iconify,
    #info-credit-container .iconify
) {
    color: var(--theme-accent-strong) !important;
}

body.game-page[data-ui-theme] :is(#game-ui-scale-controls button, .logout) {
    border-color: var(--theme-border) !important;
    background: var(--theme-control) !important;
    color: var(--theme-accent-strong) !important;
    transition: border-color var(--theme-duration) var(--theme-ease), background var(--theme-duration) var(--theme-ease), color var(--theme-duration) var(--theme-ease), box-shadow var(--theme-duration) var(--theme-ease), transform 80ms ease;
}

body.game-page[data-ui-theme] :is(#game-ui-scale-controls button, .logout):hover:not(:disabled) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-glow) !important;
}

body.game-page[data-ui-theme] :is(#game-ui-scale-controls button, .logout):active:not(:disabled) {
    background: var(--theme-control-active) !important;
    transform: translateY(1px);
}

body.game-page[data-ui-theme] #main-screen > footer,
body.game-page[data-ui-theme] #game-footer {
    border-color: var(--theme-border) !important;
    background: transparent !important;
    color: var(--theme-muted-readable) !important;
    box-shadow: inset 0 1px 0 var(--theme-border), 0 -14px 32px rgba(0, 0, 0, 0.24) !important;
}

body.game-page[data-ui-theme] #main-screen > footer p,
body.game-page[data-ui-theme] #game-footer p {
    color: var(--theme-muted-readable) !important;
}

body.game-page[data-ui-theme] #main-screen > footer :is(a, button):not(.danger):hover,
body.game-page[data-ui-theme] #game-footer :is(a, button):not(.danger):hover {
    color: var(--theme-accent-strong) !important;
}

/* Desktop, mobile and side action navigation. */
body.game-page[data-ui-theme] #main-screen > nav {
    border-color: var(--theme-border) !important;
    background: color-mix(in srgb, var(--theme-panel-deep) 94%, transparent) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 -1px 0 var(--theme-border), var(--theme-shadow) !important;
}

body.game-page[data-ui-theme] #navbar-hamburger .side-menu-list {
    background: transparent !important;
}

body.game-page[data-ui-theme] :is(
    #chat-modal-button-mobile,
    #message-modal-button-mobile,
    .navbar-burger
) {
    border-color: var(--theme-border) !important;
    background: var(--theme-control) !important;
    color: var(--theme-accent-strong) !important;
    transition: border-color var(--theme-duration) var(--theme-ease), background var(--theme-duration) var(--theme-ease), color var(--theme-duration) var(--theme-ease), box-shadow var(--theme-duration) var(--theme-ease), transform 80ms ease;
}

body.game-page[data-ui-theme] :is(
    #chat-modal-button-mobile,
    #message-modal-button-mobile,
    .navbar-burger
):hover:not(:disabled) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-glow) !important;
}

body.game-page[data-ui-theme] :is(
    #chat-modal-button-mobile,
    #message-modal-button-mobile,
    .navbar-burger
):active:not(:disabled) {
    background: var(--theme-control-active) !important;
    transform: translateY(1px);
}

body.game-page[data-ui-theme] #desktop-action-bar {
    border: 1px solid var(--theme-border) !important;
    background:
        radial-gradient(circle at 50% 0%, var(--theme-accent-soft), transparent 72%),
        linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), var(--theme-shadow), var(--theme-glow) !important;
}

body.game-page[data-ui-theme] #desktop-action-bar .desktop-action-item {
    --desktop-action-accent: var(--theme-accent) !important;
    border: 1px solid transparent;
    background: linear-gradient(180deg, var(--theme-accent-soft), transparent) !important;
    color: var(--theme-accent-strong) !important;
    transition: border-color var(--theme-duration) var(--theme-ease), background var(--theme-duration) var(--theme-ease), box-shadow var(--theme-duration) var(--theme-ease), transform 80ms ease;
}

body.game-page[data-ui-theme] #desktop-action-bar .desktop-action-item + .desktop-action-item::before {
    background: var(--theme-border) !important;
}

body.game-page[data-ui-theme] #desktop-action-bar .desktop-action-item:hover:not(:disabled) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 0 0 1px var(--theme-accent-soft), var(--theme-glow) !important;
    transform: translateY(-1px);
}

body.game-page[data-ui-theme] #desktop-action-bar .desktop-action-item:active:not(:disabled) {
    background: var(--theme-control-active) !important;
    transform: translateY(1px);
}

body.game-page[data-ui-theme] #desktop-action-bar .desktop-action-item:is(.is-active, [aria-pressed="true"], [aria-selected="true"]) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-selected) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 -2px 0 var(--theme-selection), 0 0 24px var(--theme-selection-soft) !important;
}

body.game-page[data-ui-theme] #desktop-action-bar :is(.desktop-action-icon, .action-button-sf-icon, .action-icon-mask) {
    color: currentColor !important;
    filter: drop-shadow(0 0 7px var(--sf-icon-theme-glow)) !important;
}

body.game-page[data-ui-theme] #desktop-action-bar .action-icon-mask {
    background-color: transparent !important;
}

body.game-page[data-ui-theme] #desktop-action-bar .desktop-action-label {
    color: currentColor !important;
}

body.game-page[data-ui-theme] #mobile-action-bar-panel {
    border-color: var(--theme-border) !important;
    background: color-mix(in srgb, var(--theme-panel-deep) 88%, transparent) !important;
    box-shadow: var(--theme-shadow), var(--theme-glow) !important;
}

body.game-page[data-ui-theme] #mobile-action-bar .mobile-action-icon-btn,
body.game-page[data-ui-theme] :is(#button-menu, #navbar-hamburger) .side-menu-item {
    border-color: transparent !important;
    background: var(--theme-control) !important;
    color: var(--theme-accent-strong) !important;
    transition: border-color var(--theme-duration) var(--theme-ease), background var(--theme-duration) var(--theme-ease), color var(--theme-duration) var(--theme-ease), box-shadow var(--theme-duration) var(--theme-ease), transform 80ms ease;
}

body.game-page[data-ui-theme] #mobile-action-bar .mobile-action-icon-btn:hover:not(:disabled),
body.game-page[data-ui-theme] :is(#button-menu, #navbar-hamburger) .side-menu-item:hover:not(:disabled) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-glow) !important;
}

body.game-page[data-ui-theme] :is(#button-menu, #navbar-hamburger) .side-menu-item.patreon-support-menu-item {
    border-color: var(--sf-disabled-action-border) !important;
    background: linear-gradient(180deg, rgba(105, 25, 35, 0.72), rgba(35, 8, 13, 0.96)) !important;
    color: var(--sf-interactive-danger-text) !important;
    box-shadow: inset 0 0 0 1px rgba(202, 74, 85, 0.08), 0 0 12px rgba(90, 17, 27, 0.16) !important;
}

body.game-page[data-ui-theme] :is(#button-menu, #navbar-hamburger) .side-menu-item.patreon-support-menu-item:hover:not(:disabled) {
    border-color: var(--sf-interactive-danger-hover) !important;
    background: linear-gradient(180deg, rgba(120, 30, 40, 0.78), rgba(42, 9, 15, 0.98)) !important;
    color: #efb3b6 !important;
    box-shadow: 0 0 18px rgba(90, 17, 27, 0.24) !important;
}

body.game-page[data-ui-theme] #mobile-action-bar .mobile-action-icon-btn:active:not(:disabled),
body.game-page[data-ui-theme] :is(#button-menu, #navbar-hamburger) .side-menu-item:active:not(:disabled) {
    background: var(--theme-control-active) !important;
    transform: scale(0.98);
}

body.game-page[data-ui-theme] #mobile-action-bar :is(.mobile-action-icon-btn, #mobile-action-bar-toggle):is(.is-active, [aria-expanded="true"], [aria-pressed="true"]),
body.game-page[data-ui-theme] :is(#button-menu, #navbar-hamburger) .side-menu-item:is(.is-active, [aria-current="page"], [aria-pressed="true"]) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-selected) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 -2px 0 var(--theme-selection), 0 0 24px var(--theme-selection-soft) !important;
}

body.game-page[data-ui-theme] #mobile-action-bar-toggle::before,
body.game-page[data-ui-theme] #mobile-action-bar-toggle::after {
    background: linear-gradient(90deg, transparent, var(--theme-accent), transparent) !important;
}

body.game-page[data-ui-theme] #mobile-action-bar .mobile-action-icon,
body.game-page[data-ui-theme] :is(#button-menu, #navbar-hamburger) .side-menu-icon {
    color: currentColor !important;
}

/* Only genuinely mask-backed icons need a painted background; local SF PNGs keep their own colors. */
body.game-page[data-ui-theme] #mobile-action-bar :is(
    .action-button-sf-icon,
    .mobile-action-icon.iconify
) {
    background-color: currentColor;
}

body.game-page[data-ui-theme] #mobile-action-bar .action-icon-mask {
    background-color: transparent !important;
    filter: drop-shadow(0 0 7px var(--sf-icon-theme-glow)) !important;
}

body.game-page[data-ui-theme] #mobile-action-bar .mobile-action-label,
body.game-page[data-ui-theme] :is(#button-menu, #navbar-hamburger) .side-menu-label {
    color: currentColor !important;
}

/* Player sidebar: chrome changes; health, energy and tactical fills retain meaning. */
body.game-page[data-ui-theme] #player-infos {
    border: 0 !important;
    background: transparent !important;
    color: var(--theme-text) !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] #player-info-item-container {
    background: transparent !important;
}

body.game-page[data-ui-theme] #player-infos :is(#statistics-fieldset, #status-fieldset, #events-log, .hud-stats-panel) {
    border-color: var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel)) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 8px 20px rgba(0, 0, 0, 0.18) !important;
}

body.game-page[data-ui-theme] #player-infos fieldset > legend {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control) !important;
    color: var(--theme-accent-strong) !important;
    box-shadow: var(--theme-glow) !important;
}

body.game-page[data-ui-theme] #player-infos .hud-stats-panel :is(label, .iconify) {
    color: var(--theme-accent-strong) !important;
}

body.game-page[data-ui-theme] #player-infos .hud-progress-track {
    border-color: var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-deep), color-mix(in srgb, var(--theme-panel-deep) 76%, black 24%)) !important;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.54) !important;
}

body.game-page[data-ui-theme] #player-infos :is(#player-effects, #empty-effect-state, #player-event-container) {
    color: var(--theme-muted-readable) !important;
}

/* Modal frames, headers, content surfaces and footers. Craft is deliberately absent. */
body.game-page[data-ui-theme] :is(
    .button-menu-modal-frame:not(.craft-shell),
    .modal-window-panel,
    .ui-choice-modal-panel,
    .actor-modal-shell--framed,
    .foreground-modal-shell
) {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at 12% 0%, var(--theme-accent-soft), transparent 38%),
        linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    color: var(--theme-text) !important;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.58), var(--theme-glow) !important;
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) > :is(
    .button-menu-modal-header,
    header,
    .tutorial-modal-header,
    .actor-modal__header
) {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at 9% 20%, var(--theme-accent-soft), transparent 42%),
        linear-gradient(100deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 -1px 0 var(--theme-border) !important;
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) .modal-header-with-art::before {
    background-image:
        linear-gradient(90deg, var(--theme-panel-deep) 0%, color-mix(in srgb, var(--theme-panel) 78%, transparent) 52%, color-mix(in srgb, var(--theme-panel) 35%, transparent) 78%, var(--theme-panel) 100%),
        var(--modal-header-art, none) !important;
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) .modal-header-with-art::after {
    background: linear-gradient(180deg, var(--theme-accent-soft), transparent) !important;
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) :is(
    .modal-body,
    .actor-modal__body,
    .tutorial-reader-body,
    .character-modal-scroll-area,
    .event-modal-log-container,
    .inventory-modal__content,
    .mail-list-panel,
    .options-body
) {
    background: linear-gradient(180deg, var(--theme-panel), var(--theme-panel-deep)) !important;
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) :is(
    .options-card,
    .options-account-hero,
    .options-account-detail,
    .character-modal-panels-shell,
    .inventory-modal-pane,
    .equipped-module-group,
    .module-item,
    .inventory-module-row,
    .inventory-resource-row,
    .mission-active-row,
    .event-modal-state,
    .mail-item,
    .chat-dialogue-card,
    .tutorial-progress-card,
    .tutorial-menu-group,
    .tutorial-mission-button,
    .tutorial-objective-card,
    .tutorial-help-row,
    .actor-hero,
    .actor-profile-card,
    .actor-summary-card,
    .actor-section,
    .actor-inventory-group,
    .actor-profile__item,
    .actor-inventory-row,
    .actor-effect-chip,
    [data-missions-board-section],
    [data-missions-journal-grid] > section
) {
    border-color: var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel)) !important;
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) :is(
    .module-item,
    .inventory-module-row,
    .inventory-resource-row,
    .mission-active-row,
    .mail-item,
    .tutorial-mission-button,
    .actor-profile__item,
    .actor-inventory-row
):hover {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    box-shadow: inset 0 0 0 1px var(--theme-accent-soft), var(--theme-glow) !important;
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) > :is(
    footer,
    .button-menu-modal-footer,
    .tutorial-modal-footer,
    .actor-modal__footer
) {
    border-color: var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    color: var(--theme-muted-readable) !important;
    box-shadow: inset 0 1px 0 var(--theme-border), 0 -14px 30px rgba(0, 0, 0, 0.24) !important;
}

/* Shared non-semantic controls inside themed modal roots. */
body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) button:not(.modal-window-header-control):not(.danger):not([class*="--danger"]):not([data-variant="danger"]):not(.options-theme-card):not(:disabled):not(.is-disabled):not([aria-disabled="true"]) {
    border-color: var(--theme-border) !important;
    background: var(--theme-control) !important;
    color: var(--theme-accent-strong) !important;
    transition: border-color var(--theme-duration) var(--theme-ease), background var(--theme-duration) var(--theme-ease), color var(--theme-duration) var(--theme-ease), box-shadow var(--theme-duration) var(--theme-ease), opacity var(--theme-duration) var(--theme-ease), transform 80ms ease;
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) button:not(.modal-window-header-control):not(.danger):not([class*="--danger"]):not([data-variant="danger"]):not(.options-theme-card):hover:not(:disabled):not([aria-disabled="true"]) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 0 0 1px var(--theme-accent-soft), var(--theme-glow) !important;
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) button:not(.modal-window-header-control):not(.danger):not([class*="--danger"]):not([data-variant="danger"]):not(.options-theme-card):active:not(:disabled):not([aria-disabled="true"]) {
    background: var(--theme-control-active) !important;
    transform: translateY(1px);
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) button:not(.modal-window-header-control):not(.danger):not([class*="--danger"]):not([data-variant="danger"]):not(.options-theme-card):is(.is-active, [aria-selected="true"], [aria-pressed="true"], [aria-current="page"]) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-selected) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 -2px 0 var(--theme-selection), 0 0 24px var(--theme-selection-soft) !important;
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) :is(
    .sf-modal-close-btn,
    .options-action-btn,
    .options-tab,
    .inventory-action-btn,
    .trade-modal-action-btn,
    .group-inline-btn,
    .map-sector-filter-toggle,
    .map-world-tool-button,
    .map-modal-tab,
    .character-modal-tab,
    .tab-btn,
    .corp-action-btn,
    .action-button-sf,
    .ui-choice-modal-btn,
    [data-missions-board-refresh],
    [data-missions-board-tab-trigger]
):not(.options-action-btn--danger):not(.trade-modal-action-btn--danger):not(.group-inline-btn--danger):not(.danger):not([data-variant="danger"]):not(:disabled):not(.is-disabled):not([aria-disabled="true"]) {
    border-color: var(--theme-border) !important;
    background: var(--theme-control) !important;
    color: var(--theme-accent-strong) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04) !important;
    transition: border-color var(--theme-duration) var(--theme-ease), background var(--theme-duration) var(--theme-ease), color var(--theme-duration) var(--theme-ease), box-shadow var(--theme-duration) var(--theme-ease), opacity var(--theme-duration) var(--theme-ease), transform 80ms ease;
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) :is(
    .sf-modal-close-btn,
    .options-action-btn,
    .options-tab,
    .inventory-action-btn,
    .trade-modal-action-btn,
    .group-inline-btn,
    .map-sector-filter-toggle,
    .map-world-tool-button,
    .map-modal-tab,
    .character-modal-tab,
    .tab-btn,
    .corp-action-btn,
    .action-button-sf,
    .ui-choice-modal-btn,
    [data-missions-board-refresh],
    [data-missions-board-tab-trigger]
):not(.options-action-btn--danger):not(.trade-modal-action-btn--danger):not(.group-inline-btn--danger):not(.danger):not([data-variant="danger"]):hover:not(:disabled):not([aria-disabled="true"]) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 0 0 1px var(--theme-accent-soft), var(--theme-glow) !important;
    transform: translateY(-1px);
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) :is(
    .sf-modal-close-btn,
    .options-action-btn,
    .options-tab,
    .inventory-action-btn,
    .trade-modal-action-btn,
    .group-inline-btn,
    .map-sector-filter-toggle,
    .map-world-tool-button,
    .map-modal-tab,
    .character-modal-tab,
    .tab-btn,
    .corp-action-btn,
    .action-button-sf,
    .ui-choice-modal-btn,
    [data-missions-board-refresh],
    [data-missions-board-tab-trigger]
):not(.options-action-btn--danger):not(.trade-modal-action-btn--danger):not(.group-inline-btn--danger):not(.danger):not([data-variant="danger"]):active:not(:disabled):not([aria-disabled="true"]) {
    background: var(--theme-control-active) !important;
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.34) !important;
    transform: translateY(1px);
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) :is(
    .options-tab,
    .map-modal-tab,
    .character-modal-tab,
    .tab-btn,
    [data-missions-board-tab-trigger]
):is(.is-active, [aria-selected="true"], [aria-pressed="true"], .border-emerald-400, .bg-emerald-400) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-selected) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 -2px 0 var(--theme-selection), 0 0 24px var(--theme-selection-soft) !important;
}

/* Forms, dropdowns, filters and pagination in all themed non-craft modal shells. */
body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) :is(
    input:not([type="checkbox"]):not([type="radio"]),
    textarea,
    select,
    .dropdown-menu,
    .filter-panel,
    .pagination-control
) {
    border-color: var(--theme-border) !important;
    background-color: var(--theme-panel-deep) !important;
    color: var(--theme-text) !important;
    caret-color: var(--theme-accent);
    transition: border-color var(--theme-duration) var(--theme-ease), background-color var(--theme-duration) var(--theme-ease), box-shadow var(--theme-duration) var(--theme-ease);
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) :is(input, textarea, select)::placeholder {
    color: color-mix(in srgb, var(--theme-muted) 72%, transparent) !important;
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) :is(
    input:not([type="checkbox"]):not([type="radio"]),
    textarea,
    select
):hover:not(:disabled) {
    border-color: var(--theme-border-strong) !important;
    background-color: var(--theme-surface-1) !important;
}

body.game-page[data-ui-theme] .button-menu-modal-frame:not(.craft-shell) :is(input[type="checkbox"], input[type="radio"]) {
    accent-color: var(--theme-accent);
}

/* Unified keyboard focus and disabled states. */
body.game-page[data-ui-theme] :is(
    button,
    a[href],
    input,
    textarea,
    select,
    [tabindex]:not([tabindex="-1"])
):not(.craft-shell *):not(.modal-window-header-control):focus-visible {
    outline: 2px solid transparent !important;
    box-shadow: var(--theme-focus-ring) !important;
}

body.game-page[data-ui-theme] :is(button, input, textarea, select):not(.craft-shell *):disabled,
body.game-page[data-ui-theme] [aria-disabled="true"]:not(.craft-shell *) {
    border-color: color-mix(in srgb, var(--theme-border) 52%, transparent) !important;
    background: var(--theme-control-disabled) !important;
    color: color-mix(in srgb, var(--theme-muted) 56%, transparent) !important;
    box-shadow: none !important;
    cursor: not-allowed !important;
    filter: saturate(0.45);
    opacity: 0.62;
    transform: none !important;
}

/* Semantic feedback remains recognizable and is consistent across skins. */
body.game-page[data-ui-theme] :is(.is-success, .status-success, [data-status="success"]):not(.craft-shell *) {
    border-color: color-mix(in srgb, var(--theme-success) 52%, transparent) !important;
    background-color: var(--theme-success-soft) !important;
    color: var(--theme-success) !important;
}

body.game-page[data-ui-theme] :is(.is-warning, .status-warning, [data-status="warning"]):not(.craft-shell *) {
    border-color: color-mix(in srgb, var(--theme-warning) 52%, transparent) !important;
    background-color: var(--theme-warning-soft) !important;
    color: var(--theme-warning) !important;
}

body.game-page[data-ui-theme] :is(.is-danger, .status-danger, [data-status="danger"], [data-variant="danger"]):not(.craft-shell *) {
    border-color: color-mix(in srgb, var(--theme-danger) 52%, transparent) !important;
    background-color: var(--theme-danger-soft) !important;
    color: var(--theme-danger) !important;
}

body.game-page[data-ui-theme] :is(.is-info, .status-info, [data-status="info"]):not(.craft-shell *) {
    border-color: color-mix(in srgb, var(--theme-info) 52%, transparent) !important;
    background-color: var(--theme-info-soft) !important;
    color: var(--theme-info) !important;
}

body.game-page[data-ui-theme] :is(.danger, [class*="--danger"], [data-variant="danger"]):not(.craft-shell *):hover:not(:disabled) {
    border-color: var(--theme-danger) !important;
    background: color-mix(in srgb, var(--theme-danger-soft) 76%, #250709 24%) !important;
    color: #fecaca !important;
    box-shadow: 0 0 20px var(--theme-danger-soft) !important;
}

/* Toasts, hints, badges and floating feedback. */
body.game-page[data-ui-theme] :is(
    .toast,
    .notification,
    .game-tooltip,
    [role="tooltip"],
    .popover,
    .context-menu
):not(.craft-shell *):not(#mp-notification-container *):not(.disabled-action-tooltip):not([class*="error"]):not(.is-danger):not(.status-danger):not([data-status="danger"]):not([data-variant="danger"]) {
    border-color: var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-shadow), var(--theme-glow) !important;
}

body.game-page[data-ui-theme] :is(.badge, .chip, .tag):not(.is-success):not(.is-warning):not(.is-danger):not(.craft-shell *):not(:is(
    .event-log-item *,
    [role="progressbar"], [role="progressbar"] *,
    .sf-timer-status__progress *,
    [class*="progress-track"] *, [class*="progress-fill"] *,
    [class*="faction-accent"], [class*="faction-accent"] *
)) {
    border-color: var(--theme-border) !important;
    background: var(--theme-panel-soft) !important;
    color: var(--theme-accent-strong) !important;
}

@media (prefers-reduced-motion: reduce) {
    body.game-page[data-ui-theme],
    body.game-page[data-ui-theme] *,
    body.game-page[data-ui-theme] *::before,
    body.game-page[data-ui-theme] *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}

/* Outer layout shells intentionally remain transparent above every skin. */
body.game-page[data-ui-theme] :is(
    #main-info-container,
    .main-info-container,
    #info-container,
    #side-menu-list,
    #button-menu .side-menu-list,
    #navbar-hamburger .side-menu-list,
    #player-infos,
    #info-sector-container,
    #main-screen > footer,
    #game-footer,
    #navbar-hamburger
) {
    background: transparent !important;
}

body.game-page[data-ui-theme] :is(#main-info-container, .main-info-container, #info-container, #player-infos, #info-sector-container) {
    border: 0 !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] #navbar-hamburger {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

body.game-page[data-ui-theme] #navbar-hamburger > nav {
    background: rgba(0, 0, 0, 0.68) !important;
    -webkit-backdrop-filter: blur(12px) saturate(120%) !important;
    backdrop-filter: blur(12px) saturate(120%) !important;
}

body.game-page[data-ui-theme] .logout,
body.game-page[data-ui-theme] .logout:is(:hover, :active, :focus, :focus-visible) {
    border-color: transparent !important;
    background: transparent !important;
    box-shadow: none !important;
}

@media (min-width: 1024px) {
    body.game-page[data-ui-theme] :is(#main-screen > footer, #game-footer) {
        border: 0 !important;
        box-shadow: none !important;
    }
}

/*
 * Modal interior theme bridge.
 *
 * The first modal skin predates player themes and exposes a petrol/cyan set of
 * custom properties. Rebinding that visual vocabulary here lets every modal
 * keep its layout while receiving the active theme palette. Semantic colors
 * (logs, factions, errors and progress indicators) are deliberately excluded.
 */
body.game-page[data-ui-theme] :is(
    .button-menu-modal-frame:not(.craft-shell),
    .modal-window-panel:not(.craft-shell),
    .ui-choice-modal-panel,
    .actor-modal-shell--framed,
    .foreground-modal-shell,
    .game-image-cropper__dialog,
    .wreck-loot-panel,
    #death-respawn-overlay > div
) {
    --sf-proto-void: var(--theme-surface-0);
    --sf-proto-modal: var(--theme-surface-1);
    --sf-proto-modal-strong: var(--theme-surface-2);
    --sf-proto-surface: var(--theme-surface-2);
    --sf-proto-surface-raised: var(--theme-surface-3);
    --sf-proto-surface-soft: var(--theme-panel-soft);
    --sf-proto-surface-deep: var(--theme-panel-deep);
    --sf-proto-text: var(--theme-text);
    --sf-proto-text-soft: var(--theme-text-soft);
    --sf-proto-text-muted: var(--theme-muted-readable);
    --sf-proto-text-dim: color-mix(in srgb, var(--theme-muted-readable) 82%, transparent);
    --sf-proto-cyan: var(--theme-accent-strong);
    --sf-proto-teal: var(--theme-accent);
    --sf-proto-green: var(--theme-accent);
    --sf-proto-amber: var(--theme-selection);
    --sf-proto-violet: var(--theme-structure, var(--theme-selection));
    --sf-proto-line: var(--theme-border);
    --sf-proto-line-strong: var(--theme-border-strong);
    --sf-proto-line-green: var(--theme-border-strong);
    --sf-modal-frame-inner-bg: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep));
    --sf-modal-frame-underlay: linear-gradient(180deg, var(--theme-panel-deep), var(--theme-surface-0));
    --modal-bg: var(--theme-panel-deep);
    --modal-accent: var(--theme-accent);
    --ui-theme-accent: var(--theme-accent);
    --ui-theme-accent-strong: var(--theme-accent-strong);
    --ui-theme-accent-soft: var(--theme-accent-soft);
    --ui-theme-line: var(--theme-border);
    --ui-theme-line-strong: var(--theme-border-strong);
    --ui-theme-panel: var(--theme-panel);
    --ui-theme-panel-mid: var(--theme-panel-raised);
    --ui-theme-panel-highlight: var(--theme-surface-3);
    --ui-theme-panel-deep: var(--theme-panel-deep);
    --ui-theme-control-bg: var(--theme-surface-2);
    --ui-theme-control-hover: var(--theme-surface-3);
    --ui-theme-footer-bg: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep));
    --ui-theme-text: var(--theme-text);
    --ui-theme-muted: var(--theme-muted-readable);
}

body.game-page[data-ui-theme] #corporation-modal {
    --corp-accent: var(--theme-accent);
    --corp-accent-strong: var(--theme-accent-strong);
    --corp-accent-soft: var(--theme-accent-soft);
    --corp-line: var(--theme-border);
    --corp-line-strong: var(--theme-border-strong);
    --corp-panel: var(--theme-panel);
    --corp-panel-strong: var(--theme-panel-deep);
    --corp-text: var(--theme-text);
    --corp-muted: var(--theme-muted-readable);
    --corp-shadow: var(--theme-shadow), var(--theme-glow);
}

/* Actor type/faction accents remain semantic; only their neutral surfaces move with the theme. */
body.game-page[data-ui-theme] .actor-modal-shell--framed {
    --actor-panel: var(--theme-panel-raised);
    --actor-panel-strong: var(--theme-panel-deep);
    --actor-text: var(--theme-text);
    --actor-muted: var(--theme-muted-readable);
}

/* Restore the historical semantic palette below roots whose neutral variables are rebound above. */
body.game-page[data-ui-theme] :is(
    .button-menu-modal-frame:not(.craft-shell),
    .modal-window-panel:not(.craft-shell),
    .actor-modal-shell--framed,
    .foreground-modal-shell
) :is(
    .event-log-item,
    [role="progressbar"],
    .sf-timer-status__progress,
    .mission-active-progress,
    .sector-access-handshake__progress,
    .skill-details__mastery-progression,
    .progress-bar-color,
    [class*="progress-track"],
    [class*="progress-fill"],
    [id$="-progress-bar"]
) {
    --sf-proto-void: #061017;
    --sf-proto-modal: #0c1a24;
    --sf-proto-modal-strong: #102330;
    --sf-proto-surface: #132a36;
    --sf-proto-surface-raised: #193845;
    --sf-proto-surface-soft: #10212b;
    --sf-proto-surface-deep: #081218;
    --sf-proto-text: #e7f4f7;
    --sf-proto-text-soft: #c2d8df;
    --sf-proto-text-muted: #91aeb9;
    --sf-proto-text-dim: #69828d;
    --sf-proto-cyan: #6ad8ff;
    --sf-proto-teal: #53d7c2;
    --sf-proto-line: rgba(114, 213, 242, 0.2);
    --sf-proto-line-strong: rgba(114, 213, 242, 0.44);
}

/* High-specificity replacements for the original modal prototype selectors. */
body.game-page[data-ui-theme] :is(
    #character-modal > .button-menu-modal-frame,
    #event-modal-content,
    #task-modal-content,
    #chat-modal-content,
    #mail-modal-content,
    #map-modal-content,
    #inventory-modal > .button-menu-modal-frame,
    #tutorial-menu-content,
    #tutorial-reader-content,
    #tutorial-completion-content
) {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at 12% 0%, var(--theme-accent-soft), transparent 38%),
        linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    background-color: var(--theme-panel-deep) !important;
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] :is(
    #character-modal .button-menu-modal-header,
    #event-modal .button-menu-modal-header,
    #task-modal .button-menu-modal-header,
    #chat-modal .button-menu-modal-header,
    #mail-modal-content .button-menu-modal-header,
    #map-modal .button-menu-modal-header,
    #inventory-modal .inventory-modal__header,
    #tutorial-menu-content .tutorial-modal-header,
    #tutorial-reader-content .tutorial-modal-header,
    #tutorial-completion-content .tutorial-modal-header,
    #tutorial-menu-content .tutorial-modal-footer,
    #tutorial-reader-content .tutorial-modal-footer,
    #tutorial-completion-content .tutorial-modal-footer
) {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at 9% 20%, var(--theme-accent-soft), transparent 42%),
        linear-gradient(100deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 -1px 0 var(--theme-border) !important;
}

body.game-page[data-ui-theme] :is(
    #character-modal .modal-header-with-art,
    #event-modal .modal-header-with-art,
    #task-modal .modal-header-with-art,
    #chat-modal .modal-header-with-art,
    #mail-modal-content .modal-header-with-art,
    #map-modal .modal-header-with-art,
    #tutorial-menu-content .modal-header-with-art,
    #tutorial-reader-content .modal-header-with-art
)::before {
    background-image:
        linear-gradient(90deg, var(--theme-panel-deep) 0%, color-mix(in srgb, var(--theme-panel) 78%, transparent) 52%, color-mix(in srgb, var(--theme-panel) 35%, transparent) 78%, var(--theme-panel) 100%),
        var(--modal-header-art, none) !important;
}

body.game-page[data-ui-theme] :is(
    #character-modal .modal-header-with-art,
    #event-modal .modal-header-with-art,
    #task-modal .modal-header-with-art,
    #chat-modal .modal-header-with-art,
    #mail-modal-content .modal-header-with-art,
    #map-modal .modal-header-with-art,
    #tutorial-menu-content .modal-header-with-art,
    #tutorial-reader-content .modal-header-with-art
)::after {
    background: linear-gradient(180deg, var(--theme-accent-soft), transparent) !important;
}

body.game-page[data-ui-theme] :is(
    #character-modal .button-menu-modal-header h2 > i,
    #event-modal .button-menu-modal-header h2 > i,
    #task-modal .button-menu-modal-header h2 > i,
    #chat-modal .button-menu-modal-header h2 > i,
    #mail-modal-content .button-menu-modal-header h2 > i,
    #map-modal .button-menu-modal-header h2 > i,
    #inventory-modal .inventory-modal__header h2 > i,
    #tutorial-menu-content .tutorial-modal-title-icon,
    #tutorial-reader-content .tutorial-modal-title-icon,
    #tutorial-completion-content .tutorial-modal-title-icon
) {
    color: var(--theme-accent-strong) !important;
    filter: drop-shadow(0 0 10px var(--theme-accent-soft)) !important;
}

body.game-page[data-ui-theme] :is(
    #character-modal .character-modal-scroll-area,
    #event-modal .event-modal-log-container,
    #task-modal-content > .flex-1,
    #chat-modal #chat-messages,
    #mail-modal-content #mail-list,
    #map-modal-content > .flex-1,
    #inventory-modal .inventory-modal__content,
    #tutorial-menu-content > .p-3,
    #tutorial-reader-content .tutorial-reader-body,
    #tutorial-completion-content .tutorial-reader-body,
    .actor-modal-shell--framed .actor-modal__body
) {
    background:
        radial-gradient(circle at 12% 0%, color-mix(in srgb, var(--theme-accent) 7%, transparent), transparent 36%),
        linear-gradient(180deg, var(--theme-panel), var(--theme-panel-deep)) !important;
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] :is(
    #character-modal #character-modal-summary,
    #character-modal .character-modal-panels-shell,
    #task-modal [data-missions-board-section],
    #task-modal [data-missions-journal-grid] > section,
    #event-modal .event-modal-state,
    #mail-modal-content .mail-list-panel,
    #map-modal .map-modal-tab-rail,
    #inventory-modal .inventory-modal-pane,
    #tutorial-menu-content .tutorial-progress-card,
    #tutorial-reader-content .tutorial-objective-card,
    #tutorial-completion-content .tutorial-objective-card,
    .actor-modal-shell--framed .actor-hero,
    .actor-modal-shell--framed .actor-profile-card,
    .actor-modal-shell--framed .actor-summary-card,
    .actor-modal-shell--framed .actor-section,
    .actor-modal-shell--framed .actor-inventory-group
) {
    border-color: var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel)) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), 0 12px 28px rgba(0, 0, 0, 0.18) !important;
}

body.game-page[data-ui-theme] :is(
    #task-modal [data-missions-board-message],
    #task-modal [data-missions-active-list],
    #task-modal [data-missions-completed-list],
    #task-modal [data-missions-board-list],
    #task-modal [data-missions-board-active-list],
    #task-modal .mission-active-row,
    #mail-modal-content .mail-item,
    #chat-modal .chat-dialogue-card,
    #inventory-modal .equipped-module-group,
    #inventory-modal .module-item,
    #inventory-modal .inventory-module-row,
    #inventory-modal .inventory-resource-row,
    #tutorial-menu-content .tutorial-menu-group,
    #tutorial-menu-content .tutorial-mission-button,
    #tutorial-reader-content .tutorial-help-row,
    .actor-modal-shell--framed .actor-profile__item,
    .actor-modal-shell--framed .actor-inventory-row,
    .actor-modal-shell--framed .actor-effect-chip
) {
    border-color: var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel)) !important;
    color: var(--theme-text-soft) !important;
}

body.game-page[data-ui-theme] :is(
    #task-modal [data-missions-board-tab-trigger],
    #character-modal .character-modal-tab,
    #chat-modal #tab-sector,
    #chat-modal #tab-faction,
    #chat-modal #tab-group,
    #mail-modal-content .tab-btn,
    #map-modal .map-modal-tab,
    #event-modal .event-pagination-controls button,
    #task-modal [data-missions-completed-page-nav],
    #tutorial-reader-content .tutorial-reader-nav,
    #tutorial-reader-content .tutorial-reader-primary
) {
    border-color: var(--theme-border) !important;
    background: var(--theme-control) !important;
    color: var(--theme-muted) !important;
}

body.game-page[data-ui-theme] :is(
    #task-modal [data-missions-board-tab-trigger].bg-emerald-400,
    #character-modal .character-modal-tab.is-active,
    #chat-modal #tab-sector.border-emerald-400,
    #chat-modal #tab-faction.border-emerald-400,
    #chat-modal #tab-group.border-emerald-400,
    #mail-modal-content .tab-btn.border-emerald-400,
    #map-modal .map-modal-tab.is-active,
    #tutorial-menu-content .tutorial-menu-group.is-active,
    #tutorial-menu-content .tutorial-mission-button.is-active,
    #tutorial-reader-content .tutorial-reader-primary
) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-selected) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 -2px 0 var(--theme-selection), 0 0 24px var(--theme-selection-soft) !important;
}

body.game-page[data-ui-theme] :is(
    #character-modal .character-modal-tab,
    #chat-modal #tab-sector,
    #chat-modal #tab-faction,
    #chat-modal #tab-group,
    #mail-modal-content .tab-btn,
    #map-modal .map-modal-tab,
    #task-modal [data-missions-board-tab-trigger],
    #event-modal .event-pagination-controls button,
    #task-modal [data-missions-completed-page-nav],
    #tutorial-reader-content .tutorial-reader-nav,
    #tutorial-menu-content .tutorial-menu-group-header,
    #tutorial-menu-content .tutorial-mission-button
):hover:not(:disabled) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 0 0 1px var(--theme-accent-soft), var(--theme-glow) !important;
}

body.game-page[data-ui-theme] :is(
    #chat-modal #chat-input,
    #mail-modal-content #search-message,
    #mail-modal-content input,
    #mail-modal-content textarea,
    #character-modal select,
    #inventory-modal input
) {
    border-color: var(--theme-border) !important;
    background: var(--theme-panel-deep) !important;
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] :is(
    #chat-modal #chat-input,
    #mail-modal-content #search-message,
    #mail-modal-content input,
    #mail-modal-content textarea,
    #character-modal select,
    #inventory-modal input
):focus {
    border-color: var(--theme-border-strong) !important;
    box-shadow: var(--theme-focus-ring) !important;
}

body.game-page[data-ui-theme] :is(
    #chat-modal #chat-send,
    #task-modal [data-missions-board-refresh],
    #task-modal button.bg-emerald-400,
    #tutorial-reader-content .tutorial-reader-primary
):not(.danger):not([data-variant="danger"]) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-selected) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-glow) !important;
}

body.game-page[data-ui-theme] :is(
    #inventory-modal .equipped-empty-slot,
    #inventory-modal .inventory-empty-row,
    #task-modal [data-missions-active-list]:empty,
    #task-modal [data-missions-completed-list]:empty
) {
    border-color: var(--theme-border) !important;
    background: var(--theme-panel-deep) !important;
    color: var(--theme-muted) !important;
}

body.game-page[data-ui-theme] :is(
    #mail-modal-content .mail-item-status,
    #inventory-modal .inventory-module-type-badge,
    #inventory-modal .equipped-module-count,
    #tutorial-menu-content .tutorial-menu-group-meta,
    #tutorial-menu-content .tutorial-progress-card span:last-child
) {
    border-color: var(--theme-border) !important;
    background: var(--theme-panel-soft) !important;
    color: var(--theme-text-soft) !important;
}

body.game-page[data-ui-theme] :is(#map-modal .map-sector-scroll, #map-modal #map-world-viewport) {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at 20% 0%, var(--theme-accent-soft), transparent 34%),
        linear-gradient(180deg, var(--theme-panel), var(--theme-panel-deep)) !important;
}

body.game-page[data-ui-theme] :is(
    #map-modal .map-sector-filter-toggle,
    #map-modal .map-sector-filter,
    #map-modal .map-world-tool-button
) {
    border-color: var(--theme-border) !important;
    background: var(--theme-control) !important;
    color: var(--theme-text-soft) !important;
}

body.game-page[data-ui-theme] #map-modal .map-sector-filter.is-active {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-selected) !important;
    color: var(--theme-accent-strong) !important;
}

/* Blue, cyan and emerald utility remnants are neutral UI accents inside modals only. */
body.game-page[data-ui-theme] :is(
    .button-menu-modal-frame:not(.craft-shell),
    .modal-window-panel:not(.craft-shell),
    .ui-choice-modal-panel,
    .actor-modal-shell--framed,
    .foreground-modal-shell
) :is(
    [class^="text-emerald-"], [class*=" text-emerald-"],
    [class^="text-blue-"], [class*=" text-blue-"],
    [class^="text-cyan-"], [class*=" text-cyan-"],
    [class^="text-sky-"], [class*=" text-sky-"]
):not([style*="color"]):not(:is(
    .event-log-item, .event-log-item *,
    [role="progressbar"], [role="progressbar"] *,
    .sf-timer-status__progress, .sf-timer-status__progress *,
    .mission-active-progress, .mission-active-progress *,
    .sector-access-handshake__progress, .sector-access-handshake__progress *,
    .skill-details__mastery-progression, .skill-details__mastery-progression *,
    .progress-bar-color, .progress-bar-color *,
    [class*="progress-track"], [class*="progress-track"] *,
    [class*="progress-fill"], [class*="progress-fill"] *,
    [id$="-progress-bar"], [id$="-progress-bar"] *,
    [role="alert"], [role="alert"] *,
    [class*="error"], [class*="error"] *,
    [class*="faction-accent"], [class*="faction-accent"] *,
    .chat-dialogue-author, .chat-dialogue-faction
)) {
    color: var(--theme-accent-strong) !important;
}

body.game-page[data-ui-theme] :is(
    .button-menu-modal-frame:not(.craft-shell),
    .modal-window-panel:not(.craft-shell),
    .ui-choice-modal-panel,
    .actor-modal-shell--framed,
    .foreground-modal-shell
) :is(
    [class^="border-emerald-"], [class*=" border-emerald-"],
    [class^="border-blue-"], [class*=" border-blue-"],
    [class^="border-cyan-"], [class*=" border-cyan-"],
    [class^="border-sky-"], [class*=" border-sky-"]
):not(:is(
    .event-log-item, .event-log-item *,
    [role="progressbar"], [role="progressbar"] *,
    .sf-timer-status__progress, .sf-timer-status__progress *,
    .mission-active-progress, .mission-active-progress *,
    .sector-access-handshake__progress, .sector-access-handshake__progress *,
    .skill-details__mastery-progression, .skill-details__mastery-progression *,
    .progress-bar-color, .progress-bar-color *,
    [class*="progress-track"], [class*="progress-track"] *,
    [class*="progress-fill"], [class*="progress-fill"] *,
    [id$="-progress-bar"], [id$="-progress-bar"] *,
    [role="alert"], [role="alert"] *,
    [class*="error"], [class*="error"] *,
    [class*="faction-accent"], [class*="faction-accent"] *
)) {
    border-color: var(--theme-border) !important;
}

body.game-page[data-ui-theme] :is(
    .button-menu-modal-frame:not(.craft-shell),
    .modal-window-panel:not(.craft-shell),
    .ui-choice-modal-panel,
    .actor-modal-shell--framed,
    .foreground-modal-shell
) :is(
    [class^="bg-emerald-"], [class*=" bg-emerald-"],
    [class^="bg-blue-"], [class*=" bg-blue-"],
    [class^="bg-cyan-"], [class*=" bg-cyan-"],
    [class^="bg-sky-"], [class*=" bg-sky-"]
):not(:is(
    .event-log-item, .event-log-item *,
    [role="progressbar"], [role="progressbar"] *,
    .sf-timer-status__progress, .sf-timer-status__progress *,
    .mission-active-progress, .mission-active-progress *,
    .sector-access-handshake__progress, .sector-access-handshake__progress *,
    .skill-details__mastery-progression, .skill-details__mastery-progression *,
    .progress-bar-color, .progress-bar-color *,
    [class*="progress-track"], [class*="progress-track"] *,
    [class*="progress-fill"], [class*="progress-fill"] *,
    [id$="-progress-bar"], [id$="-progress-bar"] *,
    [role="alert"], [role="alert"] *,
    [class*="error"], [class*="error"] *,
    [class*="faction-accent"], [class*="faction-accent"] *
)) {
    background-color: var(--theme-panel-soft) !important;
}

body.game-page[data-ui-theme] :is(
    .button-menu-modal-frame:not(.craft-shell),
    .modal-window-panel:not(.craft-shell),
    .ui-choice-modal-panel,
    .actor-modal-shell--framed,
    .foreground-modal-shell
) :is(
    [class*="ring-emerald-"], [class*="ring-blue-"],
    [class*="ring-cyan-"], [class*="ring-sky-"]
):not(:is(.event-log-item *, [role="progressbar"] *, .mission-active-progress *, .sector-access-handshake__progress *, .skill-details__mastery-progression *, [class*="progress-fill"] *, [class*="faction-accent"] *)) {
    --tw-ring-color: var(--theme-focus) !important;
}

body.game-page[data-ui-theme] :is(
    .button-menu-modal-frame:not(.craft-shell),
    .modal-window-panel:not(.craft-shell),
    .ui-choice-modal-panel,
    .actor-modal-shell--framed,
    .foreground-modal-shell
) :is(
    [class*="shadow-emerald-"], [class*="shadow-blue-"],
    [class*="shadow-cyan-"], [class*="shadow-sky-"]
):not(:is(.event-log-item *, [role="progressbar"] *, .mission-active-progress *, .sector-access-handshake__progress *, .skill-details__mastery-progression *, [class*="progress-fill"] *, [class*="faction-accent"] *)) {
    --tw-shadow-color: var(--theme-accent-soft) !important;
}

/* Accessibility skin: stronger separation with deliberately reduced visual noise. */
body.game-page[data-ui-theme="high-contrast"] #player-infos :is(
    #statistics-fieldset,
    #status-fieldset,
    #events-log,
    #container-core-stats,
    #container-defense-stats
) {
    border: 2px solid var(--theme-border-strong) !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme="high-contrast"] :is(
    #info-container,
    #player-infos,
    #button-menu,
    #navbar-hamburger,
    #mobile-action-bar,
    #main-screen > nav,
    #main-screen > footer,
    .button-menu-modal-frame:not(.craft-shell)
),
body.game-page[data-ui-theme="high-contrast"] :is(
    #info-container,
    #player-infos,
    #button-menu,
    #navbar-hamburger,
    #mobile-action-bar,
    #main-screen > nav,
    #main-screen > footer,
    .button-menu-modal-frame:not(.craft-shell)
) * {
    text-shadow: none !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
}

body.game-page[data-ui-theme="retro-terminal"] .button-menu-modal-frame:not(.craft-shell) {
    background:
        repeating-linear-gradient(180deg, rgba(57, 255, 106, 0.018) 0 1px, transparent 1px 4px),
        linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
}

/* Semantic header controls override legacy green utility classes in every theme. */
body.game-page[data-ui-theme] button.modal-window-header-control {
    appearance: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: #60a5fa !important;
    box-shadow: none !important;
    filter: none !important;
}

body.game-page[data-ui-theme] button.modal-window-header-control:hover {
    border: 0 !important;
    background: transparent !important;
    color: #f87171 !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] button.modal-window-header-control:is(:focus, :focus-visible, :active) {
    border: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] button.modal-window-header-control :is(i, .iconify) {
    background: transparent !important;
    color: inherit !important;
}

/* Keep HUD event categories identical to the full event log, independently of the theme. */
body.game-page[data-ui-theme] :is(.event-log-item-hud, .event-log-item-modal) {
    border-color: rgba(16, 185, 129, 0.22) !important;
    border-left-color: rgba(52, 211, 153, 0.58) !important;
    background: linear-gradient(135deg, rgba(3, 7, 7, 0.9), rgba(7, 37, 30, 0.46)) !important;
    box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.08), 0 12px 24px rgba(0, 0, 0, 0.16) !important;
}

body.game-page[data-ui-theme] :is(.event-log-item-hud, .event-log-item-modal).event-log-item--minor {
    background: linear-gradient(135deg, rgba(3, 7, 7, 0.76), rgba(7, 37, 30, 0.28)) !important;
    box-shadow: inset 0 0 0 1px rgba(16, 185, 129, 0.05) !important;
    opacity: 1;
}

body.game-page[data-ui-theme] :is(.event-log-item-hud, .event-log-item-modal).event-log-item--achievement {
    border-color: rgba(34, 211, 238, 0.24) !important;
    border-left-color: rgba(103, 232, 249, 0.78) !important;
    background: linear-gradient(135deg, rgba(3, 10, 15, 0.9), rgba(8, 47, 73, 0.42)) !important;
    box-shadow: inset 0 0 0 1px rgba(34, 211, 238, 0.1), 0 0 12px rgba(34, 211, 238, 0.14) !important;
}

body.game-page[data-ui-theme] :is(.event-log-item-hud, .event-log-item-modal).event-log-item--mission {
    border-color: rgba(96, 165, 250, 0.24) !important;
    border-left-color: rgba(147, 197, 253, 0.78) !important;
    background: linear-gradient(135deg, rgba(4, 10, 20, 0.9), rgba(30, 64, 175, 0.28)) !important;
    box-shadow: inset 0 0 0 1px rgba(96, 165, 250, 0.1), 0 0 12px rgba(59, 130, 246, 0.12) !important;
}

body.game-page[data-ui-theme] :is(.event-log-item-hud, .event-log-item-modal).event-log-item--tone-combat {
    border-color: rgba(248, 113, 113, 0.28) !important;
    border-left-color: rgba(248, 113, 113, 0.82) !important;
    background: linear-gradient(135deg, rgba(18, 8, 11, 0.86), rgba(127, 29, 29, 0.24)) !important;
}

body.game-page[data-ui-theme] :is(.event-log-item-hud, .event-log-item-modal).event-log-item--tone-scan {
    border-color: rgba(34, 211, 238, 0.26) !important;
    border-left-color: rgba(34, 211, 238, 0.78) !important;
    background: linear-gradient(135deg, rgba(3, 12, 18, 0.86), rgba(8, 145, 178, 0.22)) !important;
}

body.game-page[data-ui-theme] :is(.event-log-item-hud, .event-log-item-modal):is(.event-log-item--tone-maintenance, .event-log-item--tone-economy) {
    border-color: rgba(245, 158, 11, 0.24) !important;
    border-left-color: rgba(251, 191, 36, 0.76) !important;
    background: linear-gradient(135deg, rgba(18, 12, 4, 0.86), rgba(146, 64, 14, 0.2)) !important;
}

body.game-page[data-ui-theme] :is(.event-log-item-hud, .event-log-item-modal).event-log-item--tone-navigation {
    border-color: rgba(125, 211, 252, 0.24) !important;
    border-left-color: rgba(125, 211, 252, 0.72) !important;
    background: linear-gradient(135deg, rgba(3, 10, 15, 0.86), rgba(14, 116, 144, 0.2)) !important;
}

body.game-page[data-ui-theme="command-interface"] #statistics-fieldset :is(#container-core-stats, #container-defense-stats) {
    border: 1px solid var(--theme-border-strong) !important;
    background: linear-gradient(180deg, var(--theme-surface-2), var(--theme-surface-1)) !important;
    box-shadow: inset 0 0 0 1px var(--theme-accent-soft), 0 0 14px rgba(52, 211, 153, 0.12) !important;
}

body.game-page[data-ui-theme] :is(#button-menu, #navbar-hamburger) .side-menu-list :is(.side-menu-item, .wiki-nav-item):not(:hover):not(:active):not(.is-active):not([aria-current="page"]):not([aria-pressed="true"]) {
    background-color: transparent !important;
    background-image: none !important;
}

body.game-page[data-ui-theme] :is(
    .modal-window-actions > button,
    .modal-window-action,
    .tutorial-window-action,
    [data-modal-window-minimize],
    [data-modal-window-close],
    [data-tutorial-minimize],
    .button-menu-modal-header > button[data-modal-hide],
    .button-menu-modal-header > button[id^="close-"],
    .actor-modal__header > button[data-actor-modal-close="true"],
    .craft-header > .craft-header__close
) {
    width: auto !important;
    min-width: 0 !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: #60a5fa !important;
    font-size: 1.5rem !important;
    line-height: 1 !important;
    text-shadow: none !important;
    box-shadow: none !important;
    filter: none !important;
}

body.game-page[data-ui-theme] :is(
    .modal-window-actions > button,
    .modal-window-action,
    .tutorial-window-action,
    [data-modal-window-minimize],
    [data-modal-window-close],
    [data-tutorial-minimize],
    .button-menu-modal-header > button[data-modal-hide],
    .button-menu-modal-header > button[id^="close-"],
    .actor-modal__header > button[data-actor-modal-close="true"],
    .craft-header > .craft-header__close
) :is(i, .iconify) {
    background: transparent !important;
    color: inherit !important;
}

body.game-page[data-ui-theme] :is(
    .modal-window-actions > button,
    .modal-window-action,
    .tutorial-window-action,
    [data-modal-window-minimize],
    [data-modal-window-close],
    [data-tutorial-minimize],
    .button-menu-modal-header > button[data-modal-hide],
    .button-menu-modal-header > button[id^="close-"],
    .actor-modal__header > button[data-actor-modal-close="true"],
    .craft-header > .craft-header__close
):hover {
    color: #f87171 !important;
    background: transparent !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] :is(
    .modal-window-actions > button,
    .modal-window-action,
    .tutorial-window-action,
    [data-modal-window-minimize],
    [data-modal-window-close],
    [data-tutorial-minimize],
    .button-menu-modal-header > button[data-modal-hide],
    .button-menu-modal-header > button[id^="close-"],
    .actor-modal__header > button[data-actor-modal-close="true"],
    .craft-header > .craft-header__close
):is(:focus, :focus-visible, :active) {
    background: transparent !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] [data-modal-window-no-backdrop="true"] {
    background: transparent !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

body.game-page[data-ui-theme] [data-modal-window-no-backdrop="true"] > .glow-ring,
body.game-page[data-ui-theme]:has([data-modal-window-no-backdrop="true"]:not(.hidden)) > [modal-backdrop] {
    display: none !important;
}

/* Final desktop chrome corrections, kept theme-aware. */
body.game-page[data-ui-theme] :is(#info-sector-container, #button-menu, #navbar-hamburger) .logout,
body.game-page[data-ui-theme] :is(#info-sector-container, #button-menu, #navbar-hamburger) .logout:is(:hover, :active, :focus, :focus-visible),
body.game-page[data-ui-theme] :is(#info-sector-container, #button-menu, #navbar-hamburger) .logout::before,
body.game-page[data-ui-theme] :is(#info-sector-container, #button-menu, #navbar-hamburger) .logout::after {
    border-color: transparent !important;
    background: transparent !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] #player-infos #statistics-fieldset {
    background: linear-gradient(180deg, var(--theme-surface-2), var(--theme-surface-1)) !important;
}

body.game-page[data-ui-theme] [data-modal-window-no-backdrop="true"] .button-menu-modal-frame [data-modal-window-header] .modal-window-actions > button,
body.game-page[data-ui-theme] .tutorial-window-action {
    appearance: none !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    color: #60a5fa !important;
    box-shadow: none !important;
    filter: none !important;
}

body.game-page[data-ui-theme] [data-modal-window-no-backdrop="true"] .button-menu-modal-frame [data-modal-window-header] .modal-window-actions > button:hover,
body.game-page[data-ui-theme] .tutorial-window-action:hover {
    border: 0 !important;
    background: transparent !important;
    color: #f87171 !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] [data-modal-window-no-backdrop="true"] .button-menu-modal-frame [data-modal-window-header] .modal-window-actions > button :is(i, .iconify),
body.game-page[data-ui-theme] .tutorial-window-action :is(i, .iconify) {
    background: transparent !important;
    color: inherit !important;
}

@media (min-width: 1024px) {
    body.game-page[data-ui-theme] #desktop-action-bar,
    body.game-page[data-ui-theme] #desktop-action-bar .desktop-action-item,
    body.game-page[data-ui-theme] #desktop-action-bar .desktop-action-item:is(:hover, :active, :focus, :focus-visible, .is-active, [aria-pressed="true"], [aria-selected="true"]) {
        border: 0 !important;
        background: transparent !important;
        box-shadow: none !important;
    }

    body.game-page[data-ui-theme] #desktop-action-bar .desktop-action-item + .desktop-action-item::before {
        display: none !important;
    }
}

/* Game-board windows never dim or blur the board behind them. */
body.game-page[data-ui-theme] :is(
    [data-modal-window-no-backdrop="true"],
    [id$="-modal"].fixed.inset-0,
    .sector-access-handshake.fixed.inset-0
) {
    background-color: transparent !important;
    background-image: none !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

body.game-page[data-ui-theme] :is(.modal-backdrop, [modal-backdrop]) {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Disabled controls keep their danger state; board-modal action cards own a compact locked state. */
body.game-page[data-ui-theme] :is(
    button:disabled,
    button[aria-disabled="true"],
    button.is-disabled,
    button.cursor-not-allowed,
    .action-button-sf[aria-disabled="true"],
    [role="button"][aria-disabled="true"]
):not(.modal-window-header-control):not(.actor-action-card):not(.ui-choice-modal-btn):not(.options-theme-card) {
    border-color: var(--sf-disabled-action-border) !important;
    background: var(--sf-disabled-action-background) !important;
    color: var(--sf-disabled-action-text) !important;
    text-shadow: none !important;
    box-shadow: var(--sf-disabled-action-shadow) !important;
    opacity: 1 !important;
    filter: none !important;
}

body.game-page[data-ui-theme] :is(
    button:disabled,
    button[aria-disabled="true"],
    button.is-disabled,
    button.cursor-not-allowed,
    .action-button-sf[aria-disabled="true"],
    [role="button"][aria-disabled="true"]
):not(.modal-window-header-control):not(.actor-action-card):not(.ui-choice-modal-btn):not(.options-theme-card) :is(i, span, strong, .iconify) {
    color: inherit !important;
}

body.game-page[data-ui-theme] .action-button-sf[aria-disabled="true"] img {
    filter: brightness(0) invert(1) !important;
}

/* Docking and undocking keep the original emerald command-channel identity. */
body.game-page[data-ui-theme] .sector-access-handshake {
    --theme-surface-0: #020b0d;
    --theme-surface-1: #051719;
    --theme-surface-2: #082824;
    --theme-surface-3: #0c3a31;
    --theme-panel-deep: #020b0d;
    --theme-panel: #051719;
    --theme-panel-raised: #082824;
    --theme-panel-soft: rgba(8, 40, 36, 0.76);
    --theme-text: #ecfdf5;
    --theme-text-soft: #d1fae5;
    --theme-muted: #85bda9;
    --theme-accent: #34d399;
    --theme-accent-strong: #a7f3d0;
    --theme-accent-soft: rgba(52, 211, 153, 0.17);
    --theme-selection: #34d399;
    --theme-selection-strong: #a7f3d0;
    --theme-selection-soft: rgba(52, 211, 153, 0.17);
    --theme-focus: rgba(110, 231, 183, 0.76);
    --theme-border: rgba(52, 211, 153, 0.24);
    --theme-border-strong: rgba(110, 231, 183, 0.5);
    --theme-control: linear-gradient(180deg, #082824, #051719);
    --theme-control-hover: linear-gradient(180deg, #0c3a31, #082824);
    --theme-control-active: linear-gradient(180deg, #051719, #082824);
    --theme-control-selected: linear-gradient(180deg, #0c3a31, #082824);
    --theme-glow: 0 0 24px rgba(52, 211, 153, 0.17);
    --sf-proto-void: #061017;
    --sf-proto-modal: #0c1a24;
    --sf-proto-modal-strong: #102330;
    --sf-proto-surface: #132a36;
    --sf-proto-surface-raised: #193845;
    --sf-proto-surface-soft: #10212b;
    --sf-proto-surface-deep: #081218;
    --sf-proto-text: #e7f4f7;
    --sf-proto-text-soft: #c2d8df;
    --sf-proto-text-muted: #91aeb9;
    --sf-proto-cyan: #6ad8ff;
    --sf-proto-teal: #53d7c2;
    --sf-proto-green: #5cd7a1;
    --sf-proto-line: rgba(114, 213, 242, 0.2);
    --sf-proto-line-strong: rgba(114, 213, 242, 0.44);
    --actor-accent: #4af0a7;
    --actor-accent-strong: #c9ffe3;
    --actor-line: rgba(74, 240, 167, 0.24);
    --actor-line-strong: rgba(74, 240, 167, 0.46);
    --actor-glow: rgba(74, 240, 167, 0.22);
    --actor-panel: rgba(7, 13, 23, 0.92);
    --actor-panel-strong: rgba(4, 8, 16, 0.96);
    --actor-text: #ecfdff;
    --actor-muted: rgba(177, 255, 219, 0.74);
}

/* Informative tooltips follow the active skin; danger/error tooltips remain untouched. */
body.game-page[data-ui-theme] :is(
    .skill-tooltip,
    .effect-description-tooltip,
    .mission-objective-tooltip,
    .module-tooltip > ul,
    #map-world-tooltip,
    #inventory-module-tooltip > ul,
    #inventory-ship-tooltip
):not(.disabled-action-tooltip):not([class*="error"]):not(.is-danger):not([data-variant="danger"]) {
    border-color: var(--theme-border-strong) !important;
    background:
        radial-gradient(circle at 92% 4%, var(--theme-accent-soft), transparent 38%),
        linear-gradient(155deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    color: var(--theme-text) !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.05),
        var(--theme-shadow),
        var(--theme-glow) !important;
}

body.game-page[data-ui-theme] .skill-tooltip__header {
    border-color: var(--theme-border) !important;
    background: linear-gradient(90deg, var(--theme-accent-soft), transparent 72%) !important;
}

body.game-page[data-ui-theme] .skill-tooltip__header::after {
    background: linear-gradient(90deg, transparent, var(--theme-accent-strong)) !important;
    box-shadow: 0 0 8px var(--theme-accent-soft) !important;
}

body.game-page[data-ui-theme] :is(
    .skill-tooltip .tt-title,
    .effect-description-tooltip__title,
    .mission-objective-tooltip__title
) {
    color: var(--theme-accent-strong) !important;
    text-shadow: 0 0 16px var(--theme-accent-soft) !important;
}

body.game-page[data-ui-theme] :is(
    .skill-tooltip .tt-meta,
    .mission-objective-tooltip__meta,
    .skill-details__roleplay,
    .skill-details__mastery-next,
    .skill-details__mastery-note,
    .skill-details__section-title,
    .skill-details__stat-label,
    .skill-details__stat-footer,
    .mission-objective-tooltip__item--empty
) {
    color: var(--theme-muted) !important;
}

body.game-page[data-ui-theme] :is(
    .skill-details,
    .effect-description-tooltip__body,
    .mission-objective-tooltip__body,
    .mission-objective-tooltip__item,
    .skill-details__stat-current
) {
    color: var(--theme-text-soft) !important;
}

body.game-page[data-ui-theme] :is(.skill-details__mastery, .skill-details__stat, .skill-details__context) {
    border-color: var(--theme-border) !important;
    background:
        linear-gradient(155deg, var(--theme-accent-soft), transparent 68%),
        var(--theme-panel-soft) !important;
}

body.game-page[data-ui-theme] .skill-details__mastery::before {
    background: linear-gradient(180deg, var(--theme-accent-strong), var(--theme-accent)) !important;
    box-shadow: 0 0 10px var(--theme-accent-soft) !important;
}

body.game-page[data-ui-theme] :is(
    .skill-details__mastery-label,
    .skill-details__stat-gain
) {
    border-color: var(--theme-border) !important;
    background: var(--theme-accent-soft) !important;
    color: var(--theme-accent-strong) !important;
}

body.game-page[data-ui-theme] :is(
    .skill-details__mastery-access,
    .skill-details__stat-next,
    .skill-details__context-row strong
) {
    color: var(--theme-accent-strong) !important;
}

body.game-page[data-ui-theme] :is(.skill-details__stat-arrow, .skill-details__context-row) {
    color: var(--theme-muted) !important;
}

body.game-page[data-ui-theme] .skill-details__section-title::after {
    background: linear-gradient(90deg, var(--theme-border-strong), transparent) !important;
}

body.game-page[data-ui-theme] .effect-description-tooltip::before {
    border-top-color: var(--theme-panel-deep) !important;
}

body.game-page[data-ui-theme] .effect-description-tooltip.is-below::before {
    border-top-color: transparent !important;
    border-bottom-color: var(--theme-panel-deep) !important;
}

/*
 * The game board must always remain visible around every window layer.
 * These selectors target modal/overlay containers only; the actual panels keep
 * their own opaque themed surfaces.
 */
body.game-page :is(
    [data-modal-window-no-backdrop="true"],
    [role="dialog"][aria-modal="true"].fixed.inset-0,
    .modal.fixed.inset-0,
    [id$="-modal"].fixed.inset-0,
    [id$="-overlay"].fixed.inset-0,
    [id$="-backdrop"].fixed.inset-0,
    .fixed.inset-0[class*="modal"],
    .ui-choice-modal-layer,
    .game-image-cropper,
    .sector-access-handshake,
    #modal-loader,
    #signup-invite-modal-overlay,
    #combat-scene-backdrop,
    #repair-enhancement-scene-backdrop,
    #death-respawn-overlay,
    [class*=" modal-overlay"],
    [class*=" modal-backdrop"]
) {
    background-color: transparent !important;
    background-image: none !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

/* Flowbite inserts these as separate empty nodes, so they can be removed visually. */
body.game-page :is(.modal-backdrop, [modal-backdrop]) {
    display: none !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* A modal surface may keep its own background, but never blur the board below it. */
body.game-page :is(
    .button-menu-modal-frame,
    .actor-modal-shell--framed,
    .foreground-modal-shell,
    .modal-window-panel,
    .ui-choice-modal-panel,
    .game-image-cropper__dialog
),
body.game-page :is(
    .button-menu-modal-frame,
    .actor-modal-shell--framed,
    .foreground-modal-shell,
    .modal-window-panel,
    .ui-choice-modal-panel,
    .game-image-cropper__dialog
) * {
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

/*
 * Submodal theme completion.
 *
 * Several nested windows predate the shared modal vocabulary and still use
 * component-specific emerald/cyan values. Their neutral surfaces and actions
 * now follow the selected skin; errors, danger states, progress, logs and
 * docking retain their semantic/original palettes.
 */
body.game-page[data-ui-theme] :is(
    .ui-choice-modal-panel,
    .game-image-cropper__dialog,
    .wreck-loot-panel
) {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at 12% 0%, var(--theme-accent-soft), transparent 38%),
        linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    background-color: var(--theme-panel-deep) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-shadow), var(--theme-glow) !important;
}

body.game-page[data-ui-theme]:not([data-ui-theme="command-interface"]) :is(
    .ui-choice-modal-panel.tutorial-modal-panel,
    .ui-choice-modal-panel--framed
) {
    border: 1px solid var(--theme-border-strong) !important;
    -webkit-border-image: none !important;
    border-image: none !important;
    border-radius: 1rem !important;
}

body.game-page[data-ui-theme="high-contrast"] :is(
    .ui-choice-modal-panel.tutorial-modal-panel,
    .ui-choice-modal-panel--framed
) {
    border-width: 2px !important;
}

body.game-page[data-ui-theme] .ui-choice-modal-panel.tutorial-modal-panel::before {
    border: 0 !important;
    background:
        linear-gradient(180deg, var(--theme-accent-soft), transparent 34%),
        radial-gradient(circle at top, var(--theme-selection-soft), transparent 44%) !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] .ui-choice-modal-orb {
    border-color: var(--theme-border-strong) !important;
    background: radial-gradient(circle, var(--theme-selection-soft), var(--theme-panel-soft)) !important;
    color: var(--theme-selection-strong) !important;
    box-shadow: 0 0 22px var(--theme-selection-soft) !important;
}

body.game-page[data-ui-theme] :is(.ui-choice-modal-text, .ui-choice-modal-text strong) {
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] .ui-choice-modal-btn:not(:disabled):not(.is-disabled):not([aria-disabled="true"]) {
    border-color: var(--theme-border) !important;
    background: var(--theme-control) !important;
    color: var(--theme-text-soft) !important;
}

body.game-page[data-ui-theme] .ui-choice-modal-btn:hover:not(:disabled):not(.is-disabled):not([aria-disabled="true"]) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-glow) !important;
}

body.game-page[data-ui-theme] .ui-choice-modal-btn--confirm:not(:disabled):not(.is-disabled):not([aria-disabled="true"]) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-selected) !important;
    color: var(--theme-selection-strong) !important;
}

body.game-page[data-ui-theme] .ui-choice-modal-btn:is(:disabled, .is-disabled, [aria-disabled="true"]) {
    border-color: rgba(202, 74, 85, 0.62) !important;
    background:
        radial-gradient(circle at 9% 20%, rgba(230, 107, 115, 0.11), transparent 34%),
        linear-gradient(180deg, rgba(67, 15, 23, 0.98), rgba(29, 5, 10, 0.99)) !important;
    color: #fff5f4 !important;
    box-shadow:
        inset 0 1px 0 rgba(255, 224, 224, 0.045),
        inset 0 0 0 1px rgba(202, 74, 85, 0.08),
        0 7px 18px rgba(0, 0, 0, 0.2) !important;
    opacity: 1 !important;
    filter: none !important;
    transform: none !important;
}

body.game-page[data-ui-theme] .ui-choice-modal-btn:is(:disabled, .is-disabled, [aria-disabled="true"]) .ui-choice-modal-btn__icon {
    opacity: 0.82;
    filter: grayscale(0.72) saturate(0.48) brightness(1.12) drop-shadow(0 0 5px rgba(230, 107, 115, 0.2)) !important;
}

body.game-page[data-ui-theme] .ui-choice-modal-btn:is(:disabled, .is-disabled, [aria-disabled="true"]) .ui-choice-modal-btn__lock {
    border-color: rgba(230, 107, 115, 0.72) !important;
    background: #241014 !important;
    color: #f08a91 !important;
    box-shadow: 0 0 9px rgba(230, 107, 115, 0.22) !important;
}

body.game-page[data-ui-theme] .game-image-cropper__stage {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at 20% 0%, var(--theme-accent-soft), transparent 36%),
        linear-gradient(180deg, var(--theme-panel), var(--theme-panel-deep)),
        linear-gradient(90deg, var(--theme-border) 1px, transparent 1px),
        linear-gradient(var(--theme-border) 1px, transparent 1px) !important;
    background-size: auto, auto, 28px 28px, 28px 28px !important;
}

body.game-page[data-ui-theme] :is(
    .game-image-cropper__title,
    .game-image-cropper__zoom
) {
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] .game-image-cropper__instruction {
    color: var(--theme-muted) !important;
}

body.game-page[data-ui-theme] .game-image-cropper__crop-box {
    border-color: var(--theme-accent) !important;
    box-shadow:
        inset 0 0 0 1px var(--theme-accent-soft),
        0 0 0 9999px rgba(3, 7, 18, 0.6),
        0 0 22px var(--theme-accent-soft) !important;
}

body.game-page[data-ui-theme] .game-image-cropper__button {
    border-color: var(--theme-border) !important;
    background: var(--theme-control) !important;
    color: var(--theme-text-soft) !important;
}

body.game-page[data-ui-theme] .game-image-cropper__button:hover:not(:disabled) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-glow) !important;
}

body.game-page[data-ui-theme] .game-image-cropper__button--primary {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-selected) !important;
    color: var(--theme-selection-strong) !important;
}

body.game-page[data-ui-theme] #wreck-loot-modal.wreck-loot-overlay {
    background: transparent !important;
    -webkit-backdrop-filter: none !important;
    backdrop-filter: none !important;
}

body.game-page[data-ui-theme] :is(
    .wreck-loot-title,
    .wreck-loot-count,
    .wreck-loot-item-name,
    .wreck-loot-section-header
) {
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] .wreck-loot-subtitle {
    color: var(--theme-muted) !important;
}

body.game-page[data-ui-theme] .wreck-loot-close {
    border: 0 !important;
    background: transparent !important;
    color: #60a5fa !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] .wreck-loot-close:hover {
    border: 0 !important;
    background: transparent !important;
    color: #f87171 !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] :is(
    .wreck-loot-tab,
    .wreck-loot-btn:not(:disabled):not(.is-disabled):not([aria-disabled="true"])
) {
    border-color: var(--theme-border) !important;
    background: var(--theme-control) !important;
    color: var(--theme-text-soft) !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] :is(
    .wreck-loot-tab:hover,
    .wreck-loot-btn:hover:not(:disabled):not(.is-disabled):not([aria-disabled="true"])
) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-glow) !important;
}

body.game-page[data-ui-theme] .wreck-loot-tab.is-active {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-selected) !important;
    color: var(--theme-selection-strong) !important;
    box-shadow: 0 0 16px var(--theme-selection-soft) !important;
}

body.game-page[data-ui-theme] :is(
    .wreck-loot-section,
    .wreck-loot-item,
    .wreck-loot-empty,
    .wreck-loot-item-visual,
    .wreck-loot-pill:not(.is-bad):not(.is-chance)
) {
    border-color: var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel)) !important;
    color: var(--theme-text-soft) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035) !important;
}

body.game-page[data-ui-theme] .wreck-loot-item:hover {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
}

body.game-page[data-ui-theme] .wreck-loot-content {
    border-top-color: var(--theme-border) !important;
}

body.game-page[data-ui-theme] .wreck-loot-message:not([data-tone="error"]) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-selection-soft) !important;
    color: var(--theme-selection-strong) !important;
    box-shadow: 0 0 18px var(--theme-selection-soft) !important;
}

body.game-page[data-ui-theme] .wreck-loot-message:not([data-tone="error"])::before {
    color: var(--theme-selection) !important;
}

body.game-page[data-ui-theme] .corporation-inline-root {
    --corp-accent: var(--theme-accent);
    --corp-accent-strong: var(--theme-accent-strong);
    --corp-accent-soft: var(--theme-accent-soft);
    --corp-gold: var(--theme-selection);
    --corp-line: var(--theme-border);
    --corp-line-strong: var(--theme-border-strong);
    --corp-panel: var(--theme-panel);
    --corp-panel-strong: var(--theme-panel-deep);
    --corp-text: var(--theme-text);
    --corp-muted: var(--theme-muted);
    --corp-shadow: var(--theme-shadow), var(--theme-glow);
}

body.game-page[data-ui-theme] .bank-inline-root:not(.docking-inline-root *) {
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] .bank-inline-root:not(.docking-inline-root *) :is(
    .bank-inline-stat-card,
    .bank-inline-section
) {
    border-color: var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel)) !important;
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] .bank-inline-root:not(.docking-inline-root *) :is(
    .bank-inline-label,
    .bank-inline-value
) {
    color: var(--theme-accent-strong) !important;
}

body.game-page[data-ui-theme] .bank-inline-root:not(.docking-inline-root *) :is(
    .bank-inline-hint,
    .bank-inline-note
) {
    color: var(--theme-muted) !important;
}

body.game-page[data-ui-theme] .bank-inline-root:not(.docking-inline-root *) .bank-inline-input {
    border-color: var(--theme-border) !important;
    background: var(--theme-panel-deep) !important;
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] .bank-inline-root:not(.docking-inline-root *) .bank-inline-input:focus {
    border-color: var(--theme-border-strong) !important;
    box-shadow: var(--theme-focus-ring) !important;
}

body.game-page[data-ui-theme] .bank-inline-root:not(.docking-inline-root *) .bank-inline-btn:not(:disabled):not(.is-disabled):not([aria-disabled="true"]) {
    border-color: var(--theme-border) !important;
    background: var(--theme-control) !important;
    color: var(--theme-text-soft) !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] .bank-inline-root:not(.docking-inline-root *) .bank-inline-btn:hover:not(:disabled):not(.is-disabled):not([aria-disabled="true"]) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-glow) !important;
}

body.game-page[data-ui-theme] .bank-inline-root:not(.docking-inline-root *) :is(
    .bank-inline-autocomplete,
    .bank-inline-autocomplete-item
) {
    border-color: var(--theme-border) !important;
    background: var(--theme-panel-deep) !important;
    color: var(--theme-text-soft) !important;
}

body.game-page[data-ui-theme] .bank-inline-root:not(.docking-inline-root *) .bank-inline-autocomplete-item:hover {
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] .bank-inline-root:not(.docking-inline-root *) .bank-inline-message:not(.is-error) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-selection-soft) !important;
    color: var(--theme-selection-strong) !important;
    box-shadow: 0 0 18px var(--theme-selection-soft) !important;
}

body.game-page[data-ui-theme] .bank-inline-root:not(.docking-inline-root *) .bank-inline-message:not(.is-error)::before {
    color: var(--theme-selection) !important;
}

body.game-page[data-ui-theme] #death-respawn-overlay > div {
    background:
        radial-gradient(circle at 50% 0%, var(--theme-danger-soft), transparent 42%),
        linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-shadow) !important;
}

body.game-page[data-ui-theme] #death-respawn-overlay > div > :is(.text-zinc-100, .text-zinc-400) {
    color: var(--theme-text-soft) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root {
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root :is(
    section,
    aside,
    article,
    [class*="rounded-[22px]"],
    [class*="rounded-[24px]"],
    [class*="rounded-[26px]"],
    [class*="rounded-[28px]"]
):not([class*="red-"]) {
    border-color: var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel)) !important;
    color: var(--theme-text-soft) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root :is([data-market-tab], [data-shop-tab]) {
    border-color: var(--theme-border) !important;
    background: var(--theme-control) !important;
    color: var(--theme-text-soft) !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root :is([data-market-tab], [data-shop-tab]):hover {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-glow) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root :is([data-market-tab], [data-shop-tab])[aria-pressed="true"] {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-selected) !important;
    color: var(--theme-selection-strong) !important;
    box-shadow: 0 0 18px var(--theme-selection-soft) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root [data-market-history-table] {
    overflow-x: auto;
    overflow-y: auto;
    max-height: min(28rem, 48vh);
    max-height: min(28rem, 48dvh);
    border: 1px solid var(--theme-border) !important;
    border-radius: 26px !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    background-clip: padding-box !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.045), var(--theme-glow) !important;
    scrollbar-color: var(--theme-scroll-thumb) var(--theme-scroll-track);
    isolation: isolate;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root .market-history-table {
    overflow: hidden;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 25px;
    color: var(--theme-text-soft) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root .market-history-head {
    border-color: var(--theme-border) !important;
    background: var(--theme-control-selected) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root .market-history-columns {
    color: var(--theme-selection-strong) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root .market-history-head th {
    border-bottom: 1px solid var(--theme-border);
    background: color-mix(in srgb, var(--theme-surface-3) 68%, var(--theme-selection) 32%);
}

body.game-page[data-ui-theme] .commerce-hub-inline-root .market-history-head th:first-child {
    border-top-left-radius: 24px;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root .market-history-head th:last-child {
    border-top-right-radius: 24px;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root .market-history-table tbody tr:not(:last-child) td {
    border-bottom: 1px solid color-mix(in srgb, var(--theme-border) 54%, transparent);
}

body.game-page[data-ui-theme] .commerce-hub-inline-root .market-history-table tbody tr:last-child td:first-child {
    border-bottom-left-radius: 24px;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root .market-history-table tbody tr:last-child td:last-child {
    border-bottom-right-radius: 24px;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root :is(.market-history-item, .market-history-price) {
    color: var(--theme-accent-strong) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root :is(.market-history-empty, .market-history-pagination) {
    border-color: var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel)) !important;
    color: var(--theme-text-soft) !important;
}

body.game-page[data-ui-theme] .shop-inline-root .shop-item-card__visual {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at center, var(--theme-accent-soft), transparent 68%),
        linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root :is(
    [class*="text-emerald-"],
    [class*="text-cyan-"],
    [class*="text-sky-"]
):not([class*="error"]):not([class*="faction"]) {
    color: var(--theme-accent-strong) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root [class*="text-amber-"] {
    color: var(--theme-selection-strong) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root :is(
    [class*="border-emerald-"],
    [class*="border-cyan-"],
    [class*="border-sky-"],
    [class*="border-amber-"]
):not([class*="error"]):not([class*="faction"]) {
    border-color: var(--theme-border) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root :is(
    [class*="bg-emerald-"],
    [class*="bg-cyan-"],
    [class*="bg-sky-"]
):not([class*="error"]):not([class*="faction"]) {
    background-color: var(--theme-accent-soft) !important;
}

body.game-page[data-ui-theme] .commerce-hub-inline-root [class*="bg-amber-"] {
    background-color: var(--theme-selection-soft) !important;
}

body.game-page[data-ui-theme] .commerce-hub-tooltip {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-panel-deep) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-shadow), var(--theme-glow) !important;
}

/* Scale limits and unavailable target cycles reuse the compact locked action-card state. */
body.game-page[data-ui-theme] :is(
    #game-ui-scale-controls .game-ui-scale-button:disabled,
    .combat-target-selector__cycle:is(:disabled, [aria-disabled="true"])
) {
    border-color: var(--sf-disabled-action-border) !important;
    background: var(--sf-disabled-action-background) !important;
    color: var(--sf-disabled-action-text) !important;
    text-shadow: none !important;
    box-shadow: var(--sf-disabled-action-shadow) !important;
    opacity: 1 !important;
    filter: none !important;
}

body.game-page[data-ui-theme] :is(
    #game-ui-scale-controls .game-ui-scale-button:disabled,
    .combat-target-selector__cycle:is(:disabled, [aria-disabled="true"])
) :is(i, span) {
    color: var(--sf-disabled-action-text) !important;
}

/* Hangar management follows the skin; only the docking handshake stays emerald. */
body.game-page[data-ui-theme] .docking-inline-root {
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] .docking-inline-root > div,
body.game-page[data-ui-theme] .docking-inline-root .docking-inline-loading {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at top, var(--theme-accent-soft), transparent 58%),
        linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] .docking-inline-root article {
    border: 1px solid var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel)) !important;
    color: var(--theme-text-soft) !important;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035) !important;
}

body.game-page[data-ui-theme] .docking-inline-root article:hover {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
}

body.game-page[data-ui-theme] .docking-inline-root :is(
    .docking-inline-loading-title,
    .docking-ship-trigger,
    .docking-ship-detail-list
) {
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] .docking-inline-root .docking-inline-loading-icon {
    filter: drop-shadow(0 0 10px var(--theme-accent-soft)) !important;
}

body.game-page[data-ui-theme] .docking-inline-root .docking-action-btn:not(:disabled):not(.is-disabled):not([aria-disabled="true"]) {
    border: 0 !important;
    background: transparent !important;
    color: var(--theme-accent) !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] .docking-inline-root .docking-action-btn[data-tone="gold"]:not(:disabled):not(.is-disabled):not([aria-disabled="true"]) {
    color: var(--theme-selection) !important;
}

body.game-page[data-ui-theme] .docking-inline-root .docking-action-btn:hover:not(:disabled):not(.is-disabled):not([aria-disabled="true"]) {
    border: 0 !important;
    background: transparent !important;
    color: var(--theme-accent-strong) !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme] .docking-inline-root .docking-action-btn[data-tone="gold"]:hover:not(:disabled):not(.is-disabled):not([aria-disabled="true"]) {
    color: var(--theme-selection-strong) !important;
}

body.game-page[data-ui-theme] .docking-inline-root :is(
    .docking-ship-detail-image,
    .docking-ship-expanded
) {
    border-color: var(--theme-border) !important;
    background: var(--theme-panel-deep) !important;
    color: var(--theme-text-soft) !important;
}

body.game-page[data-ui-theme] .docking-inline-root .docking-ship-detail-line strong {
    color: var(--theme-accent-strong) !important;
}

body.game-page[data-ui-theme] .docking-inline-root .bank-inline-message:not(.is-error) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-selection-soft) !important;
    color: var(--theme-selection-strong) !important;
    box-shadow: 0 0 18px var(--theme-selection-soft) !important;
}

/* Keep the embedded combat scene and its intrinsic grid horizontally centered. */
body.game-page[data-ui-theme] .actor-modal-shell:has(.combat-scene) [id$="-combat-container"] {
    display: flex !important;
    align-items: stretch !important;
    justify-content: center !important;
    width: 100% !important;
    max-width: 100% !important;
}

body.game-page[data-ui-theme] .actor-modal-shell:has(.combat-scene) .combat-scene {
    width: 100% !important;
    max-width: 100% !important;
    margin-inline: auto !important;
}

body.game-page[data-ui-theme] .combat-scene .scene-layout {
    align-self: center !important;
    margin-inline: auto !important;
}

/*
 * Filled modal states must use the same palette as their frame.
 *
 * Group cards and a few inventory ornaments predate theme variables. Craft has
 * its own component vocabulary, so its variables are bridged instead of
 * flattening its industrial layout into the generic modal rules.
 */
body.game-page[data-ui-theme] #group-modal .group-member-card {
    border-color: var(--theme-border) !important;
    background:
        linear-gradient(
            145deg,
            var(--theme-panel-raised),
            color-mix(in srgb, var(--theme-panel) 84%, var(--theme-accent) 16%)
        ) !important;
    color: var(--theme-text) !important;
    box-shadow: inset 0 0 0 1px var(--theme-accent-soft) !important;
}

body.game-page[data-ui-theme] #group-modal :is(
    .group-member-title,
    .group-member-name,
    .group-member-location-value,
    .group-stat-value,
    .group-autocomplete-row
) {
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] #group-modal :is(
    .group-member-index,
    .group-member-location-key,
    .group-stat-label
) {
    color: var(--theme-accent-strong) !important;
}

body.game-page[data-ui-theme] #group-modal :is(
    .group-member-sector,
    .group-member-coordinates,
    .group-stat-item
) {
    border-color: var(--theme-border) !important;
    background: var(--theme-panel-deep) !important;
    color: var(--theme-text-soft) !important;
    box-shadow: inset 0 0 0 1px var(--theme-accent-soft) !important;
}

body.game-page[data-ui-theme] #group-modal .group-member-badge {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-selection-soft) !important;
    color: var(--theme-selection-strong) !important;
}

body.game-page[data-ui-theme] #group-modal .group-autocomplete-row:hover {
    background: var(--theme-control-hover) !important;
}

body.game-page[data-ui-theme] #inventory-modal .equipped-modules-panel {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at 15% 10%, var(--theme-accent-soft), transparent 45%),
        linear-gradient(180deg, var(--theme-panel), var(--theme-panel-deep)) !important;
}

body.game-page[data-ui-theme] #inventory-modal .equipped-module-group::before {
    background:
        linear-gradient(90deg, var(--theme-accent-soft), transparent 28%),
        linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent 26%) !important;
}

body.game-page[data-ui-theme] #inventory-modal :is(
    .equipped-module-legend__label,
    .inventory-section-title,
    .inventory-item-title-qty,
    .inventory-item-side__qty
) {
    color: var(--theme-accent-strong) !important;
}

body.game-page[data-ui-theme] #inventory-modal :is(
    .equipped-module-count,
    .inventory-section,
    .inventory-action-btn:not(.success):not(.danger):not(:disabled):not(.is-disabled)
) {
    border-color: var(--theme-border) !important;
    background: var(--theme-panel-deep) !important;
    color: var(--theme-text-soft) !important;
    box-shadow: inset 0 0 0 1px var(--theme-accent-soft) !important;
}

body.game-page[data-ui-theme] #inventory-modal :is(
    .module-item::before,
    .inventory-module-row::before
) {
    background: linear-gradient(
        180deg,
        var(--theme-accent-soft),
        var(--theme-accent-strong),
        var(--theme-accent-soft)
    ) !important;
    box-shadow: 0 0 10px var(--theme-accent-soft) !important;
}

body.game-page[data-ui-theme] #inventory-modal .inventory-action-btn:not(.success):not(.danger):hover:not(:disabled):not(.is-disabled) {
    border-color: var(--theme-border-strong) !important;
    background: var(--theme-control-hover) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-glow) !important;
}

body.game-page[data-ui-theme] #craft-modal {
    --craft-bg: var(--theme-surface-0);
    --craft-panel: var(--theme-surface-1);
    --craft-panel-strong: var(--theme-surface-2);
    --craft-line: var(--theme-border);
    --craft-line-strong: var(--theme-border-strong);
    --craft-accent: var(--theme-accent);
    --craft-accent-soft: var(--theme-accent-strong);
    --craft-text: var(--theme-text);
    --craft-muted: var(--theme-muted-readable);
    --craft-warning: var(--theme-warning);
    --craft-danger: var(--theme-danger);
    --craft-shadow: var(--theme-shadow), var(--theme-glow);
    --sf-modal-frame-inner-bg: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep));
    --sf-modal-frame-underlay: linear-gradient(180deg, var(--theme-panel-deep), var(--theme-surface-0));
}

body.game-page[data-ui-theme] #craft-modal .craft-shell {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at 12% 0%, var(--theme-accent-soft), transparent 38%) padding-box,
        linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep)) padding-box,
        linear-gradient(180deg, var(--theme-panel-deep), var(--theme-surface-0)) border-box !important;
    background-color: var(--theme-panel-deep) !important;
    color: var(--theme-text) !important;
    box-shadow: var(--theme-shadow), var(--theme-glow) !important;
}

body.game-page[data-ui-theme] #craft-modal .craft-header {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at 9% 20%, var(--theme-accent-soft), transparent 42%),
        linear-gradient(100deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] #craft-modal .craft-footer {
    border-color: var(--theme-border) !important;
    background: linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel-deep)) !important;
    color: var(--theme-text) !important;
}

body.game-page[data-ui-theme] #craft-modal .craft-header__plain-icon {
    color: var(--theme-accent-strong) !important;
    filter: drop-shadow(0 0 10px var(--theme-accent-soft)) !important;
}

body.game-page[data-ui-theme] #craft-modal .craft-browser__ship-subgroup {
    border-color: var(--theme-border) !important;
    background:
        linear-gradient(180deg, var(--theme-accent-soft), transparent),
        linear-gradient(180deg, var(--theme-panel-raised), var(--theme-panel)) !important;
    box-shadow: inset 0 0 0 1px var(--theme-accent-soft), var(--theme-glow) !important;
}

body.game-page[data-ui-theme] #craft-modal .craft-browser-card__illustration-frame {
    border-color: var(--theme-border) !important;
    background:
        radial-gradient(circle at 50% 12%, var(--theme-accent-soft), transparent 58%),
        linear-gradient(180deg, var(--theme-panel), var(--theme-panel-deep)) !important;
}

body.game-page[data-ui-theme] #craft-modal .craft-browser-card__illustration {
    filter:
        drop-shadow(0 10px 18px rgba(0, 0, 0, 0.34))
        drop-shadow(0 0 22px var(--theme-accent-soft)) !important;
}

body.game-page[data-ui-theme] #craft-modal,
body.game-page[data-ui-theme] #craft-modal * {
    scrollbar-color: var(--theme-scroll-thumb) var(--theme-scroll-track);
}

body.game-page[data-ui-theme] #craft-modal *::-webkit-scrollbar-track {
    background: var(--theme-scroll-track);
}

body.game-page[data-ui-theme] #craft-modal *::-webkit-scrollbar-thumb {
    border-color: var(--theme-scroll-track);
    background: var(--theme-scroll-thumb);
}

body.game-page[data-ui-theme] #craft-modal *::-webkit-scrollbar-thumb:hover {
    background: var(--theme-scroll-thumb-hover);
}

/* Reuse the matching metallic frame where one exists; accessibility stays plain. */
body.game-page[data-ui-theme="deep-space"] :is(
    .button-menu-modal-frame,
    .actor-modal-shell--sector-element
) {
    -webkit-border-image: url('/static/img/ux/modal-cadres/metallic_blue_borders_1024_cropped_lossless.webp') 92 120 92 120 / 1 / 0 stretch !important;
    border-image: url('/static/img/ux/modal-cadres/metallic_blue_borders_1024_cropped_lossless.webp') 92 120 92 120 / 1 / 0 stretch !important;
}

body.game-page[data-ui-theme="martian-forge"] :is(
    .button-menu-modal-frame,
    .actor-modal-shell--sector-element
) {
    -webkit-border-image: url('/static/img/ux/modal-cadres/metallic_red_borders_1024_cropped_lossless.webp') 92 120 92 120 / 1 / 0 stretch !important;
    border-image: url('/static/img/ux/modal-cadres/metallic_red_borders_1024_cropped_lossless.webp') 92 120 92 120 / 1 / 0 stretch !important;
}

body.game-page[data-ui-theme="void-protocol"] :is(
    .button-menu-modal-frame,
    .actor-modal-shell--sector-element
) {
    -webkit-border-image: url('/static/img/ux/modal-cadres/metallic_blue_borders_1024_cropped_lossless.webp') 92 120 92 120 / 1 / 0 stretch !important;
    border-image: url('/static/img/ux/modal-cadres/metallic_blue_borders_1024_cropped_lossless.webp') 92 120 92 120 / 1 / 0 stretch !important;
}

body.game-page[data-ui-theme="high-contrast"] :is(
    .button-menu-modal-frame,
    .actor-modal-shell--sector-element
) {
    border: 2px solid var(--theme-border-strong) !important;
    -webkit-border-image: none !important;
    border-image: none !important;
    border-radius: 1rem !important;
    box-shadow: none !important;
}

body.game-page[data-ui-theme="high-contrast"] :is(#craft-modal, #craft-modal *) {
    text-shadow: none !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
}
