@media screen {
  html[data-theme="dark"]:is([data-theme-surface="auth"], [data-theme-surface="marketing"], [data-theme-surface="legal"], [data-theme-surface="wiki"], [data-theme-surface="admin"]) {
    color-scheme: dark;
    --night-page: #111a15;
    --night-panel: #1b2b22;
    --night-raised: #23382b;
    --night-hover: #2b4434;
    --night-field: #131f18;
    --night-line: #3c5748;
    --night-control: #657e6e;
    --night-text: #edf5ee;
    --night-muted: #b5c8ba;
    --night-link: #a0dfaf;
    --night-focus: #c4e99b;
    --night-button: #286441;
    --night-button-hover: #32734c;
    --night-gold: #f4d994;
    --night-gold-panel: #3a301e;
    --night-red: #f6b6aa;
    --night-red-panel: #3e2827;
    --night-shadow: 0 18px 48px #070e0a60;
    background: var(--night-page);
    color: var(--night-text);
  }

  html[data-theme="dark"]:is([data-theme-surface="auth"], [data-theme-surface="marketing"], [data-theme-surface="legal"], [data-theme-surface="wiki"], [data-theme-surface="admin"]) :focus-visible {
    outline: 2px solid var(--night-focus);
    outline-offset: 3px;
  }

  html[data-theme="dark"]:is([data-theme-surface="auth"], [data-theme-surface="wiki"], [data-theme-surface="admin"]) :is(input, textarea)::placeholder {
    color: var(--night-muted);
    opacity: 1;
  }

  html[data-theme="dark"]:is([data-theme-surface="auth"], [data-theme-surface="wiki"], [data-theme-surface="admin"]) input:-webkit-autofill {
    -webkit-text-fill-color: var(--night-text);
    box-shadow: 0 0 0 1000px var(--night-field) inset;
  }

  /* Account access and recovery */
  html[data-theme="dark"][data-theme-surface="auth"] .auth-panel {
    background: radial-gradient(ellipse at 76% 5%, #243e2d, transparent 46%), var(--night-page);
  }

  html[data-theme="dark"][data-theme-surface="auth"] :is(.auth-card, .recovery-card) {
    background: var(--night-panel);
    border-color: var(--night-line);
    box-shadow: var(--night-shadow);
  }

  html[data-theme="dark"][data-theme-surface="auth"] :is(.auth-intro, .auth-links, .recovery-card > p, label small, .check-label, .signup-explainer p) {
    color: var(--night-muted);
  }

  html[data-theme="dark"][data-theme-surface="auth"] :is(.auth-card a, .continue-link, .mobile-brand, .login-captcha-retry, .signup-explainer strong) {
    color: var(--night-link);
  }

  html[data-theme="dark"][data-theme-surface="auth"] :is(label, .login-captcha-choices legend) {
    color: var(--night-text);
  }

  html[data-theme="dark"][data-theme-surface="auth"] input:not([type="checkbox"], [type="radio"]) {
    background: var(--night-field);
    border-color: var(--night-control);
    color: var(--night-text);
  }

  html[data-theme="dark"][data-theme-surface="auth"] input:focus {
    border-color: var(--night-focus);
  }

  html[data-theme="dark"][data-theme-surface="auth"] input:user-invalid { border-color: var(--night-red); }
  html[data-theme="dark"][data-theme-surface="auth"] input:is([type="checkbox"], [type="radio"]) { accent-color: var(--night-link); }

  html[data-theme="dark"][data-theme-surface="auth"] :is(.password-field button, .recovery-icon, .recovery-grid code, .referral-invite, .signup-explainer, .login-captcha-options label) {
    background: var(--night-raised);
    border-color: var(--night-line);
    color: var(--night-text);
  }

  html[data-theme="dark"][data-theme-surface="auth"] .login-captcha-options label:has(input:checked) {
    background: var(--night-hover);
    border-color: var(--night-link);
    box-shadow: inset 0 0 0 1px var(--night-link);
  }

  html[data-theme="dark"][data-theme-surface="auth"] .password-meter:not([data-score="4"]) i { background-color: var(--night-control); }
  html[data-theme="dark"][data-theme-surface="auth"] .password-meter[data-score="1"] i:nth-child(-n+1) { background-color: var(--night-red); }
  html[data-theme="dark"][data-theme-surface="auth"] .password-meter[data-score="2"] i:nth-child(-n+2) { background-color: var(--night-gold); }
  html[data-theme="dark"][data-theme-surface="auth"] .password-meter[data-score="3"] i:nth-child(-n+3) { background-color: #b1ce76; }
  html[data-theme="dark"][data-theme-surface="auth"] .password-meter[data-score="4"] i { background-color: var(--night-link); }

  html[data-theme="dark"][data-theme-surface="auth"] .signup-account-warning {
    color: var(--night-gold);
    background: var(--night-gold-panel);
    border-color: #8b713c;
  }

  html[data-theme="dark"][data-theme-surface="auth"] .form-message { color: var(--night-red); }
  html[data-theme="dark"][data-theme-surface="auth"] .form-message.success { color: var(--night-link); }
  html[data-theme="dark"][data-theme-surface="auth"] .auth-submit { background: linear-gradient(135deg, #215638, var(--night-button-hover)); }

  @media (max-width: 520px) {
    html[data-theme="dark"][data-theme-surface="auth"] .auth-panel { background: var(--night-panel); }
    html[data-theme="dark"][data-theme-surface="auth"] :is(.auth-card, .recovery-card) { box-shadow: none; }
  }

  /* Public landing page */
  html[data-theme="dark"][data-theme-surface="marketing"] {
    --cream: var(--night-page);
    --paper: var(--night-panel);
    --ink: var(--night-text);
    --muted: var(--night-muted);
    --forest: var(--night-text);
    --forest-2: var(--night-link);
    --line: var(--night-line);
    --shadow: var(--night-shadow);
  }

  html[data-theme="dark"][data-theme-surface="marketing"] body {
    background: radial-gradient(ellipse at 55% 0, #21392a, transparent 540px), var(--night-page);
  }

  html[data-theme="dark"][data-theme-surface="marketing"] .marketing-header {
    background: #15231ced;
    border-color: var(--night-line);
  }

  html[data-theme="dark"][data-theme-surface="marketing"] :is(.marketing-brand small, .marketing-header nav a, .marketing-footer nav a, .marketing-footer-bottom small, .hero-lead, .hero-payout-note, .hero-proof span, .floating-card small) {
    color: var(--night-muted);
  }

  html[data-theme="dark"][data-theme-surface="marketing"] :is(.marketing-header nav a:hover, .marketing-footer nav a:hover, .hero h1 em, .eyebrow:not(.light)) {
    color: var(--night-link);
  }

  html[data-theme="dark"][data-theme-surface="marketing"] :is(.skip-link, .primary-button:not(.light)) {
    background: var(--night-button);
  }

  html[data-theme="dark"][data-theme-surface="marketing"] .primary-button:not(.light):hover { background: var(--night-button-hover); }
  html[data-theme="dark"][data-theme-surface="marketing"] .primary-button.light { color: #17271d; }

  html[data-theme="dark"][data-theme-surface="marketing"] :is(.secondary-button, .launch-pill, .floating-card, .pool-player) {
    color: var(--night-text);
    background: var(--night-raised);
    border-color: var(--night-control);
  }

  html[data-theme="dark"][data-theme-surface="marketing"] :is(.secondary-button:hover, .pool-player) { background: var(--night-hover); }
  html[data-theme="dark"][data-theme-surface="marketing"] .hero-proof span { border-color: var(--night-line); }
  html[data-theme="dark"][data-theme-surface="marketing"] .hero-world::before { background: linear-gradient(145deg, #2b5036, #467b4d); }
  html[data-theme="dark"][data-theme-surface="marketing"] .hero-world-image { border-color: #547761; }
  html[data-theme="dark"][data-theme-surface="marketing"] .step-number { color: #a2baa8; }

  html[data-theme="dark"][data-theme-surface="marketing"] :is(.feature-grid article:not(.feature-large), .faq-grid details, .rarity-section, .marketing-footer) {
    background: var(--night-panel);
    border-color: var(--night-line);
  }

  html[data-theme="dark"][data-theme-surface="marketing"] .feature-icon.green { background: #2a4530; }
  html[data-theme="dark"][data-theme-surface="marketing"] .feature-icon.blue { background: #263f4d; }
  html[data-theme="dark"][data-theme-surface="marketing"] .feature-icon.gold { background: #493b23; }
  html[data-theme="dark"][data-theme-surface="marketing"] .feature-icon.berry { background: #48313e; }
  html[data-theme="dark"][data-theme-surface="marketing"] .rarity-stack span { box-shadow: none; }
  html[data-theme="dark"][data-theme-surface="marketing"] .rarity-stack .common { color: #c0d7c8; background: #243a30; }
  html[data-theme="dark"][data-theme-surface="marketing"] .rarity-stack .uncommon { color: #a1df9f; background: #203c2b; }
  html[data-theme="dark"][data-theme-surface="marketing"] .rarity-stack .rare { color: #a9d6fb; background: #203647; }
  html[data-theme="dark"][data-theme-surface="marketing"] .rarity-stack .epic { color: #e0bdfa; background: #382d45; }
  html[data-theme="dark"][data-theme-surface="marketing"] .rarity-stack .legendary { color: var(--night-gold); background: var(--night-gold-panel); }
  html[data-theme="dark"][data-theme-surface="marketing"] .rarity-stack .mythical { color: #f7bfde; background: linear-gradient(135deg, #4c293a, #352b4c); }

  /* Terms, privacy, and support */
  html[data-theme="dark"][data-theme-surface="legal"] .legal-header {
    background: #15231ced;
    border-color: var(--night-line);
  }

  html[data-theme="dark"][data-theme-surface="legal"] .legal-brand { color: var(--night-text); }
  html[data-theme="dark"][data-theme-surface="legal"] :is(.legal-header nav a, .legal-content a, .legal-footer a) { color: var(--night-link); }

  html[data-theme="dark"][data-theme-surface="legal"] .legal-content {
    background: var(--night-panel);
    border-color: var(--night-line);
    box-shadow: var(--night-shadow);
  }

  html[data-theme="dark"][data-theme-surface="legal"] :is(.legal-content p, .legal-content li, .legal-footer) { color: var(--night-muted); }
  html[data-theme="dark"][data-theme-surface="legal"] .notice { background: var(--night-gold-panel); }
  html[data-theme="dark"][data-theme-surface="legal"] .legal-content .notice { color: var(--night-gold); }

  /* Wiki reference tables, navigation and search */
  html[data-theme="dark"][data-theme-surface="wiki"] {
    --ink: var(--night-text);
    --muted: var(--night-muted);
    --green: var(--night-link);
    --line: var(--night-line);
    --paper: var(--night-panel);
    --cream: var(--night-page);
    --gold: var(--night-gold);
  }

  html[data-theme="dark"][data-theme-surface="wiki"] a:hover { color: #d2f2cf; }
  html[data-theme="dark"][data-theme-surface="wiki"] .wiki-header { background: #15231cf5; }
  html[data-theme="dark"][data-theme-surface="wiki"] .kicker { color: var(--night-link); }
  html[data-theme="dark"][data-theme-surface="wiki"] .wiki-card:hover { border-color: var(--night-control); }

  html[data-theme="dark"][data-theme-surface="wiki"] :is(.skip, .play-link, .wiki-search button) {
    color: var(--night-text);
    background: var(--night-button);
  }

  html[data-theme="dark"][data-theme-surface="wiki"] :is(.play-link, .wiki-search button):hover {
    color: var(--night-text);
    background: var(--night-button-hover);
  }

  html[data-theme="dark"][data-theme-surface="wiki"] .wiki-search input {
    color: var(--night-text);
    background: var(--night-field);
    border-color: var(--night-control);
  }

  html[data-theme="dark"][data-theme-surface="wiki"] :is(.related, caption, .table-hint, .sort-status, .wiki-sidebar nav a:hover) { background: var(--night-raised); }
  html[data-theme="dark"][data-theme-surface="wiki"] :is(.sort-arrow, .table-hint) { color: var(--night-muted); }
  html[data-theme="dark"][data-theme-surface="wiki"] :is(th, td) { border-color: var(--night-line); }
  html[data-theme="dark"][data-theme-surface="wiki"] thead { color: var(--night-text); background: var(--night-raised); }
  html[data-theme="dark"][data-theme-surface="wiki"] th[aria-sort] { background: var(--night-hover); }
  html[data-theme="dark"][data-theme-surface="wiki"] tbody tr:nth-child(even) { background: #1e3026; }
  html[data-theme="dark"][data-theme-surface="wiki"] tbody tr:hover { background: var(--night-hover); }
  html[data-theme="dark"][data-theme-surface="wiki"] .note { color: var(--night-gold); background: var(--night-gold-panel); }

  /* Private administration and reporting */
  html[data-theme="dark"][data-theme-surface="admin"] {
    --forest: var(--night-text);
    --green: var(--night-button);
    --line: var(--night-line);
    --muted: var(--night-muted);
    --card: var(--night-panel);
  }

  html[data-theme="dark"][data-theme-surface="admin"] .admin-topbar { background: #19291f; }
  html[data-theme="dark"][data-theme-surface="admin"] .admin-sidebar { background: linear-gradient(180deg, #173726, #11271d); }
  html[data-theme="dark"][data-theme-surface="admin"] :is(.eyebrow, .metric em, .view-user, .withdrawal-crypto, .pool-leader b, .guild-task-row > em, .ban-history-restored .ban-history-action) { color: var(--night-link); }
  html[data-theme="dark"][data-theme-surface="admin"] :is(.pulse-row span, .search-row label, .timeline-item time, .pass-schedule-item label > span, .season-builder label > span, .monitor-list span, .pool-control-card form label > span, .announcement-editor > label:first-child, .announcement-toggle, .ban-history-eyebrow, .ban-history-intro, .ban-history-empty, .ban-history-date, .ban-history-meta, .ban-history-matches dt, .ban-history-account > span, .ban-history-account > small) { color: var(--night-muted); }
  html[data-theme="dark"][data-theme-surface="admin"] :is(.detail-id code, .wallet-destination, .monitor-list strong, .ban-history-matches dd) { color: var(--night-text); }

  html[data-theme="dark"][data-theme-surface="admin"] :is(.topbar-actions button:not(.theme-control), .quiet-button, .close-button, .history-tabs button) {
    color: var(--night-text);
    background: var(--night-raised);
    border-color: var(--night-control);
  }

  html[data-theme="dark"][data-theme-surface="admin"] :is(.topbar-actions button:not(.theme-control), .quiet-button, .close-button, .history-tabs button):hover { background: var(--night-hover); }
  html[data-theme="dark"][data-theme-surface="admin"] :is(.history-tabs button.active, .profit-periods button[aria-pressed="true"]) { color: var(--night-text); background: var(--night-button); }

  html[data-theme="dark"][data-theme-surface="admin"] :is(input:not([type="checkbox"], [type="radio"]), select, textarea),
  html[data-theme="dark"][data-theme-surface="admin"] #newest-accounts select {
    color: var(--night-text);
    background: var(--night-field);
    border-color: var(--night-control);
  }

  html[data-theme="dark"][data-theme-surface="admin"] :is(input, textarea, select):focus,
  html[data-theme="dark"][data-theme-surface="admin"] #newest-accounts select:focus { border-color: var(--night-focus); }
  html[data-theme="dark"][data-theme-surface="admin"] input:is([type="checkbox"], [type="radio"]) { accent-color: var(--night-link); }

  html[data-theme="dark"][data-theme-surface="admin"] .loading {
    background-image: linear-gradient(100deg, var(--night-panel), var(--night-hover), var(--night-panel));
  }

  html[data-theme="dark"][data-theme-surface="admin"] :is(.metric-icon, .timeline-icon, .pulse-row i, .detail-metrics div, .schedule-item, .readiness-grid article, .monitor-list > div, .pool-control-summary > div, .pool-leader, .guild-task-row, .guild-task-row > i, .admin-mfa-key, .ban-history-meta > span, .ban-history-matches, .ban-history-related li, .profit-periods) {
    background: var(--night-raised);
    border-color: var(--night-line);
  }

  html[data-theme="dark"][data-theme-surface="admin"] :is(dialog, .ban-history, .ban-history-event, .profit-metrics article) {
    background: var(--night-panel);
    border-color: var(--night-line);
    color: var(--night-text);
  }

  html[data-theme="dark"][data-theme-surface="admin"] dialog::backdrop { background: #080e0acf; }
  html[data-theme="dark"][data-theme-surface="admin"] :is(th, .profit-table thead th) { background: var(--night-raised); color: var(--night-muted); }
  html[data-theme="dark"][data-theme-surface="admin"] :is(tbody tr:hover, .profit-table tr.selected) { background: var(--night-hover); }
  html[data-theme="dark"][data-theme-surface="admin"] :is(.threshold-summary span, .ban-history-related h5 > span) { color: var(--night-muted); background: var(--night-hover); }

  html[data-theme="dark"][data-theme-surface="admin"] :is(.health-badge, .status-chip, .readiness-status.ready, .monitor-overall.ready, .pool-leader > span, .profit-tag, .restore-button) {
    color: var(--night-link);
    background: #234230;
    border-color: #527b60;
  }

  html[data-theme="dark"][data-theme-surface="admin"] .status-chip.closed { color: var(--night-muted); background: var(--night-hover); }

  html[data-theme="dark"][data-theme-surface="admin"] :is(.status-chip.admin, .status-chip.upcoming, .status-chip.pending, .status-chip.queued, .status-chip.retry, .status-chip.submitting, .status-chip.settling, .pass-schedule-item.needs-content, .admin-mfa-recovery, .ban-history-note, .profit-notice, .profit-tag.estimated) {
    color: var(--night-gold);
    background: var(--night-gold-panel);
    border-color: #89703e;
  }

  html[data-theme="dark"][data-theme-surface="admin"] :is(.schedule-warning, .ban-history-action) { color: var(--night-gold); }

  html[data-theme="dark"][data-theme-surface="admin"] :is(.health-badge.attention, .status-chip.suspended, .status-chip.failed, .status-chip.rejected, .status-chip.cancelled, .readiness-status.blocked, .monitor-overall.blocked, .monitor-error, .ban-history-current, .danger-button:not(.restore-button)) {
    color: var(--night-red);
    background: var(--night-red-panel);
    border-color: #906154;
  }

  html[data-theme="dark"][data-theme-surface="admin"] :is(.ban-history-current > span, .profit-deduction) { color: var(--night-red); }
  html[data-theme="dark"][data-theme-surface="admin"] .profit-metrics .profit-balance { background: #234b33; border-color: #567d60; }
  html[data-theme="dark"][data-theme-surface="admin"] .profit-metrics .profit-balance.negative { background: var(--night-red-panel); border-color: #906154; }
}
