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

:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --border: #272727;
  --border-bright: #3a3a3a;
  --text: #e8e8e8;
  --muted: #666;
  --dimmed: #3d3d3d;
  --accent: #e8e8e8;
  --red:    #e05252;
  --green:  #5ec97a;
  --yellow: #d4aa3f;
  --orange: #d97b3a;
  --purple: #9b7fe8;
  --pink:   #d965a0;
  --font-mono: 'IBM Plex Mono', monospace;
  --font-sans: 'IBM Plex Sans', sans-serif;
  --radius: 6px;
  --transition: 0.22s ease;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 300;
  overflow: hidden;
}

/* ── Layout ── */
#app {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%; height: 100%;
  padding: 2rem 1.5rem;
  overflow-y: auto;
}

.page {
  display: none;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  max-width: 500px;
  animation: fadein 0.4s ease;
}
.page.active { display: flex; }

@keyframes fadein {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 2rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1rem;
}

.task-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
}

.nav-arrows {
  display: flex;
  gap: 8px;
}

.nav-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  width: 32px; height: 32px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  transition: border-color var(--transition), background var(--transition);
  font-family: var(--font-mono);
}
.nav-btn:hover { border-color: var(--border-bright); background: var(--surface); }
.nav-btn:disabled { opacity: 0.25; cursor: not-allowed; }
.nav-btn.hidden { visibility: hidden; }

/* ── Typography ── */
.section-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 1.2rem;
}

h2 {
  font-family: var(--font-mono);
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 1rem;
  line-height: 1.3;
  color: var(--text);
}

p {
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 300;
  line-height: 1.75;
  color: #bbb;
  margin-bottom: 0.85rem;
}

ul { list-style: none; margin-bottom: 1rem; }
ul li {
  font-family: var(--font-sans);
  font-size: 14px;
  color: #bbb;
  padding: 5px 0 5px 18px;
  position: relative;
  line-height: 1.6;
}
ul li::before {
  content: '—';
  position: absolute;
  left: 0;
  color: var(--dimmed);
}

.warn {
  border: 1px solid #5a3030;
  background: #1a0d0d;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: var(--font-sans);
  font-size: 13px;
  color: #e08080;
  margin-top: 1rem;
}

/* ── Buttons ── */
.btn {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.05em;
  padding: 10px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border-bright);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), transform 0.1s;
  margin-top: 1.5rem;
}
.btn:hover { background: var(--surface); border-color: #555; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}
.btn-primary:hover { background: #ccc; border-color: #ccc; }

/* ── Stimulus display ── */
#stim-area {
  width: 100%;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  margin-bottom: 1.2rem;
  position: relative;
  overflow: hidden;
}

#stim-word {
  font-family: var(--font-mono);
  font-size: 56px;
  font-weight: 600;
  letter-spacing: -1px;
  line-height: 1;
  transition: opacity 0.1s, transform 0.12s;
  user-select: none;
}
#stim-word.flash {
  opacity: 0.4;
  transform: scale(1.06);
}

#stim-hint {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dimmed);
  margin-top: 14px;
  font-family: var(--font-mono);
  text-align: center;
}

/* ── Progress ── */
.progress-wrap {
  width: 100%;
  height: 2px;
  background: var(--border);
  border-radius: 2px;
  margin-bottom: 1.2rem;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  background: var(--text);
  border-radius: 2px;
  transition: width 0.35s ease;
}

/* ── Stats row ── */
.stats-row {
  display: flex;
  gap: 10px;
  width: 100%;
  margin-bottom: 1.2rem;
}
.stat {
  flex: 1;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.stat-lbl {
  display: block;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}
.stat-val {
  display: block;
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}

/* ── Feedback ── */
#feedback-line {
  font-size: 12px;
  color: var(--muted);
  min-height: 18px;
  text-align: center;
  width: 100%;
  transition: color 0.2s;
  font-family: var(--font-mono);
  margin-top: 0.5rem;
}
#feedback-line.ok  { color: var(--green); }
#feedback-line.bad { color: var(--red); }

/* ── Results ── */
.result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  margin: 1.2rem 0;
}

.result-card {
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}
.result-card .rc-lbl {
  display: block;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 6px;
}
.result-card .rc-val {
  display: block;
  font-size: 24px;
  font-weight: 500;
}

/* ── Chart ── */
.chart-wrap {
  width: 100%;
  padding: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 0.5rem;
}
.chart-wrap canvas { max-height: 220px; }

/* ── Step instruction ── */
.step-num {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }

/* ── Responsive ── */
@media (max-width: 480px) {
  #app { padding: 1.2rem 1rem; }
  .page-header { margin-bottom: 1.4rem; }
  h2 { font-size: 19px; }
  #stim-word { font-size: 42px; }
  .stat-val { font-size: 16px; }
}
