/* 认知训练平台 - 深色主题 */

:root {
    --bg: #0f1117;
    --bg-card: #1a1d2e;
    --bg-card-hover: #22263a;
    --text: #e0e0e0;
    --text-secondary: #8890a8;
    --accent: #6c8cff;
    --accent-glow: rgba(108, 140, 255, 0.3);
    --green: #4ade80;
    --yellow: #facc15;
    --red: #f87171;
    --blue: #60a5fa;
    --border: #2a2e3e;
    --radius: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans SC", sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* 头部 */
.header {
    text-align: center;
    padding: 32px 0 24px;
}
.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.header .subtitle {
    color: var(--text-secondary);
    margin-top: 6px;
    font-size: 0.95rem;
}

/* 状态栏 */
.status-bar {
    display: flex;
    gap: 16px;
    justify-content: center;
    margin-bottom: 28px;
    flex-wrap: wrap;
}
.status-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 20px;
    text-align: center;
    min-width: 100px;
}
.status-item .value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent);
}
.status-item .label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* 任务卡片 */
.task-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}
.task-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
}
.task-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent-glow);
}
.task-card .icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}
.task-card h3 {
    font-size: 1.15rem;
    margin-bottom: 6px;
}
.task-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}
.task-card .meta {
    display: flex;
    gap: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}
.task-card .badge {
    position: absolute;
    top: 12px;
    right: 12px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.badge-done { background: rgba(74,222,128,0.15); color: var(--green); }
.badge-pending { background: rgba(250,204,21,0.15); color: var(--yellow); }

/* 图表区 */
.chart-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 32px;
}
.chart-section h2 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--text-secondary);
}
.chart-wrap {
    position: relative;
    width: 100%;
    height: 280px;
}
.chart-wrap canvas { width: 100% !important; height: 100% !important; }

/* 加载/空状态 */
.loading, .empty {
    text-align: center;
    padding: 48px 16px;
    color: var(--text-secondary);
}
.loading .spinner {
    width: 36px; height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==================== 训练页面 ==================== */
.train-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 16px;
}

/* 任务说明 */
.instructions {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
}
.instructions h2 {
    font-size: 1.4rem;
    margin-bottom: 16px;
}
.instructions .desc {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.8;
    margin-bottom: 20px;
    text-align: left;
}
.instructions .key-hint {
    display: inline-block;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 14px;
    margin: 4px;
    font-family: monospace;
    font-size: 0.9rem;
}
.btn {
    display: inline-block;
    padding: 12px 32px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-sm { padding: 8px 20px; font-size: 0.85rem; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--accent); }

/* jsPsych 覆盖 */
.jspsych-content {
    max-width: 100% !important;
}
.jspsych-display-element {
    background: var(--bg) !important;
    color: var(--text) !important;
    font-family: inherit !important;
}

/* 结果面板 */
.results {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    text-align: center;
    display: none;
}
.results.show { display: block; }
.results h2 {
    font-size: 1.4rem;
    margin-bottom: 16px;
    color: var(--green);
}
.results .score-big {
    font-size: 3rem;
    font-weight: 800;
    color: var(--accent);
}
.results .score-detail {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 8px 0 20px;
}
.results .stats-row {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin: 16px 0 24px;
    flex-wrap: wrap;
}
.results .stat-item {
    background: var(--bg);
    border-radius: 8px;
    padding: 12px 20px;
}
.results .stat-value { font-size: 1.3rem; font-weight: 700; }
.results .stat-label { font-size: 0.75rem; color: var(--text-secondary); }

/* N-Back 网格 */
.nback-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    width: 260px;
    margin: 0 auto 20px;
}
.nback-cell {
    aspect-ratio: 1;
    background: var(--bg);
    border: 2px solid var(--border);
    border-radius: 8px;
    transition: all 0.12s ease;
}
.nback-cell.active {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 20px var(--accent-glow);
}

/* Stroop 颜色词 */
.stroop-word {
    font-size: 4rem;
    font-weight: 800;
    text-align: center;
    margin: 20px 0;
    user-select: none;
}
.stroop-keys {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 20px;
}
.stroop-key {
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    min-width: 70px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary);
}
.stroop-key kbd {
    display: block;
    font-size: 1.5rem;
    color: var(--text);
    margin-bottom: 4px;
}

/* 速度处理 */
.speed-canvas-wrap {
    position: relative;
    width: 100%;
    height: 400px;
    background: var(--bg);
    border-radius: var(--radius);
    overflow: hidden;
}

/* 响应式 */
@media (max-width: 600px) {
    .header h1 { font-size: 1.5rem; }
    .task-grid { grid-template-columns: 1fr; }
    .status-bar { gap: 8px; }
    .status-item { min-width: 80px; padding: 10px 14px; }
    .status-item .value { font-size: 1.3rem; }
    .stroop-word { font-size: 3rem; }
}
