/* Mobile colors only. Specific overrides keep existing desktop layout and palette intact.
   Loaded through the common head so standalone legal/auth and game dialogs agree. */
@media (max-width: 800px) {
  :root { color-scheme: light; }
  body, body.native-auth { background-color: #f4f1ea !important; }
}
@media (max-width: 800px) and (prefers-color-scheme: dark) {
  :root { color-scheme: dark; --paper: #111820; --mobile-surface: #1d2733; --mobile-raised: #283443; --mobile-text: #eef3fa; --mobile-muted: #bcc9d8; --mobile-line: #607086; }
  body, body.native-auth { background: #111820 !important; color: var(--mobile-text) !important; }
  body aside, body .auth-main, body .registration-main { background-color: #111820 !important; }
  body :is(h1,h2,h3,h4,label,legend), body :is(.brand,.native-switch,.auth-help,.game-clock strong,.game-clock small) { color: var(--mobile-text) !important; }
  body a { color: #9cc9ff; }
  body .auth-alternative, body.native-auth .auth-alternative { color: #9cc9ff !important; text-decoration: underline; text-underline-offset: 3px; }
  body :is(.site-header,.native-auth-header,.game-header) { background: #111820b3 !important; border-color: var(--mobile-line) !important; }
  body .game-header { background: #1118206b !important; }
  body :is(.card,.account-section,.auth-card,.registration-card,.rules-menu-card,.rules-toc,.rules-document,.support-card,.support-panel,.registration-note,.map-credits,.auth-info-menu) {
    background-color: var(--mobile-surface) !important; color: var(--mobile-text) !important; border-color: var(--mobile-line) !important; box-shadow: none !important;
  }
  body :is(#cards-panel,#settings-panel) { background: transparent !important; }
  body :is(.account-details span,.auth-hint,.account-delete-hint,.auth-small,.fine,.rules-version,.rules-menu-card small,.auth-card p,.registration-card p,.registration-intro p,.form-hint,.hand-card small,.location,.feed,.rules-document p,.rules-document li) { color: var(--mobile-muted) !important; }
  body :is(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),select,textarea) { background: #111820 !important; color: var(--mobile-text) !important; border-color: #8496ad !important; }
  body input::placeholder, body textarea::placeholder { color: #a9b8ca !important; opacity: 1; }
  body input:-webkit-autofill { -webkit-text-fill-color: #eef3fa; box-shadow: 0 0 0 1000px #111820 inset; }
  body button { background-color: var(--mobile-raised); color: var(--mobile-text); border-color: var(--mobile-line); }
  body :is(.auth-submit,.registration-submit,.native-switch,.auth-menu-register,.auth-menu-trigger,.schedule-button,#map-expand,.reading-close,.modal-close,#legend-toggle,#native-legal-back) { background: var(--mobile-raised) !important; color: var(--mobile-text) !important; border-color: var(--mobile-line) !important; }
  body .account-section .account-delete-button, body #demo-reset-confirm { background: #9f2825 !important; color: #fff !important; border-color: #ffaaa5 !important; }
  body #game-account .demo-signout { background: var(--mobile-raised) !important; color: var(--mobile-text) !important; -webkit-text-fill-color: var(--mobile-text) !important; border-color: #8496ad !important; }
  body #game-account .demo-signout:hover, body #game-account .demo-signout:active { background: #35455a !important; }
  body :is(dialog,.modal-card,.reading-modal-heading,#native-legal-modal .reading-modal-heading,.card-info-card,.rules-summary,.rules-document th,.rules-document td,.rulebook-tools,#rulebook-contents,.how-to-play-content section) {
    background-color: var(--mobile-surface) !important; color: var(--mobile-text) !important; border-color: var(--mobile-line) !important;
  }
  body dialog::backdrop { background: #000a; }
  body #card-info-summary { color: #bcc9d8 !important; }
  /* Detail dialogs share the dark surfaces without changing player/map colors. */
  body :is(.card-info-card,#territory-modal) { box-shadow: 0 14px 40px #0008 !important; }
  body .card-info-step { background: var(--mobile-raised) !important; border-color: var(--mobile-line) !important; }
  body .card-info-step b { color: #ffb7b7 !important; }
  body .card-info-step p { color: var(--mobile-text) !important; }
  body .card-info-heading > i:not(.war):not(.blockade) { color: #111827 !important; }
  body #territory-modal :is(.territory-popup,.territory-details,.fortification-status,.territory-history) { background: var(--mobile-surface) !important; color: var(--mobile-text) !important; }
  body #territory-modal :is(.territory-popup-header,.territory-facts > div,.territory-scoring) { border-color: var(--mobile-line) !important; }
  body #territory-modal :is(.territory-popup-header p,.territory-facts span,.fortification-status > div:first-child > span) { color: var(--mobile-muted) !important; }
  body #territory-modal .territory-history-toggle { background: var(--mobile-raised) !important; color: var(--mobile-text) !important; }
  body #territory-modal .territory-history-toggle:hover { background: #35455a !important; }
  body #territory-modal .territory-ledger p { color: var(--mobile-text) !important; }
  body #territory-modal .territory-ledger time { color: var(--mobile-muted) !important; }
  body #territory-modal .territory-ledger li { border-color: var(--mobile-line) !important; }
  body #territory-modal .reading-close { box-shadow: none !important; }
  body #territory-modal .fort-step { background: var(--mobile-raised) !important; color: var(--mobile-muted) !important; border-color: var(--mobile-line) !important; }
  body #territory-modal .fort-step.complete { background: #183e33 !important; color: #c0f5dc !important; border-color: #74c9a7 !important; }
  body #territory-modal .territory-alert { border-color: var(--mobile-line) !important; }
  body #territory-modal .fortified-alert { background: #283443; color: #eef3fa; }
  body #territory-modal .war-alert { background: #43272e; color: #ffd6d6; }
  body #territory-modal .freeze-alert { background: #173a44; color: #c5efff; }
  body #territory-modal .blockade-alert { background: #203659; color: #d5e6ff; }
  body #territory-modal .trade-alert { background: #203c32; color: #c0f5dc; }

  body :is(.bonus-leader,.score small,.bonus > span) { color: var(--mobile-muted) !important; }
  body .bonus-leader strong, body .bonus-race-points { color: #86efac !important; }
  body .bonus-race-modal small { color: var(--mobile-muted) !important; }
  body :is(.bonus,.score) { border-color: var(--mobile-line) !important; }

  body .registration-countdown, body .rules-check { background: #283443 !important; color: #eef3fa !important; border-color: #607086 !important; }
  body .registration-countdown strong, body .rules-check :is(span,u) { color: #eef3fa !important; }
  body :is(.auth-error,.registration-errors,#account-message.account-error) { background: #4b2027 !important; color: #ffd6d6 !important; border-color: #ee9caa !important; }
  body :is(.auth-success,.registration-success,#account-message:not(.account-error)) { background: #183e33 !important; color: #c0f5dc !important; border-color: #74c9a7 !important; }
  body .hand-card { background: #213043 !important; color: var(--mobile-text) !important; border-color: #879ab2 !important; box-shadow: none; }
  body .hand-card.war, body .rules-document .card-rule.war-rule { background: #43272e !important; }
  body .hand-card.freeze, body .rules-document .card-rule.freeze-rule { background: #173a44 !important; }
  body .hand-card.trade, body .rules-document .card-rule.trade-rule { background: #203c32 !important; }
  body .hand-card.double, body .rules-document .card-rule.double-rule { background: #44391e !important; }
  body .hand-card.mulligan, body .rules-document .card-rule.mulligan-rule { background: #3c294c !important; }
  body .hand-card.joker, body .rules-document .card-rule.joker-rule { background: var(--mobile-surface) !important; }
  body .hand-card.blockade, body .rules-document .card-rule.blockade-rule { background: #203659 !important; }
  body .hand-card:not(.war):not(.blockade) .hand-card-top > i { color: #111827 !important; }
  body .hand-card :is(button,.card-info-button) { background: #34465b !important; color: var(--mobile-text) !important; border-color: #a2b4ca !important; }
  body :is(.pending-action,.trade-proposal,.trade-pending,.empty-hand,.reclaim-notice,.territory-facts,.territory-popup-header,.leaflet-popup-content-wrapper,.leaflet-popup-tip) { background: var(--mobile-surface) !important; color: var(--mobile-text) !important; }
	body .trade-proposal { background: #203c32 !important; }
	body .trade-proposal > span, body .trade-pending > span { color: var(--mobile-muted) !important; }
	body .trade-pending .cancel-trade-button { background: #34465b !important; color: var(--mobile-text) !important; border-color: #a2b4ca !important; }
	body .pending-action.freeze { background: #173a44 !important; }
	body .pending-action.blockade { background: #203659 !important; }
	body .pending-action > i { background: #34465bb8 !important; }
	body .pending-action button { background: #34465b !important; }
  body :is(.map-legend,.native-map-attribution,.leaflet-control-attribution) { background: #1d2733ed !important; color: var(--mobile-text) !important; border-color: #8d9cb0 !important; }
  body .map-legend a, body .leaflet-control-attribution a { color: #9cc9ff !important; }
  body #legend-more .legend-symbols :is(svg,i) { color: #eef3fa !important; }
  body #legend-more .legend-symbols svg { fill: currentColor !important; }
  /* Keep the map tile/territory palette intact; dark mode applies to its controls. */
  body :is(.claims-status,.mobile-schedule) { background: #283443 !important; color: #eef3fa !important; border-color: #607086 !important; }
  body .claims-status :is(b,span) { color: #bcc9d8 !important; }
  body #demo-banner { background: #3c331e !important; color: #fff0c2 !important; border-color: #a98e47 !important; }
  body #demo-banner :is(button,select) { background: #242f3b !important; color: var(--mobile-text) !important; }
  body .mobile-tabs { background: #1118206b !important; border-color: #607086 !important; }
  body .mobile-tabs button:not([aria-pressed="true"]) { background: #111820b3 !important; color: #eef3fa !important; }
  body .mobile-tabs button[aria-pressed="true"] { background: #fbbf24 !important; color: #111827 !important; border-color: #fff0c2 !important; }
  body .auth-info-menu .auth-info-link { background: transparent !important; color: #eef3fa !important; border-color: #607086 !important; }
  body .auth-info-menu .auth-info-link:hover { background: #344354 !important; }
  body :is(.auth-info-chevron,.rules-menu-card > i) { color: #bcc9d8 !important; }
  body :is(.legal-footer,.native-auth-footer,.rules-lede,.rules-summary span,.formula span,.rules-document .card-rule,.card-rule h3 span,.step,.power,.bonus-card,.faq-item,.season-banner,.daily-note,.registration-info,.registration-note) { background: var(--mobile-surface) !important; color: var(--mobile-text) !important; border-color: var(--mobile-line) !important; }
  body :is(.hero,.rules-section,.score-section,.fortify-section,.powers-section,.bonus-section,.faq-section,.join-section) { background-color: #111820 !important; color: var(--mobile-text) !important; }
  body :is(.hero-sub,.step p,.power p,.score-copy p,.score-copy li,.fortify-copy p,.section-heading p,.legal-notice,.rules-lede,.legal-footer a,.native-auth-footer a) { color: var(--mobile-muted) !important; }
  body .rules-document .rules-closing, body .rules-document .rules-closing :is(b,u) { color: #000 !important; }
  body .fortify-copy h2 span, body .game-clock > span { color: #ffb7b7 !important; }
  body .hand-card .card-info-button:focus-visible { outline-color: #9cc9ff !important; }
  body :focus-visible { outline-color: #9cc9ff !important; }
  body :is(#toast,#pull-refresh) { background: #283443 !important; color: #eef3fa !important; border-color: #a2b4ca !important; }
}
@media (max-width: 800px) and (prefers-reduced-transparency: reduce) {
  body .game-header, body .mobile-tabs { background: #f4f1ea !important; backdrop-filter: none; -webkit-backdrop-filter: none; }
  body .game-header::before { backdrop-filter: none; -webkit-backdrop-filter: none; }
}
@media (max-width: 800px) and (prefers-color-scheme: dark) and (prefers-reduced-transparency: reduce) {
  body .game-header, body .mobile-tabs { background: #111820 !important; }
}

@media (max-width: 800px) and (prefers-color-scheme: dark) {
	body .reclaim-notice { background: #43272e !important; color: #ffe4e6 !important; border-color: #ee9caa !important; box-shadow: none; }
	body .reclaim-notice p { color: #ffe4e6 !important; }
	body .reclaim-notice > div span { background: #612e3a !important; color: #fff1f2 !important; border-color: #ee9caa !important; }
	body .mobile-war-banner { background: #43272e !important; color: #ffe4e6 !important; border-color: #ee9caa !important; }
}
