/* IQ Test site styles. Hand-written, no framework, no external requests. Light and dark themes follow the OS setting. */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #eef0f9;
  --ink: #14162b;
  --muted: #545a78;
  --line: #dfe2ef;
  --brand: #4338ca;
  --brand-hover: #3730a3;
  --brand-ink: #ffffff;
  --accent: #0d9488;
  --focus: #f59e0b;
  --notice-bg: #fff7e6;
  --notice-line: #f3d18a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 22, 43, 0.06), 0 10px 28px rgba(20, 22, 43, 0.07);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}

/* The dark palette is written twice on purpose: once for visitors whose device asks for dark (unless they picked another
   theme in the accessibility panel), and once for visitors who picked dark themselves. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]):not([data-theme="contrast"]) {
    --bg: #0e1024;
    --surface: #171a36;
    --surface-2: #1e2245;
    --ink: #eceefc;
    --muted: #a6abcf;
    --line: #2c3163;
    --brand: #8b93ff;
    --brand-hover: #a7adff;
    --brand-ink: #0e1024;
    --accent: #2dd4bf;
    --notice-bg: #2a2410;
    --notice-line: #6b5a1c;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.35);
  }
}

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

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0e1024;
  --surface: #171a36;
  --surface-2: #1e2245;
  --ink: #eceefc;
  --muted: #a6abcf;
  --line: #2c3163;
  --brand: #8b93ff;
  --brand-hover: #a7adff;
  --brand-ink: #0e1024;
  --accent: #2dd4bf;
  --notice-bg: #2a2410;
  --notice-line: #6b5a1c;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 10px 28px rgba(0, 0, 0, 0.35);
}

/* High contrast: pure black and white with yellow for everything interactive (contrast ratios above 15:1). */
:root[data-theme="contrast"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #000000;
  --surface-2: #101010;
  --ink: #ffffff;
  --muted: #f2f2f2;
  --line: #ffffff;
  --brand: #ffe600;
  --brand-hover: #ffffff;
  --brand-ink: #000000;
  --accent: #00e5ff;
  --focus: #00e5ff;
  --notice-bg: #000000;
  --notice-line: #ffe600;
  --shadow: none;
}

:root[data-theme="contrast"] .hero {
  background: none;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main {
  flex: 1 0 auto;
  outline: none;
}

/* Programmatic focus targets (the question heading, the main region) must not land under the sticky header. */
[tabindex="-1"] {
  scroll-margin-top: 5rem;
}

img,
svg {
  max-width: 100%;
}

a {
  color: var(--brand);
  text-underline-offset: 0.2em;
}

a:hover {
  color: var(--brand-hover);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}

h1,
h2,
h3 {
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 0.6em;
}

h1 {
  font-size: clamp(2rem, 5vw + 0.5rem, 3.2rem);
  font-weight: 800;
}

h2 {
  font-size: clamp(1.5rem, 2.5vw + 0.6rem, 2rem);
  font-weight: 750;
}

h3 {
  font-size: 1.2rem;
  font-weight: 700;
}

p {
  margin: 0 0 1em;
}

.wrap {
  width: 100%;
  max-width: 70rem;
  margin-inline: auto;
  padding-inline: 1rem;
}

@media (min-width: 48rem) {
  .wrap {
    padding-inline: 1.5rem;
  }
}

.skip-link {
  position: absolute;
  inset-inline-start: 1rem;
  top: -4rem;
  background: var(--brand);
  color: var(--brand-ink);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  z-index: 10;
  transition: top 0.15s;
}

.skip-link:focus {
  top: 1rem;
}

/* ---------- header ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 4rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--ink);
  text-decoration: none;
}

.brand:hover {
  color: var(--ink);
}

.brand-mark {
  width: 2rem;
  height: 2rem;
  color: var(--brand);
}

.brand-mark .ink {
  fill: var(--brand-ink);
}

.brand-mark .ink-stroke {
  stroke: var(--brand-ink);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 0.25rem 1.25rem;
}

.site-nav a:not(.btn) {
  color: var(--ink);
  text-decoration: none;
  font-weight: 550;
  padding: 0.35rem 0;
  border-bottom: 2px solid transparent;
}

.site-nav a:not(.btn):hover,
.site-nav a[aria-current="page"] {
  border-bottom-color: var(--brand);
}

@media (max-width: 40rem) {
  .site-nav a:not(.btn) {
    display: none;
  }
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1.3rem;
  border-radius: 999px;
  border: 2px solid transparent;
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--brand);
  color: var(--brand-ink);
}

.btn-primary:hover {
  background: var(--brand-hover);
  color: var(--brand-ink);
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn-ghost:hover {
  border-color: var(--brand);
  color: var(--ink);
}

.btn-small {
  padding: 0.45rem 1rem;
  font-size: 0.95rem;
  background: var(--brand);
  color: var(--brand-ink);
}

.btn-small:hover {
  background: var(--brand-hover);
  color: var(--brand-ink);
}

.btn-large {
  padding: 0.95rem 1.8rem;
  font-size: 1.1rem;
}

.btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

/* ---------- home ---------- */

.hero {
  padding: clamp(2.5rem, 7vw, 5.5rem) 0 clamp(2rem, 5vw, 4rem);
  background:
    radial-gradient(60rem 26rem at 85% -10%, color-mix(in srgb, var(--brand) 22%, transparent), transparent 70%),
    radial-gradient(40rem 22rem at 0% 110%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 70%);
}

.eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
}

.lead {
  font-size: clamp(1.1rem, 1vw + 0.9rem, 1.35rem);
  color: var(--muted);
  max-width: 42rem;
}

.hero .lead {
  margin-bottom: 0;
}

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  list-style: none;
  padding: 0;
  margin: 1.75rem 0 0;
}

.facts li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  font-size: 0.95rem;
  color: var(--muted);
}

.facts strong {
  color: var(--ink);
}

.section {
  padding: clamp(2.25rem, 5vw, 4rem) 0;
}

.section-tint {
  background: var(--surface-2);
}

.section-intro {
  max-width: 46rem;
  color: var(--muted);
}

.card-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  margin-top: 1.5rem;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.card h3 {
  margin-bottom: 0.4rem;
}

.card p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.card-count {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

.steps {
  list-style: none;
  padding: 0;
  margin: 1.5rem 0 0;
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  counter-reset: step;
}

.steps li {
  counter-increment: step;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  padding-inline-start: 4rem;
  position: relative;
}

.steps li::before {
  content: counter(step);
  position: absolute;
  inset-inline-start: 1.2rem;
  top: 1.3rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  background: var(--brand);
  color: var(--brand-ink);
  font-weight: 800;
  display: grid;
  place-items: center;
}

.steps p {
  margin-bottom: 0;
  color: var(--muted);
}

.prose-block {
  max-width: 46rem;
}

.more-link {
  margin-top: 1.25rem;
  font-weight: 650;
}

.cta-band {
  text-align: center;
}

.cta-band p {
  color: var(--muted);
}

/* ---------- FAQ ---------- */

.faq-list {
  display: grid;
  gap: 0.75rem;
  margin: 1.5rem 0;
}

.faq-item,
.faq-item-static {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 1.25rem;
}

.faq-item summary,
.faq-item-static summary {
  cursor: pointer;
  font-weight: 650;
  padding: 1rem 0;
  list-style-position: outside;
}

.faq-item[open] summary,
.faq-item-static[open] summary {
  color: var(--brand);
}

.faq-item p,
.faq-item-static p {
  color: var(--muted);
}

/* ---------- content pages ---------- */

.prose {
  max-width: 46rem;
  padding-top: clamp(2rem, 5vw, 3.5rem);
  padding-bottom: clamp(2rem, 5vw, 3.5rem);
}

.prose h1 {
  margin-bottom: 0.4em;
}

.prose h2 {
  margin-top: 2.2em;
}

.prose h3 {
  margin-top: 1.6em;
}

.prose ul,
.prose ol {
  padding-inline-start: 1.4rem;
  margin: 0 0 1.2em;
}

.prose li {
  margin-bottom: 0.5em;
}

.table-wrap {
  overflow-x: auto;
  margin: 1.25rem 0 1.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.98rem;
}

.table caption {
  text-align: start;
  padding: 0.85rem 1rem;
  font-weight: 650;
  color: var(--muted);
}

.table th,
.table td {
  text-align: start;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--line);
  vertical-align: top;
}

.table thead th {
  background: var(--surface-2);
  font-size: 0.82rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  border-top: 0;
}

.table tbody th {
  font-weight: 700;
  white-space: nowrap;
}

.cta-band-inline {
  margin: 2.5rem 0 0;
}

/* ---------- test page ---------- */

.test-page {
  padding-top: clamp(1.5rem, 4vw, 3rem);
  padding-bottom: 4rem;
  max-width: 56rem;
}

.page-title {
  margin-bottom: 0.3em;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.4rem;
  box-shadow: var(--shadow);
}

.panel h2 {
  font-size: 1.25rem;
}

.intro-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(18rem, 1fr));
  margin: 1.5rem 0;
}

.checklist {
  margin: 0;
  padding-inline-start: 1.2rem;
  color: var(--muted);
}

.checklist li {
  margin-bottom: 0.5rem;
}

.notice {
  background: var(--notice-bg);
  border: 1px solid var(--notice-line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.25rem 0;
}

.notice p {
  margin: 0 0 0.6rem;
}

.restart {
  margin-inline-start: 0.5rem;
}

/* ---------- test runner ---------- */

.runner-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.5rem 1rem;
  margin-bottom: 0.75rem;
}

.runner-count {
  font-size: clamp(1.25rem, 2vw + 0.8rem, 1.6rem);
  margin: 0;
  outline: none;
}

.runner-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.domain-badge {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.15rem 0.75rem;
  font-weight: 600;
}

.clock {
  font-variant-numeric: tabular-nums;
}

progress {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 0.6rem;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

progress::-webkit-progress-bar {
  background: var(--surface-2);
}

progress::-webkit-progress-value {
  background: var(--brand);
  border-radius: 999px;
}

progress::-moz-progress-bar {
  background: var(--brand);
  border-radius: 999px;
}

.question-card {
  margin: 1.25rem 0;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 0;
}

/* A legend floated to full width lays out inside the fieldset instead of straddling its top border. */
.prompt {
  float: inline-start;
  width: 100%;
  font-size: clamp(1.15rem, 1.5vw + 0.8rem, 1.4rem);
  font-weight: 650;
  line-height: 1.4;
  padding: 0;
  margin: 0 0 1rem;
  white-space: pre-line;
}

.prompt + * {
  clear: both;
}

.stem {
  max-width: 30rem;
  margin: 0 auto 1.25rem;
  color: var(--ink);
}

.pz {
  display: block;
  width: 100%;
  height: auto;
}

.options {
  display: grid;
  gap: 0.6rem;
}

.option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.option:hover {
  border-color: var(--brand);
}

.option:has(input:checked) {
  border-color: var(--brand);
  background: color-mix(in srgb, var(--brand) 12%, var(--surface));
}

.option:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.option input {
  width: 1.2rem;
  height: 1.2rem;
  flex: none;
  accent-color: var(--brand);
}

.option-body {
  flex: 1;
  min-width: 0;
}

/* Six picture options read best as 3 x 2. */
.options-visual {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  max-width: 34rem;
  margin-inline: auto;
}

@media (max-width: 26rem) {
  .options-visual {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.options-visual .option {
  flex-direction: column;
  align-items: stretch;
  gap: 0.5rem;
  padding: 0.75rem;
  text-align: center;
}

.options-visual .option input {
  align-self: center;
}

.option-art {
  display: block;
  width: 5.5rem;
  margin: 0 auto;
  color: var(--ink);
}

.option-label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.runner-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 1.25rem 0;
}

.navigator {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 0 1rem;
}

.navigator summary {
  cursor: pointer;
  font-weight: 650;
  padding: 0.85rem 0;
}

.navigator summary span {
  font-weight: 400;
  color: var(--muted);
}

.nav-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(2.6rem, 1fr));
  gap: 0.4rem;
  padding: 0.25rem 0 1rem;
}

.nav-dot {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 650;
  min-height: 2.6rem;
  border-radius: 10px;
  border: 2px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  cursor: pointer;
}

.nav-dot.is-answered {
  background: color-mix(in srgb, var(--brand) 18%, var(--surface));
  border-color: color-mix(in srgb, var(--brand) 55%, var(--line));
}

.nav-dot.is-current {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px var(--brand);
}

.review {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* ---------- result ---------- */

.result-page {
  padding-top: clamp(2rem, 5vw, 3.5rem);
  padding-bottom: 4rem;
  max-width: 50rem;
}

.result-page h1 {
  font-size: clamp(1.6rem, 4vw + 0.5rem, 2.6rem);
}

.score {
  display: inline-block;
  color: var(--brand);
  font-size: 1.35em;
  font-variant-numeric: tabular-nums;
}

.score-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
  margin-bottom: 1.5rem;
}

.band {
  margin: 0 0 0.25rem;
  font-size: 1.4rem;
}

.band-label {
  font-weight: 800;
}

.band-range {
  color: var(--muted);
  font-size: 1rem;
}

.band-text {
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr));
  gap: 1rem;
  margin: 1.25rem 0 0;
}

.stats div {
  background: var(--surface-2);
  border-radius: 12px;
  padding: 0.9rem 1rem;
}

.stats dt {
  font-size: 0.82rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
}

.stats dd {
  margin: 0.15rem 0 0;
  font-size: 1.05rem;
}

.stats strong {
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
}

.domain-list {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: grid;
  gap: 1rem;
}

.domain-head {
  display: flex;
  justify-content: space-between;
  font-weight: 600;
  margin-bottom: 0.3rem;
}

.domain-score {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

meter {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  height: 0.85rem;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  overflow: hidden;
}

meter::-webkit-meter-bar {
  background: var(--surface-2);
  border: 0;
  border-radius: 999px;
  height: 0.85rem;
}

meter::-webkit-meter-optimum-value,
meter::-webkit-meter-suboptimum-value,
meter::-webkit-meter-even-less-good-value {
  background: linear-gradient(90deg, var(--brand), var(--accent));
  border-radius: 999px;
}

meter::-moz-meter-bar {
  background: linear-gradient(90deg, var(--brand), var(--accent));
  border-radius: 999px;
}

.disclaimer {
  background: var(--notice-bg);
  border: 1px solid var(--notice-line);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin: 1.5rem 0;
  font-size: 0.98rem;
}

.share-panel {
  margin-bottom: 1.5rem;
}

.share-panel p {
  color: var(--muted);
}

.share-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

/* ---------- status ---------- */

.status-page {
  padding-top: clamp(3rem, 8vw, 6rem);
  padding-bottom: 5rem;
  max-width: 46rem;
}

/* ---------- footer ---------- */

.site-footer {
  flex: none;
  margin-top: 2rem;
  border-top: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 0.95rem;
}

.footer-inner {
  padding-block: 2rem;
}

.footer-note {
  max-width: 44rem;
}

.site-footer nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin-bottom: 1rem;
}

.site-footer a {
  color: var(--ink);
}

.copyright {
  margin: 0;
  font-size: 0.85rem;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  * {
    transition: none !important;
  }
}

/* ---------- header tools: language menu and accessibility button ---------- */

.site-nav {
  margin-inline-start: auto;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

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

.icon {
  width: 1.25rem;
  height: 1.25rem;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-width: 2.5rem;
  min-height: 2.5rem;
  padding: 0.35rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.tool-btn::-webkit-details-marker {
  display: none;
}

.tool-btn:hover {
  border-color: var(--brand);
}

.lang-menu {
  position: relative;
}

.lang-current {
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 40rem) {
  .lang-current {
    display: none;
  }

  /* Brand, start button and two tool buttons must share a phone-width row without any of them breaking onto two
     lines. If a very narrow screen still cannot fit them, the header wraps instead of scrolling sideways. */
  .header-inner {
    flex-wrap: wrap;
    gap: 0.25rem 0.5rem;
  }

  .brand {
    font-size: 1rem;
    gap: 0.4rem;
  }

  .brand span,
  .site-nav .btn-small {
    white-space: nowrap;
  }

  .site-nav .btn-small {
    padding: 0.45rem 0.85rem;
    font-size: 0.9rem;
  }

  .tool-btn {
    min-width: 2.25rem;
    min-height: 2.25rem;
    padding: 0.3rem;
  }

  .header-tools {
    gap: 0.25rem;
  }
}

.lang-list {
  position: absolute;
  inset-inline-end: 0;
  top: calc(100% + 0.4rem);
  z-index: 20;
  min-width: 11rem;
  max-height: 70vh;
  overflow-y: auto;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.lang-list a {
  display: block;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 550;
}

.lang-list a:hover,
.lang-list a[aria-current] {
  background: var(--surface-2);
}

.lang-list a[aria-current] {
  font-weight: 800;
}

.lang-hint {
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}

.lang-hint-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.5rem 1rem;
  padding: 0.5rem 1rem;
  font-size: 0.95rem;
}

.lang-hint-inner a {
  font-weight: 700;
}

/* ---------- accessibility dialog ---------- */

.a11y-dialog {
  width: 100%;
  max-width: min(34rem, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.a11y-dialog::backdrop {
  background: rgba(10, 12, 30, 0.6);
}

.a11y-body {
  max-height: calc(100vh - 2rem);
  padding: 1.25rem;
  overflow-y: auto;
}

.a11y-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.a11y-head h2 {
  margin: 0;
  font-size: 1.3rem;
}

.a11y-note,
.a11y-help {
  margin: 0.5rem 0 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.a11y-help {
  margin: 0 0 0.25rem;
  padding-inline-start: 1.75rem;
}

.a11y-group {
  margin: 0 0 1rem;
  padding: 0.5rem 1rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 12px;
}

.a11y-group legend {
  padding: 0 0.4rem;
  font-weight: 700;
}

.a11y-choice {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0;
  cursor: pointer;
}

.a11y-choice input {
  flex: none;
  width: 1.15rem;
  height: 1.15rem;
  accent-color: var(--brand);
}

.a11y-size {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.a11y-size output {
  min-width: 4rem;
  font-weight: 800;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.a11y-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem;
}

/* ---------- sharing ---------- */

.share-preview {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border-inline-start: 4px solid var(--brand);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--ink);
  font-size: 0.98rem;
}

.share-landing .lead {
  margin-block: 1.25rem;
}

/* An IQ range such as "110–119" must never break across two lines. */
.band-range {
  white-space: nowrap;
}

/* ---------- pictures described in words ---------- */

.prompt-line {
  display: block;
}

/* Always available to screen readers; shown on screen when "Show text descriptions of pictures" is on. */
.option-desc,
.stem-desc {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.a11y-describe .option-desc,
.a11y-describe .stem-desc {
  position: static;
  display: block;
  width: auto;
  height: auto;
  margin: 0.35rem 0 0;
  overflow: visible;
  clip-path: none;
  white-space: normal;
  color: var(--muted);
  font-size: 0.85rem;
}

.a11y-describe .stem-desc {
  max-width: 34rem;
  margin: 0 auto 1.25rem;
  padding: 0.75rem 1rem;
  border: 1px dashed var(--line);
  border-radius: 8px;
  font-size: 0.95rem;
  text-align: start;
}

/* ---------- accessibility settings applied to the page ---------- */

html[data-a11y-size="115"] { font-size: 115%; }
html[data-a11y-size="130"] { font-size: 130%; }
html[data-a11y-size="150"] { font-size: 150%; }
html[data-a11y-size="175"] { font-size: 175%; }
html[data-a11y-size="200"] { font-size: 200%; }

/* Verdana-style faces have wide, open letters that many readers with dyslexia or low vision find easier. */
.a11y-font {
  --font: Verdana, Tahoma, "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

.a11y-font body {
  letter-spacing: 0.02em;
  word-spacing: 0.08em;
}

/* The WCAG 1.4.12 text-spacing values: line height 1.5+, paragraph gap 2x, letter 0.12em, word 0.16em. */
.a11y-spacing body {
  line-height: 1.9;
  letter-spacing: 0.06em;
  word-spacing: 0.16em;
}

.a11y-spacing p,
.a11y-spacing li,
.a11y-spacing dd {
  margin-bottom: 1.6em;
}

.a11y-links a,
.a11y-links a:hover {
  text-decoration: underline !important;
  text-decoration-thickness: 2px;
  font-weight: 700;
}

.a11y-targets .btn,
.a11y-targets .tool-btn,
.a11y-targets .option,
.a11y-targets .nav-dot,
.a11y-targets .lang-list a,
.a11y-targets .a11y-choice,
.a11y-targets summary {
  min-height: 3.25rem;
}

.a11y-targets .nav-dot {
  min-width: 3.25rem;
}

.a11y-targets .option input,
.a11y-targets .a11y-choice input {
  width: 1.6rem;
  height: 1.6rem;
}

.a11y-focus :focus-visible {
  outline: 5px solid var(--focus) !important;
  outline-offset: 3px !important;
  box-shadow: 0 0 0 3px var(--bg) !important;
}

.a11y-motion,
.a11y-motion *,
.a11y-motion *::before,
.a11y-motion *::after {
  animation: none !important;
  transition: none !important;
  scroll-behavior: auto !important;
}

.a11y-hideclock .clock {
  display: none;
}

/* ---------- other scripts ---------- */

/* Arabic letters join, so any letter-spacing (even the small negative one on headings) breaks the words apart. */
:root:lang(ar),
:root:lang(ar) * {
  letter-spacing: 0 !important;
  word-spacing: normal !important;
}

:root:lang(ar) {
  --font: "Segoe UI", Tahoma, "Noto Sans Arabic", "Noto Naskh Arabic", system-ui, sans-serif;
}

:root:lang(ja) {
  --font: system-ui, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", sans-serif;
}

:root:lang(zh) {
  --font: system-ui, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", "Hiragino Sans GB", sans-serif;
}

:root:lang(ja) body,
:root:lang(zh) body {
  line-height: 1.8;
}

/* Puzzle grids, sequences and dice are drawn left to right in every language. */
.stem,
.option-art {
  direction: ltr;
}
