:root {
  color-scheme: dark;
  --bg: #08110f;
  --surface: #0d1916;
  --surface-strong: #12211d;
  --line: rgba(192, 220, 208, 0.14);
  --line-strong: rgba(192, 220, 208, 0.28);
  --text: #eff8f3;
  --muted: #9eb7ad;
  --accent: #6fe0b4;
  --accent-strong: #3fbe8d;
  --danger: #f38f78;
  --focus: #f4d76e;
  --radius: 18px;
  --shadow: 0 20px 60px rgba(0, 0, 0, 0.24);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 20% -10%, rgba(64, 141, 112, 0.12), transparent 34rem),
    var(--bg);
  color: var(--text);
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

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

[hidden] {
  display: none !important;
}

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

.screen--setup,
.screen--results {
  min-height: 100vh;
  padding: 64px 28px 80px;
}

.setup-shell,
.results-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
}

.intro {
  max-width: 780px;
  margin-bottom: 42px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 16px;
  font-size: clamp(2.6rem, 6vw, 5rem);
  font-weight: 650;
  letter-spacing: -0.055em;
  line-height: 0.96;
}

h2 {
  margin-bottom: 4px;
  font-size: 1.18rem;
  letter-spacing: -0.02em;
}

.lede {
  max-width: 720px;
  margin-bottom: 0;
  color: #c3d5ce;
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.7;
}

kbd {
  padding: 2px 8px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 0.85em;
  box-shadow: inset 0 -2px rgba(0, 0, 0, 0.25);
}

.setup-grid,
.results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(18, 33, 29, 0.92), rgba(11, 23, 20, 0.92));
  box-shadow: var(--shadow);
}

.setup-grid .panel {
  padding: 26px;
}

.section-heading {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 24px;
}

.section-heading p,
.history-header p,
.results-header p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.step {
  display: grid;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.fields label {
  display: grid;
  gap: 8px;
  color: #cbdcd5;
  font-size: 0.84rem;
  font-weight: 650;
}

.input-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 11px;
  background: rgba(4, 11, 9, 0.55);
}

.input-wrap:focus-within {
  border-color: var(--accent);
}

.input-wrap input {
  width: 100%;
  min-width: 0;
  padding: 12px 4px 12px 14px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 1.08rem;
  font-weight: 700;
}

.input-wrap > span {
  padding: 0 14px 0 8px;
  color: var(--muted);
}

.calibration-note {
  margin: 15px 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.mode-picker {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  border: 0;
}

.mode-card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(4, 11, 9, 0.35);
  cursor: pointer;
}

.mode-card:hover {
  border-color: var(--line-strong);
}

.mode-card:has(input:checked) {
  border-color: rgba(111, 224, 180, 0.55);
  background: rgba(69, 158, 122, 0.11);
}

.mode-card input {
  position: absolute;
  opacity: 0;
}

.mode-card__body {
  display: grid;
  flex: 1;
  color: var(--muted);
  font-size: 0.78rem;
}

.mode-card__title {
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 750;
}

.radio-mark {
  width: 18px;
  height: 18px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.mode-card:has(input:checked) .radio-mark {
  border: 5px solid var(--accent);
}

.start-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin: 22px 0;
  padding: 22px 4px;
}

.start-guidance {
  display: flex;
  align-items: center;
  gap: 16px;
}

.start-guidance p {
  margin: 0;
  color: #c3d5ce;
  font-size: 0.9rem;
}

.fixation-sample {
  position: relative;
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
}

.fixation-sample::before,
.fixation-sample::after {
  position: absolute;
  content: "";
  background: var(--focus);
}

.fixation-sample::before {
  top: 12px;
  left: 0;
  width: 26px;
  height: 2px;
}

.fixation-sample::after {
  top: 0;
  left: 12px;
  width: 2px;
  height: 26px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 52px;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #04100c;
  font-weight: 800;
  cursor: pointer;
  transition: background-color 120ms ease, transform 120ms ease;
}

.primary-button:hover {
  background: #8ae9c4;
}

.primary-button:active {
  transform: translateY(1px);
}

.error-message {
  padding: 12px 16px;
  border: 1px solid rgba(243, 143, 120, 0.4);
  border-radius: 10px;
  background: rgba(243, 143, 120, 0.08);
  color: #ffc1b2;
}

.history {
  margin-top: 14px;
  padding: 26px;
}

.history-header,
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.history-header h2 {
  margin: 0;
}

.text-button,
.quiet-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.8rem;
  cursor: pointer;
}

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

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

.history-empty {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 22px;
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
  color: var(--muted);
}

.history-empty > span {
  color: var(--accent);
  font-size: 1.5rem;
}

.history-empty p {
  margin: 0;
  font-size: 0.86rem;
}

.history-empty strong {
  color: #cadbd4;
}

.history-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.history-summary article {
  display: grid;
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(4, 11, 9, 0.3);
}

.history-summary span {
  color: var(--muted);
  font-size: 0.72rem;
}

.history-summary strong {
  margin-top: 2px;
  font-size: 1.25rem;
}

.history-summary svg {
  width: 100%;
  margin-top: 8px;
}

.history-summary polyline {
  fill: none;
  stroke: var(--accent);
  stroke-width: 2;
  vector-effect: non-scaling-stroke;
}

.history-footnote {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
}

.disclaimer {
  margin-top: 22px;
  padding: 18px 20px;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.65;
}

.disclaimer strong {
  color: #cbdcd5;
}

.screen--test {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #040908;
}

.test-stage {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 560px;
  overflow: hidden;
  background: radial-gradient(circle at center, #0b1512 0, #07100e 34%, #040908 75%);
  isolation: isolate;
}

.test-status {
  position: absolute;
  z-index: 4;
  top: 22px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 9px;
  transform: translateX(-50%);
  color: #748b82;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.status-dot {
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: #40534b;
}

.test-exit,
.fullscreen-button {
  position: absolute;
  z-index: 5;
  top: 16px;
  padding: 8px 10px;
}

.test-exit {
  left: 16px;
}

.fullscreen-button {
  right: 16px;
}

.fixation,
.stimulus {
  position: absolute;
  top: 50%;
  left: 50%;
}

.fixation {
  z-index: 3;
  width: 30px;
  height: 30px;
  transform: translate(-50%, -50%);
}

.fixation::before,
.fixation::after {
  position: absolute;
  content: "";
  background: var(--focus);
  box-shadow: 0 0 8px rgba(244, 215, 110, 0.22);
}

.fixation::before {
  top: 14px;
  width: 30px;
  height: 2px;
}

.fixation::after {
  left: 14px;
  width: 2px;
  height: 30px;
}

.fixation span {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #06100d;
  border: 1px solid var(--focus);
}

.stimulus {
  z-index: 2;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #f4fff9;
  box-shadow: 0 0 7px 2px rgba(229, 255, 244, 0.5);
  opacity: 0;
  pointer-events: none;
}

.stimulus--visible {
  opacity: 0.88;
}

.test-instruction {
  position: absolute;
  z-index: 4;
  top: calc(50% + 45px);
  left: 50%;
  display: grid;
  width: min(90%, 460px);
  transform: translateX(-50%);
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
}

.test-instruction strong {
  color: #ceddd7;
  font-size: 0.9rem;
}

.response-button {
  position: absolute;
  z-index: 5;
  bottom: 24px;
  left: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: min(420px, calc(100% - 40px));
  min-height: 64px;
  transform: translateX(-50%);
  border: 1px solid rgba(111, 224, 180, 0.36);
  border-radius: 13px;
  background: rgba(25, 59, 48, 0.5);
  color: #d6ece3;
  font-weight: 750;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.response-button:hover {
  border-color: rgba(111, 224, 180, 0.65);
  background: rgba(30, 75, 59, 0.6);
}

.response-button small {
  padding: 3px 8px;
  border: 1px solid rgba(158, 183, 173, 0.22);
  border-radius: 5px;
  color: var(--muted);
  font-size: 0.65rem;
  text-transform: uppercase;
}

.response-button--pressed {
  background: rgba(56, 139, 106, 0.65);
}

.countdown-dialog {
  width: min(440px, calc(100% - 40px));
  padding: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 18px;
  background: #0a1512;
  color: var(--text);
  text-align: center;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.55);
}

.countdown-dialog::backdrop {
  background: rgba(2, 6, 5, 0.82);
}

.countdown-dialog p,
.countdown-dialog span {
  color: var(--muted);
}

.countdown-dialog p {
  margin-bottom: 4px;
}

.countdown-dialog strong {
  display: block;
  margin: 8px 0;
  color: var(--focus);
  font-size: 5rem;
  font-weight: 500;
  line-height: 1;
}

.countdown-dialog span {
  font-size: 0.82rem;
}

.results-header {
  margin-bottom: 34px;
}

.results-header h1 {
  margin-bottom: 10px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.metric {
  display: grid;
  align-content: space-between;
  min-height: 116px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.metric span {
  color: var(--muted);
  font-size: 0.72rem;
}

.metric strong {
  font-size: clamp(1.25rem, 2.2vw, 1.85rem);
  letter-spacing: -0.04em;
}

.metric--accent {
  border-color: rgba(111, 224, 180, 0.42);
  background: rgba(29, 72, 56, 0.52);
}

.results-grid {
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.7fr);
}

.result-map-panel,
.central-panel {
  padding: 24px;
}

.section-heading--compact {
  justify-content: space-between;
  margin-bottom: 12px;
}

.legend {
  display: flex;
  gap: 14px;
  color: var(--muted);
  font-size: 0.72rem;
}

.legend span {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-hit {
  background: var(--accent);
}

.legend-miss {
  background: var(--danger);
}

#result-map {
  display: block;
  width: 100%;
  height: 360px;
  border-radius: 12px;
  background: rgba(4, 11, 9, 0.45);
}

.central-panel {
  display: flex;
  flex-direction: column;
}

.central-score {
  display: grid;
  margin: 18px 0 24px;
}

.central-score strong {
  color: var(--accent);
  font-size: 3.7rem;
  font-weight: 600;
  letter-spacing: -0.06em;
  line-height: 1;
}

.central-score small {
  font-size: 0.45em;
}

.central-score span {
  color: var(--muted);
  font-size: 0.78rem;
}

.central-panel dl {
  display: grid;
  gap: 0;
  margin: 0;
}

.central-panel dl div {
  display: flex;
  justify-content: space-between;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}

.central-panel dt {
  color: var(--muted);
  font-size: 0.82rem;
}

.central-panel dd {
  margin: 0;
  font-weight: 750;
}

.small-note {
  margin: auto 0 0;
  padding-top: 24px;
  color: #7e988e;
  font-size: 0.72rem;
}

.disclaimer--results {
  margin-top: 24px;
}

@media (max-width: 900px) {
  .screen--setup,
  .screen--results {
    padding: 42px 20px 64px;
  }

  .setup-grid,
  .results-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .history-summary {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .screen--setup,
  .screen--results {
    padding: 30px 15px 50px;
  }

  .fields,
  .metric-grid {
    grid-template-columns: 1fr 1fr;
  }

  .start-row,
  .results-header,
  .history-header,
  .section-heading--compact {
    align-items: stretch;
    flex-direction: column;
  }

  .primary-button {
    width: 100%;
  }

  .history-summary {
    grid-template-columns: 1fr;
  }

  .test-stage {
    min-height: 480px;
  }

  .fullscreen-button {
    display: none;
  }

  .test-status {
    top: 58px;
  }

  #result-map {
    height: 280px;
  }
}

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