/* ==========================================================================
   Oddilo 05 — Reaction Time Test (Ability Series 01)
   Playful Precision Lab Aesthetic with Zero-Lag Instant Signal Pad
   ========================================================================== */

:root {
  --bg-paper: #F7F5F0;
  --bg-surface: #FFFFFF;
  --bg-subtle: #EFECE3;
  --ink: #16161A;
  --ink-muted: #5F5E6C;
  --border-soft: #E2DDD0;
  --signal-wait: #E53935;
  --signal-go: #00B87C;
  --signal-warn: #FFB800;
  --accent-blue: #2D5BFF;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --shadow-tactile: 0 4px 0 #16161A;
  --shadow-tactile-sm: 0 2px 0 #16161A;
  --font-display: 'Space Grotesk', 'Inter', system-ui, -apple-system, sans-serif;
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background-color: var(--bg-paper);
  background-image: radial-gradient(rgba(22, 22, 26, 0.065) 1px, transparent 1px);
  background-size: 22px 22px;
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* ---------- Topbar ---------- */
.topbar {
  width: 100%;
  border-bottom: 1.5px solid var(--border-soft);
  background: rgba(247, 245, 240, 0.92);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  background: transparent;
  border: none;
  padding: 4px 6px 4px 2px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink);
}

.brand-wordmark {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.18rem;
  letter-spacing: -0.03em;
  line-height: 1;
}

.brand-cat-tag {
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 6px;
  background: #E6F8F2;
  color: #007A57;
  border: 1px solid #00A878;
}

.topbar-pb-pill {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  font-weight: 600;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--bg-surface);
  border: 1.5px solid var(--border-soft);
  color: var(--ink);
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1.5px solid var(--border-soft);
  background: var(--bg-surface);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: border-color 0.14s ease, transform 0.12s ease;
}

.icon-btn:hover {
  border-color: var(--ink);
  transform: translateY(-1px);
}

/* ---------- Main App Shell ---------- */
.app-shell {
  width: 100%;
  max-width: 740px;
  margin: 0 auto;
  padding: 18px 16px 42px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* ---------- 5-Round Telemetry Strip ---------- */
.round-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.round-chip {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-soft);
  border-radius: 12px;
  padding: 8px 6px;
  text-align: center;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.round-chip.current {
  border-color: var(--ink);
  box-shadow: var(--shadow-tactile-sm);
}

.round-chip.done {
  background: #FFFFFF;
  border-color: var(--ink);
}

.round-chip-lbl {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.round-chip-val {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.96rem;
  font-variant-numeric: tabular-nums;
  margin-top: 2px;
  color: var(--ink);
}

/* ---------- Full-Focus Tactile Reaction Pad ---------- */
.pad-wrap {
  position: relative;
}

.reaction-pad {
  width: 100%;
  min-height: clamp(320px, 52dvh, 430px);
  border-radius: var(--radius-lg);
  border: 2.5px solid var(--ink);
  box-shadow: 0 7px 0 #16161A;
  background: var(--bg-surface);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px 22px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  position: relative;
  overflow: hidden;
  outline: none;
}

/* Corner calibration ticks inside pad */
.pad-corner {
  position: absolute;
  width: 12px;
  height: 12px;
  border-color: currentColor;
  opacity: 0.22;
  pointer-events: none;
}
.pad-corner.tl { top: 16px; left: 16px; border-top: 2px solid; border-left: 2px solid; }
.pad-corner.tr { top: 16px; right: 16px; border-top: 2px solid; border-right: 2px solid; }
.pad-corner.bl { bottom: 16px; left: 16px; border-bottom: 2px solid; border-left: 2px solid; }
.pad-corner.br { bottom: 16px; right: 16px; border-bottom: 2px solid; border-right: 2px solid; }

/* CRITICAL: Zero transition delay when switching to Waiting or GO signal! */
.reaction-pad.state-waiting {
  transition: none !important;
  background: var(--signal-wait);
  color: #FFFFFF;
}

.reaction-pad.state-go {
  transition: none !important;
  background: var(--signal-go);
  color: #FFFFFF;
}

.reaction-pad.state-false {
  transition: none !important;
  background: var(--signal-warn);
  color: var(--ink);
}

.reaction-pad.state-round {
  background: var(--bg-surface);
  color: var(--ink);
}

.pad-icon {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  border: 2px solid currentColor;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.14);
}

.pad-kicker {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.78;
  margin-bottom: 8px;
}

.pad-headline {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.1rem, 6.5vw, 3.35rem);
  letter-spacing: -0.035em;
  line-height: 1.04;
  margin: 0 0 10px;
  font-variant-numeric: tabular-nums;
}

.pad-sub {
  margin: 0;
  font-size: clamp(0.94rem, 2.5vw, 1.06rem);
  opacity: 0.86;
  max-width: 36ch;
  line-height: 1.45;
}

.pad-action-pill {
  margin-top: 22px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  padding: 13px 26px;
  border-radius: 14px;
  border: 2px solid var(--ink);
  background: var(--ink);
  color: #FFFFFF;
  box-shadow: 0 3px 0 rgba(22, 22, 26, 0.25);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.reaction-pad.state-false .pad-action-pill {
  background: var(--ink);
  color: #FFFFFF;
}

.kbd-hint {
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-top: -6px;
}

/* Confetti Canvas Overlay */
.confetti-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 50;
}

/* ---------- 5-Round Summary Result Card ---------- */
.summary-card {
  background: var(--bg-surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: 0 7px 0 #16161A;
  padding: 24px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: popIn 0.34s cubic-bezier(0.22, 1.25, 0.36, 1) forwards;
}

.summary-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1.5px dashed var(--border-soft);
  padding-bottom: 16px;
  flex-wrap: wrap;
}

.summary-badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

.tier-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
}

.pb-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
  background: #FFE066;
  color: var(--ink);
  border: 1.5px solid var(--ink);
  animation: popIn 0.4s cubic-bezier(0.22, 1.5, 0.36, 1) forwards;
}

.summary-hero-ms {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(2.4rem, 7vw, 3.2rem);
  letter-spacing: -0.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  margin: 0 0 6px;
}

.summary-hero-ms span {
  font-size: 0.45em;
  color: var(--ink-muted);
  font-weight: 600;
  margin-left: 4px;
}

.summary-blurb {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-muted);
  line-height: 1.45;
  max-width: 44ch;
}

.summary-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.stat-box {
  background: var(--bg-paper);
  border: 1.5px solid var(--border-soft);
  border-radius: 12px;
  padding: 12px 10px;
  text-align: center;
}

.stat-val {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.32rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat-lbl {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-top: 4px;
}

/* 5-Round Visual Bar Chart */
.chart-box {
  background: var(--bg-paper);
  border: 1.5px solid var(--border-soft);
  border-radius: 16px;
  padding: 16px 14px 12px;
}

.chart-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 12px;
}

.chart-legend { flex-basis: 100%; }

.bars-area {
  position: relative;
  height: 110px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  align-items: end;
  margin: 22px 0 20px;
}

.avg-ref-line {
  position: absolute;
  left: 0;
  right: 0;
  border-top: 1.5px dashed rgba(22, 22, 26, 0.45);
  pointer-events: none;
  z-index: 4;
  transform: translateY(50%);
}

.avg-ref-tag {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  background: var(--ink);
  color: #FFFFFF;
  padding: 1px 6px;
  border-radius: 4px;
}

.bar-col {
  position: relative;
  height: 100%;
  z-index: 3;
}

.bar-ms {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.bar-fill {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 52px;
  border-radius: 8px 8px 4px 4px;
  box-shadow: inset 0 0 0 1.8px var(--ink);
  background: var(--accent-blue);
  transition: height 0.45s cubic-bezier(0.22, 1.25, 0.36, 1);
}

.bar-fill.fastest { background: var(--signal-go); }
.bar-fill.slowest { background: var(--signal-warn); }

.bar-lbl {
  position: absolute;
  bottom: -20px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--ink-muted);
}

.summary-actions {
  display: grid;
  grid-template-columns: 1.25fr 1fr;
  gap: 10px;
}

.btn-primary {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.02rem;
  height: 54px;
  border-radius: var(--radius-md);
  border: 2px solid var(--ink);
  background: var(--ink);
  color: #FFFFFF;
  box-shadow: var(--shadow-tactile);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.15s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 5px 0 #16161A;
  background: var(--accent-blue);
}

.btn-primary:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #16161A;
}

.btn-secondary {
  height: 54px;
  padding: 0 18px;
  border-radius: var(--radius-md);
  border: 2px solid var(--ink);
  background: var(--bg-surface);
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.96rem;
  box-shadow: var(--shadow-tactile-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, background 0.14s ease;
}

.btn-secondary:hover {
  background: var(--bg-subtle);
  transform: translateY(-1px);
}

/* ---------- Concise SEO-Friendly Editorial Info Below Fold ---------- */
.info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 8px;
}

.info-card {
  background: var(--bg-surface);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 18px;
}

.info-card h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1rem;
  margin: 0 0 6px;
}

.info-card p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.52;
  color: var(--ink-muted);
}

/* ---------- Modal & Toast ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(22, 22, 26, 0.45);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 60;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 2px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 0 #16161A;
  padding: 20px;
}

.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.modal-title { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; margin: 0; }
.lab-list { display: flex; flex-direction: column; gap: 8px; }
.lab-item {
  width: 100%; text-align: left; padding: 11px 13px; border-radius: 12px;
  border: 1.5px solid var(--border-soft); background: var(--bg-paper);
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  cursor: pointer; color: var(--ink);
}
.lab-item.live { background: #FFFFFF; border-color: var(--ink); }
.lab-item-name { font-family: var(--font-display); font-weight: 700; font-size: 0.92rem; display: block; }
.lab-item-desc { font-size: 0.76rem; color: var(--ink-muted); }
.lab-pill { font-family: var(--font-mono); font-size: 0.65rem; font-weight: 700; padding: 3px 8px; border-radius: 999px; text-transform: uppercase; }
.lab-pill.live { background: #E6F8F2; color: #007A57; border: 1px solid #00A878; }
.lab-pill.launched { background: #EBF0FF; color: #1D4ED8; border: 1px solid #2D5BFF; }

.toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #FFFFFF;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.86rem;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 6px 20px rgba(22, 22, 26, 0.25);
  opacity: 0;
  pointer-events: none;
  z-index: 80;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.95) translateY(6px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

@media (max-width: 580px) {
  .topbar-inner { padding: 8px 12px; }
  .brand-cat-tag { display: none; }
  .app-shell { padding: 12px 12px 32px; gap: 14px; }
  .reaction-pad { min-height: 48dvh; padding: 24px 16px; }
  .round-strip { gap: 6px; }
  .round-chip-val { font-size: 0.84rem; }
  .kbd-hint { display: none; }
  .summary-actions { grid-template-columns: 1fr; }
  .info-grid { grid-template-columns: 1fr; }
}

/* ---------- "How fast are you?" Benchmark Comparison Block ---------- */
.bench-box {
  background: var(--bg-paper);
  border: 1.5px solid var(--border-soft);
  border-radius: 16px;
  padding: 15px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bench-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.bench-kicker {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 0.96rem;
  color: var(--ink);
}

.bench-delta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 700;
}

.bench-ruler-wrap {
  padding-top: 26px;
  padding-bottom: 4px;
}

.bench-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: #E5E0D4;
  border: 1.5px solid var(--ink);
}

.bench-span {
  position: absolute;
  top: 0;
  bottom: 0;
  opacity: 0.32;
}

.bench-marker-med {
  position: absolute;
  top: -5px;
  bottom: -5px;
  width: 2px;
  background: var(--ink);
  transform: translateX(-50%);
  z-index: 2;
}

.bench-med-tag {
  position: absolute;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--ink-muted);
  white-space: nowrap;
}

.bench-marker-avg {
  position: absolute;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: rgba(22, 22, 26, 0.35);
  transform: translateX(-50%);
  z-index: 1;
}

.bench-marker-you {
  position: absolute;
  top: 50%;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  transform: translate(-50%, -50%);
  z-index: 4;
  box-shadow: 0 2px 0 rgba(22, 22, 26, 0.2);
}

.bench-you-tag {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #FFFFFF;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 6px;
  white-space: nowrap;
}

.bench-ticks {
  position: relative;
  height: 16px;
  margin-top: 20px;
  font-family: var(--font-mono);
  font-size: 0.62rem;
  color: var(--ink-muted);
}
.bench-ticks span { position: absolute; transform: translateX(-50%); }
.bench-ticks span:first-child { transform: none; }
.bench-ticks span:last-child { transform: translateX(-100%); }
.bench-marker-you.at-min .bench-you-tag { left: 7px; transform: none; }
.bench-marker-you.at-max .bench-you-tag { left: auto; right: 7px; transform: none; }

.bench-source {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--ink-muted);
  line-height: 1.4;
}

.bench-source a {
  color: var(--ink);
  text-decoration: underline;
}

/* More room for desktop play; the summary and smaller layouts keep their original sizing. */
@media (min-width: 900px) {
  .app-shell:has(> #padSection:not(.hidden)) {
    max-width: 1072px;
    padding: 14px 16px;
    gap: 12px;
  }
  .app-shell:has(> #padSection:not(.hidden)) .reaction-pad {
    min-height: clamp(300px, calc(100dvh - 360px), 560px);
  }
  .app-shell:has(> #padSection:not(.hidden)) .pad-headline {
    font-size: clamp(3.1rem, 4vw, 4rem);
  }
  .app-shell:has(> #padSection:not(.hidden)) .pad-kicker { font-size: .82rem; }
  .app-shell:has(> #padSection:not(.hidden)) .pad-sub { margin-inline: auto; }
  .app-shell:has(> #padSection:not(.hidden)) .round-chip-lbl { font-size: .7rem; }
  .app-shell:has(> #padSection:not(.hidden)) .round-chip-val { font-size: 1.1rem; }
  .app-shell:has(> #padSection:not(.hidden)) .kbd-hint { margin-bottom: 0; }
  .app-shell:has(> #padSection:not(.hidden)) .info-grid { margin-top: 0; }
  .app-shell:has(> #padSection:not(.hidden)) .info-card { padding: 12px 16px; }
}
