/* Night watch preserves the original watercolor hues with dedicated materials.
   Geometry and visibility masks remain identical across the two palettes.
   Timber rails already belong to the dark material family in the daytime DA. */
.theme-button > span:first-child {
  font-size: 20px;
  line-height: 1;
}
/* Keep the five utility commands on the same rail, in both palettes. */
.game-shell .topbar .header-tools {
  grid-template-columns: repeat(5, 30px);
}
.game-shell .topbar .header-tools .ghost {
  min-width: 30px;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e3dac4;
  --teal: #34584d;
  --gold: #c2a36c;
  --paper: #302f28;
  --muted: #b9b29d;
  --line: #655e4b;
  --ivory: #e3dac4;
  --brass: #c2a36c;
  --paper-shadow: 0 2px 3px #050d1240, 0 8px 24px #050d1260;

  body,
  .game-shell {
    background: #292b25;
  }
  #board {
    background: #1b2526;
  }
  /* Night cloud and sea materials own their pigments. Useful moving marks have
     their own exposure, so dimming the background cannot swallow the ship. */
  .chart-vessel,
  .chart-fleet {
    filter: brightness(0.85);
  }
  .chart-vessel.historical-vessel {
    filter: grayscale(1);
  }
  .chart-effects {
    opacity: 0.85;
  }
  .game-shell .topbar,
  .instrument-bar {
    background:
      linear-gradient(#0002, #0002),
      var(--timber) repeat #373028;
  }
  button,
  input,
  select {
    color: var(--ink);
    border-color: var(--line);
    background: var(--fiber), #3b3c31;
  }
  button:hover:not(:disabled),
  input:focus,
  select:focus {
    background-color: #4a4b3b;
    border-color: var(--brass);
  }
  button.primary,
  .modal .choice.primary {
    background: var(--fiber), #34584d;
    color: #e1e5d7;
    border-color: #71846b;
  }
  button.primary:hover:not(:disabled) {
    background: var(--fiber), #416856;
  }
  button.gold {
    background: var(--fiber), #705c38;
    color: #f3e1b6;
  }
  button.ghost {
    background: transparent;
    border-color: transparent;
  }
  .modal-header .close {
    border: 1px solid #8e7d58;
    color: var(--muted);
  }
  .crew-tabs button,
  .crew-tabs button:hover:not(:disabled) {
    background: transparent;
    border: 0;
    border-bottom: 2px solid transparent;
  }
  .crew-tabs button.active {
    border-bottom-color: var(--brass);
    color: var(--ink);
  }
  /* The captain and opponent remain part of the single timber rail. Generic
     folio/button surfaces must never turn these groups into separate cards. */
  .topbar .statusbar,
  .topbar .opponent-link,
  .topbar .score-chip {
    background: transparent;
    box-shadow: none;
  }
  .topbar .opponent-link,
  .topbar .score-chip {
    border: 0;
    color: var(--ivory);
  }
  .topbar .score-chip {
    border-left: 1px solid #c2a36c45;
    color: #dfc38c;
  }
  .topbar .opponent-link:hover,
  .topbar .score-chip:hover {
    background: #c7b18418;
  }
  .topbar .captain .eyebrow,
  .topbar .stat .ui-icon,
  .topbar .stat strong small,
  .topbar .opponent-link small {
    color: #c6b38b;
  }
  button.danger,
  .warning,
  .error {
    color: #e0a08a;
  }
  :focus-visible {
    outline-color: #d1b279;
  }
  .turn-controls,
  .sidebar,
  .game-shell .dock-left .sidebar,
  .modal,
  .chart-context,
  .upcoming-events {
    background: var(--fiber), var(--paper);
    color: var(--ink);
    border-color: #8e7d58;
  }
  .modal {
    box-shadow:
      0 2px 0 #786a4e,
      0 5px 0 #2a2b27,
      0 22px 70px #030a11b0;
  }
  .overlay,
  .game-shell + .overlay {
    background: #14201bd1;
  }
  .modal:has([data-action="setup-submit"]) .modal-header,
  .public-crew-card,
  .bid-footer input,
  .panel-head,
  .dock-left .sidebar .panel-head,
  .modal-header,
  .modal > .footer,
  .event-summary,
  .map-controls,
  .notice,
  .report-emblem,
  .attack-estimate,
  .crew-management,
  .token-row .tag,
  .collapse-all,
  .report-vessel,
  .report-outcome,
  .auction-result-lot,
  .auction-verdict-seal {
    background: var(--fiber), #38372d;
    color: var(--ink);
    border-color: var(--line);
  }
  .modal .choice,
  #panel-crew .crew-card,
  .navigation-grid button,
  .map-controls button,
  .crew-card,
  .report-reward,
  .report-detail,
  .report-vessel.is-yours,
  .turn-actions button:not(.primary) {
    background: var(--fiber), #3c3d31;
    color: var(--ink);
    border-color: #716b54;
  }
  #panel-crew .crew-card:hover,
  .modal .close:hover {
    background-color: #4a4b3b;
  }
  .ledger-menu button,
  .instrument-bar .panel-toggle,
  .title-foot .title-link {
    background: transparent;
  }
  .modal .choice.selected,
  .instrument-bar .panel-toggle[aria-expanded="true"],
  .instrument-bar .panel-toggle[aria-expanded="true"]:hover {
    background: var(--fiber), #46523b;
    color: #e1e5d7;
    border-color: #af9c70;
  }
  .modal .choice.selected::after,
  .instrument-bar .panel-toggle[aria-expanded="true"] .ui-icon {
    color: #c1b18b;
  }
  .eyebrow,
  .section-head,
  .gold-text,
  .gold-text .ui-icon,
  .modal .choice .gold-text,
  .modal-heading .eyebrow,
  .modal-body > .eyebrow,
  .audio-settings .volume-value,
  .lot-stats,
  .title-slot .symbol,
  .log em {
    color: var(--gold);
  }
  .events-toggle small,
  .upcoming-event small,
  .ledger-menu button small,
  .guide-section p,
  .setup-selection,
  .crew-tabs .small,
  .sea-rules summary,
  .modal .footer small,
  .captain .eyebrow,
  .sea-location small,
  .crew-card small,
  .crew-explanation,
  .crew-capacity,
  .crew-tabs button,
  .modal .lead,
  .modal .choice span,
  .panel-head .ghost,
  .log p,
  .sea-chip,
  .event-summary .balance,
  .report-label,
  .report-reward p,
  .report-detail p,
  .report-consequence p,
  .report-side > span,
  .report-explanation,
  .auction-verdict p,
  .auction-result-lot p {
    color: var(--muted);
  }
  .events-toggle,
  .guide-section summary,
  .crew-management summary,
  .public-stats dd,
  .modal:has([data-action="setup-submit"]) h3,
  .modal-header h2,
  .event-feed > strong,
  .chart-context > strong,
  .crew-tabs button.active,
  .report-balance > h3,
  .report-consequence > h3,
  .report-reward strong,
  .report-side,
  .report-force,
  .stat .ui-icon {
    color: var(--ink);
  }
  .resource-info:hover::after,
  .resource-info:focus-visible::after,
  .title-slot:hover::after,
  .title-slot:focus::after {
    background: var(--fiber), #3b3c31;
    color: var(--ink);
    border-color: var(--brass);
  }
  .upcoming-event > .ui-icon,
  .ledger-menu button > span {
    color: var(--gold);
  }
  .upcoming-event.is-due,
  .has-deadline .events-toggle > .ui-icon {
    color: #dfa58b;
  }
  .ledger-menu button.primary {
    color: #d6dfbd;
    background: transparent;
  }
  .ledger-menu button:not(.primary):hover,
  .ledger-menu button.primary:hover {
    background: #4a4b3b;
  }
  .sea-location {
    color: var(--ink);
    text-shadow: 0 1px 3px #06121b;
  }
  .progress {
    background: #474c3a;
  }
  .sidebar,
  .modal-body {
    scrollbar-color: #7e806a #302f28;
  }
  /* Raster folios keep their printed inks; lower their light without inversion. */
  .character-sheet {
    filter: brightness(0.72);
  }
  .title-screen {
    background: var(--fiber), #303b32;
    color: var(--ink);
  }
  .title-screen::before {
    background:
      linear-gradient(90deg, #273027ee, #27302760 48%, transparent 74%),
      radial-gradient(ellipse at 70% 55%, transparent 28%, #242d26c0 100%);
  }
  .title-screen::after {
    border-color: #8f7b535c;
    outline-color: #101d2840;
    box-shadow:
      inset 0 0 0 3px #a58c4f16,
      0 0 0 10px #1a211f;
  }
  .title-world {
    filter: brightness(0.55);
  }
  .title-chart {
    mix-blend-mode: multiply;
  }
  .title-masthead h1,
  .visitor-berth p {
    color: #e4d6b5;
    text-shadow: none;
  }
  .title-masthead p,
  .visitor-berth span,
  .harbor-heading p,
  .harbor-motto,
  .title-foot .title-link,
  .title-edition,
  .vessel-name,
  .vessel-name small {
    color: #bcb99f;
  }
  .title-foot .title-link[aria-pressed="true"],
  .title-foot .title-link:hover {
    color: #d2be92;
    background: #c7b18415;
  }
  .harbor-order,
  .harbor-order:hover:not(:disabled) {
    background: var(--timber) repeat #373028;
    color: #e5d5ac;
  }
}
@media (max-width: 760px) {
  .game-shell .topbar .header-tools {
    grid-template-columns: repeat(5, 26px);
  }
  .game-shell .topbar .header-tools .ghost {
    min-width: 26px;
    padding-inline: 3px;
  }
  .title-audio {
    gap: 6px;
  }
  .title-audio .theme-button {
    padding-inline: 0;
  }
  .title-audio .theme-button > span + span {
    display: none;
  }
}
