/* V0.24: use the user's actual forced-color palette, only while it is active.
   No fixed light/dark palette, bitmap inversion, or persistent theme preference. */
@media screen and (forced-colors: active) {
  :root {
    forced-color-adjust: auto;
    color-scheme: light dark;
    --ink: CanvasText; --muted: CanvasText; --line: CanvasText;
    --paper: Canvas; --dark: Canvas; --forest: CanvasText;
    --gold: CanvasText; --gold-light: Canvas; --red: CanvasText; --green: CanvasText;
    --platform-ink: CanvasText; --platform-paper: Canvas;
    --energy-mn: CanvasText; --energy-sk: CanvasText;
    --energy-uk: CanvasText; --energy-gu: CanvasText;
    --page-bg: none; --panel-bg: none;
  }

  :root, :root body {
    background: Canvas !important;
    color: CanvasText !important;
    background-image: none !important;
  }

  /* URL textures survive native forced-colors. Remove them, including in new
     dynamically rendered cards, notes, dialogs and account/store panels.
     Opaque system surfaces also prevent text behind a popup showing through. */
  :root body * {
    color: inherit !important;
    background-color: Canvas !important;
    background-image: none !important;
    border-color: currentColor !important;
    box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
    backdrop-filter: none !important;
    mix-blend-mode: normal !important;
    background-blend-mode: normal !important;
  }
  :root body *::before, :root body *::after {
    color: inherit !important;
    background-color: transparent !important;
    background-image: none !important;
    border-color: currentColor !important;
    box-shadow: none !important;
    text-shadow: none !important;
    filter: none !important;
    mix-blend-mode: normal !important;
  }

  :root body a { color: LinkText !important; text-decoration: underline !important; }
  :root body a:visited { color: VisitedText !important; }
  :root body :is(button, .btn, .button, .platform-button, .social-button, [role="button"], [role="tab"], summary) {
    background-color: ButtonFace !important;
    color: ButtonText !important;
    border: 1px solid ButtonText !important;
    opacity: 1 !important;
  }
  /* A selected control's labels and SVGs must share its foreground/background
     pair; text spans must not paint Canvas rectangles over Highlight. */
  :root body :is(button, a, .btn, .button, .platform-button, [role="button"], [role="tab"], summary, mark) *,
  :root body :is(button, a, .btn, .button, .platform-button, [role="button"], [role="tab"], summary, mark) *::before,
  :root body :is(button, a, .btn, .button, .platform-button, [role="button"], [role="tab"], summary, mark) *::after {
    color: inherit !important;
    background-color: transparent !important;
    opacity: 1 !important;
  }
  :root body :is(input, textarea, select, option, optgroup) {
    background-color: Field !important;
    color: FieldText !important;
    border: 1px solid FieldText !important;
    caret-color: FieldText !important;
    opacity: 1 !important;
  }
  :root body input:is([type="checkbox"], [type="radio"], [type="range"]) {
    appearance: auto !important;
    accent-color: Highlight;
  }
  :root body ::placeholder { color: GrayText !important; opacity: 1 !important; }
  :root body input::file-selector-button {
    background: ButtonFace !important;
    color: ButtonText !important;
    border: 1px solid ButtonText !important;
  }

  :root body :is(button, .btn, .button, .platform-button, [role="button"], summary):hover:not(:disabled):not([aria-disabled="true"]),
  :root body button:is(.selected, .active, .filled, [aria-pressed="true"], [aria-selected="true"], [aria-current]:not([aria-current="false"])),
  :root body :is(a, [role="tab"]):is([aria-current]:not([aria-current="false"]), [aria-selected="true"]),
  :root body .btn.selected, :root body .choice.selected,
  :root body option:checked, :root body mark {
    background-color: Highlight !important;
    color: HighlightText !important;
    border-color: Highlight !important;
  }
  :root body :is(button, a, [role="tab"]):is(.selected, .active, [aria-pressed="true"], [aria-selected="true"], [aria-current]:not([aria-current="false"])) {
    text-decoration: underline !important;
    text-underline-offset: .2em;
    border-style: double !important;
    border-width: 3px !important;
  }
  :root body :is(.resource-card.selected, .socket-option.selected) {
    border: 3px double Highlight !important;
  }
  :root body .pip:not(.filled) { border-style: dashed !important; }
  :root body .pip.filled { border-style: solid !important; }
  :root body .effect-blocked { border-style: dashed !important; }
  :root body .progress-track { border: 1px solid CanvasText !important; }
  :root body .progress-fill { background-color: Highlight !important; }

  :root body :is(:disabled, [aria-disabled="true"], .is-unavailable, .nav-unavailable) {
    color: GrayText !important;
    border-color: GrayText !important;
    opacity: 1 !important;
  }
  :root body :is(button:disabled, input:disabled, select:disabled, textarea:disabled, [role="button"][aria-disabled="true"]) {
    background-color: ButtonFace !important;
  }
  :root body :is(.is-in-progress, .content-locked, .race-unowned, .availability-label, .note, .muted, .pip) { opacity: 1 !important; }
  :root body :is(button, a, input, select, textarea, summary, [tabindex]):focus-visible {
    outline: 3px solid Highlight !important;
    outline-offset: 3px !important;
  }
  :root body :is(dialog, #toast, .stat-popup, .effect-popup, [role="tooltip"], .platform-notice) {
    background-color: Canvas !important;
    color: CanvasText !important;
    border: 2px solid CanvasText !important;
  }
  :root body dialog::backdrop { background: Canvas !important; opacity: .85; backdrop-filter: none !important; }
  :root body ::selection { background: Highlight !important; color: HighlightText !important; }
  :root body svg { forced-color-adjust: auto; }

  /* Nonessential artwork is removed instead of recoloring pixels arbitrarily.
     Meaningful maps, portraits and other images retain their content. */
  :root body :is(.hero-art, .ink-compass, .motes, .magic-specks, .website-mascot,
    .footer-emblem, .fay-icon, img.sketch[alt=""], .archetype-medallion[aria-hidden="true"]) { display: none !important; }
  :root body .hero::before, :root body .hero-art::after { display: none !important; }
  :root body :is(.forest-art, .forest-topic) { mask-image: none !important; -webkit-mask-image: none !important; }
  :root body img { opacity: 1 !important; }
  :root body img:not([alt=""]):not(.brand-logo) { border: 1px solid CanvasText !important; }
  :root body :is(a.brand, .footer-brand, .workshop-platform-brand, .atelier-brand) > img { display: none !important; }
  :root body :is(a.brand, .footer-brand, .workshop-platform-brand, .atelier-brand)::after {
    content: "Mystica Originals";
    display: block;
    font: 700 18px/1.3 system-ui, sans-serif;
    letter-spacing: normal;
    color: inherit !important;
  }
  :root body .hero { min-height: 0 !important; height: auto !important; max-height: none !important; padding-bottom: 100px !important; }
  :root body .hero h1 { max-width: 100% !important; }
  :root body .hero-copy { padding-bottom: 36px !important; }
  :root body .page-hero { min-height: 0 !important; }
}
