:root[data-theme="red"] {
  --theme-bg: #260911;
  --theme-glow: #641629;
  --theme-panel: #39101c;
  --theme-field: #481422;
  --theme-text: var(--ui-off-white);
  --theme-muted: #e4c8c9;
  --theme-accent: #f7cc70;
  --theme-border: #b58354;
}
:root[data-theme="beige"] {
  --theme-bg: #f5ead5;
  --theme-glow: #d9ba84;
  --theme-panel: #fff6e4;
  --theme-field: #fffaf0;
  --theme-text: #352213;
  --theme-muted: #684b36;
  --theme-accent: #78500d;
  --theme-border: #a57832;
}
#siteTheme {
  font: inherit;
  color: var(--theme-accent, #f7cc70);
  background: var(--theme-field, #0c172d);
  border: 1px solid var(--theme-border, #f7cc70);
  border-radius: 10px;
  padding: 7px 10px;
  max-width: 100%;
}
:root:is([data-theme="red"], [data-theme="beige"]) body {
  background: radial-gradient(ellipse at top left, var(--theme-glow), var(--theme-bg) 62%);
  color: var(--theme-text);
}
:root:is([data-theme="red"], [data-theme="beige"]) :is(.login-panel, .selected-game, .card, #game, dialog, .player-menu nav, .wallet-chip, .account-page main section) {
  background: var(--theme-panel);
  color: var(--theme-text);
  border-color: var(--theme-border);
}
:root:is([data-theme="red"], [data-theme="beige"]) :is(button, input, select, .action, .wallet-add, .balances a) {
  background: var(--theme-field);
  color: var(--theme-text);
  border-color: var(--theme-border);
}
:root:is([data-theme="red"], [data-theme="beige"]) .primary {
  background: linear-gradient(#ffdc85, #dda030);
  color: #211400;
}
:root:is([data-theme="red"], [data-theme="beige"]) :is(a, .accent, .showcase h2, .game-launch) { color: var(--theme-accent); }
:root:is([data-theme="red"], [data-theme="beige"]) :is(.muted, small, .note, footer, input::placeholder) { color: var(--theme-muted); }
:root:is([data-theme="red"], [data-theme="beige"]) :is(.carousel-hub, .arc-board) {
  background: var(--theme-field);
  color: var(--theme-text);
  border-color: var(--theme-border);
}
:root:is([data-theme="red"], [data-theme="beige"]) #game button.correct { background: #275737; color: var(--ui-off-white, #f2e5d8); }
:root:is([data-theme="red"], [data-theme="beige"]) #game button.wrong { background: #813342; color: var(--ui-off-white, #f2e5d8); }
:root:is([data-theme="red"], [data-theme="beige"]) :is(#downloadDialog, #trialDialog, #trialNickname) {
  background: var(--theme-panel);
  color: var(--theme-text);
  border-color: var(--theme-border);
}
:root:is([data-theme="red"], [data-theme="beige"]) :is(.dashboard-head, #arcMenu .card, .game-grid .card, .side-drawer) {
  background: var(--theme-panel);
  color: var(--theme-text);
  border-color: var(--theme-border);
}
:root[data-theme="beige"] :is(.login-page .recovery-links a, .login-page footer a, .dashboard-brand, .side-drawer a, .account-page strong, .play-back) {
  color: var(--theme-accent);
}

.login-header { justify-content: flex-start; }
#siteTheme { cursor: pointer; }
.theme-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.login-header #siteTheme {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
}

@font-face {
  font-family: "Noto Sans Arabic UI";
  src: url("ui-fonts/noto-sans-arabic-Regular.woff") format("woff");
  font-weight: 400;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans Arabic UI";
  src: url("ui-fonts/noto-sans-arabic-Bold.woff") format("woff");
  font-weight: 700;
  font-display: swap;
}

:root {
  --ui-off-white: #f2e5d8;
  --ui-font: "Noto Sans Arabic UI", system-ui, sans-serif;
  --ui-text: #e7dff5;
  --ui-detail: #b9cedd;
  --ui-field-text: #e1eaff;
  --ui-drawer-ink: #f3cf80;
}

:root[data-theme="red"] {
  --ui-off-white: #d3a8b6;
  --ui-text: var(--ui-off-white);
  --ui-detail: #c39baa;
  --ui-drawer-ink: #d1a373;
  --ui-field-text: #d8adbb;
}

:root[data-theme="beige"] {
  --ui-text: #4c3549;
  --ui-detail: #5f4a68;
  --ui-field-text: #49344b;
  --ui-drawer-ink: #251e19;
}

:root body {
  font-family: var(--ui-font);
  color: var(--ui-text);
}

:root :is(button, input, select, textarea) { font-family: inherit; }
:root :is(.muted, .note, .dashboard-identity small, .game-grid small, .dashboard-footer, #menuNumber) { color: var(--ui-detail); }
:root :is(.entry input:not([type="checkbox"]), .account-page input, .account-page select, .account-page textarea) { color: var(--ui-field-text); }
:root :is(.entry input, .account-page input, .account-page textarea)::placeholder { color: var(--ui-detail); }
:root :is(.dashboard-identity strong, .game-grid h3, .login-page figcaption, .login-page .game-caption, dialog) { color: var(--ui-text); }
:root[data-theme] .side-drawer :is(nav a, nav #profileUpdate, #logout, .drawer-heading button) {
  color: var(--ui-drawer-ink);
  font-weight: 700;
}
:root[data-theme] .side-drawer nav a:is(:hover, :focus-visible),
:root[data-theme] .side-drawer nav #profileUpdate {
  background: color-mix(in srgb, var(--ui-drawer-ink) 12%, transparent);
}

:root {
  --game-label-ink: #f3cf80;
}
:root[data-theme="red"] { --game-label-ink: var(--ui-off-white); }
:root[data-theme="beige"] { --game-label-ink: #251e19; }

:root[data-theme] :is(#language, #menuOpen, #playerName, #playerNumber, #menuName, #menuNumber,
  .game-grid h3, .contest-feature h3, .login-page .game-caption, #arcTitle) {
  color: var(--game-label-ink);
}

:root[data-theme="red"] .home-page .contest-panel .game-launch {
  color: var(--theme-bg);
}
:root[data-theme="red"] .login-page .selected-game {
  color: var(--ui-off-white);
}

:root {
  --scroll-track: #0e172a;
  --scroll-thumb: #b88b44;
  --scroll-thumb-hover: #e5bd6c;
}
:root[data-theme="red"] {
  --scroll-track: #39101c;
  --scroll-thumb: #b77d58;
  --scroll-thumb-hover: #d9a57e;
}
:root[data-theme="beige"] {
  --scroll-track: #f0e1c5;
  --scroll-thumb: #8c652e;
  --scroll-thumb-hover: #69491e;
}

@media (forced-colors: none) {
  @supports selector(::-webkit-scrollbar) {
    ::-webkit-scrollbar { width: 10px; height: 10px; }
    ::-webkit-scrollbar-track, ::-webkit-scrollbar-corner { background: var(--scroll-track); }
    ::-webkit-scrollbar-thumb {
      background: var(--scroll-thumb);
      border: 2px solid var(--scroll-track);
      border-radius: 999px;
    }
    ::-webkit-scrollbar-thumb:hover { background: var(--scroll-thumb-hover); }
  }

  @supports not selector(::-webkit-scrollbar) {
    :root { scrollbar-color: var(--scroll-thumb) var(--scroll-track); }
    :root, dialog, .arc-board { scrollbar-width: thin; }
  }
}

/* Shared text palette for all pages, including game feedback and dialogs. */
:root {
  --theme-ink: #f3cf80;
  --theme-ink-on-gold: #4b3109;
  --theme-correct-surface: #17382a;
  --theme-wrong-surface: #422333;
}
:root[data-theme="red"] {
  --theme-ink: #d1a373;
  --theme-ink-on-gold: #4e271c;
}
:root[data-theme="beige"] {
  --theme-ink: #251e19;
  --theme-ink-on-gold: #251e19;
  --theme-correct-surface: #d3e7d5;
  --theme-wrong-surface: #f0d5d9;
}

:root body,
:root body :where(*):not(svg, svg *) {
  color: var(--section-ink, var(--theme-ink)) !important;
}

:root body :where(input, textarea)::placeholder {
  color: var(--theme-ink) !important;
  opacity: .78;
}

/* Keep solid gold actions readable with a deeper shade of the same palette. */
:root body :is(.primary, a.game-launch, #competitionIntro.with-trivia-demo #competitionReady) {
  --section-ink: var(--theme-ink-on-gold);
}

:root body :is(
  #game #options button.correct,
  #competitionIntro .demo-answers [data-result="correct"],
  .quiz-rounds li[data-result="correct"],
  .memory-grid button[aria-pressed="true"]
) {
  background: var(--theme-correct-surface);
}
:root body :is(
  #game #options button.wrong,
  #competitionIntro .demo-answers [data-result="wrong"],
  .quiz-rounds li[data-result="wrong"]
) {
  background: var(--theme-wrong-surface);
}

:root[data-theme="beige"] body :is(.wallet-add, #profileComplete, #skipIntro) {
  background: var(--theme-field);
}
:root body .gold-help-button span { background: none; }
:root[data-theme="beige"] body .gold-help-button {
  background: linear-gradient(150deg,#ffe2a2,#ce9c4b);
}
#pictures svg text { fill: var(--theme-ink); }
:root[data-theme="beige"] #pictures svg g > circle { fill: var(--theme-field); }
