/*
 * Shared Gukhalo theme layer. Load after a page's own stylesheet.
 * New pages should use the shared palette variables (--ink, --muted, --purple-*).
 */
/* Use native system cursors for crisp, predictable rendering across devices. */
:root {
  color-scheme: light;
  --site-page-start: #faf8ff;
  --site-page-mid: #f2ebff;
  --site-page-end: #ffffff;
  --site-surface: rgba(255, 255, 255, 0.86);
  --site-surface-solid: #ffffff;
  --site-border: rgba(116, 52, 215, 0.14);
  --site-shadow: 0 25px 75px rgba(57, 22, 97, 0.15);
  --theme-toggle-bg: rgba(255, 255, 255, 0.9);
  --theme-toggle-border: #e8dcff;
  --theme-toggle-ink: #55239a;
}

html[data-theme="dark"] {
  color-scheme: dark;
  --purple-900: #f6f0ff;
  --purple-800: #e5d8f8;
  --purple-700: #d0b3ff;
  --purple-600: #b18aff;
  --purple-500: #c19bff;
  --purple-300: #81639f;
  --purple-200: #43324f;
  --purple-100: #251a30;
  --ink: #f6f0ff;
  --muted: #bcaecb;
  --white: #f6f0ff;
  --game-bg: #171020;
  --shadow: 0 30px 85px rgba(0, 0, 0, 0.38);
  --site-page-start: #110b18;
  --site-page-mid: #1a1025;
  --site-page-end: #100b17;
  --site-surface: rgba(29, 21, 40, 0.9);
  --site-surface-solid: #21172d;
  --site-border: rgba(193, 155, 255, 0.2);
  --site-shadow: 0 25px 75px rgba(0, 0, 0, 0.38);
  --theme-toggle-bg: rgba(37, 26, 48, 0.96);
  --theme-toggle-border: #4a365b;
  --theme-toggle-ink: #d0b3ff;
}

html { background: var(--site-page-mid); }
.card { position: relative; }
body { transition: background-color 180ms ease, color 180ms ease; }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--theme-toggle-border);
  border-radius: 14px;
  background: var(--theme-toggle-bg);
  color: var(--theme-toggle-ink);
  box-shadow: 0 8px 20px rgba(57, 22, 97, 0.1);
  cursor: pointer;
  transition: transform 160ms ease, background-color 180ms ease, border-color 180ms ease, color 180ms ease;
  -webkit-tap-highlight-color: transparent;
}
.theme-toggle:hover { transform: translateY(-2px); }
.theme-toggle:active { transform: translateY(0); }
.theme-toggle:focus-visible { outline: 3px solid rgba(141, 77, 242, 0.45); outline-offset: 3px; }
.theme-toggle svg { width: 21px; height: 21px; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-icon-sun { display: block; }
.theme-toggle-home { position: absolute; z-index: 3; top: 18px; right: 18px; }
.top-actions, .game-head-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex: 0 0 auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

html[data-theme="dark"] body {
  background: radial-gradient(ellipse at 82% 0%, rgba(116, 52, 215, 0.18), transparent 42%),
              linear-gradient(145deg, var(--site-page-start) 0%, var(--site-page-mid) 52%, var(--site-page-end) 100%);
}
html[data-theme="dark"] .blob { opacity: 0.22; }
html[data-theme="dark"] .grid {
  opacity: 0.25;
  background-image: linear-gradient(rgba(193, 155, 255, 0.09) 1px, transparent 1px),
                    linear-gradient(90deg, rgba(193, 155, 255, 0.09) 1px, transparent 1px);
}
html[data-theme="dark"] .card,
html[data-theme="dark"] .game-shell,
html[data-theme="dark"] .car-shell {
  border-color: var(--site-border);
  background: var(--site-surface);
  box-shadow: var(--site-shadow);
}
html[data-theme="dark"] .game-card {
  border-color: #3f2c50;
  background: #21172d;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.2);
}
html[data-theme="dark"] .game-card:hover {
  border-color: rgba(193, 155, 255, 0.48);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.3);
}
html[data-theme="dark"] .badge { background: #2b1d3a; border-color: #463257; }
html[data-theme="dark"] .footer-row,
html[data-theme="dark"] .game-foot,
html[data-theme="dark"] .game-footer,
html[data-theme="dark"] .control-note { color: #a99ab8; }
html[data-theme="dark"] .game-overlay { background: rgba(8, 4, 14, 0.88); }
html[data-theme="dark"] .score-panel { border-color: #44314f; background: #251a30; }
html[data-theme="dark"] .game-hint {
  border-color: #4a365b;
  background: rgba(31, 22, 43, 0.96);
  color: #d0b3ff;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.3);
}
html[data-theme="dark"] .close-game { border-color: #44314f; }
html[data-theme="dark"] .close-game:hover { background: #342342; }

html[data-theme="dark"] .stat { border-color: #44314f; background: #281d34; }
html[data-theme="dark"] .steer-button {
  border-color: #49365a;
  background: #261b32;
  color: #e8dcff;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.25);
}
html[data-theme="dark"] .steer-button:active { background: #342342; }
html[data-theme="dark"] .pause-label { background: rgba(37, 26, 48, 0.96); color: #f6f0ff; }
html[data-theme="dark"] .back-link { background: #2b1d3a; border-color: #49365a; }
html[data-theme="dark"] .start-button {
  background: #7434d7;
  color: #ffffff;
  box-shadow: 0 8px 0 #100b17, 0 15px 25px rgba(0, 0, 0, 0.32);
}
html[data-theme="dark"] .restart-button { background: #6f30ca; color: #ffffff; }
html[data-theme="dark"] .restart-button:hover { background: #8142dc; }

@media (max-width: 390px) {
  .theme-toggle { width: 40px; height: 40px; border-radius: 12px; }
  .theme-toggle-home { top: 14px; right: 14px; }
  .top-actions { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle, body { transition: none; }
}
