:root[data-theme="light"] {
  --bg: #f7f8f2;
  --surface: #ffffff;
  --surface-2: #e9eee4;
  --line: #d5ded0;
  --text: #202d24;
  --muted: #606f62;
  --mint: #426f44;
  --orange: #a34f20;
  color-scheme: light;
}

/* Keep the accent readable on both the pale page and filled buttons. */
:root[data-theme="light"] :is(.primary-button, .hero-search button, .toast) { color: #fff; }
:root[data-theme="light"] .primary-button:hover { background: #365d38; }
:root[data-theme="light"] :is(.hero-search, .outline-button) { border-color: #a8b9a1; }
:root[data-theme="light"] .outline-button:hover { border-color: var(--mint); }
:root[data-theme="light"] .hero-visual { background-image: radial-gradient(#c6d2bd 1px, transparent 1px); }
:root[data-theme="light"] .source-label { color: var(--mint); }
:root[data-theme="light"] kbd { background: var(--surface-2); border-color: #a8b9a1; }
:root[data-theme="light"] .compatibility-note { background: #426f440a; }
:root[data-theme="light"] .platform-arcade .console-symbol,
:root[data-theme="light"] .platform-gba .console-symbol { color: #7856a4; }
:root[data-theme="light"] .platform-snes .console-symbol { color: #84781e; }
:root[data-theme="light"] .platform-nds .console-symbol { color: #356c87; }
:root[data-theme="light"] .platform-dos .console-symbol { color: #886637; }
:root[data-theme="light"] .platform-java .console-symbol { color: #357467; }
.card-play, .card-platform, .art-caption { color: #f2f2dc; }
:root[data-theme="light"] .player-overlay { background: var(--bg); }
:root[data-theme="light"] .player-pause { background: #f7f8f2ed; }
:root[data-theme="light"] .touch-controls :is(.dpad, .touch-middle) button {
  background: var(--surface-2);
  border-color: #a8b9a1;
}
:root[data-theme="light"] .player-stage[data-immersive] .touch-options { background: #fffffff2; }

.header-actions { display: flex; align-items: center; flex-shrink: 0; }
.header-saved { min-height: 44px; }
.header-saved-icon { width: 18px; height: 18px; flex-shrink: 0; }
.header-saved b { min-width: 20px; border-radius: 999px; text-align: center; }

/* A quiet utility row keeps preferences together below the footer links. */
.site-footer { background: color-mix(in srgb, var(--surface) 35%, var(--bg)); }
.footer-inner { display: block; padding-top: 36px; padding-bottom: max(24px, env(safe-area-inset-bottom, 0px)); }
.footer-main, .footer-bottom { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.footer-main { padding-bottom: 28px; }
.footer-brand { flex-shrink: 0; }
.footer-brand .brand-icon { font-size: 28px; margin-right: 5px; }
.footer-brand p { margin-top: 6px; font-size: 12px; }
.footer-links { flex-wrap: wrap; justify-content: flex-end; gap: 8px 24px; }
.footer-links a { display: inline-flex; align-items: center; min-height: 44px; }
.footer-bottom { border-top: 1px solid var(--line); padding-top: 20px; }
.footer-note { display: block; font-size: 11px; line-height: 1.6; }
.footer-preferences { display: flex; align-items: center; gap: 10px; }
.theme-picker { position: relative; }
.language-switch, .theme-picker summary {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 124px;
  min-height: 44px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  cursor: pointer;
  list-style: none;
  white-space: nowrap;
  touch-action: manipulation;
  transition: background-color 180ms ease, border-color 180ms ease, color 180ms ease;
}
.language-switch { justify-content: center; }
.language-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.theme-picker summary::-webkit-details-marker { display: none; }
.language-switch:hover, .theme-picker summary:hover, .theme-picker[open] summary {
  border-color: var(--mint);
  background: var(--surface-2);
  color: var(--mint);
}
.language-switch:hover .language-icon { color: inherit; }
.theme-icon { display: none; width: 18px; height: 18px; flex-shrink: 0; }
[data-theme-preference="dark"] .theme-picker summary .theme-icon-dark,
[data-theme-preference="light"] .theme-picker summary .theme-icon-light,
[data-theme-preference="system"] .theme-picker summary .theme-icon-system { display: block; }
.theme-picker [data-theme-label] { flex: 1; }
.theme-chevron { width: 14px; height: 14px; color: var(--muted); transform: rotate(180deg); transition: transform 180ms ease; }
.theme-picker[open] .theme-chevron { transform: rotate(0); }
.theme-menu {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  z-index: 20;
  width: 236px;
  max-width: calc(100vw - 32px);
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 16px 40px #0002;
  transform-origin: bottom right;
}
.theme-picker[open] .theme-menu { animation: theme-menu-enter 160ms ease-out; }
.theme-menu .theme-menu-title {
  margin: 0;
  padding: 8px 10px 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.3px;
  line-height: 1.5;
  text-transform: uppercase;
}
.theme-menu button {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 16px;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 56px;
  padding: 8px 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  text-align: left;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.5;
  touch-action: manipulation;
  transition: background-color 180ms ease, color 180ms ease;
}
.theme-menu button:hover { background: var(--surface-2); }
.theme-menu button:active { background: color-mix(in srgb, var(--mint) 16%, var(--surface)); }
.theme-menu button[aria-pressed="true"] { background: color-mix(in srgb, var(--mint) 10%, var(--surface)); }
.theme-option-icon {
  width: 32px;
  height: 32px;
  padding: 7px;
  border-radius: 9px;
  background: var(--surface-2);
  color: var(--muted);
}
.theme-menu button[aria-pressed="true"] .theme-option-icon {
  background: color-mix(in srgb, var(--mint) 14%, var(--surface));
  color: var(--mint);
}
.theme-option-copy { display: flex; flex-direction: column; gap: 2px; }
.theme-check { width: 16px; height: 16px; color: var(--mint); opacity: 0; }
.theme-menu button[aria-pressed="true"] .theme-check { opacity: 1; }
.theme-menu small { color: var(--muted); font-size: 12px; font-weight: 400; }
.theme-menu button:focus-visible { outline-offset: -2px; }

@keyframes theme-menu-enter {
  from { opacity: 0; transform: translateY(4px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .language-switch, .theme-picker summary, .theme-chevron, .theme-menu button { transition: none; }
  .theme-picker[open] .theme-menu { animation: none; }
}

@media (max-width: 900px) {
  .header-inner { flex-wrap: wrap; }
  .header-inner nav { order: 3; width: 100%; justify-content: center; }
  .footer-main { align-items: flex-start; flex-direction: column; gap: 16px; }
  .footer-links { justify-content: flex-start; }
}
@media (max-width: 600px) {
  .footer-inner { padding-top: 28px; }
  .footer-main { padding-bottom: 20px; gap: 12px; }
  .footer-links, html[lang="zh-CN"] .footer-links { gap: 0 20px; font-size: 12px; }
  .footer-bottom { align-items: flex-start; flex-direction: column; gap: 16px; padding-top: 20px; }
  .footer-preferences { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); width: 100%; }
  .footer-preferences > * { min-width: 0; }
  .theme-picker summary { width: 100%; min-width: 0; }
}
@media (max-width: 360px) {
  .header-inner .beta { display: none; }
  .header-inner .wordmark { font-size: 20px; }
  .header-inner .brand-icon { font-size: 24px; margin-right: 3px; }
  .header-saved { gap: 4px; }
}
