:root {
  color-scheme: light;
  --paper: #f7f4ed;
  --ink: #171717;
  --muted: #68635a;
  --line: #d8d0c1;
  --upper: #fffdf7;
  --lower: #f2f7f5;
  --accent: #b44e39;
  --topbar-height: 72px;
  --bar-height: 104px;
  --grid-row-gap: clamp(16px, 2.6svh, 34px);
  --test-field-top-gap: clamp(16px, 3svh, 26px);
  --test-viewport-height: calc(100dvh - var(--topbar-height) - var(--bar-height) - env(safe-area-inset-bottom));
  --test-tile-height: max(74px, calc((var(--test-viewport-height) - var(--test-field-top-gap) - (4 * var(--grid-row-gap))) / 4.5));
  --xample: #ED1C24;

}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
  scroll-behavior: auto;
}

html.landing-document {
  height: auto;
  min-height: 100%;
  overflow-x: hidden;
  overflow-y: auto;
}

body {
  margin: 0;
  min-width: 320px;
  height: 100dvh;
  overflow: hidden;
  padding-bottom: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a {
  font: inherit;
}

.topbar {
  position: fixed;
  top: 0;
  right: 0;
  left: 0;
  z-index: 5;
  height: var(--topbar-height);
  min-height: 0;
  padding: 12px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid rgba(23, 23, 23, 0.16);
  background: rgba(0, 0, 0, 0.93);
  backdrop-filter: blur(18px);
}

.test-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.test-metrics {
  display: grid;
  justify-items: end;
  gap: 2px;
  color: #ffffff;
  text-align: right;
}

.average-score {
  color: #aaaaaa;
  font-size: clamp(0.72rem, 2.2vw, 0.88rem);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.test-timer {
  display: none;
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.15rem, 4vw, 1.8rem);
  font-weight: 900;
  line-height: 1;
}

.is-testing .average-score,
.is-finished .average-score {
  display: none;
}

.is-testing .test-timer,
.is-finished .test-timer {
  display: block;
}

main {
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  bottom: calc(var(--bar-height) + env(safe-area-inset-bottom));
  left: 0;
  overflow-x: hidden;
  overflow-y: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: auto;
  touch-action: none;
  background: var(--paper);
}

.is-start-screen .test-field,
.is-testing .start-panel,
.is-start-screen .scroll-indicator {
  display: none;
}

.scroll-indicator {
  position: fixed;
  top: calc(var(--topbar-height) + 14px);
  right: max(6px, env(safe-area-inset-right));
  bottom: calc(var(--bar-height) + env(safe-area-inset-bottom) + 14px);
  z-index: 4;
  width: 8px;
  border-radius: 999px;
  background: rgba(23, 23, 23, 0.14);
  pointer-events: none;
}

.scroll-thumb {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  min-height: 42px;
  border-radius: inherit;
  background: rgba(23, 23, 23, 0.66);
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: #AAAAAA;
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin-top: 2px;
  font-size: clamp(1.25rem, 3vw, 2rem);
  line-height: 1;
  color: #FFFFFF;
}

.debug-result {
  color: var(--accent);
  font-size: 0.82em;
}

button,
.jump {
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid rgba(23, 23, 23, 0.18);
  border-radius: 6px;
  background: #ffffff;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.jump:hover {
  border-color: rgba(23, 23, 23, 0.42);
}

.start-panel {
  display: grid;
  min-height: 100%;
  padding: clamp(18px, 5vw, 48px);
  place-items: center;
}

.start-card {
  display: grid;
  gap: clamp(18px, 3.2svh, 32px);
  width: min(720px, 100%);
  padding: clamp(24px, 6vw, 56px);
  border: 1px solid rgba(23, 23, 23, 0.14);
  border-radius: 8px;
  background: rgba(40, 40, 40, 0.9);
  box-shadow: 0 18px 48px rgba(23, 23, 23, 0.08);
}

.start-card p {
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(1.35rem, 5.4vw, 2.5rem);
  font-weight: 800;
  line-height: 1.12;
}

.start-card strong {
  color: var(--xample);
}

.field {
  position: relative;
  padding: 0 clamp(12px, 4vw, 44px) var(--grid-row-gap);
}

.field:first-child {
  padding-top: var(--test-field-top-gap);
}

.target-field {
  scroll-margin-top: 80px;
}

.target-field,
.neutral-field {
  background: var(--paper);
}

.word-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: clamp(10px, 2.2vw, 30px);
  row-gap: var(--grid-row-gap);
  max-width: 1180px;
  margin: 0 auto;
}

.target-field .word-grid {
  grid-auto-flow: row;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.word {
  display: grid;
  place-items: center;
  height: var(--test-tile-height);
  min-height: 0;
  padding: 10px 8px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  font-size: clamp(1.18rem, 4.8vw, 2.25rem);
  font-weight: 850;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.neutral-field {
  display: block;
  overflow: visible;
}

.neutral-grid {
  transform: none;
}

.neutral-grid .word {
  background: transparent;
  border-color: transparent;
}

.crib-dialog {
  width: min(680px, calc(100vw - 28px));
  border: 1px solid rgba(23, 23, 23, 0.22);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
}

.crib-dialog::backdrop {
  background: rgba(23, 23, 23, 0.44);
}

.result-dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid rgba(23, 23, 23, 0.22);
  border-radius: 8px;
  background: #fffdf8;
  color: var(--ink);
  text-align: center;
}

.result-dialog::backdrop {
  background: rgba(23, 23, 23, 0.54);
}

.result-dialog form {
  display: grid;
  gap: 12px;
}

.result-kicker,
.final-average {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.result-dialog h2 {
  font-size: clamp(1.55rem, 6vw, 2.25rem);
  line-height: 1;
}

.final-time {
  font-variant-numeric: tabular-nums;
  font-size: clamp(3rem, 15vw, 5rem);
  font-weight: 900;
  line-height: 1;
}

.result-dialog button {
  justify-self: center;
  min-width: 120px;
  margin-top: 4px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 850;
  text-transform: uppercase;
}

.crib-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.crib-note {
  margin-bottom: 16px;
  color: var(--muted);
}

.crib-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  gap: 8px;
}

.crib-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.run-log {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.run-log div {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.prompt-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(104px, 18vw);
  gap: 14px;
  align-items: center;
  min-height: var(--bar-height);
  padding: 14px max(16px, env(safe-area-inset-left)) calc(14px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  border-top: 1px solid rgba(23, 23, 23, 0.16);
  background: rgba(255, 253, 248, 0.96);
  box-shadow: 0 -10px 28px rgba(23, 23, 23, 0.08);
  backdrop-filter: blur(18px);
  touch-action: manipulation;
}

.prompt-bar p:first-child {
  font-size: clamp(1.3rem, 5vw, 2rem);
  font-weight: 850;
  line-height: 1.05;
}

.prompt-bar p:last-child {
  margin-top: 4px;
  color: var(--muted);
  font-size: clamp(0.9rem, 2.8vw, 1.05rem);
  font-weight: 700;
  text-transform: uppercase;
}

#nextPrompt {
  min-height: 64px;
  border-color: rgba(23, 23, 23, 0.3);
  background: var(--ink);
  color: #ffffff;
  font-size: clamp(1rem, 3.8vw, 1.35rem);
  font-weight: 850;
  touch-action: manipulation;
  text-transform: uppercase;
}

.landing-page {
  height: auto;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: auto;
  padding-bottom: 0;
}

.landing-page .landing-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.landing-page .nav-action,
.landing-page .primary-link,
.landing-page .secondary-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 6px;
  font-weight: 800;
  text-decoration: none;
}

.landing-page .nav-action,
.landing-page .primary-link {
  background: #ffffff;
  color: #171717;
}

.landing-page .secondary-link {
  border: 1px solid rgba(255, 255, 255, 0.34);
  color: #ffffff;
}

.landing-main {
  position: static;
  display: block;
  min-height: 100dvh;
  padding-top: var(--topbar-height);
  overflow: visible;
  touch-action: auto;
}

.landing-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(280px, 0.95fr);
  gap: clamp(28px, 6vw, 76px);
  align-items: center;
  min-height: calc(100dvh - var(--topbar-height));
  padding: clamp(42px, 8vw, 92px) clamp(18px, 6vw, 72px);
  background:
    linear-gradient(180deg, rgba(23, 23, 23, 0.92), rgba(23, 23, 23, 0.82)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.08) 0 1px, transparent 1px 52px);
  color: #ffffff;
}

.study-label,
.section-kicker {
  color: #aaaaaa;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.landing-hero h2 {
  max-width: 820px;
  margin-top: 14px;
  font-size: clamp(2.8rem, 8.6vw, 6.8rem);
  line-height: 0.94;
}

.hero-lede {
  max-width: 700px;
  margin-top: 24px;
  color: rgba(255, 255, 255, 0.82);
  font-size: clamp(1.08rem, 2.4vw, 1.45rem);
  line-height: 1.45;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
}

.sample-board {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 2vw, 18px);
}

.sample-board span {
  display: grid;
  min-height: clamp(92px, 12vw, 148px);
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  font-size: clamp(1.5rem, 3.2vw, 2.5rem);
  font-weight: 900;
}

.landing-section,
.landing-grid {
  padding: clamp(42px, 7vw, 86px) clamp(18px, 6vw, 72px);
}

.landing-section {
  max-width: 1060px;
}

.landing-section h2 {
  margin-top: 10px;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: 1;
}

.landing-section p {
  max-width: 860px;
  margin-top: 18px;
  color: #3d3933;
  font-size: clamp(1rem, 2vw, 1.18rem);
  line-height: 1.7;
}

.landing-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  background: #d8d0c1;
}

.landing-grid article {
  min-height: 260px;
  padding: clamp(22px, 4vw, 38px);
  background: #fffdf8;
}

.landing-grid h3 {
  margin: 0;
  font-size: clamp(1.2rem, 2.2vw, 1.55rem);
}

.landing-grid p {
  margin-top: 14px;
  color: #4d4840;
  line-height: 1.65;
}

.compact-section {
  border-top: 1px solid var(--line);
}

.method-list {
  display: grid;
  gap: 12px;
  max-width: 800px;
  margin: 24px 0 0;
  padding-left: 1.25rem;
  color: #302d28;
  font-size: clamp(1.05rem, 2.2vw, 1.25rem);
  line-height: 1.55;
}

.inline-link {
  margin-top: 28px;
  background: #171717;
  color: #ffffff;
}

.reference-section {
  padding-bottom: clamp(64px, 10vw, 110px);
  border-top: 1px solid var(--line);
}

.reference-note {
  font-size: 0.95rem;
}

.source-list {
  display: grid;
  gap: 8px;
  max-width: 860px;
  margin: 22px 0 0;
  padding-left: 1.2rem;
  color: #4d4840;
  line-height: 1.55;
}

@media (max-width: 700px) {
  :root {
    --topbar-height: 72px;
    --bar-height: 108px;
  }

  .intro {
    grid-template-columns: 1fr;
    min-height: calc(100svh - var(--bar-height) - 96px);
  }

  .target-field {
    scroll-margin-top: 84px;
  }

  .word {
    font-size: clamp(1rem, 4.7vw, 1.32rem);
  }

  .prompt-bar {
    grid-template-columns: minmax(0, 1fr) 104px;
    min-height: 108px;
  }

  .landing-page .landing-topbar {
    gap: 12px;
  }

  .landing-page .nav-action {
    min-height: 38px;
    padding: 8px 10px;
    font-size: 0.86rem;
  }

  .landing-hero {
    grid-template-columns: 1fr;
    min-height: auto;
  }

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

  .landing-grid {
    grid-template-columns: 1fr;
  }
}
