html { color-scheme: light; }
.header-menu__appearance { margin: 0; text-align: left; }
.header-menu__appearance > span { flex: 1; }
.header-menu__appearance select { font: inherit; color: var(--ink-soft); background: transparent; border: 0; min-height: 44px; max-width: 7rem; }

:root[data-theme="dark"][data-theme] { color-scheme: dark; background: #19181d; }
:root[data-theme="dark"][data-theme], :root[data-theme="dark"][data-theme] body {
  --cream: #19191d;
  --cream-deep: #343137;
  --paper: #252429;
  --ink: #f6eddf;
  --ink-soft: #c4b9c9;
  --plum: #e1c8eb;
  --plum-deep: #f6eddf;
  --teal: #8bd49a;
  --teal-soft: #253c30;
  --green-deep: #8bd49a;
  --coral: #ffac98;
  --coral-deep: #ffac98;
  --coral-soft: #472c29;
  --lavender: #d1b5ee;
  --lavender-soft: #393044;
  --gold: #e8c46c;
  --gold-soft: #493c23;
  --line: #514a50;
  --tile-face: #1a1e27;
  --tile-edge: #08090b;
  --tile-merged-face: var(--tile-face);
  --tile-merged-edge: #48494e;
  --tile-latest-face: #38324f;
  --settings-border: #514a50;
  --button-bevel: inset 0 1px 0 #ffffff20, inset 0 -2px 0 #00000040, 0 3px 0 #00000050;
}
:root[data-theme="dark"][data-theme] body { background: #19181d; color: var(--ink); }
:root[data-theme="dark"][data-theme] .site-backdrop {
  content: url("/artwork/racetrack/dark.png");
  opacity: 1;
  mask-image: linear-gradient(to bottom, transparent, #000 25%);
}
:root[data-theme="dark"][data-theme] :is(.site-header, .site-header__who, .app-nav, .home__invite, .home__suggested .player-result, details.finished-games, .game-card, .settings__panel, .settings__avatar-option, .input, .game-chat__input, .post-game__banner, .home__more, .pending-invites__item) {
  background: var(--paper); color: var(--ink); border-color: var(--line);
}
:root[data-theme="dark"][data-theme] .onboarding .site-header { background: transparent; }
:root[data-theme="dark"][data-theme] :is(.brand, .settings__title, .settings__heading, .game-card__name) { color: var(--ink); }
:root[data-theme="dark"][data-theme] .site-header__count { background: var(--lavender-soft); color: var(--ink); }
:root[data-theme="dark"][data-theme] .game-list__count { background: var(--cream-deep); color: var(--ink-soft); }
:root[data-theme="dark"][data-theme] .game-list__count--turn { background: var(--green-deep); color: var(--paper); }
:root[data-theme="dark"][data-theme] :is(.notification-update:not([hidden]), .flash .flash__notice) { background: #253c30; color: #b5e1cc; border-color: #547660; }
:root[data-theme="dark"][data-theme] :is(.button--primary, .marketing .button--primary) { background: #2c7a22; border-color: #397f43; color: #fffdf7; }
:root[data-theme="dark"][data-theme] :is(.button--danger, .button--play) { background: #963e30; border-color: #bf6a56; color: #fffdf7; }
:root[data-theme="dark"][data-theme] :is(.game-chat__summary, .game-chat--floating .game-chat__panel:not([open]) .game-chat__summary) { background: #493454; color: #fffdf7; }
:root[data-theme="dark"][data-theme] :is(.game-options > .game-options__back, .settings__gold) { color: #200e30; }
:root[data-theme="dark"][data-theme] :is(.settings__helper, .settings__note, .settings__field .field__label) { color: var(--ink-soft); }
:root[data-theme="dark"][data-theme] .board-scroll { background: #403b32; border-color: #675b45; box-shadow: inset 0 1px 0 #ffffff20, 0 3px 8px #00000060; }
:root[data-theme="dark"][data-theme] .board { background: #494334; }
:root[data-theme="dark"][data-theme] .square { background: #302d29; color: #294b68; box-shadow: inset 0 0 0 1px #ffffff0a; }
:root[data-theme="dark"][data-theme] .square--double_letter { background: #294454; color: #bcdff5; }
:root[data-theme="dark"][data-theme] .square--triple_letter { background: #29493e; color: #b5e1cc; }
:root[data-theme="dark"][data-theme] .square--double_word { background: #574039; color: #f1c5b6; }
:root[data-theme="dark"][data-theme] .square--triple_word { background: #733e31; color: #ffd8c9; }
:root[data-theme="dark"][data-theme] .square--center { background: #5b4925; color: #f3d58c; }
:root[data-theme="dark"][data-theme] .tile { color: #f1f2f3; background: var(--tile-face); border-color: #45474c; border-bottom-color: #08090b; box-shadow: inset 1px 1px 0 #ffffff20, 0 2px 0 #08090b, 0 4px 8px #00000040; }
:root[data-theme="dark"][data-theme] .tile__points { color: #d3d5d8; }
:root[data-theme="dark"][data-theme] .tile--merged { background: var(--tile-merged-face); }
:root[data-theme="dark"][data-theme] .tile--latest { background: var(--tile-latest-face); }
:root[data-theme="dark"][data-theme] .rack { background: #202d3a; border-color: #42576a; box-shadow: inset 0 1px 0 #ffffff20, 0 3px 0 #211e19; }
:root[data-theme="dark"][data-theme] :is(.square.is-drop-target, .square.has-draft) { background: #284c3b; }
:root[data-theme="dark"][data-theme] :is(.square.is-drop-invalid, .square:has(.tile--draft.is-invalid)) { background: #623b34; }
:root[data-theme="dark"][data-theme] :is(.status-banner, .move-score) { background: #253c30; color: #b5e1cc; border-color: #547660; }
:root[data-theme="dark"][data-theme] .status-banner--over { background: transparent; }
:root[data-theme="dark"][data-theme] .board-latest-play { background: #293f4e; color: #b8ddf3; box-shadow: inset 0 0 0 1px #56778a; }
:root[data-theme="dark"][data-theme] :is(.tile.is-selected, .tile:focus-visible, .square:focus-visible) { outline-color: #8bd49a; }
:root[data-theme="dark"][data-theme] :is(.win-chance, .game-play-dock .button:not(.button--play, .game-options__back, .game-sound-toggle, .game-resign), .game-chat__body, .game-chat__messages, .home__suggested-reroll, .finished-games__more) { background: var(--paper); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"][data-theme] :is(.game-play-dock .controls .button, .game-options > .button, .game-chat--floating .game-chat__summary) { border-color: var(--line); box-shadow: var(--button-bevel); }
:root[data-theme="dark"][data-theme] .player__name { color: var(--ink-soft); }
:root[data-theme="dark"][data-theme] .player--you .player__number { color: #8dc8ef; }
:root[data-theme="dark"][data-theme] .player--opponent .player__number { color: #f0b398; }
:root[data-theme="dark"][data-theme] .win-chance { box-shadow: inset 0 -3px 0 #00000040, 0 3px 8px #00000030; }
:root[data-theme="dark"][data-theme] .win-chance__row--primary { color: #76d4a3; }
:root[data-theme="dark"][data-theme] .win-chance__row--secondary { color: #8dc8ef; }
:root[data-theme="dark"][data-theme] .win-chance__track::before { background: repeating-linear-gradient(to right, #c4b9c966 0 3px, transparent 3px 7px); }
:root[data-theme="dark"][data-theme] .app-nav__link[aria-current="page"] { background: #393044; color: var(--ink); }
:root[data-theme="dark"][data-theme] .game-options > .game-options__back { background: #e0ba55; color: #200e30; }
:root[data-theme="dark"][data-theme] .game-options > .game-sound-toggle { background: #253c30; color: #b5e1cc; }
:root[data-theme="dark"][data-theme] .game-options > .game-resign { background: #472c29; color: #ffac98; }
:root[data-theme="dark"][data-theme] :is(.game-card__status--turn, .home__invite-copy) { background: #2c7a22; color: #fffdf7; }
:root[data-theme="dark"][data-theme] :is(.game-card__status--waiting, .home-page .finished-games__more) { color: #200e30; background: #e0ba55; }

/* Keep the account trigger within its slot, including the 56px touch minimum. */
@media (max-width: 600px) {
  .game-page .site-header { display: block; position: absolute; top: max(0px, env(safe-area-inset-top)); right: max(6px, env(safe-area-inset-right)); z-index: 60; border: 0; background: transparent; }
  .game-page .site-header__inner { width: 56px; min-height: 60px; padding: 0; gap: 0; }
  .game-page .site-header :is(.brand, .site-header__games, .notification-menu, .header-menu__label, .header-menu__chevron) { display: none; }
  .game-page .header-menu__toggle { width: 56px; height: 56px; padding: 0; margin: 0; justify-content: center; }
  .game-page .header-menu__toggle::before { display: none; }
  .game-page .header-menu__avatar { width: 32px; height: 32px; }
}

:root[data-theme="dark"] .header-menu.site-header .site-header__who { background: #252429; color: #f6eddf; border-color: #514a50; }
:root[data-theme="dark"][data-theme] .tile--latest-play { background: var(--tile-latest-face); }
:root[data-theme="dark"][data-theme] .game-chat .game-chat__input { background: #19191d; color: #f6eddf; border-color: #69717e; caret-color: #b8ddf3; }
:root[data-theme="dark"][data-theme] .game-chat__input::placeholder { color: #b4becb; opacity: 1; }
:root[data-theme="dark"][data-theme] :is(.game-chat__panel, .home-page .player-results, .home-page .player-result--invite, .home-page .player-result--none, .signin-confirmation__back) { background: var(--paper); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"][data-theme] :is(.game-chat__unread, .game-card__unread-chat) { background: #493454; color: #fffdf7; }
:root[data-theme="dark"][data-theme] :is(.game-card__status--accept, .signin-confirmation__check) { background: #2c7a22; color: #fffdf7; }
:root[data-theme="dark"][data-theme] .game-card__result--won { color: #8bd49a; }
:root[data-theme="dark"][data-theme] :is(.onboarding .signin__text, .onboarding .field__label, .signin-confirmation__help) { color: var(--ink-soft); }
:root[data-theme="dark"][data-theme] .tile--draft { background: var(--tile-face); border-color: #8dc8ef; }
:root[data-theme="dark"][data-theme] .tile--draft.is-invalid { background: #623b34; border-color: #ffac98; }

:root[data-theme="dark"][data-theme] .tile__letter--blank { color: #e0eefa; }

:root[data-theme="dark"][data-theme] .game-chat__message { background: var(--cream-deep); color: var(--ink); }
:root[data-theme="dark"][data-theme] .game-chat__author { color: var(--ink-soft); }
:root[data-theme="dark"][data-theme] .game-chat__error { color: #ffac98; }

:root[data-theme="dark"][data-theme] .skip-link { background: #493454; color: #fffdf7; }
:root[data-theme="dark"][data-theme] :is(.game-card__avatar, .player-result__avatar, .header-menu__avatar, .onboarding__preview-tile) { background: var(--cream-deep); color: var(--ink); }
:root[data-theme="dark"][data-theme] :is(.home-page .button--secondary:not(.game-nudge__button, .home__new-game), .home-page .home__suggested-reroll) { background: var(--cream-deep); color: var(--ink); border-color: var(--line); }
:root[data-theme="dark"][data-theme] :is(.home__invite-error, .game-card__invitation-error, .field__error) { color: #ffac98; }
:root[data-theme="dark"][data-theme] .flash .flash__alert { background: #472c29; color: #ffac98; border-color: #bf6a56; }
@media (max-width: 600px) {
  .game-scoreboard { grid-template-columns: 44px minmax(0, 1fr) auto minmax(0, 1fr) 44px; }
  .game-play-dock .game-options > .button { padding-inline: 2px; gap: 3px; }
}

:root[data-theme="dark"][data-theme] .signin-confirmation { background: var(--teal-soft); color: var(--ink); }

:root[data-theme="dark"][data-theme] .game-chat--floating .game-chat__panel:not([open]) .game-chat__summary[data-chat-disabled="true"] { background: #343137; color: #918b96; border-color: #514a50; box-shadow: none; }
