:root {
  color-scheme: light;
  --bg: #f1f1ec;
  --surface: #ffffff;
  --surface-soft: #e8eadf;
  --surface-raised: #ffffff;
  --text: #1d1e19;
  --muted: #686a5e;
  --line: #d9dacc;
  --brand: #bcee29;
  --brand-hover: #b0e51c;
  --brand-ink: #1c1e0f;
  --success: #117a47;
  --success-soft: #dff4e8;
  --warning: #9b5600;
  --warning-soft: #fff0d5;
  --danger: #b93442;
  --danger-soft: #fbe5e8;
  --focus: #1d1e19;
  --font-display: "Space Grotesk", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --shadow: 0 1px 2px rgba(29, 30, 25, 0.04), 0 16px 44px rgba(29, 30, 25, 0.07);
  --radius-lg: 32px;
  --radius-md: 22px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  padding: 24px 22px 64px;
  color: var(--text);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

::selection {
  background: color-mix(in srgb, var(--brand) 50%, transparent);
}

button,
input {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  transition:
    background-color 150ms ease,
    border-color 150ms ease,
    color 150ms ease,
    box-shadow 150ms ease,
    transform 70ms ease;
}

button:not(:disabled):active {
  transform: scale(0.97);
}

button:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

.wrap,
.appbar {
  width: 100%;
  max-width: 980px;
  margin-inline: auto;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-left: auto;
}

.helpbtn {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--text);
  background: var(--surface);
  font-size: 16px;
  font-weight: 600;
}

.helpbtn:hover {
  border-color: color-mix(in srgb, var(--muted) 55%, var(--line));
  background: var(--surface-soft);
}

.appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 34px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border-radius: 50%;
  color: var(--brand-ink);
  background: var(--brand);
  font-size: 17px;
  font-weight: 600;
}

/* Stacked two-line wordmark (MATH / MADics); tight leading pulls the two lines
   close together and holds the block vertically centred on the mark. */
.brand-word {
  line-height: 0.85;
}

.mainnav {
  display: flex;
  gap: 2px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  box-shadow: 0 8px 30px rgba(45, 45, 42, 0.06);
  backdrop-filter: blur(20px);
}

.mainnav button {
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 500;
}

.mainnav button.active {
  color: var(--brand-ink);
  background: var(--brand);
  font-weight: 600;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: enter 260ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.eyebrow,
.label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.hero {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  min-height: 320px;
  overflow: hidden;
  padding: 42px 46px;
  border: 1px solid color-mix(in srgb, var(--surface) 82%, var(--line));
  border-radius: 38px;
  background: linear-gradient(155deg, color-mix(in srgb, var(--brand) 13%, var(--surface-soft)), var(--surface-soft) 58%);
  box-shadow: var(--shadow);
}

.hero-copy {
  position: relative;
  z-index: 1;
  max-width: 650px;
}

/* Match the tagline exactly: same family (both inherit body), size and weight,
   with the eyebrow's uppercasing and tracking dropped. */
.hero .eyebrow {
  margin-bottom: 15px;
  font-size: 17px;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
  line-height: 0.2;
}

.hero h1 {
  max-width: 690px;
  font-family: var(--font-display);
  font-size: clamp(58px, 10vw, 96px);
  font-weight: 500;
  line-height: 0.92;
  letter-spacing: -0.015em;
}

.hero h1 .flash {
  display: block;
}

/* Space Grotesk ships upright only, so a real italic is unavailable. A fixed
   skew is used instead of font-style, which browsers synthesize inconsistently
   and at an angle steep enough to collide the D with the following i. Skewing
   does not change layout width, so the margins keep the leaning glyphs clear of
   their upright neighbours without opening a word-space. */
.wm-i {
  display: inline-block;
  margin-right: 0.07em;
  margin-left: 0.01em;
  font-style: normal;
  transform: skewX(-11deg);
}

/* The leading M is followed by the lowercase "ath", which needs no clearance —
   the trailing margin would just open a gap between M and a. */
.wm-lead {
  margin-right: 0;
  letter-spacing: -0.08em;
}

.hero .tagline {
  max-width: 470px;
  margin-top: 20px;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.5;
}

/* A second tagline line sits at natural line spacing, not a fresh block gap. */
.hero .tagline + .tagline {
  margin-top: 0;
}

.hero::after {
  content: "∞";
  position: absolute;
  top: 25px;
  right: 44px;
  color: var(--brand-ink);
  font-size: 138px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -12px;
}

.hero::before {
  content: "";
  position: absolute;
  top: 36px;
  right: 28px;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: var(--brand);
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: 27px;
}

.arcade-btn,
.startbtn,
.btnrow button {
  min-height: 52px;
  padding: 0 24px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
}

.arcade-btn {
  border: 0;
}

.arcade-btn.primary,
.startbtn,
.btn-primary {
  border: 0;
  color: var(--brand-ink);
  background: var(--brand);
}

.arcade-btn.primary:hover,
.startbtn:hover,
.btn-primary:hover {
  background: var(--brand-hover);
}

.arcade-btn.secondary,
.btn-ghost {
  border: 1px solid var(--line);
  background: var(--surface);
}

.arcade-btn.secondary:hover,
.btn-ghost:hover {
  background: var(--surface-soft);
}

.home-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.mini-card,
.quick-chip {
  min-height: 100px;
  padding: 20px 22px;
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: left;
}

.mini-card {
  color: var(--muted);
  font-size: 12px;
}

.mini-card strong {
  display: block;
  margin-top: 12px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.quick-settings {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.quick-chip {
  min-height: 48px;
  padding: 0 17px;
  border-radius: 999px;
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
}

.quick-chip:hover {
  border-color: color-mix(in srgb, var(--muted) 55%, var(--line));
}

.quick-chip span {
  color: var(--muted);
}

.daily-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* .daily-btn::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
} */

.challenge-note {
  display: none;
  margin-bottom: 12px;
  padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--line));
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--warning-soft);
  font-size: 13px;
}

.challenge-note.show {
  display: block;
}

.page-heading {
  margin: 8px 0 30px;
}

.page-heading h1 {
  font-family: var(--font-display);
  font-size: clamp(46px, 7vw, 72px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.03em;
}

.page-heading p {
  margin-top: 12px;
  color: var(--muted);
  font-size: 16px;
}

.card,
.results-hero {
  border: 1px solid color-mix(in srgb, var(--line) 72%, transparent);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.card {
  padding: 28px;
  margin-top: 16px;
}

#scr-setup .card {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 13px 32px;
  padding: 32px;
}

#scr-setup .setting-group {
  min-width: 0;
}

#scr-setup .setting-group.wide,
#scr-setup .startbtn,
#scr-setup .rules {
  grid-column: 1 / -1;
}

.label {
  margin: 14px 0 9px;
}

.label:first-child {
  margin-top: 0;
}

.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 5px;
  border-radius: 17px;
  background: var(--bg);
}

.seg button {
  flex: 1 1 auto;
  min-height: 42px;
  padding: 8px 12px;
  border: 0;
  border-radius: 13px;
  color: var(--muted);
  background: transparent;
  font-size: 14px;
  font-weight: 500;
}

.seg button:hover {
  color: var(--text);
}

.seg button.on {
  color: var(--brand-ink);
  background: var(--brand);
  font-weight: 600;
}

/* Score multiplier shown on the difficulty options. */
.seg button em {
  font-style: normal;
  font-weight: 600;
  opacity: .55;
}

.practice-note {
  margin-bottom: 14px;
  padding: 12px 16px;
  border: 1px solid color-mix(in srgb, var(--warning) 35%, var(--line));
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--warning-soft);
  font-size: 13px;
  text-align: center;
}

.names {
  display: none;
  gap: 8px;
  margin-top: 9px;
}

.names.show {
  display: flex;
}

.names input {
  min-width: 0;
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--bg);
}

.rules {
  display: grid;
  gap: 7px;
  padding-left: 19px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
  text-align: left;
}

.playtop {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.round-controls {
  display: flex;
  gap: 7px;
}

.quitbtn,
.controlbtn {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
}

.quitbtn:hover {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--line));
}

.controlbtn:hover {
  color: var(--text);
}

.hud {
  display: flex;
  gap: 8px;
}

.hud .stat {
  flex: 1;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: center;
}

.hud .stat .v {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.hud .stat .k,
.hud-player-name {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.hud .stat .v.neg {
  color: var(--danger);
}

.streak-hot {
  color: var(--warning);
}

.timetext {
  margin: 24px 0 9px;
  text-align: center;
  font-family: var(--font-display);
  font-size: 48px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.timerbar {
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-soft);
}

.timerbar .fill {
  height: 100%;
  border-radius: inherit;
  background: var(--brand);
  transition: width 100ms linear;
}

.timerbar .fill.low {
  background: var(--warning);
}

.lvlchip,
.hint {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.lvlchip {
  margin: 12px 0 8px;
}

.hint {
  margin-top: 10px;
}

.qcard {
  padding: 42px 30px 30px;
  border: 1px solid color-mix(in srgb, var(--line) 68%, transparent);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.qtext {
  font-family: var(--font-display);
  font-size: clamp(54px, 10vw, 82px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.025em;
}

.feedback {
  min-height: 27px;
  margin-top: 10px;
  font-size: 16px;
  font-weight: 600;
}

.feedback.good {
  color: var(--success);
}

.feedback.bad {
  color: var(--danger);
}

.feedback.warn {
  color: var(--warning);
}

.options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 18px;
}

.options button {
  position: relative;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  background: var(--bg);
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.options button:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--muted) 55%, var(--line));
  background: color-mix(in srgb, var(--surface) 45%, var(--bg));
}

.options button:disabled {
  cursor: default;
}

.options button .key {
  position: absolute;
  top: 7px;
  left: 10px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 500;
}

.options button.picked-good {
  border-color: var(--success);
  color: var(--success);
  background: var(--success-soft);
}

.options button.picked-bad {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--danger-soft);
}

.options button.reveal {
  outline: 2px solid var(--success);
  outline-offset: 2px;
}

.passbtn {
  width: 100%;
  margin-top: 13px;
  padding: 11px;
  border: 1px dashed var(--line);
  border-radius: 17px;
  color: var(--muted);
  background: transparent;
}

.passbtn:hover {
  color: var(--warning);
  border-color: var(--warning);
}

.qcard.flash-good {
  animation: flash-good 500ms ease-out;
}

.qcard.flash-bad {
  animation: flash-bad 500ms ease-out;
}

.qcard.streak-pop {
  animation: streak-pop 600ms ease-out;
}

@keyframes flash-good {
  0% { box-shadow: 0 0 0 3px var(--success); }
}

@keyframes flash-bad {
  0% { box-shadow: 0 0 0 3px var(--danger); }
}

@keyframes streak-pop {
  40% {
    transform: scale(1.018);
    box-shadow: 0 0 0 6px var(--warning-soft);
  }
}

.countdown,
.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  place-items: center;
  padding: 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(20px);
}

.countdown.show,
.modal-layer.show {
  display: grid;
}

.countdown span {
  display: grid;
  width: min(44vw, 220px);
  aspect-ratio: 1;
  place-items: center;
  border-radius: 50%;
  color: var(--brand-ink);
  background: var(--brand);
  font-family: var(--font-display);
  font-size: clamp(70px, 20vw, 128px);
  font-weight: 500;
  animation: count-in 450ms cubic-bezier(0.34, 1.4, 0.64, 1);
}

@keyframes count-in {
  from {
    opacity: 0;
    transform: scale(0.6);
  }
}

.modal {
  position: relative;
  width: min(100%, 430px);
  padding: 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.modal p {
  margin: 10px 0 23px;
  color: var(--muted);
  line-height: 1.5;
}

.modal-close {
  position: absolute;
  top: 15px;
  right: 15px;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: var(--surface);
  font-size: 22px;
  line-height: 1;
}

.modal-close:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.scoring-modal {
  text-align: left;
}

.scoring-modal h2 {
  padding-right: 40px;
}

.scoring-rules {
  display: grid;
  gap: 11px;
  margin: 22px 0;
  padding-left: 19px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.scoring-rules li::marker {
  color: var(--brand-hover);
}

.score-formula {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.score-formula span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.score-formula strong {
  font-size: 14px;
  font-weight: 600;
}

.scoring-modal .score-formula ~ p {
  margin: 13px 0 0;
  font-size: 13px;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.modal-actions button {
  flex: 1;
  min-height: 48px;
  border-radius: 999px;
  font-weight: 600;
}

.modal-primary {
  border: 0;
  color: var(--brand-ink);
  background: var(--brand);
}

.modal-danger {
  border: 0;
  color: #fff;
  background: var(--danger);
}

.modal-ghost {
  border: 1px solid var(--line);
  background: var(--surface);
}

.handoff {
  padding: 60px 26px;
  text-align: center;
}

.handoff h2 {
  font-family: var(--font-display);
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.025em;
}

.handoff p {
  margin: 10px 0 24px;
  color: var(--muted);
  line-height: 1.6;
}

.results-hero {
  padding: 34px;
}

.winner,
.newbest {
  margin-bottom: 9px;
  text-align: center;
  font-weight: 600;
}

.winner {
  color: var(--text);
  font-size: 22px;
}

.newbest {
  color: var(--success);
}

.score-arena {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 10px;
  margin: 22px 0;
}

.player-result {
  min-width: 0;
  padding: 28px 17px;
  border: 1px solid var(--line);
  border-radius: 26px;
  background: var(--bg);
  text-align: center;
}

.player-result.solo {
  grid-column: 1 / 4;
  width: 100%;
  max-width: 430px;
  margin: auto;
}

.player-badge {
  display: inline-grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 50%;
  color: var(--brand-ink);
  background: var(--brand);
  font-size: 14px;
  font-weight: 600;
}

.player-name {
  display: block;
  overflow: hidden;
  margin-top: 15px;
  font-size: clamp(20px, 4vw, 26px);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-score {
  display: block;
  margin-top: 4px;
  font-family: var(--font-display);
  font-size: clamp(62px, 11vw, 90px);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.035em;
}

.player-stats,
.subscore {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.player-stats {
  margin-top: 12px;
}

.subscore {
  text-align: center;
}

.versus {
  align-self: center;
  padding: 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
}

.game-played {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  overflow: hidden;
  margin-top: 22px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--bg);
}

.game-played > div {
  min-width: 0;
  padding: 13px 10px;
  text-align: center;
}

.game-played > div + div {
  border-left: 1px solid var(--line);
}

.meta-label {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.meta-value {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  font-size: 14px;
  font-weight: 500;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-detail {
  margin-top: 17px;
  padding-top: 17px;
  border-top: 1px solid var(--line);
}

.result-detail summary {
  color: var(--muted);
  font-weight: 500;
  text-align: center;
  cursor: pointer;
}

.result-detail table {
  margin-top: 13px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  padding: 9px;
  border-bottom: 1px solid var(--line);
  text-align: center;
  font-variant-numeric: tabular-nums;
}

th {
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
}

td:first-child,
th:first-child {
  text-align: left;
}

.learning-grid {
  display: grid;
  grid-template-columns: 0.75fr 1.25fr;
  gap: 12px;
  margin-top: 12px;
}

.insight-card,
.review-card {
  margin-top: 0;
  box-shadow: none;
}

.insight-lead {
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
}

.insight-copy {
  margin-top: 9px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.miss-list {
  display: grid;
  gap: 7px;
  margin-top: 13px;
}

.miss-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg);
}

.miss-question {
  font-size: 17px;
  font-weight: 600;
}

.miss-answer {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.miss-time {
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.perfect-review {
  margin-top: 13px;
  padding: 18px;
  border-radius: var(--radius-sm);
  color: var(--success);
  background: var(--success-soft);
  font-weight: 600;
  text-align: center;
}

.share-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.share-row button {
  flex: 1;
  min-height: 48px;
  padding: 0 17px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}

.share-btn {
  border: 0;
  color: var(--brand-ink);
  background: var(--brand);
}

.share-status {
  min-height: 20px;
  margin-top: 7px;
  color: var(--success);
  font-size: 12px;
  text-align: center;
}

#top-card {
  overflow-x: auto;
}

.hs-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.empty-results {
  padding: 70px 24px;
  text-align: center;
}

.empty-icon {
  display: inline-grid;
  width: 112px;
  height: 112px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  font-size: 44px;
}

.empty-results h2 {
  margin: 14px 0 7px;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.empty-results p {
  margin-bottom: 21px;
  color: var(--muted);
}

.btnrow {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.btnrow button {
  flex: 1;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  margin: -1px;
}

.sitefoot {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: 100%;
  max-width: 980px;
  margin: 48px auto 0;
  padding-top: 22px;
  border-top: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
  color: var(--muted);
  font-size: 12.5px;
}

.sitefoot strong {
  color: var(--text);
  font-weight: 600;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #121310;
    --surface: #1d1e1a;
    --surface-soft: #272921;
    --surface-raised: #232420;
    --text: #f2f3ea;
    --muted: #abad9e;
    --line: #383a31;
    --success: #65cf91;
    --success-soft: #193d2b;
    --warning: #f4a43c;
    --warning-soft: #493015;
    --danger: #f17680;
    --danger-soft: #4a2228;
    --focus: #f2f3ea;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 44px rgba(0, 0, 0, 0.32);
  }
}

@media (max-width: 700px) {
  body {
    padding: 17px 13px 102px;
  }

  .sitefoot {
    margin-top: 34px;
    text-align: center;
  }

  .appbar {
    margin-bottom: 25px;
  }

  .mainnav {
    position: fixed;
    z-index: 30;
    right: 13px;
    bottom: 13px;
    left: 13px;
    justify-content: space-around;
    padding: 6px;
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    box-shadow: 0 15px 45px rgba(35, 35, 32, 0.16);
  }

  .mainnav button {
    flex: 1;
    padding: 11px 7px;
  }

  .hero {
    min-height: 380px;
    padding: 31px 25px;
    border-radius: 31px;
  }

  .hero::before {
    top: 24px;
    right: -38px;
    width: 150px;
    height: 150px;
  }

  .hero::after {
    top: 17px;
    right: -12px;
    font-size: 114px;
  }

  .hero h1 {
    font-size: clamp(58px, 19vw, 82px);
  }

  .hero .tagline {
    max-width: 300px;
    font-size: 15px;
  }

  .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .home-strip,
  .learning-grid {
    grid-template-columns: 1fr;
  }

  .mini-card {
    min-height: 88px;
  }

  #scr-setup .card {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  #scr-setup .setting-group.wide,
  #scr-setup .startbtn,
  #scr-setup .rules {
    grid-column: auto;
  }

  .names.show {
    flex-direction: column;
  }

  .hud .stat {
    padding: 12px 7px;
  }

  .hud .stat .v {
    font-size: 22px;
  }

  .qcard {
    padding: 34px 15px 23px;
    border-radius: 28px;
  }

  .options button {
    padding: 17px 8px;
  }

  .score-arena {
    grid-template-columns: 1fr;
  }

  .player-result.solo {
    grid-column: auto;
  }

  .versus {
    padding: 2px 0;
    text-align: center;
  }

  .results-hero {
    padding: 22px 15px;
  }

  .game-played {
    grid-template-columns: 1fr 1fr;
  }

  .game-played > div:nth-child(3) {
    border-top: 1px solid var(--line);
    border-left: 0;
  }

  .game-played > div:nth-child(4) {
    border-top: 1px solid var(--line);
  }

  .modal-actions,
  .share-row {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- Accounts and global leaderboard ---------- */

/* Author display rules below would otherwise beat the UA stylesheet's
   [hidden] { display: none }, leaving hidden elements on screen. */
[hidden] {
  display: none !important;
}

.account-chip {
  max-width: 150px;
  overflow: hidden;
  color: var(--text);
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cloud-bucket {
  margin: -4px 0 14px;
  color: var(--muted);
  font-size: 13px;
}

#cloud-card {
  overflow-x: auto;
}

.claim-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  padding: 16px 18px;
  border: 1px solid color-mix(in srgb, var(--brand) 55%, var(--line));
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--brand) 16%, var(--surface));
}

.claim-copy {
  display: grid;
  gap: 4px;
}

.claim-copy strong {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.3px;
}

.claim-copy span {
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.4;
}

.claim-btn {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 20px;
  border: 0;
  border-radius: 999px;
  color: var(--brand-ink);
  background: var(--brand);
  font-size: 14px;
  font-weight: 600;
}

.claim-btn:hover {
  background: var(--brand-hover);
}

#lb-table .lb-me td,
#top-table .lb-me td,
#history-table .lb-me td {
  color: var(--text);
  background: color-mix(in srgb, var(--brand) 22%, transparent);
  font-weight: 600;
}

/* Six columns; keep the page from scrolling sideways on a phone. */
#history-card {
  overflow-x: auto;
}

.cloud-status {
  min-height: 18px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12.5px;
}

.cloud-status[data-tone="good"] {
  color: var(--success);
}

.cloud-status[data-tone="warn"] {
  color: var(--warning);
}

/* ---------- Sign-in modal ---------- */

.auth-modal {
  text-align: left;
}

.auth-modal h2 {
  padding-right: 40px;
}

.auth-google {
  width: 100%;
  min-height: 50px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font-size: 15px;
  font-weight: 600;
}

.auth-google:hover {
  background: var(--surface-soft);
}

.auth-google:disabled {
  color: var(--muted);
  cursor: progress;
}

.auth-or {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 18px 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.auth-or::before,
.auth-or::after {
  height: 1px;
  flex: 1;
  background: var(--line);
  content: "";
}

.auth-email {
  display: grid;
  gap: 8px;
}

.auth-email input,
#form-name input,
#form-confirm input {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  background: var(--bg);
  font-size: 15px;
}

.auth-email button {
  min-height: 50px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
}

.auth-email button:disabled {
  cursor: progress;
  filter: saturate(0.4);
}

.auth-fine {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.auth-whoami {
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--bg);
  font-size: 14px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

#auth-signed-in .modal-actions {
  margin-top: 16px;
}

.auth-status {
  min-height: 18px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12.5px;
  line-height: 1.45;
}

.auth-status[data-tone="good"] {
  color: var(--success);
}

.auth-status[data-tone="warn"] {
  color: var(--warning);
}

#form-name .modal-actions,
#form-confirm .modal-actions {
  margin-top: 14px;
}

@media (max-width: 720px) {
  .claim-banner {
    flex-direction: column;
    align-items: stretch;
  }

  .claim-btn {
    width: 100%;
  }

  .account-chip {
    max-width: 110px;
  }
}

/* The wordmark is one long unbreakable word, so below this width it starves the
   header tools. The mark alone carries the brand; the hero repeats the name. */
@media (max-width: 460px) {
  .brand-word {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    margin: -1px;
  }

  .header-tools {
    gap: 6px;
  }
}
