* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0c0c0e;
  --panel: #141417;
  --border: #26262b;
  --text: #d6d6dc;
  --muted: #76767e;
  --accent: #ffffff;
  --warn: #c9a227;
  --miss: #8a4a4a;
  --overlay: rgba(20, 20, 23, 0.96);
  --scrim: rgba(12, 12, 14, 0.8);
  /* Width of the centred column the top bar and footer content sit in. */
  --content-width: 1280px;
  /* UI and display (wordmark, headings) fonts — one place to swap them. */
  --font-ui: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  --font-display: 'JetBrains Mono', ui-monospace, Consolas, monospace;
  /* One step dimmer than muted, for hover states. Recomputed per theme. */
  --dim: color-mix(in srgb, var(--muted) 55%, var(--bg));
}

html,
body,
#root {
  height: 100%;
}

/* Themed scrollbar, so it doesn't default to the OS's light/grey chrome. */
* {
  scrollbar-color: var(--border) transparent;
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--dim);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  overflow: hidden;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100%;
}

/* top bar */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  /* Content sits in a centred column (like Monkeytype), so the wordmark is
     set in from the edge on wide screens; 24px minimum on narrow ones. */
  padding: 0 max(24px, calc((100% - var(--content-width)) / 2));
  height: 52px;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 22px;
}

.wordmark {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
  user-select: none;
}

/* In the top bar the wordmark is the home link. */
button.wordmark {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  text-align: left;
}

button.wordmark:hover {
  opacity: 0.7;
}

/* Account menu: opens on hover or keyboard focus. */
.navmenu {
  position: relative;
}

.navmenu-list {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 20;
  min-width: 120px;
  padding: 4px 0;
  background: var(--panel);
  border: none;
  flex-direction: column;
}

/* Menus in the left nav ("more") open rightwards, laid out in a row. */
.topbar-left .navmenu-list {
  left: 0;
  right: auto;
  flex-direction: row;
  padding: 0 4px;
}

.navmenu:hover .navmenu-list,
.navmenu:focus-within .navmenu-list {
  display: flex;
}

.navmenu-list .navlink {
  text-align: left;
  white-space: nowrap;
  padding: 7px 14px;
}

.wordmark span {
  color: var(--muted);
}

.topnav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.navlink {
  background: none;
  border: none;
  color: var(--muted);
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}

.navlink:hover:not(:disabled) {
  color: var(--dim);
}

.navlink.active:hover:not(:disabled) {
  color: var(--dim);
}

.navlink.active {
  color: var(--dim);
}

.navlink:disabled {
  cursor: default;
  opacity: 0.4;
}

a.navlink {
  display: inline-block;
  text-decoration: none;
}

/* game mode pills (first item on the config bar) */

.modefield {
  margin-right: 14px;
}

/* Mode settings flow after the fixed mode pills and wrap beneath themselves. */
.config-settings {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 12px;
  min-width: 0;
}

.slider.cslider {
  width: 64px;
  align-self: center;
}

.cval {
  color: var(--text);
  font-size: 10px;
  min-width: 3em;
}

/* Compact config bar: everything at roughly half the old footprint. */
.configbar {
  gap: 8px;
}

.config-settings {
  gap: 8px;
}

.configbar .pill {
  padding: 3px 7px;
  font-size: 10.5px;
}

.configbar .cfield {
  gap: 2px;
}

.configbar .cfield label {
  font-size: 9px;
}

.configbar .hgroup {
  gap: 5px;
}

.configbar .wsel {
  padding: 3px 7px;
  font-size: 11px;
  color: var(--dim);
}

/* Play bar: no white — slider handles and values use the selected dim shade. */
.configbar .slider::-webkit-slider-thumb,
.configbar .slider:hover::-webkit-slider-thumb {
  background: var(--dim);
}

.configbar .slider::-moz-range-thumb,
.configbar .slider:hover::-moz-range-thumb {
  background: var(--dim);
}

.configbar .cval,
.configbar .pb b {
  color: var(--dim);
}

.configbar .wsel .caret {
  font-size: 9px;
}

.configbar .cnum {
  font-size: 10px;
}

.configbar .cnum input {
  width: 42px;
  padding: 3px 5px;
  font-size: 10.5px;
}

/* Selected states: text and marker both in the theme's dim shade. On the
   play bar a line slides under the selected option (thicker for the mode);
   on the settings page selected is just the light text. */
.pillgroup {
  position: relative;
}

.pill-line {
  display: none;
}

.configbar .pill-line {
  display: block;
  position: absolute;
  left: 0;
  bottom: 0;
  height: 2px;
  background: var(--dim);
  pointer-events: none;
}

.configbar .modefield .pill-line {
  height: 3px;
}

.configbar .pill-line.slide {
  transition:
    transform 0.18s ease-out,
    width 0.18s ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .configbar .pill-line.slide {
    transition: none;
  }
}

/* Settings page: selected is just the light shade (no brackets). */
.settings-page .pill.active,
.settings-page .pill.active:hover {
  color: var(--text);
}

.configbar .pb,
.configbar .unranked {
  font-size: 10px;
  padding-bottom: 4px;
}

.unranked {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 8px;
  cursor: help;
}

.pill {
  background: none;
  border: none;
  color: var(--muted);
  padding: 7px 16px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
}

.pill:hover {
  color: var(--dim);
}

.pill.active:hover {
  color: var(--dim);
}

/* Selected = the same dim as hover, so nothing on the bars glares. */
.pill.active {
  color: var(--dim);
}

/* config bar */

/* Mode pills pinned at the left so they never move; settings fill the rest. */
.configbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  /* Left edge lines up with the wordmark (same rule as .topbar). */
  padding: 6px 24px 10px max(24px, calc((100% - var(--content-width)) / 2));
  flex-shrink: 0;
}

.cfield {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cfield label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pb {
  color: var(--muted);
  font-size: 12px;
  padding-bottom: 8px;
  margin-left: 10px;
}

.pb b {
  color: var(--text);
  font-weight: 600;
}

.pillgroup {
  display: flex;
  background: var(--panel);
  border: none;
}

.hgroup {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cnum {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.cnum input {
  width: 58px;
  background: var(--panel);
  border: none;
  color: var(--text);
  padding: 6px 7px;
  font-size: 13px;
  font-family: inherit;
}

.wfield {
  position: relative;
}

.wsel {
  padding: 7px 12px;
  font-size: 14px;
  color: var(--accent);
  background: var(--panel);
  border: none;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.wsel .caret {
  color: var(--muted);
  font-size: 11px;
}

.wdrop {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  display: flex;
  flex-direction: column;
  white-space: nowrap;
  background: var(--panel);
  border: none;
  z-index: 5;
}

/* play area */

.playwrap {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.playwrap.offstage {
  display: none;
}

.play-area {
  position: relative;
  flex: 1;
  min-height: 0;
}

.play-area canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.hud {
  position: absolute;
  top: 10px;
  left: 12px;
  color: var(--muted);
  font-size: 12px;
  pointer-events: none;
  user-select: none;
}

.hint {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 13px;
  pointer-events: none;
  user-select: none;
}

.warning {
  position: absolute;
  top: 10px;
  right: 196px;
  color: var(--warn);
  font-size: 12px;
  pointer-events: none;
}

/* Lock-in: while a test runs with the mouse captured, everything but the
   game fades away quickly; it fades back with the results or on Esc. */
.topnav,
.configbar,
.botbar,
.quickbox,
.hint,
.hud,
.start-btn {
  transition: opacity 0.18s ease-out;
}

/* The wordmark stays; only the nav links beside it fade. */
.app.locked-in .topbar .topnav,
.app.locked-in .configbar,
.app.locked-in .botbar,
.app.locked-in .quickbox,
.app.locked-in .hint,
.app.locked-in .start-btn {
  opacity: 0;
  pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
  .topnav,
  .configbar,
  .botbar,
  .quickbox,
  .hint,
  .hud,
  .start-btn {
    transition: none;
  }
}

/* in-play overlays */

/* Start test sits centred below the wall. */
.start-btn {
  position: absolute;
  bottom: 56px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: none;
  color: var(--text);
  font-size: 13px;
  padding: 7px 16px;
}

.start-btn:hover {
  color: var(--muted);
}

/* Mode pills' caption: which of "wall test" / "practice" is picked. */
.quickbox {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 190px;
  background: var(--overlay);
  border: none;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.qrow {
  display: flex;
  align-items: center;
  gap: 8px;
}

.qrow label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  width: 34px;
  flex-shrink: 0;
}

.qfield {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.qfield label {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.quickbox .pillgroup {
  flex-wrap: wrap;
}

.quickbox .pill {
  padding: 5px 8px;
  font-size: 11px;
}

.qmore {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 11px;
  text-decoration: underline;
  text-align: center;
  padding: 2px 0 0;
}

.qmore:hover {
  color: var(--dim);
}

.qrow input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: none;
  color: var(--text);
  padding: 5px 7px;
  font-size: 13px;
  font-family: inherit;
}

.qderived {
  color: var(--muted);
  font-size: 11px;
}

.qderived b {
  color: var(--text);
}

.quickbox button {
  padding: 6px 10px;
  font-size: 12px;
}

/* pages (settings / info / leaderboards) */

.page {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 28px 24px 48px;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
}

.page h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
  margin-bottom: 26px;
}

.page section {
  margin-bottom: 34px;
}

.page section h2 {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.setrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.setinfo {
  flex: 1;
}

.setname {
  font-size: 14px;
  color: var(--text);
}

.setdesc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin-top: 2px;
}

.setdesc b {
  color: var(--text);
}

.setrow input[type='number'],
.setrow input[type='text'],
.setrow input[type='email'] {
  background: var(--panel);
  border: none;
  color: var(--text);
  padding: 7px 9px;
  font-size: 14px;
  font-family: inherit;
  width: 140px;
}

.setrow input:focus {
  outline: 1px solid var(--muted);
}

/* settings page */

/* Full width like the info page: content lines up with the top bar's edges. */
.page.settings-page {
  max-width: none;
  padding-left: max(24px, calc((100% - var(--content-width)) / 2));
  padding-right: max(24px, calc((100% - var(--content-width)) / 2));
}

.settings-layout {
  display: flex;
  gap: 34px;
  align-items: flex-start;
}

.settings-nav {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 120px;
}

.settings-nav .navlink {
  text-align: left;
  padding: 5px 0;
}

.settings-body {
  flex: 1;
  min-width: 0;
}

.settings-search {
  width: 100%;
  background: var(--panel);
  border: none;
  color: var(--text);
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  margin-bottom: 26px;
}

.settings-search:focus {
  outline: 1px solid var(--muted);
}

.settings-body section {
  scroll-margin-top: 12px;
}

.xhair-preview {
  background: var(--sky, var(--bg));
  border: none;
  display: block;
}

/* Flat sliders: a thin square track and a small square handle — no curves. */
.slider {
  width: 160px;
  height: 14px;
  margin: 0;
  background: none;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}

.slider::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--border);
  border-radius: 0;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 6px;
  height: 12px;
  margin-top: -5px;
  background: var(--text);
  border: none;
  border-radius: 0;
}

.slider::-moz-range-track {
  height: 2px;
  background: var(--border);
  border-radius: 0;
}

.slider::-moz-range-progress {
  height: 2px;
  background: var(--muted);
}

.slider::-moz-range-thumb {
  width: 6px;
  height: 12px;
  background: var(--text);
  border: none;
  border-radius: 0;
}

.slider:hover::-webkit-slider-thumb {
  background: var(--accent);
}

.slider:hover::-moz-range-thumb {
  background: var(--accent);
}

.swatch {
  width: 34px;
  height: 32px;
  padding: 0;
  border: none;
  background: var(--panel);
  cursor: pointer;
}

button.danger {
  color: var(--muted);
}

button.danger:hover {
  color: var(--dim);
}

button.danger.armed {
  color: var(--miss);

}

.settings-foot {
  margin-top: 8px;
}

@media (max-width: 760px) {
  .settings-nav {
    display: none;
  }
}

/* account: sign in / sign up */

.auth-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 40px;
  max-width: 680px;
}

.auth-col {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-col h2 {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-bottom: 1px solid var(--border);
  padding-bottom: 6px;
}

.auth-col label {
  display: flex;
  flex-direction: column;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.auth-col input {
  background: var(--panel);
  border: none;
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
  font-family: inherit;
}

.auth-col input:focus {
  outline: 1px solid var(--muted);
}

.auth-col > button[type='submit'] {
  text-align: center;
}

.auth-links {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

.auth-links .inline-link {
  color: var(--muted);
  font-size: 12px;
}

.auth-links .inline-link:hover {
  color: var(--dim);
}

.steam-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 30px;
  max-width: 680px;
}

.steam-btn {
  padding: 10px 18px;
  color: var(--accent);

  text-align: center;
}

.muted-link {
  color: var(--muted);
  font-size: 12px;
}

/* popup */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: var(--scrim);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal {
  background: var(--panel);
  border: none;
  width: 100%;
  max-width: 420px;
  padding: 22px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--accent);
}

.modal-body {
  color: var(--text);
  font-size: 13px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 4px;
}

/* Buttons inside panel-coloured boxes take the page shade to stand out. */
.modal-actions button,
.quickbox button {
  background: var(--bg);
}

.soon {
  background: var(--panel);
}

.xhair-preview {
  background: var(--panel);
}

.modal-actions button:first-child {

  color: var(--accent);
}

/* support */

.foot-link,
.inline-link {
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  cursor: pointer;
}

.foot-link {
  color: var(--muted);
  font-size: 12px;
}

.foot-link.active {
  color: var(--accent);
}

.foot-link:hover {
  color: var(--dim);
}

.inline-link {
  color: var(--text);
  font-size: inherit;
  text-decoration: underline;
}

.soon {
  color: var(--muted);
  font-size: 12px;
  border: none;
  padding: 6px 10px;
  white-space: nowrap;
}

.support-note {
  margin-top: 10px;
}

/* Results cards ignore the pointer so the canvas keeps clicks; the nudge
   opts back in (clickable once the mouse is released with Esc). */
.results .nudge {
  pointer-events: auto;
  background: none;
  border: none;
  padding: 0;
  color: var(--muted);
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
}

.results .nudge:hover {
  color: var(--dim);
}

/* info page */

/* Full width: the scroll area spans the window (scrollbar at the window's
   edge) and the content lines up with the top bar's edges. */
.page.info-page {
  max-width: none;
  padding-left: max(24px, calc((100% - var(--content-width)) / 2));
  padding-right: max(24px, calc((100% - var(--content-width)) / 2));
}

/* Creation banner: the figure lies on the first stat card, so the banner sits
   flush on the stats row (no bottom margin, nothing faded at the bottom). */
.creation-banner {
  position: relative;
  margin: 0 0 24px;
  pointer-events: none;
}

.creation-banner svg {
  display: block;
  width: 100%;
  height: auto;
}

.creation-spray {
  fill: var(--accent);
}

/* Title sits bottom-right, clear of the hand. */
.creation-overlay {
  position: absolute;
  right: 0;
  bottom: 18px;
}

.creation-overlay h1 {
  margin: 0;
}

.site-numbers {
  margin-bottom: 40px;
}

.big-counters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
}

/* Stats: plain numbers in a row under the banner. */
.big-counter {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 0;
}

.big-counter b {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.big-counter span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.site-sub,
.site-quip,
.site-you {
  margin-top: 14px;
  font-size: 14px;
  color: var(--text);
}

.site-quip {
  color: var(--muted);
  font-style: italic;
}

.site-you b {
  color: var(--accent);
}

.prose h2 {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 10px;
}

/* stats page */

.stats-page {
  max-width: 980px;
}

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
}

.tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  border: none;
  background: var(--panel);
  padding: 16px 20px;
}

.tile b {
  font-family: var(--font-display);
  font-size: 26px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.tile span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.activity-grid {
  display: block;
  width: 100%;
  max-width: 560px;
  height: auto;
  margin-top: 10px;
}

.activity-legend {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 11px;
}

.activity-key {
  width: 10px;
  height: 10px;
  display: inline-block;
}

.progress-pick {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 10px 0 14px;
}

.progress-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  align-items: baseline;
  color: var(--muted);
  font-size: 12px;
}

.progress-summary b {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
  margin-right: 4px;
}

.progress-summary .muted {
  font-size: 11px;
}

.chart-wrap {
  margin: 14px 0 4px;
  max-width: 560px;
}

.chart-wrap.big {
  max-width: none;
}

.chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid {
  stroke: var(--border);
  stroke-width: 1;
}

.chart-tick {
  fill: var(--muted);
  font-size: 10px;
  font-family: inherit;
}

.chart-line {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-linejoin: round;
}

.chart-attempt {
  fill: var(--muted);
  opacity: 0.55;
}

.chart-pb {
  fill: var(--accent);
  stroke: var(--bg);
  stroke-width: 2;
}

.chart-label {
  fill: var(--text);
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
}

.chart-xhair {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.chart-caption {
  color: var(--muted);
  font-size: 11px;
  margin-top: 4px;
  min-height: 15px;
}

.chart-legend {
  display: flex;
  gap: 16px;
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.key-dot {
  width: 4px;
  height: 4px;
  background: var(--muted);
  opacity: 0.55;
}

.key-line {
  width: 14px;
  height: 2px;
  background: var(--accent);
}

.key-pb {
  width: 8px;
  height: 8px;
  background: var(--accent);
}

.pb-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.pb-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 12px 14px;
  background: var(--panel);
  border: none;
  text-align: left;
  cursor: pointer;
}

.pb-card:hover {
  opacity: 0.7;
}

/* Selected card: an accent bar along the bottom instead of an outline. */
.pb-card.active {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.pb-card-mode {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.pb-card-name {
  font-size: 12px;
  color: var(--text);
}

.pb-card b {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--accent);
  font-weight: 700;
}

.pb-card-meta {
  font-size: 11px;
  color: var(--muted);
}

.spark {
  width: 100%;
  height: 30px;
  display: block;
}

.spark .chart-line {
  stroke-width: 1.5;
}

/* leaderboards */

.beta-tag {
  font-family: var(--font-ui);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  background: var(--panel);
  padding: 3px 7px;
  vertical-align: middle;
}

.lb-beta {
  color: var(--muted);
  font-size: 12px;
  margin: -14px 0 22px;
}

.lb-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 18px;
  align-items: flex-end;
}

.lb-scroll {
  overflow-x: auto;
}

.lb {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.lb th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 0 8px 8px;
  border-bottom: 1px solid var(--border);
}

.lb td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}

.lb .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.lb .rank {
  color: var(--muted);
  width: 36px;
  font-variant-numeric: tabular-nums;
}

.lb tbody tr:first-child td {
  color: var(--accent);
}

.lb .muted {
  color: var(--muted);
}

.lb-note {
  margin-top: 14px;
}

.lb-player {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--text);
  cursor: pointer;
}

.lb-player:hover,
.lb-player:focus-visible {
  color: var(--dim);
}

.prose {
  max-width: 560px;
  font-size: 13px;
  line-height: 1.7;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prose a {
  color: var(--text);
}

button {
  background: var(--panel);
  border: none;
  color: var(--text);
  padding: 9px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

/* Hovering dims the text rather than brightening it. :where() keeps this
   default at zero specificity so per-component hover rules always win. */
:where(button:hover:not(:disabled)) {
  color: var(--muted);
}

/* Square keyboard-focus ring instead of the browser's rounded default. */
button:focus-visible {
  outline: 1px solid var(--muted);
  outline-offset: 2px;
}

select {
  background: var(--panel);
  border: none;
  color: var(--text);
  padding: 7px 9px;
  font-size: 14px;
  font-family: inherit;
}

/* footer */

.botbar {
  /* Three columns so the centre item sits in the true middle. */
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  padding: 0 max(24px, calc((100% - var(--content-width)) / 2));
  height: 36px;
  flex-shrink: 0;
}

.foot-centre {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.foot-right {
  justify-self: end;
}

.foot-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.botbar a {
  color: var(--muted);
  font-size: 12px;
  text-decoration: none;
}

.botbar a:hover {
  color: var(--dim);
}

.botbar .navlink {
  padding: 0;
  font-size: 12px;
}

.theme-pick {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.theme-pick select {
  padding: 2px 6px;
  font-size: 12px;
}

/* theme picker (footer) + swatches */

.swatches {
  display: inline-flex;
  margin-right: 6px;
  vertical-align: middle;
}

/* One square split diagonally: background top-left, accent bottom-right. */
.swatches i {
  width: 10px;
  height: 10px;
  display: inline-block;
  /* Hairline so a swatch matching the background still shows. */
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--muted) 40%, transparent);
}

.theme-pill {
  display: inline-flex;
  align-items: center;
}

.theme-picker {
  position: relative;
}

.theme-current {
  display: inline-flex;
  align-items: center;
  background: none;
  color: var(--muted);
  font-size: 12px;
  padding: 2px 0;
}

.theme-list {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  z-index: 25;
  list-style: none;
  background: var(--panel);
  padding: 4px 0;
  min-width: 130px;
}

.theme-list.wide {
  min-width: 220px;
}

.theme-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  color: var(--text);
  font-size: 12px;
  padding: 6px 12px;
  white-space: nowrap;
}

.theme-option.active {
  color: var(--dim);
}

.theme-option.disabled {
  color: var(--muted);
  cursor: default;
}

.theme-option.disabled:hover {
  color: var(--muted);
}

.theme-option:hover,
.theme-current:hover {
  color: var(--dim);
}

.audio-blurb {
  color: var(--muted);
  font-size: 11px;
  margin-left: 8px;
}

.audio-note {
  color: var(--muted);
  font-size: 11px;
  padding: 6px 12px 2px;
}

.foot-note {
  color: var(--muted);
  font-size: 11px;
}

.about-fine {
  color: var(--muted);
  font-size: 11px;
}

/* desktop-only note (small screens) */

.mobile-note {
  display: none;
}

@media (max-width: 760px) {
  .mobile-note {
    position: fixed;
    inset: 0;
    z-index: 10;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 32px;
    text-align: center;
  }

  .mobile-note p {
    color: var(--muted);
    font-size: 14px;
    line-height: 1.7;
    max-width: 320px;
  }

  /* Stopgap until a real phone mode: on the app, the note is all there is,
     so nothing wider than the screen sits behind it (which made phones zoom
     out and scroll sideways). */
  .app:has(> .mobile-note) > :not(.mobile-note) {
    display: none;
  }

  /* The static /spray/ pages are readable on phones: let the top bar wrap. */
  .topbar {
    flex-wrap: wrap;
    height: auto;
    padding-top: 10px;
    padding-bottom: 10px;
    row-gap: 6px;
  }

  .topbar-left,
  .topnav {
    flex-wrap: wrap;
  }
}

/* results */

.results {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--overlay);
  border: none;
  padding: 22px 26px;
  min-width: 380px;
  pointer-events: none;
}

.results h2 {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
}

.results-metrics {
  display: flex;
  gap: 22px;
  font-size: 15px;
  margin-bottom: 10px;
}

.results-metrics b {
  color: var(--accent);
  font-size: 19px;
}

.results-hint {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

/* benchmark */

.benchmark-panel {
  text-align: center;
}

.benchmark-panel .benchmark-start {
  pointer-events: auto;
  position: static;
  transform: none;
  display: inline-block;
  margin: 10px 0;
}

.benchmark-score {
  font-size: 48px;
  font-weight: 700;
  color: var(--accent);
  margin: 6px 0 14px;
}

.practice-score {
  margin: 4px 0 2px;
}

.practice-score b {
  font-size: 40px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.practice-score span {
  font-size: 15px;
  color: var(--muted);
  margin-left: 2px;
}

.benchmark-progress {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* sens finder */

.sens-panel {
  max-width: 460px;
}

.sens-start {
  pointer-events: auto;
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin: 10px 0 4px;
}

.sens-start input {
  width: 72px;
  margin-left: 8px;
  background: var(--panel);
  border: none;
  color: var(--text);
  font: inherit;
  padding: 4px 6px;
}

.sens-pair {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 6px 0 12px;
}

.sens-pick {
  pointer-events: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--panel);
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  padding: 12px 10px;
  cursor: pointer;
}

.sens-pick b {
  color: var(--text);
  font-size: 26px;
  font-weight: 700;
}

.sens-pick.better b,
.sens-pick.better span:first-child {
  color: var(--accent);
}

.sens-pick:hover b {
  color: var(--dim);
}

.sens-log {
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0 10px;
  font-variant-numeric: tabular-nums;
}

.sens-log .on {
  color: var(--text);
}

/* pattern info (arriving from a /spray/<gun>/ page) */

.pattern-info {
  position: absolute;
  top: 10px;
  left: 12px;
  width: 210px;
  background: var(--overlay);
  border: none;
  padding: 14px;
}

.pattern-info-close {
  position: absolute;
  top: 6px;
  right: 8px;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  line-height: 1;
  padding: 4px;
  cursor: pointer;
}

.pattern-info-close:hover {
  color: var(--dim);
}

.pattern-info h2 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin: 0 18px 8px 0;
}

.pattern-info-svg svg {
  display: block;
  width: 100%;
  height: auto;
}

.pattern-info-svg svg polyline {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5;
}

.pattern-info-svg svg rect {
  fill: var(--text);
}

.pattern-info-facts {
  display: flex;
  gap: 14px;
  font-size: 11px;
  color: var(--muted);
  margin: 8px 0;
}

.pattern-info-facts b {
  color: var(--accent);
  font-size: 13px;
}

.pattern-info ol {
  padding-left: 16px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 10px;
}

.pattern-info ol li {
  margin-bottom: 6px;
}

.pattern-info-link {
  display: block;
  font-size: 11px;
  color: var(--muted);
  text-decoration: underline;
}

.pattern-info-link:hover {
  color: var(--dim);
}

.error-chart {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 64px;
  margin: 10px 0;
  border-bottom: 1px solid var(--border);
}

.delta-chart {
  display: flex;
  gap: 2px;
  height: 84px;
  margin: 10px 0;
}

.dcol {
  flex: 1;
  min-width: 6px;
  display: flex;
  flex-direction: column;
}

.dhalf {
  flex: 1;
  display: flex;
  justify-content: center;
}

.dhalf.top {
  align-items: flex-end;
}

.dhalf.bottom {
  align-items: flex-start;
  border-top: 1px solid var(--muted);
}

.dbar {
  width: 100%;
  background: var(--miss);
}

.dbar.hit {
  background: var(--muted);
}

.newpb {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  color: var(--accent);
  letter-spacing: -0.01em;
  margin-bottom: 8px;
}

.error-chart .bar {
  flex: 1;
  min-width: 4px;
  background: var(--miss);
}

.error-chart .bar.hit {
  background: var(--muted);
}

.landing-row {
  display: flex;
  gap: 10px;
  margin: 10px 0 8px;
}

.landing-col {
  width: 170px;
  flex-shrink: 0;
}

.landing-col .results-hint {
  margin-top: 6px;
}

.landing-svg {
  background: var(--panel);
  padding: 10px;
  width: 170px;
  height: 170px;
  box-sizing: border-box;
}

.landing-svg svg {
  display: block;
  width: 100%;
  height: 100%;
}

.landing-svg svg polyline {
  fill: none;
  stroke: var(--border);
  stroke-width: 1.5;
}

.landing-svg svg rect.shape {
  fill: var(--border);
}

.landing-svg svg rect.landing {
  fill: var(--miss);
}

.landing-svg svg rect.landing.hit {
  fill: var(--text);
}

.landing-svg svg rect.centre {
  fill: var(--border);
}

.landing-svg svg rect.target {
  fill: none;
  stroke: var(--border);
  stroke-width: 1;
}

/* duel (friends-only flick duel, DuelPanel.tsx) */

.duel-panel {
  text-align: center;
  pointer-events: auto;
}

.duel-panel .duel-btn {
  position: static;
  transform: none;
  display: inline-block;
  margin: 12px 0 8px;
}

.duel-panel .duel-btn:disabled {
  color: var(--dim);
  cursor: default;
}

.duel-invite {
  margin-bottom: 14px;
}

.duel-link {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.duel-link input,
.duel-row input {
  flex: 1;
  min-width: 0;
  background: var(--bg);
  border: none;
  color: var(--text);
  padding: 6px 8px;
  font-size: 13px;
  font-family: inherit;
}

.duel-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 6px 0;
  font-size: 13px;
}

.duel-row label {
  color: var(--muted);
  font-size: 12px;
  text-align: left;
  min-width: 80px;
}

.duel-players {
  margin-top: 14px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.duel-verdict {
  font-size: 40px;
  font-weight: 700;
  color: var(--accent);
  margin: 4px 0 6px;
}

.duel-score {
  font-size: 15px;
  margin-bottom: 12px;
}

.duel-score b {
  color: var(--accent);
  font-size: 19px;
}

.duel-metrics {
  justify-content: center;
}

.duel-note {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  color: var(--warn);
  font-size: 12px;
}

/* duel player colours: host p1, guest p2 (theme tokens) */
.duel-p1,
.duel-p1 b {
  color: var(--p1);
}

.duel-p2,
.duel-p2 b {
  color: var(--p2);
}

/* Profile: one personal best at a time, picked with the menus above it. */
.profile-best {
  margin-top: 22px;
  padding: 18px 20px;
  background: var(--panel);
}

.profile-setup {
  font-size: 12px;
  color: var(--muted);
}

.profile-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 14px 36px;
  margin: 12px 0 10px;
}

.profile-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-stat b {
  font-family: var(--font-display);
  font-size: 40px;
  line-height: 1;
  color: var(--accent);
  font-weight: 700;
}

.profile-stat em {
  font-style: normal;
  font-size: 20px;
  color: var(--text);
}

.profile-stat span,
.profile-date {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Result card replay (ReplayPlayer.tsx). */
.replay {
  margin: 12px 0 8px;
  width: 360px;
  max-width: 100%;
}

.replay-canvas {
  display: block;
  max-width: 100%;
}

.replay-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}

.replay-scrub {
  flex: 1;
  min-width: 60px;
}

.replay-time {
  font-size: 11px;
  color: var(--muted);
  min-width: 36px;
  text-align: right;
}

/* Result card with a replay: numbers and graphs left, replay right. */
.results.results-split {
  display: flex;
  align-items: flex-start;
  gap: 24px;
  width: max-content;
  max-width: calc(100vw - 48px);
}

.results-main {
  min-width: 380px;
}

.results-side {
  flex-shrink: 0;
}

/* The card ignores clicks (they belong to the game); the replay needs them. */
.replay {
  pointer-events: auto;
}

.results-side .replay {
  margin: 0;
}
