:root {
  --bg: #0d0b16;
  --panel: #1a1628;
  --fg: #f7f3ff;
  --muted: #d3cbe6;
  --line: #463d63;
  --accent: #ffcf4a;
  --accent-ink: #0d0b16;
  --focus: #ffe17a;
  --current: #2c2544;
  --score: #8fe3c8;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #faf8ff;
    --panel: #ffffff;
    --fg: #150f24;
    --muted: #3d3552;
    --line: #a59bbf;
    --accent: #5a2d91;
    --accent-ink: #ffffff;
    --focus: #1d3fb8;
    --current: #ece6f7;
    --score: #0b6650;
    color-scheme: light;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 20px;
  line-height: 1.5;
}

body { min-height: 100vh; }

h1 { font-size: 2.4rem; line-height: 1.15; margin: 0 0 0.5rem; letter-spacing: 0.01em; }
h2 { font-size: 1.4rem; margin: 0 0 0.6rem; }

.start, .game {
  max-width: 46rem;
  margin: 0 auto;
  padding: 2.5rem 16px 3rem;
}

.lead { font-size: 1.25rem; color: var(--muted); margin: 0 0 1.5rem; }
.load { color: var(--muted); min-height: 1.5em; }

.buttons { display: flex; flex-wrap: wrap; gap: 1rem; margin: 1rem 0 2rem; }

button {
  font: inherit;
  font-weight: 700;
  min-height: 3rem;
  padding: 0.6rem 1.4rem;
  border-radius: 0.6rem;
  border: 2px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
button + button { background: transparent; color: var(--fg); }

.games { margin: 0 0 1.5rem; padding-left: 1.2rem; }
.games li { margin: 0.35rem 0; }
.keys-intro { color: var(--muted); }

:focus-visible, .game:focus { outline: 3px solid var(--focus); outline-offset: 4px; }
.game:focus:not(:focus-visible) { outline-color: var(--line); }

/* the whole screen takes swipes and taps while a game is on */
.game {
  min-height: 100vh;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.hud { border-bottom: 2px solid var(--line); padding-bottom: 1rem; margin-bottom: 1.2rem; }
.hud .name { font-size: 1.6rem; font-weight: 700; margin: 0; }
.hud .numbers { margin: 0.3rem 0 0; font-size: 1.25rem; display: flex; flex-wrap: wrap; gap: 0.4rem 1.4rem; }
#hud-score { color: var(--score); font-weight: 700; }

.menu {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 0.8rem;
  padding: 1rem 1.2rem;
  margin-bottom: 1.2rem;
}
.menu ul { list-style: none; margin: 0; padding: 0; max-height: 60vh; overflow-y: auto; }
.menu li { padding: 0.45rem 0.7rem; border-radius: 0.4rem; border: 2px solid transparent; cursor: pointer; }
.menu li.current { background: var(--current); border-color: var(--focus); font-weight: 700; }
.menu ul:focus { outline: 3px solid var(--focus); outline-offset: 4px; }

.log { list-style: none; margin: 0; padding: 0; color: var(--muted); }
.log li { padding: 0.2rem 0; border-bottom: 1px solid var(--line); }
.log li:last-child { color: var(--fg); font-weight: 700; }

.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;
}

[hidden] { display: none !important; }

@media (max-width: 520px) {
  html, body { font-size: 18px; }
  h1 { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; transition: none !important; }
}

@media (forced-colors: active) {
  .menu li.current { border-color: Highlight; }
}
