/* ══════════════════════════════════════════════════════════════════
   TESTME · TEST BASE CSS
   Shared foundation for all cognitive performance tests.
   Each test imports this file and only sets --test-accent.
   ══════════════════════════════════════════════════════════════════ */


/* ── RESET ── */
*, *::before, *::after { box-sizing: border-box; }
body, main, main *, main *::before, main *::after { margin: 0; padding: 0; }

/* ── TOKENS ── */
:root {
  --test-accent: #3fa8be; /* Override per test */
  --test-accent-soft: color-mix(in srgb, var(--test-accent) 12%, transparent);
  --test-accent-border: color-mix(in srgb, var(--test-accent) 25%, transparent);

  --bg: var(--color-background);
  --card-bg: var(--color-surface);
  --card-border: var(--color-outline);
  --card-shadow: 0 12px 32px rgba(0, 0, 0, 0.05), 0 2px 4px rgba(0, 0, 0, 0.02);

  --text: var(--color-on-surface);
  --text-muted: var(--color-on-surface-variant);
  --text-faint: color-mix(in srgb, var(--color-on-surface) 65%, transparent);

  --r-xl: 14px;
  --r-lg: 10px;
  --r-md: 8px;
  --r-sm: 4px;

  --font-h: 'Manrope', system-ui, sans-serif;
  --font-b: 'Lexend', system-ui, sans-serif;
}

/* ── BASE ── */
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
html.large-text { font-size: 115%; }
body {
  font-family: var(--font-b);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── FOCUS RING ── */
:focus-visible {
  outline: 3px solid var(--test-accent);
  outline-offset: 3px;
  border-radius: 3px;
}

/* Custom focus state for text inputs to avoid thick/double outline and mismatched corner radii */
input[type="text"]:focus-visible,
input[type="search"]:focus-visible,
input[type="number"]:focus-visible,
input[type="email"]:focus-visible,
input[type="password"]:focus-visible,
input[type="tel"]:focus-visible,
input[type="url"]:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--test-accent) !important;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--test-accent) 30%, transparent) !important;
}

/* ── VISUALLY HIDDEN (for screen reader only text) ── */
.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;
}

/* ── SYSTEM REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ── DYSLEXIC FONT ── */
html.dyslexic-font *:not(.material-symbols-outlined):not(.material-symbols-rounded):not(.material-symbols-sharp):not(.material-icons) { font-family: "OpenDyslexic", "Comic Sans MS", sans-serif !important; }
html.dyslexic-font .material-symbols-outlined,
html.dyslexic-font .material-symbols-rounded,
html.dyslexic-font .material-symbols-sharp,
html.dyslexic-font .material-icons { font-family: 'Material Symbols Outlined', 'Material Icons' !important; }

/* ── HIGH CONTRAST ── */
html.high-contrast body { 
  background: #ffffff !important; 
  color: #000000 !important; 
}
html.high-contrast.dark body { 
  background: #000000 !important; 
  color: #ffffff !important; 
}
html.high-contrast .t-card { 
  background: #ffffff !important; 
  border: 2px solid #000000 !important; 
}
html.high-contrast.dark .t-card { 
  background: #000000 !important; 
  border: 2px solid #ffffff !important; 
}
html.high-contrast button { 
  border: 2px solid currentColor !important; 
}

/* ── SHELL ── */
.t-shell {
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  margin-top: 24px;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
  padding: 0 16px;
}

/* ── CENTERED CONTENT CONTAINERS ── */
.t-intro, .t-prog, .rt-hint, .f1-status-row, .t-pct-box, .t-info-card, .t-actions, .t-footer,
.chimp-status-row,
.vm-status,
.wm-task-header,
.tp-stats-row,
.cp-status-row,
.ot-status-row,
.mash-stats,
.ts-status-row,
.pm-status-row,
.chimp-status-text,
.vm-buttons,
.gng-status-row,
.gng-legend,
.stroop-buttons,
.stroop-hint,
.tp-input,
.aim-hint,
.mash-status,
.ot-status-text,
.cp-status-text,
.pm-status-text,
.sa-header,
.ts-rule-badge,
.ts-controls {
  width: 100%;
  max-width: 960px;
  margin-left: auto !important;
  margin-right: auto !important;
  padding-left: 24px !important;
  padding-right: 24px !important;
  box-sizing: border-box;
}

/* Progress/Timer tracks - match inner content width of padded headers (960px - 24px*2 = 912px) without insetting the progress fill */
.wm-timer-track,
.ts-progress,
.mash-progress {
  width: calc(100% - 48px) !important;
  max-width: 912px !important;
  margin-left: auto !important;
  margin-right: auto !important;
  padding: 0 !important;
  box-sizing: border-box;
}

/* ── AMBIENT GLOW ── */
.t-ambient-glow {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 800px;
  height: 800px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--test-accent, #3fa8be) 8%, transparent) 0%, transparent 70%);
  z-index: -1;
  pointer-events: none;
  filter: blur(80px);
  animation: glowPulse 8s ease-in-out infinite alternate;
}
@keyframes glowPulse {
  0% { transform: translate(-50%, -50%) scale(0.95); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(1.05); opacity: 1.1; }
}

/* ── TOP NAV ── */
.t-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: color-mix(in srgb, var(--color-surface) 45%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1.5px solid var(--color-outline);
  border-radius: var(--r-xl);
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.02);
  margin-top: 28px;
  margin-bottom: 20px;
}
.t-nav-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 14.5px;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -0.015em;
}
.t-nav-logo {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  flex-shrink: 0;
}
.t-nav-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.t-nav-back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-b);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  transition: all 0.15s;
}
.t-nav-back-link:hover {
  color: var(--test-accent);
  border-color: var(--test-accent-border);
  background: var(--test-accent-soft);
}
.t-nav-back-link svg {
  flex-shrink: 0;
}
.t-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  padding: 0;
}
.t-nav-btn:hover {
  color: var(--text);
  border-color: var(--color-outline-variant);
  background: var(--color-nav-hover);
}

/* ── CARD ── */
.t-card {
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
  position: relative;
}

/* ── DISTRACTION-FREE ACTIVE TEST MODE ── */
body:has(#panelTask.active) header.panda-header {
  display: none !important;
}
body:has(#panelTask.active) .t-footer {
  display: none !important;
}
body:has(#panelTask.active) .t-shell {
  margin-top: 0 !important;
  padding: 0 !important;
  height: 100vh !important;
  min-height: 100vh !important;
  justify-content: flex-start !important;
}
body:has(#panelTask.active) .t-card {
  margin: 0 !important;
}
body:has(#panelTask.active) .t-task {
  padding: 40px 0 20px !important;
  justify-content: flex-start !important;
  height: auto !important;
}
body:has(#panelTask.active) .t-stimulus,
body:has(#panelTask.active) .rt-box,
body:has(#panelTask.active) .f1-panel,
body:has(#panelTask.active) .gng-panel,
body:has(#panelTask.active) .vm-word-box,
body:has(#panelTask.active) .timer-arena,
body:has(#panelTask.active) .aim-arena,
body:has(#panelTask.active) .wm-box,
body:has(#panelTask.active) .ts-box,
body:has(#panelTask.active) .sa-box,
body:has(#panelTask.active) .sm-box,
body:has(#panelTask.active) .ps-box,
body:has(#panelTask.active) .stroop-word-box,
body:has(#panelTask.active) .tp-text-box,
body:has(#panelTask.active) .ot-arena,
body:has(#panelTask.active) .mash-arena,
body:has(#panelTask.active) .ts-arena,
body:has(#panelTask.active) .chimp-grid,
body:has(#panelTask.active) .cp-grid,
body:has(#panelTask.active) .pm-grid {
  margin-top: 0 !important;
}

/* ── PHASE PANELS (shown/hidden via .active class) ── */
.t-panel { display: none; }
.t-panel.active { display: flex; flex-direction: column; }

/* ── INTRO PANEL ── */
.t-intro {
  padding: 40px 48px;
  align-items: center;
  text-align: center;
  gap: 0;
}
@media (max-width: 768px) {
  .t-intro.active {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    text-align: center !important;
    padding: 24px 20px !important;
  }
  .t-intro-left, .t-intro-right {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
  }
  .t-intro-right {
    margin-top: 24px !important;
    gap: 16px !important;
  }
}

@media (min-width: 769px) {
  .t-intro.active {
    display: flex !important;
    flex-direction: row !important;
    gap: 48px !important;
    align-items: flex-start !important;
    text-align: left !important;
    padding: 40px 48px !important;
  }
  
  .t-intro-left {
    flex: 1.12 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-start !important;
  }
  
  .t-intro-right {
    flex: 0.88 !important;
    min-width: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
    width: 100% !important;
  }

  /* Reset all absolute grid column/row placements from old style */
  .t-intro.active .t-intro-icon,
  .t-intro.active .t-intro-title,
  .t-intro.active .t-intro-sub,
  .t-intro.active .t-btn-start,
  .t-intro.active .t-meta,
  .t-intro.active [class*="-visual"],
  .t-intro.active .t-steps {
    grid-column: auto !important;
    grid-row: auto !important;
    margin: 0 !important;
    width: 100% !important;
  }
  
  .t-intro.active .t-intro-icon {
    width: 52px !important;
    height: 52px !important;
    margin-bottom: 20px !important;
  }

  .t-intro.active .t-intro-title {
    margin-bottom: 12px !important;
    font-size: 38px !important;
  }

  .t-intro.active .t-intro-sub {
    margin-bottom: 24px !important;
    font-size: 15px !important;
  }

  .t-intro.active .t-btn-start {
    margin-bottom: 12px !important;
  }
}

.t-intro-icon {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--test-accent-soft);
  border: 1.5px solid var(--test-accent-border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  color: transparent;
  margin-bottom: 20px;
  position: relative;
  animation: iconBounce 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.t-intro-icon::before {
  content: 'psychology';
  font-family: 'Material Symbols Outlined';
  font-size: 26px;
  color: var(--test-accent);
  display: inline-block;
  line-height: 1;
}
@keyframes iconBounce { from { transform: scale(0.5); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.t-intro-title {
  font-family: var(--font-h);
  font-size: clamp(30px, 4.5vw, 40px);
  font-weight: 900;
  color: var(--text);
  line-height: 1.1;
  letter-spacing: -0.02em;
  margin-bottom: 12px;
}
.t-intro-title em { color: var(--test-accent); font-style: normal; }

.t-intro-sub {
  font-family: var(--font-b);
  font-size: 15.5px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 640px;
  margin: 0 auto 28px;
}

/* ── HOW IT WORKS — inline steps ── */
.t-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  width: 100%;
  max-width: 800px;
  margin: 0 auto 28px;
  text-align: left;
}
.t-step {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 18px;
  background: var(--color-surface-container-low);
  border: 1px solid var(--color-outline);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.01);
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s ease, border-color 0.2s ease;
}
.t-step:hover {
  transform: translateY(-2px);
  border-color: var(--color-outline-variant);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.03);
}
.t-step-num {
  width: 22px;
  height: 22px;
  min-width: 22px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--test-accent) 12%, transparent);
  color: color-mix(in srgb, var(--test-accent) 85%, #000); /* Darkened for light mode contrast */
  font-size: 11px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  border: 1px solid color-mix(in srgb, var(--test-accent) 45%, transparent); /* Darkened for light mode contrast */
}
html.dark .t-step-num {
  background: var(--test-accent-soft);
  color: var(--test-accent);
  border-color: var(--test-accent-border);
}
.t-step-text {
  font-family: var(--font-b);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.5;
}
.t-step-text strong { font-weight: 800; color: var(--text); }

/* ── START BUTTON ── */
.t-btn-start {
  width: 100%;
  max-width: 340px;
  padding: 16px 28px;
  background: color-mix(in srgb, var(--test-accent) 8%, transparent);
  color: color-mix(in srgb, var(--test-accent) 85%, #000) !important; /* Darkened for light mode contrast */
  border: 2px solid color-mix(in srgb, var(--test-accent) 45%, transparent); /* Darkened for light mode boundary contrast */
  border-radius: 16px;
  font-family: var(--font-b);
  font-size: 15.5px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.t-btn-start:hover {
  background: color-mix(in srgb, var(--test-accent) 15%, transparent);
  color: color-mix(in srgb, var(--test-accent) 90%, #000) !important;
  border-color: color-mix(in srgb, var(--test-accent) 70%, #000);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.05);
}
html.dark .t-btn-start {
  background: color-mix(in srgb, var(--test-accent) 8%, transparent);
  color: var(--test-accent) !important;
  border-color: color-mix(in srgb, var(--test-accent) 25%, transparent);
}
html.dark .t-btn-start:hover {
  background: color-mix(in srgb, var(--test-accent) 15%, transparent);
  color: var(--test-accent) !important;
  border-color: var(--test-accent);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--test-accent) 15%, transparent);
}
.t-btn-start:active {
  transform: scale(0.98) translateY(0);
}
.t-btn-start svg { width: 18px; height: 18px; transition: transform 0.2s; }
.t-btn-start:hover svg { transform: translateX(2px); }

.t-meta {
  margin-top: 12px;
  font-family: var(--font-b);
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
}

/* ── TASK PANEL ── */
.t-task {
  padding: 28px 28px 32px;
  gap: 20px;
}
@media (max-width: 480px) { .t-task { padding: 20px 16px 24px; } }

/* ── TASK CHILDREN FLEX ORDER REMOVED ── */
/* Statically defined HTML order is used instead (Header/Status -> Stimulus -> Hint/Buttons). */

/* ── PROGRESS BAR ── */
.t-prog {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.t-prog-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.t-prog-title {
  font-family: var(--font-b);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.t-prog-count {
  font-family: var(--font-h);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}
.t-prog-track {
  height: 4px;
  background: color-mix(in srgb, var(--color-surface-container-high) 80%, transparent);
  border-radius: 9999px;
  overflow: hidden;
}
.t-prog-fill {
  height: 100%;
  background: var(--test-accent);
  border-radius: 9999px;
  transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hide standard progress track if segmented trial dots are active */
.t-prog:has(.t-dots) .t-prog-track {
  display: none !important;
}

/* ── TRIAL DOTS (Sleek Compact Design) ── */
.t-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}
.t-dot {
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: color-mix(in srgb, var(--text) 15%, transparent);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}
.t-dot.current {
  width: 20px;
  background: var(--test-accent);
}
.t-dot.done {
  background: #10b981;
}
.t-dot.error {
  background: #ef4444;
}

/* ── STIMULUS AREA ── */
/* Common boundary styles applied to all gameplay containers */
.t-stimulus, .rt-box, .f1-panel, .gng-panel, .vm-word-box, .timer-arena, .wm-box, .ts-box, .sa-box, .sm-box, .ps-box, .stroop-word-box, .tp-text-box, .mash-arena, .chimp-box, .cp-box, .pm-box {
  width: 100% !important;
  border-radius: 0 !important;
  border-left: none !important;
  border-right: none !important;
  border-top: 1px solid var(--color-outline) !important;
  border-bottom: 1px solid var(--color-outline) !important;
  margin: 20px 0 !important;
  transition: background 0.15s, box-shadow 0.15s, transform 0.15s;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

/* Constrain grid and typing text containers to layout width, centered */
.tp-text-box {
  max-width: 960px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* Flex-centered arenas and layout panels (excluding CSS grids and text areas) */
.t-stimulus, .rt-box, .f1-panel, .gng-panel, .vm-word-box, .timer-arena, .wm-box, .ts-box, .sa-box, .sm-box, .ps-box, .stroop-word-box, .mash-arena, .chimp-box, .cp-box, .pm-box {
  min-height: 480px;
  display: flex;
  align-items: center;
  justify-content: center;
}
@media (max-width: 480px) {
  .t-stimulus, .rt-box, .f1-panel, .gng-panel, .vm-word-box, .timer-arena, .wm-box, .ts-box, .sa-box, .sm-box, .ps-box, .stroop-word-box, .mash-arena {
    min-height: 320px;
  }
}

/* Stimulus states */
.t-stimulus[data-state="idle"] { background: var(--color-surface-container-low); }
.t-stimulus[data-state="wait"] { background: var(--color-surface-dim); }
.t-stimulus[data-state="go"]   { background: #2ecc71; box-shadow: inset 0 0 40px rgba(46,204,113,0.4); }
.t-stimulus[data-state="hit"]  { background: #eafaf1; }
.t-stimulus[data-state="miss"] { background: #fdf2f1; }

body:has(#panelTask.active):not(:has(.aim-arena)):not(:has(.ts-arena)):not(:has(.ot-arena)) .t-shell {
  max-width: none !important;
}
body:has(#panelResult.active) .t-shell {
  max-width: none !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}

/* Constrain result children to content width during full-width results phase */
body:has(#panelResult.active) .t-nav,
body:has(#panelResult.active) .t-actions,
body:has(#panelResult.active) .t-footer {
  max-width: 960px !important;
  width: calc(100% - 32px) !important;
  margin-left: 16px !important;
  margin-right: 16px !important;
  box-sizing: border-box;
}
@media (min-width: 992px) {
  body:has(#panelResult.active) .t-nav,
  body:has(#panelResult.active) .t-actions,
  body:has(#panelResult.active) .t-footer {
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}

/* ── RESULT PANEL ── */
.t-result {
  padding: 36px 0 40px !important;
  gap: 22px;
}
@media (max-width: 480px) { .t-result { padding: 24px 0 28px !important; } }

/* ── RESULT GRID SYSTEM ── */
.t-result-grid {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  padding-left: 16px;
  padding-right: 16px;
  box-sizing: border-box;
}
.t-result-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
}

@media (min-width: 900px) {
  .t-result-grid {
    display: grid !important;
    grid-template-columns: 1.15fr 0.85fr;
    gap: 28px;
    align-items: start;
    max-width: 960px;
    margin: 0 auto;
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  body:has(#panelResult.active) #panelResult > .t-result-grid {
    max-width: 960px !important;
    width: 100% !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
  body:has(#panelResult.active) .t-result-col > * {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
  }
}

.t-result-hero {
  text-align: center;
  padding: 56px 24px 60px !important;
  background: linear-gradient(135deg, rgba(28, 28, 30, 0.4) 0%, rgba(18, 18, 18, 0.25) 100%);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--test-accent-border) !important;
  border-bottom: 1px solid var(--test-accent-border) !important;
  border-left: none !important;
  border-right: none !important;
  border-radius: 0 !important;
  width: 100% !important;
  max-width: none !important;
  margin: 0 auto 24px !important;
  position: relative;
  overflow: hidden;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.15), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

html.light .t-result-hero {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.8) 0%, rgba(245, 247, 251, 0.6) 100%);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04), inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.t-result-hero::before {
  display: none !important;
}

.t-result-hero > * {
  position: relative;
  z-index: 1;
}

.t-score-big {
  font-family: var(--font-h);
  font-size: 104px !important;
  font-weight: 900;
  color: var(--test-accent);
  line-height: 1;
  letter-spacing: -0.04em;
  text-shadow: none !important;
  margin-bottom: 6px;
}

.t-score-unit {
  font-family: var(--font-h);
  font-size: 26px;
  font-weight: 800;
  color: var(--test-accent);
  margin-left: 8px;
  letter-spacing: normal;
  display: inline-block;
  opacity: 0.8;
}

.t-score-label {
  font-family: var(--font-b);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 12px;
}

.t-score-interp {
  font-family: var(--font-b);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  margin-top: 8px;
  line-height: 1.6;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
}

/* ── COMPETITIVE RANK TIERS ── */
.t-hero-rank-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border-radius: var(--r-sm);
  font-family: var(--font-h);
  font-weight: 800;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 14px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border: 1px solid transparent;
}
.t-hero-rank-badge.challenger {
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.15) 0%, rgba(212, 175, 55, 0.05) 100%);
  border-color: rgba(212, 175, 55, 0.3);
  color: #d4af37;
  box-shadow: 0 0 16px rgba(212, 175, 55, 0.15);
}
.t-hero-rank-badge.diamond {
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.15) 0%, rgba(14, 165, 233, 0.05) 100%);
  border-color: rgba(14, 165, 233, 0.3);
  color: #0ea5e9;
  box-shadow: 0 0 16px rgba(14, 165, 233, 0.15);
}
.t-hero-rank-badge.gold {
  background: linear-gradient(135deg, rgba(245, 166, 35, 0.15) 0%, rgba(245, 166, 35, 0.05) 100%);
  border-color: rgba(245, 166, 35, 0.3);
  color: #f5a623;
  box-shadow: 0 0 16px rgba(245, 166, 35, 0.1);
}
.t-hero-rank-badge.bronze {
  background: linear-gradient(135deg, rgba(168, 85, 247, 0.15) 0%, rgba(168, 85, 247, 0.05) 100%);
  border-color: rgba(168, 85, 247, 0.3);
  color: #a855f7;
}


/* ── GHOST LINE (PERSONAL BEST TARGET) ── */
.rt-ghost-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1.5px dashed #10b981;
  opacity: 0.75;
  z-index: 5;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
}
.rt-ghost-label {
  font-family: var(--font-b);
  font-size: 8px;
  font-weight: 700;
  color: #10b981;
  background: var(--color-surface);
  border: 1px solid #10b981;
  border-radius: 4px;
  padding: 1px 4px;
  transform: translateY(-50%) translateX(-8px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

/* ── PERSONAL TREND CARD ── */
.t-trend-sparkline {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 50px;
  gap: 12px;
  margin-top: 18px;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 4px;
}
.t-trend-bar {
  flex: 1;
  max-width: 36px;
  background: var(--test-accent-soft);
  border-top: 1.5px solid var(--test-accent);
  border-radius: 2px 2px 0 0;
  min-height: 4px;
  position: relative;
  display: flex;
  justify-content: center;
  transition: all 0.2s;
}
.t-trend-bar:hover {
  background: var(--test-accent);
  opacity: 0.8;
}
.t-trend-bar-val {
  position: absolute;
  top: -16px;
  font-family: var(--font-b);
  font-size: 8px;
  font-weight: 700;
  color: var(--text-muted);
  opacity: 0.75;
  transition: opacity 0.2s;
  pointer-events: none;
}
.t-trend-bar:hover .t-trend-bar-val {
  opacity: 1;
}

/* ── UNIFIED HARDWARE & REFLEX PILL ── */
.t-hero-hardware-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  background: color-mix(in srgb, var(--color-on-surface) 4%, transparent);
  border: 1px solid color-mix(in srgb, var(--color-on-surface) 10%, transparent);
  border-radius: 30px;
  padding: 6px 16px;
  margin-top: 18px;
  font-family: var(--font-b, sans-serif);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  max-width: 100%;
  box-sizing: border-box;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}
.t-hero-hardware-pill:hover {
  background: color-mix(in srgb, var(--color-on-surface) 8%, transparent);
  border-color: color-mix(in srgb, var(--color-on-surface) 18%, transparent);
  transform: translateY(-1px);
}
.t-hero-hardware-pill .device-group {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-muted);
}
.t-hero-hardware-pill .device-group strong {
  color: var(--text);
  font-weight: 700;
}
.t-hero-hardware-pill .separator-line {
  width: 1px;
  height: 12px;
  background: color-mix(in srgb, var(--color-on-surface) 15%, transparent);
  margin: 0 2px;
}
.t-hero-hardware-pill .reflex-group {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #10b981;
}
.t-hero-hardware-pill .reflex-group strong {
  color: #10b981;
  font-weight: 800;
}
.t-hero-hardware-note {
  font-family: var(--font-b, sans-serif);
  font-size: 10px;
  color: color-mix(in srgb, var(--color-on-surface) 50%, transparent);
  margin-top: 6px;
  max-width: 600px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.4;
  text-align: center;
  opacity: 0.85;
}

/* ── PERCENTILE BAR ── */
.t-pct-box {
  padding: 24px;
  background: linear-gradient(135deg, rgba(28, 28, 30, 0.5) 0%, rgba(18, 18, 18, 0.35) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--r-xl);
  border: 1px solid var(--card-border) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
html.light .t-pct-box {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.75) 0%, rgba(245, 247, 251, 0.5) 100%);
}
.t-pct-label {
  font-family: var(--font-b);
  font-size: 14.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.5;
}
.t-pct-label strong { color: var(--text); font-weight: 800; }
.t-pct-track {
  height: 8px;
  background: var(--color-surface-variant);
  border-radius: 10px;
  position: relative;
  margin-bottom: 12px;
  overflow: visible;
}
.t-pct-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-surface-variant) 0%, var(--test-accent) 100%);
  border-radius: 10px;
  opacity: 0.6;
}
.t-pct-marker {
  position: absolute;
  top: -6px;
  width: 20px;
  height: 20px;
  background: var(--test-accent);
  border: 3.5px solid var(--color-surface);
  border-radius: 50%;
  transform: translateX(-50%);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--test-accent) 40%, transparent), 0 2px 10px rgba(0,0,0,0.18);
  transition: left 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
  animation: markerPulse 2.5s infinite;
}
@keyframes markerPulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--test-accent) 40%, transparent), 0 2px 10px rgba(0,0,0,0.18); }
  70% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--test-accent) 0%, transparent), 0 2px 10px rgba(0,0,0,0.18); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--test-accent) 0%, transparent), 0 2px 10px rgba(0,0,0,0.18); }
}
.t-pct-ends {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-b);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* ── RESULT INFO CARDS ── */
.t-info-card {
  padding: 22px 24px;
  background: linear-gradient(135deg, rgba(28, 28, 30, 0.5) 0%, rgba(18, 18, 18, 0.35) 100%);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--r-xl);
  border: 1px solid var(--card-border) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
}
html.light .t-info-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.75) 0%, rgba(245, 247, 251, 0.5) 100%);
}
.t-info-card-title {
  font-family: var(--font-h);
  font-size: 16px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.t-info-card-title .icon { font-size: 18px; display: inline-flex; align-items: center; }
.t-info-card p {
  font-family: var(--font-b);
  font-size: 14px;
  font-weight: 400;
  color: var(--text-muted);
  line-height: 1.7;
}
.t-info-card p + p { margin-top: 12px; }
.t-info-card strong { color: var(--text); font-weight: 700; }

/* ── SCORE RANGE TABLE OVERHAUL ── */
.rt-range-table {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}
.rt-range-row {
  display: grid;
  grid-template-columns: 12px 90px 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  border-radius: var(--r-md);
  font-family: var(--font-b);
  font-size: 13.5px;
  border: 1px solid transparent;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  background: color-mix(in srgb, var(--color-on-surface) 2%, transparent);
}
.rt-range-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  transition: transform 0.2s;
}
.rt-range-label { font-weight: 700; color: var(--text); }
.rt-range-val   { color: var(--text-muted); }
.rt-range-pct   { font-weight: 700; text-align: right; }

.rt-range-row.elite {
  border-color: rgba(16, 185, 129, 0.15);
  background: color-mix(in srgb, #10b981 6%, rgba(28, 28, 30, 0.05));
}
.rt-range-row.elite .rt-range-dot { background: #10b981; }
.rt-range-row.elite .rt-range-pct { color: #10b981; }

.rt-range-row.fast {
  border-color: rgba(14, 165, 233, 0.15);
  background: color-mix(in srgb, #0ea5e9 6%, rgba(28, 28, 30, 0.05));
}
.rt-range-row.fast .rt-range-dot { background: #0ea5e9; }
.rt-range-row.fast .rt-range-pct { color: #0ea5e9; }

.rt-range-row.avg {
  border-color: rgba(245, 166, 35, 0.15);
  background: color-mix(in srgb, #f5a623 6%, rgba(28, 28, 30, 0.05));
}
.rt-range-row.avg .rt-range-dot { background: #f5a623; }
.rt-range-row.avg .rt-range-pct { color: #f5a623; }

.rt-range-row.slow {
  border-color: rgba(239, 68, 68, 0.15);
  background: color-mix(in srgb, #ef4444 6%, rgba(28, 28, 30, 0.05));
}
.rt-range-row.slow .rt-range-dot { background: #ef4444; }
.rt-range-row.slow .rt-range-pct { color: #ef4444; }

.rt-range-row:hover {
  transform: translateX(3px);
  border-color: color-mix(in srgb, var(--text) 10%, transparent);
}
.rt-range-row:hover .rt-range-dot {
  transform: scale(1.3);
}

/* ── STATS GRID OVERHAUL ── */
.t-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.t-stat {
  text-align: center;
  padding: 16px 10px;
  background: linear-gradient(135deg, rgba(28, 28, 30, 0.4) 0%, rgba(18, 18, 18, 0.25) 100%);
  border: 1px solid var(--card-border);
  border-radius: var(--r-lg);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
}
html.light .t-stat {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.7) 0%, rgba(245, 247, 251, 0.4) 100%);
}
.t-stat:hover {
  transform: translateY(-2px);
  border-color: var(--test-accent-border);
  box-shadow: 0 8px 20px color-mix(in srgb, var(--test-accent) 10%, transparent);
}
.t-stat-val {
  font-family: var(--font-h);
  font-size: 26px;
  font-weight: 900;
  color: var(--test-accent);
  text-shadow: 0 0 20px color-mix(in srgb, var(--test-accent) 10%, transparent);
}
.t-stat-lbl {
  font-family: var(--font-b);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 4px;
}

/* ── TRIAL BARS OVERHAUL ── */
.rt-trial-bars {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  height: 110px;
  margin-top: 16px;
  margin-bottom: 8px;
  width: 100%;
}
.rt-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
  cursor: pointer;
}
.rt-bar-label {
  font-family: var(--font-b);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-faint);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.rt-bar {
  width: 20px;
  border-radius: 6px 6px 0 0;
  min-height: 6px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
}
.rt-bar.ok {
  background: linear-gradient(180deg, var(--test-accent) 0%, color-mix(in srgb, var(--test-accent) 70%, transparent) 100%);
  box-shadow: 0 4px 12px color-mix(in srgb, var(--test-accent) 15%, transparent);
}
.rt-bar.best {
  background: linear-gradient(180deg, #34d399 0%, #10b981 100%);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.25);
}
.rt-bar.worst {
  background: linear-gradient(180deg, #f87171 0%, #ef4444 100%);
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}
.rt-bar.error {
  background: linear-gradient(180deg, var(--color-outline-variant) 0%, var(--color-outline) 100%);
}
.rt-bar-wrap:hover .rt-bar {
  transform: translateY(-2px) scaleX(1.05);
  filter: brightness(1.08);
}
.rt-bar-wrap:hover .rt-bar.best {
  box-shadow: 0 6px 16px rgba(16, 185, 129, 0.4);
}
.rt-bar-wrap:hover .rt-bar.worst {
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.4);
}
.rt-bar-wrap:hover .rt-bar.ok {
  box-shadow: 0 6px 16px color-mix(in srgb, var(--test-accent) 30%, transparent);
}
.rt-bar-val {
  font-family: var(--font-b);
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
  transition: color 0.2s, transform 0.2s;
}
.rt-bar-wrap:hover .rt-bar-val {
  color: var(--text);
  transform: translateY(-1px);
}

/* ── FACTOR GRID ── */
.t-factors {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}
.t-factor {
  text-align: center;
  padding: 16px 12px;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  border-radius: var(--r-md);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.t-factor:hover { border-color: var(--test-accent-border); box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.t-factor-icon { font-size: 24px; display: block; margin-bottom: 8px; }
.t-factor-label { font-family: var(--font-h); font-size: 13px; font-weight: 800; color: var(--text); }
.t-factor-desc { font-family: var(--font-b); font-size: 12px; color: var(--text-muted); margin-top: 4px; line-height: 1.5; }

/* ── ACTION BUTTONS ── */
.t-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}
.t-btn-primary {
  flex: 1;
  padding: 16px;
  background: color-mix(in srgb, var(--test-accent) 8%, transparent);
  color: var(--test-accent) !important;
  border: 2px solid color-mix(in srgb, var(--test-accent) 25%, transparent);
  border-radius: var(--r-lg);
  font-family: var(--font-b);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  touch-action: manipulation;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}
.t-btn-primary:hover {
  background: color-mix(in srgb, var(--test-accent) 15%, transparent);
  border-color: var(--test-accent);
  color: var(--test-accent) !important;
  transform: translateY(-1.5px);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--test-accent) 15%, transparent);
}
.t-btn-primary:active {
  transform: scale(0.97);
}
.t-btn-secondary {
  flex: 1;
  padding: 14px;
  background: transparent;
  color: var(--color-on-surface-variant);
  border: 2px solid var(--color-outline);
  border-radius: var(--r-lg);
  font-family: var(--font-b);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.t-btn-secondary:hover { border-color: var(--test-accent); color: var(--test-accent); background: var(--test-accent-soft); }
@media (max-width: 480px) { .t-actions { flex-direction: column; } }

/* ── RESTART BUTTON (shared across all cognitive tests) ── */
.wm-restart-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  background: transparent;
  border: 1.5px solid var(--color-outline);
  border-radius: var(--r-sm);
  font-family: var(--font-b);
  font-size: 11px;
  font-weight: 700;
  color: var(--color-on-surface-variant);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
  transition: all 0.15s;
}
.wm-restart-btn:hover  { border-color: var(--test-accent); color: var(--test-accent); }
.wm-restart-btn:active { transform: scale(0.95); }

/* ── ANIMATIONS ── */
@keyframes fadeSlideUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes scaleIn {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.08); }
}
@keyframes flashGreen {
  0%   { background: #2ecc71; }
  100% { background: #f0f4f7; }
}
@keyframes flashRed {
  0%   { background: #e74c3c; }
  100% { background: #f0f4f7; }
}
@keyframes shakeElement {
  10%, 90% { transform: translate3d(-3px, 0, 0); }
  20%, 80% { transform: translate3d(5px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-7px, 0, 0); }
  40%, 60% { transform: translate3d(7px, 0, 0); }
}

.anim-fadein { animation: fadeSlideUp 0.35s cubic-bezier(0.4, 0, 0.2, 1) both; }
.anim-scalein { animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

/* Shake animation for errors/misses/early clicks */
.t-shake {
  animation: shakeElement 0.4s cubic-bezier(.36,.07,.19,.97) both;
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  perspective: 1000px;
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE
   ══════════════════════════════════════════════════════════════════ */
@media (max-width: 480px) {
  /* Shell */
  .t-shell { padding: 0 12px 36px; }

  /* Intro */
  .t-intro-title { font-size: 26px; }
  .t-intro-sub { font-size: 14px; margin-bottom: 20px; }
  .t-intro-icon { font-size: 44px; margin-bottom: 14px; }
  .t-btn-start { max-width: 100%; padding: 16px 20px; font-size: 15px; }
  .t-steps { max-width: 100%; }
  .t-step { padding: 10px 12px; }
  .t-step-text { font-size: 12.5px; }

  /* Result hero score */
  .t-score-big { font-size: 52px; }
  .t-score-unit { font-size: 18px; }
  .t-score-label { font-size: 11px; }
  .t-score-interp { font-size: 13px; }
  .t-result-hero { padding: 24px 16px; }

  /* Percentile bar */
  .t-pct-box { padding: 16px 14px; }
  .t-pct-label { font-size: 13px; }
  .t-pct-ends { font-size: 10px; }

  /* Info cards */
  .t-info-card { padding: 16px 14px; }
  .t-info-card-title { font-size: 14px; }
  .t-info-card p { font-size: 13px; }

  /* Score range table */
  .rt-range-row { grid-template-columns: 8px 60px 1fr auto; gap: 6px; padding: 8px 10px; font-size: 12px; }
  .rt-range-dot { width: 8px; height: 8px; }

  /* Stats grid */
  .t-stats { gap: 8px; }
  .t-stat { padding: 14px 6px; }
  .t-stat-val { font-size: 20px; }
  .t-stat-lbl { font-size: 10px; }

  /* Factor grid */
  .t-factors { gap: 8px; }
  .t-factor { padding: 12px 8px; }
  .t-factor-icon { font-size: 20px; margin-bottom: 6px; }
  .t-factor-label { font-size: 12px; }
  .t-factor-desc { font-size: 11px; }

  /* Action buttons */
  .t-btn-primary { padding: 14px; font-size: 14px; }
  .t-btn-secondary { padding: 12px; font-size: 13px; }
}

@media (max-width: 360px) {
  .t-score-big { font-size: 44px; }
  .t-score-unit { font-size: 16px; }
  .t-intro-title { font-size: 22px; }
  .rt-range-row { grid-template-columns: 8px 50px 1fr auto; font-size: 11px; padding: 7px 8px; }
  .t-factors { grid-template-columns: 1fr; }
}

/* ── SLEEK CENTERED FOOTER ── */
.t-footer {
  margin-top: auto;
  padding-top: 40px;
  padding-bottom: 48px; /* Added breathing room at the bottom */
  text-align: center;
  font-family: var(--font-b);
}
.t-footer-links {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px; /* Slightly wider gap for better spacing */
  font-size: 12px; /* Matches homepage text-xs */
  font-weight: 600; /* Matches homepage font-semibold */
}
.t-footer-links a,
.t-footer-links button {
  color: var(--color-footer-text, var(--text-muted));
  text-decoration: none;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  transition: color 0.15s ease;
}
.t-footer-links a:hover,
.t-footer-links button:hover {
  color: var(--test-accent);
}
.t-footer-links span {
  color: var(--color-footer-text, var(--color-outline-variant));
  user-select: none;
  opacity: 0.6;
}
.t-footer-copy {
  font-size: 11px;
  color: var(--color-footer-text, var(--text-faint));
  margin-top: 10px;
  opacity: 0.8;
}

/* ── MOBILE STEPS FALLBACK ── */
@media (max-width: 480px) {
  .t-steps {
    grid-template-columns: 1fr;
  }
}

/* ── DARK MODE COLOR OPTIMIZATIONS ── */
html.dark .rt-range-row.elite { background: color-mix(in srgb, #2ecc71 10%, var(--color-surface)) !important; }
html.dark .rt-range-row.fast  { background: color-mix(in srgb, #0ea5e9 10%, var(--color-surface)) !important; }
html.dark .rt-range-row.avg   { background: color-mix(in srgb, #f5a623 10%, var(--color-surface)) !important; }
html.dark .rt-range-row.slow  { background: color-mix(in srgb, #e74c3c 10%, var(--color-surface)) !important; }

/* Global intro visual containers styling */
[class*="-intro-visual"] {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  background: var(--color-surface-container-low);
  border: 1px solid var(--color-outline);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  min-height: 140px;
  box-sizing: border-box;
}

@media (max-width: 480px) {
  [class*="-intro-visual"] {
    gap: 16px;
    padding: 16px;
    margin-bottom: 16px;
  }
}

/* Global dark mode overrides for test status/stimulus containers to avoid bright light backgrounds */
html.dark .t-stimulus,
html.dark .rt-box,
html.dark .f1-panel,
html.dark .gng-panel,
html.dark .vm-word-box,
html.dark .timer-arena,
html.dark .wm-box,
html.dark .ts-box,
html.dark .sa-box,
html.dark .sm-box,
html.dark .ps-box,
html.dark .stroop-word-box,
html.dark .tp-text-box,
html.dark .mash-arena,
html.dark .chimp-box,
html.dark .cp-box,
html.dark .pm-box,
html.dark .chimp-grid,
html.dark .cp-grid,
html.dark .pm-grid {
  background: var(--color-surface-container-low) !important;
  border-color: var(--color-outline) !important;
  color: var(--text) !important;
}

html.dark [class*="-intro-visual"] {
  background: var(--color-surface-container-low) !important;
  border-color: var(--color-outline) !important;
}

/* F1 Columns & Bulbs dark mode adjustments */
html.dark .f1-col {
  background: var(--color-surface-container-high) !important;
  border-color: var(--color-outline) !important;
}
html.dark .f1-bulb {
  background: var(--color-outline-variant) !important;
  border-color: var(--color-outline) !important;
}
html.dark .f1-col.lit .f1-bulb {
  background: #ef4444 !important;
  border-color: #dc2626 !important;
}
html.dark .f1-panel[data-state="go"] .f1-bulb,
html.dark .f1-panel[data-state="hit"] .f1-bulb {
  background: #34d399 !important;
  border-color: #10b981 !important;
}


/* Chimp test grid cells */
html.dark .chimp-cell {
  background: var(--color-surface-container-high) !important;
  border-color: var(--color-outline) !important;
}

/* Pattern memory & sequence memory cells */
html.dark .pm-grid .pm-cell,
html.dark .sm-box .sm-block,
html.dark .sm-box .sm-cell,
html.dark .sm-mini-block {
  background: var(--color-surface-container-high) !important;
  border-color: var(--color-outline) !important;
}

/* Working memory numpad keys, digit boxes, and mini keys */
html.dark .wm-key {
  background: var(--color-surface-container-high) !important;
  border-color: var(--color-outline) !important;
  color: var(--text) !important;
  box-shadow: 0 4px 0 var(--color-outline) !important;
}
html.dark .wm-key:active {
  box-shadow: 0 0 0 var(--color-outline) !important;
}
html.dark .wm-key.clear {
  background: var(--color-surface-container-low) !important;
}
html.dark .wm-key.submit {
  background: var(--test-accent) !important;
  border-color: var(--test-accent) !important;
  color: #fff !important;
  box-shadow: 0 4px 0 color-mix(in srgb, var(--test-accent) 60%, black) !important;
}
html.dark .wm-key.submit:active {
  box-shadow: 0 0 0 color-mix(in srgb, var(--test-accent) 60%, black) !important;
}
html.dark .wm-digit-box,
html.dark .wm-mini-key {
  background: var(--color-surface-container-high) !important;
  border-color: var(--color-outline) !important;
}


/* Typing speed input field */
html.dark .tp-input {
  background: var(--color-surface-container) !important;
  border-color: var(--color-outline) !important;
  color: var(--text) !important;
}
html.dark .tp-wrong {
  background: color-mix(in srgb, #ef4444 25%, transparent) !important;
}

/* Verbal memory buttons */
html.dark .vm-btn-seen {
  background: color-mix(in srgb, #0d9488 15%, var(--color-surface)) !important;
  color: #2dd4bf !important;
  border-color: color-mix(in srgb, #0d9488 30%, var(--color-surface)) !important;
}
html.dark .vm-btn-seen:hover {
  background: #0d9488 !important;
  color: #fff !important;
  border-color: #0d9488 !important;
}
html.dark .vm-btn-new {
  background: color-mix(in srgb, #8b5cf6 15%, var(--color-surface)) !important;
  color: #a78bfa !important;
  border-color: color-mix(in srgb, #8b5cf6 30%, var(--color-surface)) !important;
}
html.dark .vm-btn-new:hover {
  background: #8b5cf6 !important;
  color: #fff !important;
  border-color: #8b5cf6 !important;
}

/* Blind timer trial rows */
html.dark .timer-trial-row {
  background: var(--color-surface-container-low) !important;
}

/* Contrast enhancement for test icons in dark mode */
html.dark .t-intro-icon {
  background: color-mix(in srgb, var(--test-accent) 20%, var(--color-surface)) !important;
  border-color: color-mix(in srgb, var(--test-accent) 40%, var(--color-surface)) !important;
}
html.dark .t-intro-icon::before {
  filter: brightness(1.25) saturate(1.25) !important;
}

/* Dark mode state overrides for gameplay containers */
html.dark .t-stimulus[data-state="hit"],
html.dark .rt-box[data-state="hit"],
html.dark .gng-panel[data-state="hit"] {
  background: color-mix(in srgb, #2ecc71 12%, var(--color-surface)) !important;
}

html.dark .t-stimulus[data-state="miss"],
html.dark .t-stimulus[data-state="early"],
html.dark .rt-box[data-state="miss"],
html.dark .rt-box[data-state="early"],
html.dark .ts-box[data-state="miss"],
html.dark .sa-box[data-state="miss"],
html.dark .sm-box[data-state="miss"],
html.dark .gng-panel[data-state="nogo"],
html.dark .gng-panel[data-state="miss"],
html.dark .f1-panel[data-state="early"] {
  background: color-mix(in srgb, #e74c3c 12%, var(--color-surface)) !important;
}

html.dark .wm-box[data-state="miss"] {
  background: color-mix(in srgb, #e74c3c 12%, var(--color-surface)) !important;
}

/* Gameplay container state: go/active */
html.dark .t-stimulus[data-state="go"],
html.dark .rt-box[data-state="go"] {
  background: #2ecc71 !important;
}
html.dark .t-stimulus[data-state="go"] *,
html.dark .rt-box[data-state="go"] * {
  color: #fff !important;
}

/* Go/No-Go panel green and yellow states */
html.dark .gng-panel[data-state="go"],
html.dark .gng-panel[data-state="correct-hold"] {
  background: color-mix(in srgb, #2ecc71 12%, var(--color-surface)) !important;
}
html.dark .gng-panel[data-state="false-alarm"] {
  background: color-mix(in srgb, #fbbf24 12%, var(--color-surface)) !important;
}

/* Working memory active flash and hit states */
html.dark .wm-box[data-state="flash"] {
  background: var(--color-surface-container-low) !important;
  color: var(--test-accent) !important;
}
html.dark .wm-box[data-state="flash"] * {
  color: var(--test-accent) !important;
}
html.dark .wm-box[data-state="hit"] {
  background: color-mix(in srgb, #2ecc71 12%, var(--color-surface)) !important;
}

/* Hit states for other containers */
html.dark .ts-box[data-state="hit"],
html.dark .sa-box[data-state="hit"] {
  background: color-mix(in srgb, #2ecc71 12%, var(--color-surface)) !important;
}

/* Pattern memory cell states overrides */
html.dark .pm-grid .pm-cell.pm-highlight {
  background: #22c55e !important;
}
html.dark .pm-grid .pm-cell.pm-correct {
  background: #22c55e !important;
  border-color: #16a34a !important;
}
html.dark .pm-grid .pm-cell.pm-wrong {
  background: #ef4444 !important;
  border-color: #dc2626 !important;
}

/* Sequence memory cell states overrides */
html.dark .sm-box .sm-block.flash {
  background: var(--test-accent) !important;
}
html.dark .sm-box .sm-block.active {
  background: var(--test-accent) !important;
  border-color: var(--test-accent) !important;
}
html.dark .sm-box .sm-block.wrong {
  background: #e74c3c !important;
  border-color: #c0392b !important;
  opacity: 1 !important;
}
html.dark .sm-box .sm-block.correct-missed {
  background: #2ecc71 !important;
  border-color: #27ae60 !important;
  opacity: 1 !important;
}

/* Chimp test cells dark mode adjustments */
html.dark .chimp-cell.chimp-num {
  background: #f59e0b !important;
  border-color: #d97706 !important;
  color: #fff !important;
}
html.dark .chimp-cell.chimp-num:hover {
  background: #d97706 !important;
}
html.dark .chimp-cell.chimp-hidden {
  background: #f59e0b !important;
  border-color: #d97706 !important;
  color: transparent !important;
}
html.dark .chimp-cell.chimp-hidden:hover {
  background: #d97706 !important;
}

/* ── LIVE HEARTS ── */
.live-heart {
  font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
  font-size: 20px;
  vertical-align: middle;
  margin: 0 2px;
  transition: color 0.15s, transform 0.15s;
  display: inline-block;
}
.live-heart.full {
  color: #ef4444;
}
.live-heart.empty {
  font-variation-settings: 'FILL' 0;
  color: var(--color-outline-variant);
  opacity: 0.5;
}
html.dark .live-heart.empty {
  color: var(--color-outline-variant) !important;
  opacity: 0.35 !important;
}

/* ── SMALL ELEVATED RETAKE BUTTON ── */
.t-btn-retake-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 18px;
  background: var(--color-primary);
  color: var(--color-on-primary);
  border: 1.5px solid var(--test-accent);
  border-radius: 9999px;
  font-family: var(--font-b);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  text-decoration: none;
  margin-top: 14px;
}
.t-btn-retake-small:hover {
  background: var(--test-accent);
  color: var(--color-background);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--test-accent) 30%, transparent);
}
.t-btn-retake-small:active {
  transform: scale(0.97);
}

/* ── UNIFIED HERO ACTIONS (TRY AGAIN & DOWNLOAD CARD) ── */
.t-hero-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 24px !important;
  width: 100%;
  max-width: 640px; /* Increased to give 3 buttons breathing room on desktop */
  margin-left: auto;
  margin-right: auto;
}

.t-hero-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  border-radius: 14px; /* Matches the site's premium rounded-rect style */
  font-family: var(--font-b);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  text-decoration: none;
  box-sizing: border-box;
  white-space: nowrap;
  border: 1.5px solid transparent;
}

.t-hero-btn-primary {
  background: color-mix(in srgb, var(--color-on-surface) 8%, transparent);
  color: var(--color-on-surface) !important;
  border: 1.5px solid color-mix(in srgb, var(--color-on-surface) 20%, transparent);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}
.t-hero-btn-primary:hover {
  background: color-mix(in srgb, var(--test-accent) 8%, transparent);
  border-color: var(--test-accent);
  color: var(--test-accent) !important;
  transform: translateY(-1.5px);
  box-shadow: 0 6px 15px color-mix(in srgb, var(--test-accent) 15%, transparent);
}
.t-hero-btn-primary:active {
  transform: scale(0.97);
}

.t-hero-btn-secondary {
  background: color-mix(in srgb, var(--color-on-surface) 4%, transparent);
  color: color-mix(in srgb, var(--color-on-surface) 60%, transparent);
  border: 1.5px solid color-mix(in srgb, var(--color-on-surface) 8%, transparent);
}
.t-hero-btn-secondary:hover {
  background: color-mix(in srgb, var(--color-on-surface) 8%, transparent);
  border-color: var(--test-accent);
  color: var(--test-accent);
  transform: translateY(-1.5px);
}
.t-hero-btn-secondary:active {
  transform: scale(0.97);
}

/* Challenge A Friend Button (Subtle, Premium Indigo) */
.t-hero-btn-challenge {
  background: color-mix(in srgb, var(--color-on-surface) 4%, transparent);
  color: color-mix(in srgb, var(--color-on-surface) 60%, transparent) !important;
  border: 1.5px solid color-mix(in srgb, var(--color-on-surface) 8%, transparent);
}
.t-hero-btn-challenge:hover {
  background: color-mix(in srgb, #6366f1 8%, transparent);
  border-color: #6366f1;
  color: #818cf8 !important;
  transform: translateY(-1.5px);
  box-shadow: 0 6px 15px rgba(99, 102, 241, 0.12);
}
.t-hero-btn-challenge:active {
  transform: scale(0.97);
}

/* Download Card Button (Premium Subtle Emerald) */
.t-hero-btn-download {
  background: color-mix(in srgb, var(--color-on-surface) 4%, transparent);
  color: color-mix(in srgb, var(--color-on-surface) 60%, transparent) !important;
  border: 1.5px solid color-mix(in srgb, var(--color-on-surface) 8%, transparent);
}
.t-hero-btn-download:hover {
  background: color-mix(in srgb, #10b981 8%, transparent);
  border-color: #10b981;
  color: #10b981 !important;
  transform: translateY(-1.5px);
  box-shadow: 0 6px 15px rgba(16, 185, 129, 0.1);
}
.t-hero-btn-download:active {
  transform: scale(0.97);
}

/* ── SCORECARD HERO DECLUTTERING & SPACING ── */
.t-hero-best-stats {
  display: flex;
  gap: 12px;
  justify-content: center;
  align-items: center;
  margin-top: 20px;
  font-size: 12.5px;
  color: var(--text-muted);
  font-family: var(--font-b);
  font-weight: 600;
  opacity: 0.85;
}

.t-hero-best-stats strong {
  color: var(--text);
}

.t-hero-device-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
}

.t-hero-device-wrapper .t-hero-hardware-pill {
  margin-top: 24px !important;
}

.t-hero-device-wrapper .t-hero-hardware-note {
  margin-top: 8px;
  font-size: 10px;
  color: var(--text-muted);
  max-width: 600px;
  opacity: 0.8;
  text-align: center;
}

@media (max-width: 480px) {
  .t-hero-actions {
    flex-direction: column;
    width: 100%;
    gap: 10px;
  }
  .t-hero-btn {
    width: 100%;
  }
}

/* ── UNIVERSAL COUNTDOWN OVERLAY ── */
.t-countdown-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
  align-items: center;
  justify-content: center;
  font-family: var(--font-h, 'Manrope', sans-serif);
  font-size: 96px;
  font-weight: 900;
  color: var(--test-accent);
  background: var(--color-surface-container-low);
  z-index: 100;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.t-countdown-overlay.active {
  display: flex;
  opacity: 1;
}
.t-countdown-num {
  animation: countdownTick 1s ease-in-out infinite;
}
@keyframes countdownTick {
  0% { transform: scale(0.5); opacity: 0; }
  10% { transform: scale(1.1); opacity: 1; }
  90% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.8); opacity: 0; }
}

.t-countdown-active > *:not(.t-countdown-overlay) {
  opacity: 0.15 !important;
  pointer-events: none !important;
  filter: blur(2px);
}

/* ── UNIVERSAL SCORE RANGE TABLE HIGHLIGHTING ── */
.rt-range-table {
  display: flex !important;
  flex-direction: column !important;
  gap: 8px !important;
  margin-top: 4px !important;
}

.rt-range-row {
  display: grid !important;
  grid-template-columns: 10px 100px 1fr auto !important;
  align-items: center !important;
  gap: 10px !important;
  padding: 8px 12px !important;
  border-radius: 8px !important;
  font-family: 'Lexend', sans-serif !important;
  font-size: 13px !important;
  opacity: 0.55 !important;
  background: var(--color-surface-container-low) !important;
  border: 1.5px solid var(--color-outline) !important;
  transform: scale(0.98) !important;
  transition: all 0.2s ease !important;
}

.rt-range-dot {
  width: 10px !important;
  height: 10px !important;
  border-radius: 50% !important;
  opacity: 0.5 !important;
}

.rt-range-label {
  font-weight: 700 !important;
  color: var(--text) !important;
}

.rt-range-val {
  color: var(--text-muted) !important;
}

.rt-range-pct {
  font-weight: 700 !important;
  text-align: right !important;
  color: var(--text-muted) !important;
}

/* Active Highlighted State */
.rt-range-row.active {
  opacity: 1 !important;
  transform: scale(1.025) !important;
  border-width: 1.5px !important;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08) !important;
  font-weight: 700 !important;
}

.rt-range-row.active .rt-range-dot {
  opacity: 1 !important;
  transform: scale(1.3) !important;
}

/* Elite Active (Green) */
.rt-range-row.active.elite {
  background: color-mix(in srgb, #10b981 12%, var(--color-surface)) !important;
  border-color: #10b981 !important;
}
.rt-range-row.active.elite .rt-range-dot {
  background: #10b981 !important;
}
.rt-range-row.active.elite .rt-range-pct {
  color: #10b981 !important;
}

/* Fast Active (Blue) */
.rt-range-row.active.fast {
  background: color-mix(in srgb, #0ea5e9 12%, var(--color-surface)) !important;
  border-color: #0ea5e9 !important;
}
.rt-range-row.active.fast .rt-range-dot {
  background: #0ea5e9 !important;
}
.rt-range-row.active.fast .rt-range-pct {
  color: #0ea5e9 !important;
}

/* Avg Active (Orange) */
.rt-range-row.active.avg {
  background: color-mix(in srgb, #f5a623 12%, var(--color-surface)) !important;
  border-color: #f5a623 !important;
}
.rt-range-row.active.avg .rt-range-dot {
  background: #f5a623 !important;
}
.rt-range-row.active.avg .rt-range-pct {
  color: #f5a623 !important;
}

/* Slow Active (Red) */
.rt-range-row.active.slow {
  background: color-mix(in srgb, #ef4444 12%, var(--color-surface)) !important;
  border-color: #ef4444 !important;
}
.rt-range-row.active.slow .rt-range-dot {
  background: #ef4444 !important;
}
.rt-range-row.active.slow .rt-range-pct {
  color: #ef4444 !important;
}

/* Dark Mode Overrides */
html.dark .rt-range-row.active.elite {
  background: color-mix(in srgb, #2ecc71 15%, var(--color-surface)) !important;
  border-color: #2ecc71 !important;
}
html.dark .rt-range-row.active.elite .rt-range-dot {
  background: #2ecc71 !important;
}
html.dark .rt-range-row.active.elite .rt-range-pct {
  color: #2ecc71 !important;
}

html.dark .rt-range-row.active.fast {
  background: color-mix(in srgb, #0ea5e9 15%, var(--color-surface)) !important;
  border-color: #0ea5e9 !important;
}
html.dark .rt-range-row.active.fast .rt-range-dot {
  background: #0ea5e9 !important;
}
html.dark .rt-range-row.active.fast .rt-range-pct {
  color: #0ea5e9 !important;
}

html.dark .rt-range-row.active.avg {
  background: color-mix(in srgb, #f5a623 15%, var(--color-surface)) !important;
  border-color: #f5a623 !important;
}
html.dark .rt-range-row.active.avg .rt-range-dot {
  background: #f5a623 !important;
}
html.dark .rt-range-row.active.avg .rt-range-pct {
  color: #f5a623 !important;
}

html.dark .rt-range-row.active.slow {
  background: color-mix(in srgb, #e74c3c 15%, var(--color-surface)) !important;
  border-color: #e74c3c !important;
}
html.dark .rt-range-row.active.slow .rt-range-dot {
  background: #e74c3c !important;
}
html.dark .rt-range-row.active.slow .rt-range-pct {
  color: #e74c3c !important;
}
