/* ===== VARIABLES ===== */
:root {
    --bg: #0a0b14;
    --surface: #131520;
    --surface2: #1c1e30;
    --border: rgba(255, 255, 255, 0.07);
    --text: #e4e4f0;
    --muted: #7878a0;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
    --ease: 0.2s ease;
}

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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ===== LAYOUT ===== */
#app { min-height: 100vh; display: flex; flex-direction: column; }

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(10, 11, 20, 0.85);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    user-select: none;
}

.logo-mark {
    font-size: 30px;
    background: linear-gradient(135deg, #4fc3f7 0%, #9c6fff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
}

.brand-name { font-size: 18px; font-weight: 700; letter-spacing: -0.3px; }
.brand-sub  { font-size: 11px; color: var(--muted); letter-spacing: 0.3px; margin-top: 1px; }

.nav-stats { display: flex; gap: 24px; }

.nav-stat-value { font-size: 18px; font-weight: 700; text-align: right; }
.nav-stat-label { font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.5px; text-align: right; }
.xp-val { color: #ffd166; }
.nav-xp-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.nav-xp-stats { display: flex; gap: 24px; }
.nav-xp-bar-wrap { width: 160px; height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.nav-xp-bar { height: 100%; background: linear-gradient(90deg, #4fc3f7, #9c6fff); border-radius: 2px; transition: width 0.4s ease; }
.nav-xp-hint { font-size: 10px; color: var(--muted); letter-spacing: 0.3px; }
.xp-earned { color: #ffd166; font-size: 22px; font-weight: 700; margin: 4px 0 16px; letter-spacing: -0.3px; }

#main {
    flex: 1;
    padding: 36px 24px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}

/* ===== DASHBOARD ===== */
.dashboard-header {
    text-align: center;
    margin-bottom: 44px;
}

.dashboard-header h1 {
    font-size: 38px;
    font-weight: 800;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #e4e4f0 0%, #8888b0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 10px;
}

.dashboard-header p {
    font-size: 15px;
    color: var(--muted);
    max-width: 480px;
    margin: 0 auto;
    line-height: 1.6;
}

.test-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(310px, 1fr));
    gap: 18px;
}

/* ===== TEST CARD ===== */
.test-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px;
    position: relative;
    overflow: hidden;
    transition: transform var(--ease), border-color var(--ease), box-shadow var(--ease);
}

.test-card::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: var(--cc, #4fc3f7);
    opacity: 0.9;
}

.test-card:hover {
    transform: translateY(-3px);
    border-color: rgba(255,255,255,0.13);
    box-shadow: var(--shadow);
}

.card-top {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 14px;
}

.card-icon {
    font-size: 26px;
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--cc);
}

.card-text h3 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }
.card-text p  { font-size: 13px; color: var(--muted); line-height: 1.4; }

.card-stats {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
}

.card-stat {
    flex: 1;
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 12px;
}

.card-stat-val {
    font-size: 20px;
    font-weight: 700;
    color: var(--cc, #4fc3f7);
    line-height: 1;
    margin-bottom: 2px;
}

.card-stat-lbl {
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.progress-wrap { flex: 1; }

.progress-track {
    height: 4px;
    background: rgba(255,255,255,0.07);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 6px;
}

.progress-fill {
    height: 100%;
    background: var(--cc, #4fc3f7);
    border-radius: 2px;
    transition: width 0.7s cubic-bezier(0.4,0,0.2,1);
}

.level-lbl {
    font-size: 12px;
    color: var(--muted);
}

.level-lbl strong { color: var(--text); }

.btn-start {
    padding: 9px 18px;
    background: var(--cc, #4fc3f7);
    color: #000;
    border: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity var(--ease), transform var(--ease);
    white-space: nowrap;
}

.btn-start:hover { opacity: 0.88; transform: scale(1.03); }

/* ===== TEST VIEW ===== */
.test-view { max-width: 660px; margin: 0 auto; }

.test-nav {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.btn-back {
    padding: 8px 16px;
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: background var(--ease);
}

.btn-back:hover { background: rgba(255,255,255,0.1); }

.test-name { font-size: 17px; font-weight: 700; }

.lv-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: rgba(255,255,255,0.07);
    color: var(--muted);
    margin-left: auto;
}

/* ===== STAGE (shared test container) ===== */
.stage {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 38px 28px;
    text-align: center;
    min-height: 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.stage-title {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.stage-desc {
    font-size: 15px;
    color: var(--muted);
    line-height: 1.6;
}

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 12px 26px;
    border: none;
    border-radius: 22px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--ease);
}

.btn-primary {
    background: linear-gradient(135deg, #4fc3f7, #9c6fff);
    color: #fff;
}

.btn-primary:hover { opacity: 0.88; transform: translateY(-1px); }

.btn-secondary {
    background: rgba(255,255,255,0.07);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-secondary:hover { background: rgba(255,255,255,0.12); }

.btn-lg { padding: 15px 38px; font-size: 16px; border-radius: 28px; }

/* ===== INSTRUCTIONS BOX ===== */
.ibox {
    background: rgba(255,255,255,0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 22px;
    text-align: left;
    max-width: 440px;
    width: 100%;
}

.ibox h4 {
    font-size: 11px;
    font-weight: 700;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-bottom: 10px;
}

.ibox ul { list-style: none; display: flex; flex-direction: column; gap: 7px; }

.ibox li {
    font-size: 13px;
    color: var(--muted);
    display: flex;
    gap: 8px;
    line-height: 1.4;
}

.ibox li::before { content: '›'; color: var(--text); font-weight: 700; flex-shrink: 0; }

/* ===== ROUND DOTS ===== */
.dots {
    display: flex;
    gap: 7px;
    justify-content: center;
}

.dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
    transition: background 0.3s;
}

.dot.ok      { background: #56e39f; }
.dot.fail    { background: #ff4757; }
.dot.current { background: #4fc3f7; animation: dotPulse 1s ease infinite; }

@keyframes dotPulse {
    0%, 100% { transform: scale(1); }
    50%       { transform: scale(1.4); }
}

/* ===== SCORE STRIP ===== */
.score-strip {
    font-size: 14px;
    color: var(--muted);
}

.score-strip strong { color: var(--text); font-size: 17px; }

/* ===== FEEDBACK ===== */
.fb-ok  { color: #56e39f; font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 7px; }
.fb-err { color: #ff4757; font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 7px; }

/* ===== NUMBER MEMORY ===== */
.seq-num {
    font-size: 72px;
    font-weight: 900;
    letter-spacing: -2px;
    font-variant-numeric: tabular-nums;
    font-family: 'Courier New', monospace;
    color: #4fc3f7;
    animation: popIn 0.25s ease;
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.85); }
    to   { opacity: 1; transform: scale(1); }
}

.digit-input {
    width: 100%;
    max-width: 300px;
    padding: 14px 20px;
    background: rgba(255,255,255,0.05);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 26px;
    text-align: center;
    letter-spacing: 10px;
    font-family: 'Courier New', monospace;
    outline: none;
    transition: border-color var(--ease);
}

.digit-input:focus { border-color: #4fc3f7; }

/* ===== TYPING SPEED ===== */
.typing-stage {
    align-items: stretch;
    text-align: left;
    justify-content: flex-start;
}

.typing-top {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    width: 100%;
    align-items: flex-start;
    flex-wrap: wrap;
}

.typing-kicker {
    font-size: 11px;
    color: var(--muted);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.typing-target {
    margin-top: 4px;
    color: #55efc4;
    font-size: 14px;
    font-weight: 800;
}

.typing-metrics {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.typing-metrics div {
    min-width: 82px;
    padding: 9px 10px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
    text-align: center;
}

.typing-metrics strong {
    display: block;
    font-size: 20px;
    color: #55efc4;
    line-height: 1;
}

.typing-metrics span {
    display: block;
    margin-top: 4px;
    font-size: 10px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.typing-prompt {
    width: 100%;
    min-height: 142px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.035);
    color: var(--muted);
    font-size: 20px;
    line-height: 1.75;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: normal;
}

.typing-prompt span { white-space: pre-wrap; }
.typing-prompt span.ok { color: #56e39f; }
.typing-prompt span.bad { color: #ff4757; background: rgba(255,71,87,0.14); }
.typing-prompt span.current { border-bottom: 2px solid #55efc4; }

.typing-input {
    width: 100%;
    min-height: 130px;
    resize: vertical;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.05);
    color: var(--text);
    font: inherit;
    font-size: 18px;
    line-height: 1.6;
    outline: none;
}

.typing-input:focus { border-color: #55efc4; }

/* ===== NUMBERS REVERSED ===== */
.reverse-num {
    font-size: 68px;
    font-weight: 900;
    letter-spacing: 4px;
    font-variant-numeric: tabular-nums;
    font-family: 'Courier New', monospace;
    color: #38d9a9;
    animation: popIn 0.25s ease;
    overflow-wrap: anywhere;
    max-width: 100%;
}

.reverse-input:focus { border-color: #38d9a9; }

/* ===== CHIMP TEST ===== */
.chimp-grid {
    display: grid;
    gap: 7px;
    width: min(430px, calc(100vw - 72px));
    padding: 12px;
    background: rgba(255,255,255,0.025);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.chimp-cell {
    aspect-ratio: 1;
    border-radius: 10px;
    border: 2px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.045);
    color: var(--text);
    font-size: 18px;
    font-weight: 900;
    cursor: pointer;
    transition: background var(--ease), border-color var(--ease), transform var(--ease);
}

.chimp-cell.has-num {
    background: rgba(116,185,255,0.16);
    border-color: rgba(116,185,255,0.55);
    color: #74b9ff;
}

.chimp-cell.hidden-num span { visibility: hidden; }
.chimp-cell:hover:not(:disabled) { transform: translateY(-1px); }
.chimp-cell.cleared { background: rgba(86,227,159,0.22); border-color: #56e39f; }
.chimp-cell.wrong { background: rgba(255,71,87,0.22); border-color: #ff4757; }

/* ===== VERBAL MEMORY ===== */
.verbal-word {
    font-size: 54px;
    font-weight: 900;
    color: #a29bfe;
    text-transform: uppercase;
    letter-spacing: 1px;
    animation: popIn 0.2s ease;
}

.verbal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.verbal-btn {
    min-width: 120px;
    justify-content: center;
}

.timer-fill.verbal-time { background: #a29bfe; }

/* ===== LETTER ORDER ===== */
.letter-seq {
    font-size: 58px;
    font-weight: 900;
    letter-spacing: 8px;
    font-variant-numeric: tabular-nums;
    font-family: 'Courier New', monospace;
    color: #feca57;
    animation: popIn 0.25s ease;
    overflow-wrap: anywhere;
    max-width: 100%;
}

.letter-input,
.math-input {
    width: 100%;
    max-width: 320px;
    padding: 14px 20px;
    background: rgba(255,255,255,0.05);
    border: 2px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 26px;
    text-align: center;
    font-family: 'Courier New', monospace;
    outline: none;
    transition: border-color var(--ease);
}

.letter-input {
    letter-spacing: 8px;
    text-transform: uppercase;
}

.letter-input:focus { border-color: #feca57; }

/* ===== MENTAL MATH ===== */
.math-problem {
    font-size: 58px;
    font-weight: 900;
    color: #00cec9;
    font-family: 'Courier New', monospace;
    animation: popIn 0.2s ease;
}

.math-input:focus { border-color: #00cec9; }
.timer-fill.math-time { background: #00cec9; }

/* ===== SYMBOL CODING ===== */
.symbol-key {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(58px, 1fr));
    gap: 8px;
    width: 100%;
    max-width: 560px;
}

.symbol-key-cell {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 9px 8px;
}

.symbol-glyph {
    font-size: 25px;
    line-height: 1.1;
    color: #ff9f43;
}

.symbol-digit {
    margin-top: 5px;
    font-size: 17px;
    font-weight: 800;
    color: var(--text);
}

.target-symbol {
    width: 122px;
    height: 122px;
    border-radius: 18px;
    background: rgba(255,159,67,0.1);
    border: 2px solid rgba(255,159,67,0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 58px;
    color: #ff9f43;
    box-shadow: 0 0 26px rgba(255,159,67,0.18);
}

.symbol-pad {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    justify-content: center;
    max-width: 420px;
}

.symbol-choice {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 2px solid rgba(255,159,67,0.5);
    background: rgba(255,159,67,0.08);
    color: #ff9f43;
    font-size: 18px;
    font-weight: 800;
    cursor: pointer;
    transition: transform var(--ease), background var(--ease), border-color var(--ease);
}

.symbol-choice:hover:not(:disabled) { transform: translateY(-1px); background: rgba(255,159,67,0.16); }
.symbol-choice.correct { background: rgba(86,227,159,0.25); border-color: #56e39f; color: #56e39f; }
.symbol-choice.wrong { background: rgba(255,71,87,0.2); border-color: #ff4757; color: #ff4757; }
.timer-fill.symbol-time { background: #ff9f43; }

/* ===== EXTRA COGNITIVE MODULES ===== */
.search-grid {
    display: grid;
    gap: 6px;
    width: min(460px, calc(100vw - 72px));
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: rgba(255,255,255,0.025);
}

.search-cell {
    aspect-ratio: 1;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 8px;
    background: rgba(255,255,255,0.045);
    color: var(--text);
    font-size: 20px;
    font-weight: 900;
    cursor: pointer;
}

.search-cell:hover { background: rgba(255,255,255,0.1); }

.pair-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 9px;
    width: 100%;
    max-width: 520px;
}

.pair-list div {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: rgba(255,255,255,0.04);
}

.pair-list strong { color: #fdcb6e; }
.pair-list span { color: var(--text); }

.pair-cue {
    font-size: 46px;
    font-weight: 900;
    color: #fdcb6e;
}

/* ===== GRID (Corsi + Spatial) ===== */
.cell-grid {
    display: inline-grid;
    gap: 7px;
    padding: 14px;
    background: rgba(255,255,255,0.02);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.grid-cell {
    width: 66px;
    height: 66px;
    border-radius: 11px;
    background: rgba(255,255,255,0.055);
    border: 2px solid rgba(255,255,255,0.08);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.grid-cell:hover:not([disabled]):not(.active) {
    background: rgba(255,255,255,0.1);
}

.grid-cell[disabled] { cursor: not-allowed; opacity: 0.5; }

.grid-cell.active {
    background: var(--cc2, #9c6fff);
    border-color: var(--cc2, #9c6fff);
    box-shadow: 0 0 18px color-mix(in srgb, var(--cc2, #9c6fff) 60%, transparent);
}

.grid-cell.selected {
    background: rgba(79,195,247,0.22);
    border-color: #4fc3f7;
}

.grid-cell.correct {
    background: rgba(86,227,159,0.25);
    border-color: #56e39f;
}

.grid-cell.incorrect {
    background: rgba(255,71,87,0.22);
    border-color: #ff4757;
}

/* ===== N-BACK ===== */
.nback-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    width: 210px;
    height: 210px;
    padding: 6px;
    background: rgba(255,255,255,0.03);
    border-radius: 14px;
    border: 1px solid var(--border);
}

.nback-cell {
    border-radius: 8px;
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    font-weight: 900;
    color: #ffb347;
    transition: all 0.12s ease;
    font-family: 'Courier New', monospace;
}

.nback-cell.lit {
    background: rgba(255,179,71,0.15);
    border-color: rgba(255,179,71,0.5);
    box-shadow: 0 0 16px rgba(255,179,71,0.28);
}

.nback-btns {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
}

.btn-nback {
    padding: 12px 22px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
    border: 2px solid;
    cursor: pointer;
    min-width: 130px;
    transition: all 0.14s ease;
    background: transparent;
}

.btn-nback.pos { border-color: #ffb347; color: #ffb347; }
.btn-nback.let { border-color: #ff6b9d; color: #ff6b9d; }
.btn-nback:hover { filter: brightness(1.25); transform: translateY(-1px); }
.btn-nback:active { transform: scale(0.95); }

.btn-nback small { display: block; font-size: 11px; opacity: 0.7; margin-top: 2px; }

/* ===== STROOP ===== */
.stroop-word {
    font-size: 60px;
    font-weight: 900;
    letter-spacing: 3px;
    text-transform: uppercase;
    animation: popIn 0.18s ease;
    text-shadow: 0 0 30px currentColor;
}

.stroop-opts {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 380px;
}

.btn-color {
    width: 64px;
    height: 64px;
    border-radius: 13px;
    border: 3px solid rgba(255,255,255,0.15);
    cursor: pointer;
    transition: transform 0.14s, border-color 0.14s, outline 0.1s;
    font-size: 10px;
    font-weight: 700;
    color: rgba(0,0,0,0.65);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 6px;
    letter-spacing: 0.3px;
}

.btn-color:hover { transform: scale(1.08); border-color: rgba(255,255,255,0.4); }

.timer-bar {
    width: 100%;
    max-width: 360px;
    height: 5px;
    background: rgba(255,255,255,0.08);
    border-radius: 3px;
    overflow: hidden;
}

.timer-fill {
    height: 100%;
    border-radius: 3px;
    background: #ff6b9d;
}

/* ===== REACTION ===== */
.rzone {
    width: 230px;
    height: 230px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 0.5px;
    border: 3px solid rgba(255,255,255,0.1);
    user-select: none;
    transition: all 0.12s ease;
}

.rzone.waiting {
    background: rgba(120,120,160,0.12);
    border-color: rgba(120,120,160,0.3);
    color: var(--muted);
}

.rzone.go {
    background: rgba(86,227,159,0.18);
    border-color: #56e39f;
    color: #56e39f;
    box-shadow: 0 0 40px rgba(86,227,159,0.28);
}

.rzone.nogo {
    background: rgba(255,71,87,0.18);
    border-color: #ff4757;
    color: #ff4757;
    box-shadow: 0 0 30px rgba(255,71,87,0.22);
}

.rzone.early { animation: shake 0.35s ease; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25%       { transform: translateX(-10px); }
    75%       { transform: translateX(10px); }
}

.rt-num {
    font-size: 40px;
    font-weight: 800;
    color: #56e39f;
    font-variant-numeric: tabular-nums;
}

kbd {
    display: inline-block;
    padding: 2px 8px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    font-size: 12px;
    font-family: monospace;
    letter-spacing: 0.3px;
}

/* ===== PROGRESS BAR (n-back / stroop) ===== */
.trial-bar {
    width: 100%;
    max-width: 360px;
}

.trial-bar-top {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--muted);
    margin-bottom: 5px;
}

/* ===== RESULTS ===== */
.results {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 48px 32px;
    text-align: center;
    animation: slideUp 0.35s ease;
}

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

.res-icon { font-size: 56px; margin-bottom: 14px; }

.results h2 {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 8px;
}

.results.passed h2 { color: #56e39f; }
.results.failed h2 { color: #ffb347; }

.res-msg { font-size: 14px; color: var(--muted); margin-bottom: 28px; line-height: 1.5; }

.res-stats {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
}

.res-stat {
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 24px;
    min-width: 110px;
}

.res-stat-val {
    font-size: 30px;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.res-stat-lbl {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lvl-up {
    display: inline-block;
    padding: 7px 18px;
    background: rgba(86,227,159,0.1);
    border: 1px solid rgba(86,227,159,0.4);
    border-radius: 20px;
    color: #56e39f;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 24px;
}

.res-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ===== FOOTER ===== */
.footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 28px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--muted);
    flex-wrap: wrap;
}

.footer-brand {
    background: linear-gradient(135deg, #4fc3f7 0%, #9c6fff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 700;
}

.footer-sep { opacity: 0.35; }

/* ===== RESPONSIVE ===== */
@media (max-width: 600px) {
    #main { padding: 16px 14px; }
    .test-grid { grid-template-columns: 1fr; }
    .stage { padding: 28px 16px; }
    .typing-prompt { font-size: 16px; min-height: 130px; }
    .typing-input { font-size: 16px; }
    .typing-metrics div { min-width: 76px; }
    .seq-num { font-size: 52px; }
    .reverse-num { font-size: 48px; }
    .verbal-word { font-size: 38px; }
    .chimp-grid { width: min(340px, calc(100vw - 44px)); gap: 5px; padding: 8px; }
    .letter-seq,
    .math-problem { font-size: 42px; }
    .letter-seq { letter-spacing: 5px; }
    .stroop-word { font-size: 44px; }
    .grid-cell { width: 52px; height: 52px; }
    .nback-grid { width: 174px; height: 174px; }
    .nback-cell { font-size: 22px; }
    .rzone { width: 190px; height: 190px; }
    .search-grid { width: min(340px, calc(100vw - 44px)); gap: 4px; }
    .search-cell { font-size: 16px; }
    .results { padding: 32px 18px; }
}

/* ===== STROOP FEEDBACK ANIMATIONS ===== */
.btn-color.flash-correct { animation: flashCorrect 0.45s ease forwards; }
.btn-color.flash-wrong   { animation: flashWrong   0.45s ease forwards; }

@keyframes flashCorrect {
    0%   { transform: scale(1);   box-shadow: none; }
    45%  { transform: scale(1.2); box-shadow: 0 0 28px rgba(86,227,159,0.85); }
    100% { transform: scale(1);   }
}

@keyframes flashWrong {
    0%,100% { transform: translateX(0); }
    20%     { transform: translateX(-8px); }
    40%     { transform: translateX(8px); }
    60%     { transform: translateX(-5px); }
    80%     { transform: translateX(5px); }
}

/* ===== STATS PAGE ===== */
.btn-stats {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--muted);
    border-radius: 8px;
    padding: 5px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color var(--ease), color var(--ease);
    margin-left: 8px;
}
.btn-stats:hover { border-color: rgba(255,255,255,0.2); color: var(--text); }

.stats-view {
    max-width: 780px;
    margin: 0 auto;
    padding: 32px 24px;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

/* Game chips */
.stats-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.stats-chip {
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color var(--ease), background var(--ease), color var(--ease);
    white-space: nowrap;
}
.stats-chip:hover { border-color: rgba(255,255,255,0.18); background: var(--surface2); }
.stats-chip.active {
    background: var(--surface2);
    border-color: rgba(255,255,255,0.25);
    color: #fff;
    font-weight: 600;
}
.stats-chip.no-data { opacity: 0.45; }

/* Game header */
.stats-header {
    display: flex;
    align-items: center;
    gap: 14px;
}
.stats-icon {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.stats-game-name {
    font-size: 20px;
    font-weight: 700;
    line-height: 1.2;
}
.stats-game-desc {
    font-size: 13px;
    color: var(--muted);
    margin-top: 2px;
}

/* Summary cards */
.stats-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
}
.stats-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
}
.stats-card-val {
    font-size: 26px;
    font-weight: 800;
    line-height: 1;
}
.stats-card-lbl {
    font-size: 11px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.7px;
    margin-top: 6px;
}

/* Section title */
.stats-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--muted);
    margin-bottom: 10px;
}

/* Chart */
.stats-chart-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
}
.stats-chart-box {
    overflow-x: auto;
}
.stats-chart-box svg {
    display: block;
    max-width: 100%;
}
.stats-chart-xlabel {
    display: flex;
    justify-content: space-between;
    padding: 6px 44px 0 44px;
    font-size: 10px;
    color: var(--muted);
    letter-spacing: 0.3px;
}

/* Empty state */
.stats-empty {
    text-align: center;
    color: var(--muted);
    font-size: 15px;
    padding: 48px 0;
}

/* Session log */
.stats-log-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    padding-bottom: 4px;
}
.stats-log {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin-top: 12px;
}
.stats-log-head th {
    background: var(--surface2);
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    padding: 9px 16px;
    text-align: left;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.stats-log-row td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.stats-log tbody tr:last-child td { border-bottom: none; }
.stats-log-row:hover td { background: rgba(255,255,255,0.03); }
td.stats-log-n { color: var(--muted); width: 36px; }
td.stats-log-date { color: var(--muted); font-size: 12px; }
td.stats-log-val { font-weight: 700; }
td.stats-log-extra { color: var(--muted); font-size: 12px; }

/* Responsive stats */
@media (max-width: 600px) {
    .stats-view { padding: 20px 14px; gap: 20px; }
    .stats-summary { grid-template-columns: repeat(2, 1fr); }
    .stats-card-val { font-size: 20px; }
    .stats-chart-xlabel { padding: 6px 8px 0 8px; }
    .stats-log-head th, .stats-log-row td { padding: 8px 10px; }
}
