/* PUBGNOTE light/dark themes — semantic contrast layer.
   The map imagery and map tools intentionally keep their dark visual contract. */
:root,
html[data-theme="light"] {
  color-scheme: light;
  --theme-canvas: #f5f6f2;
  --theme-surface: #ffffff;
  --theme-surface-soft: #eceee8;
  --theme-surface-raised: #ffffff;
  --theme-border: #c8cdc3;
  --theme-border-strong: #a7afa4;
  --theme-text: #171a16;
  --theme-text-secondary: #343b34;
  --theme-text-muted: #596258;
  --theme-placeholder: #687267;
  --theme-active-bg: #1c211c;
  --theme-active-text: #ffffff;
  --brand-lime-text: #10140e;
  --theme-accent: #dffb4f;
  --theme-accent-hover: #cee93f;
  --theme-accent-text: var(--brand-lime-text);
  --theme-accent-foreground: #596258;
  --theme-focus: #5d7400;
  --theme-success: #176c42;
  --theme-warning: #965100;
  --theme-danger: #b42332;
  --theme-danger-soft: #fff0f1;
  --theme-overlay: rgba(16, 20, 16, .62);
  --theme-row-alt: #f7f8f5;
  --theme-row-hover: #f1f8ca;
  --theme-shadow-sm: 0 1px 2px rgba(20, 25, 20, .08);
  --theme-shadow-lg: 0 16px 44px rgba(20, 25, 20, .18);
  --map-panel: #1c211b;
  --map-panel-soft: #272d25;
  --map-text: #f6f8f3;
  --map-muted: #b9c1b6;

  /* Compatibility variables consumed by the existing design layer. */
  --pn-lime: var(--theme-accent);
  --pn-lime-hover: var(--theme-accent-hover);
  --pn-lime-pressed: #c1dc34;
  --pn-lime-100: #f2f9c5;
  --pn-lime-50: #f8fbdc;
  --pn-ink: var(--theme-text);
  --pn-ink-700: var(--theme-text-secondary);
  --pn-ink-600: var(--theme-text-secondary);
  --pn-canvas: var(--theme-canvas);
  --pn-surface: var(--theme-surface);
  --pn-grey-500: var(--theme-text-muted);
  --pn-grey-400: var(--theme-placeholder);
  --pn-grey-300: var(--theme-border-strong);
  --pn-grey-200: var(--theme-border);
  --pn-grey-100: var(--theme-surface-soft);
  --pn-success: var(--theme-success);
  --pn-error: var(--theme-danger);
  --pn-warning: var(--theme-warning);
  --bg: var(--theme-canvas);
  --panel: var(--theme-surface);
  --panel-2: var(--theme-surface-soft);
  --line: var(--theme-border);
  --text: var(--theme-text);
  --muted: var(--theme-text-muted);
  --accent: var(--theme-accent);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --theme-canvas: #0b0f0c;
  --theme-surface: #141a15;
  --theme-surface-soft: #1d251f;
  --theme-surface-raised: #222b24;
  --theme-border: #3c493f;
  --theme-border-strong: #566559;
  --theme-text: #f3f6f1;
  --theme-text-secondary: #d2dad1;
  --theme-text-muted: #a9b4a9;
  --theme-placeholder: #909b91;
  --theme-active-bg: #dffb4f;
  --theme-active-text: #10140e;
  --brand-lime-text: #10140e;
  --theme-accent: #dffb4f;
  --theme-accent-hover: #edff81;
  --theme-accent-text: var(--brand-lime-text);
  --theme-accent-foreground: var(--theme-accent);
  --theme-focus: #dffb4f;
  --theme-success: #62d29a;
  --theme-warning: #ffc16a;
  --theme-danger: #ff7b89;
  --theme-danger-soft: #35171c;
  --theme-overlay: rgba(2, 5, 3, .8);
  --theme-row-alt: #111712;
  --theme-row-hover: #263018;
  --theme-shadow-sm: 0 1px 2px rgba(0, 0, 0, .34);
  --theme-shadow-lg: 0 18px 48px rgba(0, 0, 0, .52);
  --map-panel: #181d18;
  --map-panel-soft: #252c24;
  --map-text: #f6f8f3;
  --map-muted: #bdc6bb;

  --pn-lime: var(--theme-accent);
  --pn-lime-hover: var(--theme-accent-hover);
  --pn-lime-pressed: #c7e23b;
  --pn-lime-100: #2a321a;
  --pn-lime-50: #202719;
  --pn-ink: var(--theme-text);
  --pn-ink-700: var(--theme-text-secondary);
  --pn-ink-600: var(--theme-text-secondary);
  --pn-canvas: var(--theme-canvas);
  --pn-surface: var(--theme-surface);
  --pn-grey-500: var(--theme-text-muted);
  --pn-grey-400: var(--theme-placeholder);
  --pn-grey-300: var(--theme-border-strong);
  --pn-grey-200: var(--theme-border);
  --pn-grey-100: var(--theme-surface-soft);
  --pn-success: var(--theme-success);
  --pn-error: var(--theme-danger);
  --pn-warning: var(--theme-warning);
  --bg: var(--theme-canvas);
  --panel: var(--theme-surface);
  --panel-2: var(--theme-surface-soft);
  --line: var(--theme-border);
  --text: var(--theme-text);
  --muted: var(--theme-text-muted);
  --accent: var(--theme-accent);
}

html,
body {
  background: var(--theme-canvas);
  color: var(--theme-text);
}

html.theme-ready body,
html.theme-ready .topbar,
html.theme-ready .sidebar,
html.theme-ready :where(.records-stage, .leaderboard-stage, .community-stage, .buildings-stage) {
  transition: background-color 160ms ease, color 160ms ease, border-color 160ms ease;
}

::selection { background: var(--theme-accent); color: var(--theme-accent-text); }
:where(button, a, input, select, textarea):focus-visible {
  outline: 3px solid var(--theme-focus) !important;
  outline-offset: 2px;
  box-shadow: none !important;
}

/* Accessible theme controls */
.theme-toggle {
  position: relative;
  isolation: isolate;
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: 126px;
  min-width: 126px;
  min-height: 44px;
  padding: 3px;
  align-items: center;
  border: 1px solid var(--theme-border-strong);
  border-radius: 999px;
  overflow: hidden;
  background: var(--theme-surface-soft);
  color: var(--theme-text-muted);
  box-shadow: var(--theme-shadow-sm);
  cursor: pointer;
  font: 800 10px "Noto Sans KR", sans-serif;
  white-space: nowrap;
}
.theme-toggle::before {
  content: '';
  position: absolute;
  z-index: -1;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  border-radius: 999px;
  background: var(--theme-active-bg);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--theme-active-bg) 28%, transparent);
  transform: translateX(0);
  transition: transform 180ms ease, background-color 160ms ease;
}
html[data-theme="dark"] .theme-toggle::before { transform: translateX(100%); }
.theme-toggle:hover { border-color: var(--theme-text); }
.theme-toggle-option {
  position: relative;
  z-index: 1;
  display: inline-flex;
  min-width: 0;
  align-items: center;
  justify-content: center;
  gap: 3px;
  line-height: 1;
  transition: color 160ms ease;
}
.theme-toggle-option > span { font-size: 10px; }
.theme-toggle-option[data-theme-option="light"] > span:first-child,
.theme-toggle-option[data-theme-option="dark"] > span:last-child { font-size: 13px; }
html[data-theme="light"] .theme-toggle-option[data-theme-option="light"],
html[data-theme="dark"] .theme-toggle-option[data-theme-option="dark"] { color: var(--theme-active-text); }
html[data-theme="light"] .theme-toggle-option[data-theme-option="dark"],
html[data-theme="dark"] .theme-toggle-option[data-theme-option="light"] { color: var(--theme-text-muted); }

/* App chrome and navigation */
.topbar {
  border-color: var(--theme-border) !important;
  background: color-mix(in srgb, var(--theme-canvas) 94%, transparent) !important;
  color: var(--theme-text);
}
.brand { border-color: var(--theme-border) !important; color: var(--theme-text) !important; }
.brand-mark { color: var(--theme-accent-text) !important; }
.brand-title { color: var(--theme-text) !important; }
.brand small,
.service-menu-item i,
.service-menu-item small,
.service-menu-toggle small { color: var(--theme-text-muted) !important; }
.service-menu { background: var(--theme-canvas) !important; border-color: var(--theme-border) !important; }
.service-menu-item { color: var(--theme-text-secondary) !important; }
.service-menu-item:hover:not(:disabled) {
  border-color: var(--theme-border-strong) !important;
  background: var(--theme-surface-soft) !important;
  color: var(--theme-text) !important;
}
.service-menu-item.active {
  border-color: var(--theme-active-bg) !important;
  background: var(--theme-active-bg) !important;
  color: var(--theme-active-text) !important;
}
.service-menu-item.active small,
.service-menu-item.active i { color: color-mix(in srgb, var(--theme-active-text) 76%, transparent) !important; }
.service-icon,
.service-menu-toggle,
.icon-button,
.auth-trigger {
  border-color: var(--theme-border-strong) !important;
  background: var(--theme-surface) !important;
  color: var(--theme-text) !important;
}
.service-menu-item.active .service-icon {
  border-color: var(--theme-accent) !important;
  background: var(--theme-accent) !important;
  color: var(--theme-accent-text) !important;
}
.auth-trigger-icon { background-color: var(--theme-surface-soft) !important; }
.service-menu-toggle-icon i { background: var(--theme-text) !important; }

/* Sidebar and general controls */
.sidebar {
  border-color: var(--theme-border) !important;
  background: var(--theme-canvas) !important;
  color: var(--theme-text);
}
.sidebar h2,
.section-title,
.section-title button,
.feature-copy strong { color: var(--theme-text) !important; }
.eyebrow,
.section-title small,
.feature-copy span,
.site-disclaimer,
.feedback-mode-toggle small,
.feedback-mode-toggle i,
.pc-optimized-notice,
.terrain-contributor-copy em,
.operator-contact-copy span { color: var(--theme-text-muted) !important; }
.map-selector,
.panel-section,
.feature-card { border-color: var(--theme-border) !important; }
.map-tab,
.layer-toggle,
.feedback-mode-toggle,
.search-box,
.terrain-contributor-banner,
.operator-contact,
.sidebar-collapse,
.sidebar-expand {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface) !important;
  color: var(--theme-text-secondary) !important;
}
.map-tab:hover,
.layer-toggle:hover,
.feedback-mode-toggle:hover { background: var(--theme-surface-soft) !important; color: var(--theme-text) !important; }
.layer-toggle[aria-pressed="false"] {
  border-color: color-mix(in srgb, var(--theme-border) 82%, transparent) !important;
  background: color-mix(in srgb, var(--theme-surface) 82%, var(--theme-canvas)) !important;
  color: var(--theme-text-muted) !important;
}
.layer-toggle[aria-pressed="true"] {
  border-color: color-mix(in srgb, var(--category) 78%, var(--theme-border)) !important;
  background: color-mix(in srgb, var(--category) 18%, var(--theme-surface)) !important;
  color: var(--theme-text) !important;
  box-shadow: inset 3px 0 0 var(--category), 0 0 0 1px color-mix(in srgb, var(--category) 25%, transparent), 0 5px 13px rgba(0,0,0,.18) !important;
}
.layer-toggle[aria-pressed="true"]:hover {
  background: color-mix(in srgb, var(--category) 24%, var(--theme-surface)) !important;
}
.map-tab.active,
.feedback-mode-toggle.active {
  border-color: var(--theme-active-bg) !important;
  background: var(--theme-active-bg) !important;
  color: var(--theme-active-text) !important;
}
.search-box input { color: var(--theme-text) !important; }
:where(input, textarea)::placeholder { color: var(--theme-placeholder) !important; opacity: 1; }
.feedback-mode-toggle.login-required { background: color-mix(in srgb, var(--theme-warning) 9%, var(--theme-surface)) !important; }
.feedback-clear-all { background: var(--theme-danger-soft) !important; color: var(--theme-danger) !important; }

/* The map and its floating controls remain dark in both themes. */
.map-stage,
#map { background: #10130f !important; }
:where(.zone-frequency-panel, .zone-analysis-panel-shell, .floating-tools, .map-tools, .distance-guide, .drawing-toolbar),
.media-dialog {
  border-color: rgba(255,255,255,.18) !important;
  background: var(--map-panel) !important;
  color: var(--map-text) !important;
}
.floating-tools .panel-drag-grip,
.floating-tools button,
.leaflet-bar a {
  border-color: rgba(255,255,255,.16) !important;
  background: var(--map-panel) !important;
  color: var(--map-text) !important;
}
.floating-tools button:hover,
.leaflet-bar a:hover { background: var(--theme-accent) !important; color: var(--theme-accent-text) !important; }
.zone-frequency-toggle,
.zone-analysis-toggle,
.zone-frequency-phase-field button[aria-pressed="true"] {
  background: var(--theme-accent) !important;
  color: var(--theme-accent-text) !important;
}
.leaflet-popup-content-wrapper { background: var(--map-panel) !important; color: var(--map-text) !important; }
.panel-drag-grip,
.distance-guide span { color: var(--map-muted) !important; }
.toast {
  border: 1px solid rgba(255,255,255,.18) !important;
  background: var(--map-panel) !important;
  color: var(--map-text) !important;
}

/* Content canvases, heroes and forms */
:where(.records-stage, .leaderboard-stage, .community-stage, .shorts-stage, .buildings-stage) {
  background: var(--theme-canvas) !important;
  color: var(--theme-text) !important;
}
:where(.records-stage, .leaderboard-stage, .community-stage)::before {
  background: radial-gradient(circle at 84% 0%, color-mix(in srgb, var(--theme-accent) 18%, transparent), transparent 30%) !important;
}
:where(.records-hero, .full-leaderboard-hero, .community-hero, .shorts-hero, .buildings-hero) {
  border-color: var(--theme-border) !important;
  background: var(--theme-canvas) !important;
  color: var(--theme-text) !important;
}
:where(.records-hero h2, .full-leaderboard-title h2, .community-hero h2, .shorts-hero h2, .buildings-hero h2) {
  color: var(--theme-text) !important;
}
:where(.records-hero-copy p, .full-leaderboard-title p, .community-hero p, .buildings-hero p, .leaderboard-status, .community-status) {
  color: var(--theme-text-muted) !important;
}
:where(.records-content, .full-leaderboard-content, .community-content, .buildings-content) { color: var(--theme-text) !important; }
:where(.record-search-form, .full-leaderboard-controls, .board-search, .community-editor-dialog, .profile-form, .activity-report-dialog, .feedback-submit-dialog)
:where(input, select, textarea) {
  border-color: var(--theme-border-strong) !important;
  background: var(--theme-surface) !important;
  color: var(--theme-text) !important;
}
:where(.record-search-form label > span, .leaderboard-filter-group > span, .full-leaderboard-search-label > span,
.community-editor-dialog label, .profile-form label, .activity-report-dialog label, .feedback-submit-dialog label) {
  color: var(--theme-text-secondary) !important;
}
.leaderboard-platform-tabs,
.leaderboard-mode-tabs { border-color: var(--theme-border) !important; background: var(--theme-surface-soft) !important; }
.leaderboard-platform-tabs button,
.leaderboard-mode-tabs button { color: var(--theme-text-muted) !important; }
.leaderboard-platform-tabs button[aria-selected="true"],
.leaderboard-platform-tabs button.active,
.leaderboard-mode-tabs button[aria-selected="true"],
.leaderboard-mode-tabs button.active {
  background: var(--theme-surface-raised) !important;
  color: var(--theme-text) !important;
}

/* Cards and record hierarchy */
:where(.recent-player-searches, .my-records-quick, .record-result-shell, .record-overview,
.record-mode-card, .record-match-card, .normal-mode-card, .ranked-performance-card,
.record-match-item, .record-match-detail, .record-match-intel, .record-squad, .record-collapsible,
.season-select-control, .season-comparison-metric, .building-card, .community-empty,
.board-list, .board-post-card, .board-post-detail, .comment-card, .review-card, .comment-form,
.review-form, .mypage-card, .private-player-row, .shorts-card) {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface) !important;
  color: var(--theme-text) !important;
}
:where(.recent-player-searches > header strong, .my-records-quick-copy > strong,
.record-section-heading h4, .mode-card-head h5, .ranked-performance-head h5,
.record-match-copy b, .record-match-detail-head h5, .record-collapsible-summary strong,
.season-comparison-metric strong, .buildings-section-head h3, .building-card-body h4,
.building-empty-state > strong) { color: var(--theme-text) !important; }
:where(.recent-player-searches > header p, .my-records-quick-copy > p, .recent-player-empty,
.recent-player-button small, .my-records-button-copy small, .record-stat-card span,
.record-mode-stat span, .mode-stat-grid span, .ranked-stat-grid span,
.record-match-copy span, .building-card-body p, .building-empty-state > small,
.user-text) { color: var(--theme-text-muted) !important; }
.record-tabs,
.record-metric-grid { border-color: var(--theme-border) !important; background: var(--theme-surface) !important; }
.record-tabs button { color: var(--theme-text-muted) !important; }
.record-tabs button[aria-selected="true"] { color: var(--theme-text) !important; }
.record-stat-card strong,
.record-mode-stat strong,
.record-metric > strong { color: var(--theme-text) !important; }
.record-preview-grid article,
.record-profile-card {
  border-color: #3c493f !important;
  background: #181e19 !important;
  color: #f4f7f2 !important;
}
.record-preview-grid strong,
.record-profile-copy h3 { color: #f4f7f2 !important; }
.record-preview-grid p,
.record-profile-copy p,
.record-result-meta { color: #b7c1b6 !important; }
.season-select-control select { background: var(--theme-surface-soft) !important; color: var(--theme-text) !important; }

/* Leaderboard: fix the low-contrast names and activity labels explicitly. */
.full-leaderboard-summary {
  border-color: var(--theme-border) !important;
  background: var(--theme-active-bg) !important;
  color: var(--theme-active-text) !important;
}
.full-leaderboard-summary span { color: color-mix(in srgb, var(--theme-active-text) 72%, transparent) !important; }
.full-leaderboard-summary strong { color: var(--theme-active-text) !important; }
.full-leaderboard-table { border-color: var(--theme-border) !important; background: var(--theme-surface) !important; }
.full-leaderboard-table > header {
  border-color: var(--theme-border) !important;
  background: #1a1f1a !important;
  color: #f7f9f5 !important;
}
.full-leaderboard-row { border-color: var(--theme-border) !important; background: var(--theme-surface) !important; }
.full-leaderboard-row:nth-child(even) { background: var(--theme-row-alt) !important; }
.full-leaderboard-row:hover { background: var(--theme-row-hover) !important; }
.full-leaderboard-foot {
  border-color: var(--theme-border) !important;
  color: var(--theme-text-muted) !important;
}
.full-leaderboard-row > b,
.full-leaderboard-row > span,
.full-player strong,
.full-mobile-metrics b { color: var(--theme-text) !important; }
.full-player small,
.player-public-activity,
.player-public-activity > b,
.full-mobile-metrics span,
.full-mobile-metrics small,
.leaderboard-tier-fallback { color: var(--theme-text-muted) !important; }
.public-activity-link {
  border-color: var(--theme-border-strong) !important;
  background: var(--theme-surface-soft) !important;
}
.public-activity-link .activity-icon-cut { fill: var(--theme-surface-soft) !important; }
.full-leaderboard-row > button,
.full-leaderboard-actions button,
.leaderboard-full-link,
.full-leaderboard-pagination button {
  border-color: var(--theme-border-strong) !important;
  background: var(--theme-surface) !important;
  color: var(--theme-text) !important;
}
.full-leaderboard-row > button:hover,
.full-leaderboard-actions button:hover,
.leaderboard-full-link:hover,
.full-leaderboard-pagination button:hover {
  border-color: var(--theme-text) !important;
  background: var(--theme-accent) !important;
  color: var(--theme-accent-text) !important;
}
.player-name-hack,
.player-public-activity.is-hack > b { color: var(--theme-danger) !important; }

/* Community and dialog surfaces */
.board-detail,
.profile-card,
.private-player-card,
.activity-grid article,
.feature-community-panel {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface) !important;
  color: var(--theme-text) !important;
}
.board-detail h2,
.profile-card h3,
.private-player-card h3,
.private-player-heading h4,
.feature-community-panel h2 { color: var(--theme-text) !important; }
.board-detail .user-text { color: var(--theme-text-secondary) !important; }
:where(.board-detail-meta, .comment-card header, .review-card header,
.profile-card header span, .profile-card header p, .profile-privacy, .profile-field-note,
.grade-rule-note, .activity-grid span, .private-player-card > header p,
.private-player-note, .feature-community-panel > header p) {
  color: var(--theme-text-muted) !important;
}
.board-back,
#feature-community-tabs button {
  border-color: var(--theme-border) !important;
  color: var(--theme-text-muted) !important;
}
.private-player-row {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface-soft) !important;
  color: var(--theme-text) !important;
}
.private-player-content input {
  border-color: var(--theme-border-strong) !important;
  background: var(--theme-surface) !important;
  color: var(--theme-text) !important;
}
.board-categories button,
.community-actions button,
.tier-vote-form .danger,
.review-form .danger {
  border-color: var(--theme-border-strong) !important;
  background: var(--theme-surface) !important;
  color: var(--theme-text-secondary) !important;
}
.board-categories button.active,
.board-search > button:not(.community-primary) {
  border-color: var(--theme-active-bg) !important;
  background: var(--theme-active-bg) !important;
  color: var(--theme-active-text) !important;
}
.board-post-card:hover { background: var(--theme-row-hover) !important; }
:where(.community-modal-backdrop, .feature-community-backdrop, .auth-modal-backdrop,
.feedback-submit-backdrop, .activity-report-backdrop, .media-modal-backdrop) {
  background: var(--theme-overlay) !important;
}
:where(.community-editor-dialog, .feature-community-dialog, .auth-dialog,
.feedback-submit-dialog, .activity-report-dialog) {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface-raised) !important;
  color: var(--theme-text) !important;
}
:where(.auth-description, .auth-status, .auth-privacy, .auth-unofficial,
.feedback-submit-dialog header p, .feedback-submit-privacy, .activity-report-dialog header p,
.activity-report-privacy) { color: var(--theme-text-muted) !important; }
.auth-benefits,
.auth-account-menu {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface-raised) !important;
  color: var(--theme-text) !important;
}
.auth-benefits span,
.auth-account-menu small { color: var(--theme-text-muted) !important; }
.auth-account-menu > button,
.community-modal-close,
.activity-report-actions button {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface-soft) !important;
  color: var(--theme-text-secondary) !important;
}
.auth-google-button { background: #ffffff !important; color: #242722 !important; }

/* Shorts explorer follows the selected theme; the video player card stays a dark island. */
.shorts-explorer-panel h3,
.shorts-mobile-explorer h3 { color: var(--theme-text) !important; }
:where(.shorts-explorer-panel > p, .shorts-explorer-panel > header > strong,
.shorts-explorer-privacy, .shorts-focus-head p, .shorts-focus-head > strong,
.shorts-mobile-explorer > header small) { color: var(--theme-text-muted) !important; }
.shorts-mobile-explorer {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface) !important;
  color: var(--theme-text) !important;
}
.shorts-explorer-item {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface-soft) !important;
  color: var(--theme-text) !important;
}
.shorts-explorer-item:hover,
.shorts-explorer-item.active {
  border-color: var(--theme-accent) !important;
  background: var(--theme-row-hover) !important;
}
.shorts-explorer-copy > span { color: var(--theme-text-muted) !important; }
.shorts-focus-card {
  border-color: rgba(255,255,255,.18) !important;
  background: #121711 !important;
  color: #f4f7f2 !important;
}
.shorts-main-meta h3,
.shorts-feed-meta h3 { color: #f4f7f2 !important; }
.shorts-main-meta p,
.shorts-feed-meta p,
.shorts-feed-meta small,
.shorts-focus-card > footer { color: #b7c1b6 !important; }
.shorts-main-meta > a,
.shorts-feed-meta a { color: #e0e6dc !important; }

/* Legal documents share the same theme and storage choice. */
.legal-header {
  border-color: var(--theme-border) !important;
  background: color-mix(in srgb, var(--theme-canvas) 95%, transparent) !important;
  color: var(--theme-text);
}
.legal-actions { display: flex; align-items: center; gap: 10px; }
.back-link { color: var(--theme-text-muted) !important; }
body > main > .eyebrow { color: var(--theme-focus) !important; }
body > main > h1 { color: var(--theme-text); }
body > main > .lead,
body > main p,
body > main li { color: var(--theme-text-secondary) !important; }
body > main section {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface) !important;
  color: var(--theme-text);
  box-shadow: var(--theme-shadow-sm);
}
body > main h2,
.legal-card-grid strong { color: var(--theme-text) !important; }
.legal-card-grid article {
  border-color: var(--theme-border) !important;
  background: var(--theme-surface-soft) !important;
}
.notice {
  border-color: var(--theme-accent) !important;
  background: color-mix(in srgb, var(--theme-accent) 10%, var(--theme-surface)) !important;
  color: var(--theme-text-secondary) !important;
}
.legal-links a,
body > main code { color: var(--theme-focus) !important; }
body > main footer { border-color: var(--theme-border) !important; }
body > main footer p { color: var(--theme-text-muted) !important; }

@media (min-width: 1200px) and (max-width: 1599px) {
  .full-leaderboard-table > header,
  .full-leaderboard-row {
    grid-template-columns: 68px minmax(220px, 1.55fr) minmax(120px, 1fr) 100px 58px 64px 74px 74px 190px !important;
    gap: 8px !important;
  }
  .full-leaderboard-actions button { width: 92px !important; }
}

@media (max-width: 1260px) {
  .top-actions .theme-toggle { width: 116px; min-width: 116px; }
}

@media (max-width: 900px) {
  .topbar { background: color-mix(in srgb, var(--theme-canvas) 97%, transparent) !important; }
  .full-leaderboard-row { border-color: var(--theme-border) !important; }
  .full-mobile-metrics { border-color: var(--theme-border) !important; background: var(--theme-surface-soft) !important; }
}

@media (max-width: 430px) {
  .top-actions { gap: 5px !important; padding-right: 6px !important; }
  .top-actions .theme-toggle { width: 104px; min-width: 104px; min-height: 40px; }
  .theme-toggle-option { gap: 2px; }
  .theme-toggle-option > span { font-size: 9px; }
  .theme-toggle-option[data-theme-option="light"] > span:first-child,
  .theme-toggle-option[data-theme-option="dark"] > span:last-child { font-size: 11px; }
  .legal-actions { gap: 7px; }
  .legal-actions .theme-toggle { width: 104px; min-width: 104px; min-height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  html.theme-ready body,
  html.theme-ready .topbar,
  html.theme-ready .sidebar,
  html.theme-ready :where(.records-stage, .leaderboard-stage, .community-stage, .buildings-stage) {
    transition: none;
  }
  .theme-toggle::before,
  .theme-toggle-option { transition: none; }
}

/* Light-theme foreground contract: lime is a surface/border color, not text on bright surfaces. */
html[data-theme="light"] :where(
  .map-stage,
  .media-dialog,
  .record-preview-grid article,
  .record-profile-card,
  .shorts-focus-card,
  .update-cardnews-dialog
) {
  --theme-accent-foreground: var(--theme-accent);
}

/* Keep every lime surface; only repair the text/icon painted on top of it. */
html[data-theme="light"] :where(
  .map-tab.active .control-shortcut,
  .record-result-shell:not(.error) .record-empty-icon,
  .distance-guide-icon.panel-drag-grip
) {
  color: var(--brand-lime-text) !important;
}

