/* Mashinani League unified light/dark theme compatibility layer v43.4.2 */
:root {
  --mlos-mode-primary: #0fa84f;
  --mlos-mode-accent: #e2b21a;
  --mlos-mode-success: #22b45a;
  --mlos-mode-danger: #dc3c42;
  --mlos-mode-radius: 14px;
}

html[data-theme="light"],
html[data-appearance="light"] {
  color-scheme: light;
  --mlos-mode-bg: #f5f7f5;
  --mlos-mode-bg-soft: #edf2ee;
  --mlos-mode-panel: #ffffff;
  --mlos-mode-panel-soft: #f8faf8;
  --mlos-mode-text: #111914;
  --mlos-mode-muted: #5f6f65;
  --mlos-mode-border: #d8e2db;
  --mlos-mode-input: #ffffff;
  --mlos-mode-shadow: 0 18px 48px rgba(7, 33, 19, .08);

  --mlos-bg: var(--mlos-mode-bg);
  --mlos-card: var(--mlos-mode-panel);
  --mlos-ink: var(--mlos-mode-text);
  --mlos-muted: var(--mlos-mode-muted);
  --mlos-line: var(--mlos-mode-border);
  --mlv39-bg: var(--mlos-mode-bg);
  --mlv39-surface: var(--mlos-mode-bg);
  --mlv39-card: var(--mlos-mode-panel);
  --mlv39-text: var(--mlos-mode-text);
  --mlv32-bg: var(--mlos-mode-bg);
  --mlv32-bg-soft: var(--mlos-mode-bg-soft);
  --mlv32-panel: var(--mlos-mode-panel);
  --mlv32-text: var(--mlos-mode-text);
}

html[data-theme="dark"],
html[data-appearance="dark"] {
  color-scheme: dark;
  --mlos-mode-bg: #070d0b;
  --mlos-mode-bg-soft: #0b1511;
  --mlos-mode-panel: #101c17;
  --mlos-mode-panel-soft: #13231c;
  --mlos-mode-text: #f6faf7;
  --mlos-mode-muted: #a7b7ad;
  --mlos-mode-border: #2a3d33;
  --mlos-mode-input: #0b1712;
  --mlos-mode-shadow: 0 20px 58px rgba(0, 0, 0, .28);

  --mlos-bg: var(--mlos-mode-bg);
  --mlos-card: var(--mlos-mode-panel);
  --mlos-ink: var(--mlos-mode-text);
  --mlos-muted: var(--mlos-mode-muted);
  --mlos-line: var(--mlos-mode-border);
  --mlv39-bg: var(--mlos-mode-bg);
  --mlv39-surface: var(--mlos-mode-bg);
  --mlv39-card: var(--mlos-mode-panel);
  --mlv39-text: var(--mlos-mode-text);
  --mlv32-bg: var(--mlos-mode-bg);
  --mlv32-bg-soft: var(--mlos-mode-bg-soft);
  --mlv32-panel: var(--mlos-mode-panel);
  --mlv32-text: var(--mlos-mode-text);
}

body.mlos-theme-surface {
  background: var(--mlos-mode-bg) !important;
  color: var(--mlos-mode-text);
  transition: background-color .18s ease, color .18s ease;
}

body.mlos-theme-surface :where(.site, .site-content, .site-main, .content-area, .page-content, .entry-content) {
  color: inherit;
}

body.mlos-theme-surface :where(.site-header, #masthead, .main-navigation, .mobile-navigation, .mobile-nav) {
  border-color: var(--mlos-mode-border);
  background-color: color-mix(in srgb, var(--mlos-mode-panel) 94%, transparent);
  color: var(--mlos-mode-text);
}

body.mlos-theme-surface :where(.site-header, #masthead, .main-navigation, .mobile-navigation, .mobile-nav) a {
  color: inherit;
}

body.mlos-theme-surface :where(.site-footer, #colophon) {
  border-color: var(--mlos-mode-border);
  background: color-mix(in srgb, var(--mlos-mode-bg) 88%, #000);
  color: var(--mlos-mode-text);
}

body.mlos-theme-surface :where(.site-footer, #colophon) a {
  color: inherit;
}

body.mlos-theme-surface :where(
  .mlos-card,
  .mlos-form-card,
  .mlos-account-card,
  .mlos-page-head,
  .mlos-table-wrap,
  .mlos-ux-card,
  .mlos-ux-table,
  .mlos-notification-item,
  .mlos-dashboard-summary a,
  .mlos-image-control,
  .mlos-partner-edit,
  .mlos-control-row,
  .mlv39-card,
  .mlv39-panel,
  .mlv39-table-panel,
  .mlv39-leader-panel,
  .mlv39-award-card,
  .mlv32-card,
  .mlv32-panel
) {
  border-color: var(--mlos-mode-border) !important;
  background-color: var(--mlos-mode-panel) !important;
  color: var(--mlos-mode-text) !important;
  box-shadow: var(--mlos-mode-shadow);
}

body.mlos-theme-surface :where(
  .mlos-card,
  .mlos-form-card,
  .mlos-account-card,
  .mlos-page-head,
  .mlos-table-wrap,
  .mlos-ux-card,
  .mlos-notification-item,
  .mlos-dashboard-summary a,
  .mlv39-card,
  .mlv39-panel,
  .mlv32-card,
  .mlv32-panel
) :where(h1, h2, h3, h4, h5, h6, strong) {
  color: var(--mlos-mode-text);
}

body.mlos-theme-surface :where(.mlos-muted, .mlos-help, .mlos-kicker + p, .entry-meta, .posted-on, .mlv39-muted, .mlv32-muted) {
  color: var(--mlos-mode-muted) !important;
}

body.mlos-theme-surface :where(.entry-content, .page-content, .mlos-form, .mlos-form-card) :where(
  input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]),
  select,
  textarea
) {
  border-color: var(--mlos-mode-border) !important;
  background: var(--mlos-mode-input) !important;
  color: var(--mlos-mode-text) !important;
  box-shadow: none;
}

body.mlos-theme-surface :where(.entry-content, .page-content, .mlos-form, .mlos-form-card) :where(input, textarea)::placeholder {
  color: color-mix(in srgb, var(--mlos-mode-muted) 78%, transparent);
  opacity: 1;
}

body.mlos-theme-surface :where(.entry-content, .page-content, .mlos-form, .mlos-form-card) :where(input, select, textarea):focus {
  border-color: var(--mlos-mode-primary) !important;
  outline: 0;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--mlos-mode-primary) 22%, transparent) !important;
}

body.mlos-theme-surface :where(table, .mlos-ux-table) {
  border-color: var(--mlos-mode-border);
  background: var(--mlos-mode-panel);
  color: var(--mlos-mode-text);
}

body.mlos-theme-surface :where(table th, table td, .mlos-ux-table th, .mlos-ux-table td) {
  border-color: var(--mlos-mode-border) !important;
}

body.mlos-theme-surface :where(table thead th, .mlos-ux-table th) {
  background: color-mix(in srgb, var(--mlos-mode-panel) 80%, var(--mlos-mode-primary));
  color: var(--mlos-mode-text);
}

body.mlos-theme-surface :where(a) {
  text-underline-offset: .18em;
}

body.mlos-theme-surface :where(.mlos-btn.primary, .mlos-auth-submit, .mlos-new-chat-button, .mlos-chat-send) {
  background: var(--mlos-mode-primary) !important;
  color: #fff !important;
}

body.mlos-theme-surface :where(.mlos-alert, .mlos-ux-notice, .mlos-onboarding-callout, .mlos-import-safety-banner) {
  border-color: var(--mlos-mode-border);
  background: var(--mlos-mode-panel-soft);
  color: var(--mlos-mode-text);
}

body.mlos-theme-surface :where(.mlos-auth-panel) {
  background: var(--mlos-mode-bg) !important;
}

html[data-theme="dark"] body.mlos-theme-surface :where(.mlos-auth-card:not(.is-staff-card), .mlos-auth-card.is-staff-card),
html[data-appearance="dark"] body.mlos-theme-surface :where(.mlos-auth-card:not(.is-staff-card), .mlos-auth-card.is-staff-card) {
  border-color: var(--mlos-mode-border);
  background: var(--mlos-mode-panel);
  color: var(--mlos-mode-text);
}

html[data-theme="light"] body.mlos-theme-surface :where(.mlos-chat-sidebar, .mlos-chat-main, .mlos-chat-header, .mlos-chat-composer),
html[data-appearance="light"] body.mlos-theme-surface :where(.mlos-chat-sidebar, .mlos-chat-main, .mlos-chat-header, .mlos-chat-composer) {
  border-color: var(--mlos-mode-border);
  background-color: var(--mlos-mode-panel-soft);
  color: var(--mlos-mode-text);
}

[data-theme-toggle],
[data-appearance-toggle],
[data-theme-set],
[data-appearance-set] {
  color-scheme: inherit;
}

[data-theme-set].is-active,
[data-appearance-set].is-active {
  outline: 2px solid var(--mlos-mode-primary);
  outline-offset: 2px;
}

.mlos-maintenance-banner {
  position: sticky;
  top: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 48px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid color-mix(in srgb, var(--mlos-mode-accent) 55%, var(--mlos-mode-border));
  background: color-mix(in srgb, var(--mlos-mode-panel) 92%, var(--mlos-mode-accent));
  color: var(--mlos-mode-text);
  box-shadow: 0 8px 28px rgba(0,0,0,.12);
  text-align: center;
  font-size: .88rem;
  line-height: 1.4;
}

.mlos-maintenance-banner strong {
  color: var(--mlos-mode-text);
}

.mlos-maintenance-banner a {
  color: var(--mlos-mode-primary);
  font-weight: 900;
}

body.admin-bar .mlos-maintenance-banner {
  top: 32px;
}

@media (max-width: 782px) {
  body.admin-bar .mlos-maintenance-banner { top: 46px; }
  .mlos-maintenance-banner { align-items: flex-start; flex-direction: column; gap: 2px; text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  body.mlos-theme-surface { transition: none; }
}

/* v43.4.2 full frontend contrast repair ---------------------------------- */

/* The obsolete launch/update block is removed in PHP; this is a cache-safe fallback. */
body.home .mlpl-launch-block,
body.front-page .mlpl-launch-block {
  display: none !important;
}

/* WordPress/theme page surfaces must actually follow the selected mode. */
html[data-theme="dark"] body.mlos-theme-surface,
html[data-appearance="dark"] body.mlos-theme-surface,
html[data-theme="dark"] body.mlos-theme-surface :where(#page, .site, .site-content, .site-main, .content-area, .page-content, .entry-content),
html[data-appearance="dark"] body.mlos-theme-surface :where(#page, .site, .site-content, .site-main, .content-area, .page-content, .entry-content) {
  background-color: var(--mlos-mode-bg) !important;
  color: var(--mlos-mode-text) !important;
}

html[data-theme="light"] body.mlos-theme-surface,
html[data-appearance="light"] body.mlos-theme-surface,
html[data-theme="light"] body.mlos-theme-surface :where(#page, .site, .site-content, .site-main, .content-area, .page-content, .entry-content),
html[data-appearance="light"] body.mlos-theme-surface :where(#page, .site, .site-content, .site-main, .content-area, .page-content, .entry-content) {
  background-color: var(--mlos-mode-bg) !important;
  color: var(--mlos-mode-text) !important;
}

html[data-theme="dark"] body.mlos-theme-surface :where(.entry-title, .page-title, .mlos-page-head h1, .mlos-page-head h2, .site-main > h1, .site-main > h2),
html[data-appearance="dark"] body.mlos-theme-surface :where(.entry-title, .page-title, .mlos-page-head h1, .mlos-page-head h2, .site-main > h1, .site-main > h2) {
  color: var(--mlos-mode-text) !important;
}

html[data-theme="dark"] body.mlos-theme-surface :where(.mlos-page-head p, .entry-summary, .site-main > p),
html[data-appearance="dark"] body.mlos-theme-surface :where(.mlos-page-head p, .entry-summary, .site-main > p) {
  color: var(--mlos-mode-muted) !important;
}

/* Dark branded hero panels must never inherit black heading/text colours. */
body.mlos-theme-surface :where(.mlos-v32-hero, .mlos-v32-match-hero, .mlos-v294-hero, .mlos-v294-widget) {
  background: linear-gradient(135deg, #052824, #061d1b) !important;
  border-color: rgba(255,255,255,.12) !important;
  color: #ffffff !important;
}

body.mlos-theme-surface :where(.mlos-v32-hero, .mlos-v32-match-hero, .mlos-v294-hero, .mlos-v294-widget)
  :where(h1, h2, h3, h4, h5, h6, strong, b) {
  color: #ffffff !important;
  text-shadow: none !important;
}

body.mlos-theme-surface :where(.mlos-v32-hero, .mlos-v32-match-hero, .mlos-v294-hero, .mlos-v294-widget)
  :where(p, small, em, .mlos-v32-match-context > span, .mlos-v32-match-info > span) {
  color: #d6e5dd !important;
}

body.mlos-theme-surface :where(.mlos-v32-match-context strong, .mlos-v32-main-score em, .mlos-v294-hero > span, .mlos-v294-widget > span) {
  color: #9dff38 !important;
}

body.mlos-theme-surface .mlos-v32-main-score,
body.mlos-theme-surface .mlos-v32-main-score span {
  color: #ffffff !important;
}

body.mlos-theme-surface .mlos-v32-match-info .verified {
  background: #168a4d !important;
  color: #ffffff !important;
}

/* Match Centre: complete light mode palette. */
html[data-theme="light"] body.mlos-theme-surface :where(
  .mlos-v32-panel,
  .mlos-v32-completeness,
  .mlos-v32-summary article,
  .mlos-v32-competition-card,
  .mlos-v32-match-card,
  .mlos-v32-leader-card,
  .mlos-v32-history-grid article,
  .mlos-v32-download-grid article,
  .mlos-v32-login,
  .mlos-v32-checks article,
  .mlos-v32-player-results > a,
  .mlos-v32-bracket-match
),
html[data-appearance="light"] body.mlos-theme-surface :where(
  .mlos-v32-panel,
  .mlos-v32-completeness,
  .mlos-v32-summary article,
  .mlos-v32-competition-card,
  .mlos-v32-match-card,
  .mlos-v32-leader-card,
  .mlos-v32-history-grid article,
  .mlos-v32-download-grid article,
  .mlos-v32-login,
  .mlos-v32-checks article,
  .mlos-v32-player-results > a,
  .mlos-v32-bracket-match
) {
  background: #ffffff !important;
  border-color: #d8e2db !important;
  color: #111914 !important;
}

html[data-theme="light"] body.mlos-theme-surface :where(.mlos-v32-lineups > section, .mlos-v32-timeline li, .mlos-v32-inline-form, .mlos-v32-scout-reports article),
html[data-appearance="light"] body.mlos-theme-surface :where(.mlos-v32-lineups > section, .mlos-v32-timeline li, .mlos-v32-inline-form, .mlos-v32-scout-reports article) {
  background: #f7faf8 !important;
  color: #111914 !important;
}

/* Match Centre: complete dark mode palette. */
html[data-theme="dark"] body.mlos-theme-surface :where(
  .mlos-v32-panel,
  .mlos-v32-completeness,
  .mlos-v32-summary article,
  .mlos-v32-competition-card,
  .mlos-v32-match-card,
  .mlos-v32-leader-card,
  .mlos-v32-history-grid article,
  .mlos-v32-download-grid article,
  .mlos-v32-login,
  .mlos-v32-checks article,
  .mlos-v32-player-results > a,
  .mlos-v32-bracket-match
),
html[data-appearance="dark"] body.mlos-theme-surface :where(
  .mlos-v32-panel,
  .mlos-v32-completeness,
  .mlos-v32-summary article,
  .mlos-v32-competition-card,
  .mlos-v32-match-card,
  .mlos-v32-leader-card,
  .mlos-v32-history-grid article,
  .mlos-v32-download-grid article,
  .mlos-v32-login,
  .mlos-v32-checks article,
  .mlos-v32-player-results > a,
  .mlos-v32-bracket-match
) {
  background: var(--mlos-mode-panel) !important;
  border-color: var(--mlos-mode-border) !important;
  color: var(--mlos-mode-text) !important;
  box-shadow: 0 14px 38px rgba(0,0,0,.20) !important;
}

html[data-theme="dark"] body.mlos-theme-surface :where(.mlos-v32-lineups > section, .mlos-v32-timeline li, .mlos-v32-inline-form, .mlos-v32-scout-reports article),
html[data-appearance="dark"] body.mlos-theme-surface :where(.mlos-v32-lineups > section, .mlos-v32-timeline li, .mlos-v32-inline-form, .mlos-v32-scout-reports article) {
  background: var(--mlos-mode-panel-soft) !important;
  border-color: var(--mlos-mode-border) !important;
  color: var(--mlos-mode-text) !important;
}

html[data-theme="dark"] body.mlos-theme-surface :where(.mlos-v32-match-centre, .mlos-v32-panel, .mlos-v32-completeness, .mlos-v32-lineups, .mlos-v32-timeline, .mlos-v32-facts)
  :where(h1, h2, h3, h4, strong, b, dd),
html[data-appearance="dark"] body.mlos-theme-surface :where(.mlos-v32-match-centre, .mlos-v32-panel, .mlos-v32-completeness, .mlos-v32-lineups, .mlos-v32-timeline, .mlos-v32-facts)
  :where(h1, h2, h3, h4, strong, b, dd) {
  color: var(--mlos-mode-text) !important;
}

html[data-theme="dark"] body.mlos-theme-surface :where(.mlos-v32-panel, .mlos-v32-completeness, .mlos-v32-lineups, .mlos-v32-timeline, .mlos-v32-facts)
  :where(p, span, small, dt),
html[data-appearance="dark"] body.mlos-theme-surface :where(.mlos-v32-panel, .mlos-v32-completeness, .mlos-v32-lineups, .mlos-v32-timeline, .mlos-v32-facts)
  :where(p, span, small, dt) {
  color: var(--mlos-mode-muted) !important;
}

html[data-theme="dark"] body.mlos-theme-surface :where(.mlos-v32-facts > div, .mlos-v32-squad-list li, .mlos-v32-table th, .mlos-v32-table td, .mlos-v32-match-card footer),
html[data-appearance="dark"] body.mlos-theme-surface :where(.mlos-v32-facts > div, .mlos-v32-squad-list li, .mlos-v32-table th, .mlos-v32-table td, .mlos-v32-match-card footer) {
  border-color: var(--mlos-mode-border) !important;
}

html[data-theme="dark"] body.mlos-theme-surface :where(.mlos-v32-form input, .mlos-v32-form select, .mlos-v32-form textarea, .mlos-v32-inline-form input, .mlos-v32-inline-form select, .mlos-v32-toolbar input, .mlos-v32-filter input, .mlos-v32-filter select),
html[data-appearance="dark"] body.mlos-theme-surface :where(.mlos-v32-form input, .mlos-v32-form select, .mlos-v32-form textarea, .mlos-v32-inline-form input, .mlos-v32-inline-form select, .mlos-v32-toolbar input, .mlos-v32-filter input, .mlos-v32-filter select) {
  background: var(--mlos-mode-input) !important;
  border-color: var(--mlos-mode-border) !important;
  color: var(--mlos-mode-text) !important;
}

/* Voting: protect the dark hero and make all poll content follow the mode. */
body.mlos-theme-surface .mlos-v294-hero h1,
body.mlos-theme-surface .mlos-v294-hero p,
body.mlos-theme-surface .mlos-v294-hero > span {
  opacity: 1 !important;
  visibility: visible !important;
}

html[data-theme="dark"] body.mlos-theme-surface .mlos-v294-wrap,
html[data-appearance="dark"] body.mlos-theme-surface .mlos-v294-wrap {
  --v294-deep: #f6faf7;
  --v294-dark: #0b2118;
  --v294-green: #79e69c;
  --v294-lime: #9dff38;
  --v294-line: #2a3d33;
  --v294-muted: #a7b7ad;
  color: var(--mlos-mode-text) !important;
}

html[data-theme="light"] body.mlos-theme-surface .mlos-v294-wrap,
html[data-appearance="light"] body.mlos-theme-surface .mlos-v294-wrap {
  --v294-deep: #051f20;
  --v294-dark: #0b2b26;
  --v294-green: #0d533b;
  --v294-lime: #78ed2c;
  --v294-line: #d8e4de;
  --v294-muted: #60766c;
  color: #111914 !important;
}

html[data-theme="dark"] body.mlos-theme-surface :where(
  .mlos-v294-card,
  .mlos-v294-poll-head,
  .mlos-v294-poll-meta,
  .mlos-v294-nominee-card,
  .mlos-v294-results,
  .mlos-v294-result-row,
  .mlos-v294-empty,
  .mlos-v294-active-strip,
  .mlos-v294-countdown,
  .mlos-v294-voted-banner,
  .mlos-v294-citation
),
html[data-appearance="dark"] body.mlos-theme-surface :where(
  .mlos-v294-card,
  .mlos-v294-poll-head,
  .mlos-v294-poll-meta,
  .mlos-v294-nominee-card,
  .mlos-v294-results,
  .mlos-v294-result-row,
  .mlos-v294-empty,
  .mlos-v294-active-strip,
  .mlos-v294-countdown,
  .mlos-v294-voted-banner,
  .mlos-v294-citation
) {
  background: var(--mlos-mode-panel) !important;
  border-color: var(--mlos-mode-border) !important;
  color: var(--mlos-mode-text) !important;
}

html[data-theme="dark"] body.mlos-theme-surface :where(.mlos-v294-card, .mlos-v294-poll-head, .mlos-v294-poll-meta, .mlos-v294-nominee-card, .mlos-v294-results, .mlos-v294-result-row, .mlos-v294-empty)
  :where(h2, h3, strong, b),
html[data-appearance="dark"] body.mlos-theme-surface :where(.mlos-v294-card, .mlos-v294-poll-head, .mlos-v294-poll-meta, .mlos-v294-nominee-card, .mlos-v294-results, .mlos-v294-result-row, .mlos-v294-empty)
  :where(h2, h3, strong, b) {
  color: var(--mlos-mode-text) !important;
}

html[data-theme="dark"] body.mlos-theme-surface :where(.mlos-v294-card, .mlos-v294-poll-head, .mlos-v294-poll-meta, .mlos-v294-nominee-card, .mlos-v294-results, .mlos-v294-result-row, .mlos-v294-empty)
  :where(p, small, span),
html[data-appearance="dark"] body.mlos-theme-surface :where(.mlos-v294-card, .mlos-v294-poll-head, .mlos-v294-poll-meta, .mlos-v294-nominee-card, .mlos-v294-results, .mlos-v294-result-row, .mlos-v294-empty)
  :where(p, small, span) {
  color: var(--mlos-mode-muted) !important;
}

html[data-theme="dark"] body.mlos-theme-surface :where(.mlos-v294-poll-meta span, .mlos-v294-chips span, .mlos-poll-status),
html[data-appearance="dark"] body.mlos-theme-surface :where(.mlos-v294-poll-meta span, .mlos-v294-chips span, .mlos-poll-status) {
  background: var(--mlos-mode-panel-soft) !important;
  color: #9eeab5 !important;
}

html[data-theme="dark"] body.mlos-theme-surface :where(.mlos-v294-share-row a, .mlos-v294-share-row button),
html[data-appearance="dark"] body.mlos-theme-surface :where(.mlos-v294-share-row a, .mlos-v294-share-row button) {
  background: var(--mlos-mode-panel-soft) !important;
  border-color: var(--mlos-mode-border) !important;
  color: var(--mlos-mode-text) !important;
}

/* Hero actions remain deliberately high-contrast in both modes. */
body.mlos-theme-surface .mlos-v294-hero-actions a {
  background: #ffffff !important;
  border-color: rgba(255,255,255,.35) !important;
  color: #052824 !important;
}

body.mlos-theme-surface .mlos-v294-hero-actions a:first-child {
  background: #9dff38 !important;
  border-color: #9dff38 !important;
  color: #052824 !important;
}
