:root {
    --bg: #f3f6fb; --surface: #ffffff; --surface-2: #f7f9fc; --surface-3: #eef2f8;
    --border: #e3e8f0; --border-strong: #cbd5e1;
    --text: #0f172a; --text-2: #475569; --text-3: #8b98ab;
    --brand: #2563eb; --brand-hover: #1d4ed8; --brand-soft: #eef4ff; --brand-border: #c7dbff;
    --ok: #059669; --ok-soft: #ecfdf5; --ok-border: #a7f3d0;
    --warn: #d97706; --warn-soft: #fffbeb; --warn-border: #fde68a;
    --bad: #dc2626; --bad-soft: #fef2f2; --bad-border: #fecaca;
    --gold: #ca8a04; --gold-soft: #fef9c3;
    --shadow-1: 0 1px 2px rgba(15, 23, 42, .06);
    --shadow-2: 0 4px 16px rgba(15, 23, 42, .08);
    --shadow-3: 0 14px 38px rgba(15, 23, 42, .14);
    --radius: 14px; --radius-sm: 10px; --radius-xs: 8px;
    --canvas-bg: #fbfcfe;
}
[data-theme="dark"] {
    --bg: #0b1120; --surface: #151d2e; --surface-2: #1a2437; --surface-3: #212d42;
    --border: #2a3547; --border-strong: #3d4b61;
    --text: #e8eef7; --text-2: #a8b6ca; --text-3: #6b7c93;
    --brand: #4d8cf7; --brand-hover: #6ba1ff; --brand-soft: #16233b; --brand-border: #24406e;
    --ok: #34d399; --ok-soft: #0d2b21; --ok-border: #14532d;
    --warn: #fbbf24; --warn-soft: #2a1f08; --warn-border: #78350f;
    --bad: #f87171; --bad-soft: #2a1214; --bad-border: #7f1d1d;
    --gold: #fbbf24; --gold-soft: #2a1f08;
    --shadow-1: 0 1px 2px rgba(0,0,0,.4);
    --shadow-2: 0 4px 16px rgba(0,0,0,.45);
    --shadow-3: 0 14px 38px rgba(0,0,0,.6);
    --canvas-bg: #1a2437;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0; background: var(--bg); color: var(--text-2);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", Helvetica, Arial, sans-serif;
    font-size: 14px; line-height: 1.65;
    padding-top: 58px; padding-bottom: 40px;
    transition: background-color .3s ease, color .3s ease;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; color: var(--text); font-weight: 700; line-height: 1.35; }
p { margin: 0; }
button { font-family: inherit; }
a { color: var(--brand); text-decoration: none; }
.is-hidden { display: none !important; }
.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 999;
    background: var(--brand); color: #fff; padding: 8px 14px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }
.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

/* 加载动画 */
@keyframes spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }
.spin { display: inline-block; animation: spin 1s linear infinite; }

/* ---------- 顶部导航 ---------- */
.site-header {
    position: fixed; inset: 0 0 auto 0; z-index: 500; height: 58px;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid var(--border);
    transition: background-color .3s ease, border-color .3s ease;
}
.header-row { height: 58px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--text); font-size: 15px; font-weight: 700;
    white-space: nowrap; flex-shrink: 0;
}
.brand:hover { color: var(--brand); }
.brand-mark {
    width: 28px; height: 28px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px; color: #fff;
    background: linear-gradient(135deg, var(--brand), #7c3aed);
    box-shadow: 0 3px 10px rgba(37, 99, 235, .3);
}
.header-tools {
    display: flex; align-items: center; gap: 6px;
    overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none; padding: 2px 0;
}
.header-tools::-webkit-scrollbar { display: none; }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border-radius: var(--radius-xs); border: 1px solid transparent;
    font-size: 12.5px; font-weight: 600; line-height: 1.4;
    padding: 7px 13px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
    transition: background-color .16s ease, border-color .16s ease,
    color .16s ease, transform .16s ease, box-shadow .16s ease;
    user-select: none;
}
.btn .glyphicon { font-size: 11.5px; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover:not(:disabled) {
    background: var(--brand-hover); border-color: var(--brand-hover);
    box-shadow: 0 6px 16px rgba(37, 99, 235, .3);
}
.btn-success { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn-success:hover:not(:disabled) {
    background: #047857; border-color: #047857;
    box-shadow: 0 6px 16px rgba(5, 150, 105, .3);
}
.btn-ghost { background: var(--surface); border-color: var(--border); color: var(--text-2); }
.btn-ghost:hover:not(:disabled) {
    background: var(--surface-2); border-color: var(--border-strong); color: var(--brand);
}
.btn-danger-ghost { background: var(--surface); border-color: var(--border); color: var(--bad); }
.btn-danger-ghost:hover:not(:disabled) {
    background: var(--bad-soft); border-color: var(--bad-border);
}
.btn-lg { padding: 10px 26px; font-size: 14px; border-radius: var(--radius-sm); }
.btn-lg .glyphicon { font-size: 13px; }

.pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 12px; font-weight: 700; padding: 5px 11px;
    border-radius: 999px; white-space: nowrap; flex-shrink: 0;
}
.pill-progress { background: var(--brand-soft); border: 1px solid var(--brand-border); color: var(--brand); }
.pill.pulse { animation: badgePulse .8s ease; }
@keyframes badgePulse {
    0% { transform: scale(1); }
    40% { transform: scale(1.12); }
    100% { transform: scale(1); }
}

/* ---------- 卡片 ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-1);
    transition: background-color .3s ease, border-color .3s ease;
}
.section { margin-bottom: 22px; }
.section-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; flex-wrap: wrap; margin-bottom: 14px;
}
.section-title { display: inline-flex; align-items: center; gap: 8px; font-size: 17px; }
.section-title .ico {
    width: 26px; height: 26px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; background: var(--brand-soft); color: var(--brand); flex-shrink: 0;
}
.section-hint { font-size: 12.5px; color: var(--text-3); }

/* ---------- 首屏 ---------- */
.hero-card {
    padding: 26px 24px;
    background:
            radial-gradient(900px 300px at 0% -20%, rgba(37, 99, 235, .10), transparent 60%),
            radial-gradient(700px 260px at 100% 120%, rgba(16, 185, 129, .10), transparent 60%),
            var(--surface);
    border: 1px solid var(--border); border-radius: 18px;
    box-shadow: var(--shadow-1); margin-bottom: 22px;
}
.hero-title { font-size: clamp(20px, 3.4vw, 27px); letter-spacing: -.3px; margin-bottom: 8px; }
.hero-sub {
    color: var(--text-3); font-size: 13.5px;
    display: flex; align-items: center; gap: 7px; flex-wrap: wrap; margin-bottom: 20px;
}
.hero-sub .sep { color: var(--border-strong); }
.feature-grid {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px;
}
@media (max-width: 900px) { .feature-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .feature-grid { grid-template-columns: 1fr; } }
.feature {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 11px 12px; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
}
.feature-ico {
    width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; background: var(--brand-soft); color: var(--brand);
}
.feature-tt { display: block; font-size: 12.5px; font-weight: 700; color: var(--text); }
.feature-dd { display: block; font-size: 11.5px; color: var(--text-3); line-height: 1.5; }

/* ---------- 关卡卡片 ---------- */
.level-grid {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px;
}
@media (max-width: 900px) { .level-grid { grid-template-columns: 1fr; } }
.level-card {
    position: relative; display: flex; flex-direction: column;
    padding: 18px; border-radius: var(--radius);
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow-1);
    transition: transform .24s cubic-bezier(.34, 1.4, .64, 1),
    box-shadow .24s ease, border-color .24s ease, opacity .24s ease;
}
.level-card:hover {
    transform: translateY(-4px); box-shadow: var(--shadow-2); border-color: var(--brand-border);
}
.level-card.is-locked { opacity: .62; }
.level-card.is-locked:hover { transform: none; box-shadow: var(--shadow-1); border-color: var(--border); }
.level-card.is-locked::after {
    content: "完成上一关 A 级即可解锁";
    position: absolute; left: 50%; top: 4px;
    transform: translate(-50%, -110%) scale(.96);
    background: var(--text); color: var(--surface);
    font-size: 11.5px; font-weight: 600;
    padding: 6px 11px; border-radius: 8px;
    white-space: nowrap; opacity: 0; visibility: hidden;
    pointer-events: none; z-index: 30;
    transition: opacity .16s ease, transform .16s ease;
}
.level-card.is-locked:hover::after {
    opacity: 1; visibility: visible; transform: translate(-50%, -110%) scale(1);
}
.level-ribbon {
    position: absolute; top: -11px; right: -11px;
    min-width: 40px; height: 40px; padding: 0 9px;
    border-radius: 999px; display: none;
    align-items: center; justify-content: center; gap: 3px;
    font-size: 12px; font-weight: 800; color: #fff;
    background: linear-gradient(135deg, #fbbf24, #d97706);
    box-shadow: 0 5px 14px rgba(217, 119, 6, .38), 0 0 0 3px var(--surface);
    z-index: 6; animation: ribbonPop .55s cubic-bezier(.34, 1.56, .64, 1);
}
.level-ribbon.is-show { display: inline-flex; }
@keyframes ribbonPop {
    0% { transform: scale(0) rotate(-30deg); }
    60% { transform: scale(1.14) rotate(6deg); }
    100% { transform: scale(1) rotate(0); }
}
.level-top {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; margin-bottom: 12px;
}
.level-ico {
    width: 42px; height: 42px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 18px; flex-shrink: 0; transition: transform .3s ease;
}
.level-card:hover .level-ico { transform: scale(1.08) rotate(-5deg); }
.ico-lv1 { background: linear-gradient(135deg, #dbeafe, #bfdbfe); color: #1d4ed8; }
.ico-lv2 { background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #047857; }
.ico-lv3 { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #b45309; }
[data-theme="dark"] .ico-lv1 { background: linear-gradient(135deg, #1e3a5f, #1e40af); color: #93c5fd; }
[data-theme="dark"] .ico-lv2 { background: linear-gradient(135deg, #064e3b, #065f46); color: #6ee7b7; }
[data-theme="dark"] .ico-lv3 { background: linear-gradient(135deg, #78350f, #92400e); color: #fcd34d; }
.level-status {
    font-size: 11px; font-weight: 700;
    padding: 5px 10px; border-radius: 999px; white-space: nowrap;
}
.status-locked { background: var(--surface-3); color: var(--text-3); }
.status-unlocked { background: var(--ok-soft); color: var(--ok); }
.level-name { font-size: 15px; margin-bottom: 5px; }
.level-desc {
    font-size: 12.5px; color: var(--text-3); line-height: 1.6;
    min-height: 40px; margin-bottom: 12px;
}
.level-metrics {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-2); margin-bottom: 12px;
}
.tag {
    display: inline-block; font-size: 10.5px; font-weight: 700;
    color: var(--text-3); background: var(--surface-3);
    border-radius: 5px; padding: 1px 7px;
}
.grade-list { display: grid; gap: 5px; margin-bottom: 14px; }
.grade-row {
    display: flex; align-items: center; gap: 7px;
    font-size: 12px; line-height: 1.5;
    padding: 6px 10px; border-radius: var(--radius-xs);
    border: 1px solid var(--border);
    background: var(--surface-2); color: var(--text-2);
    transition: transform .16s ease, border-color .16s ease;
}
.grade-row b { color: var(--text); font-weight: 800; }
.grade-row .dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.grade-row.g-a .dot { background: var(--ok); }
.grade-row.g-b .dot { background: var(--warn); }
.grade-row.g-c .dot { background: var(--bad); }
.level-card:hover .grade-row.g-a { transform: translateX(2px); border-color: var(--ok-border); }
.level-card:hover .grade-row.g-b { transform: translateX(4px); border-color: var(--warn-border); }
.level-card:hover .grade-row.g-c { transform: translateX(6px); border-color: var(--bad-border); }
.level-foot { margin-top: auto; }
.btn-enter {
    width: 100%; background: var(--brand); border-color: var(--brand); color: #fff;
    padding: 10px 14px; font-size: 13.5px; border-radius: var(--radius-sm);
}
.btn-enter:hover:not(:disabled) {
    background: var(--brand-hover); border-color: var(--brand-hover);
    box-shadow: 0 6px 18px rgba(37, 99, 235, .32);
}
.btn-enter:disabled {
    background: var(--surface-3); border-color: var(--border); color: var(--text-3);
}
.level-card.just-unlocked { animation: unlockGlow 1.8s ease 2; }
@keyframes unlockGlow {
    0%, 100% { box-shadow: var(--shadow-1); border-color: var(--border); }
    50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, .18), 0 16px 34px rgba(16, 185, 129, .24); border-color: var(--ok); }
}

/* ---------- 内联最佳面板 ---------- */
.inline-best {
    margin-top: 20px; padding: 16px;
    border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
    animation: fadeUp .4s ease;
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
.inline-best-head {
    display: flex; align-items: center; gap: 8px;
    margin-bottom: 13px; font-size: 13px; font-weight: 700; color: var(--text);
}
.inline-best-head .ico { color: var(--gold); }
.inline-best-head .best-grade {
    margin-left: auto;
    width: 38px; height: 38px; font-size: 19px; border-radius: 10px;
}
.best-grade {
    flex-shrink: 0;
    width: 48px; height: 48px; border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 24px; font-weight: 800; letter-spacing: 1px; line-height: 1;
}
.best-grade.g-A { color: var(--ok);   background: var(--ok-soft);   border: 1px solid var(--ok-border); }
.best-grade.g-B { color: var(--warn); background: var(--warn-soft); border: 1px solid var(--warn-border); }
.best-grade.g-C { color: var(--bad);  background: var(--bad-soft);  border: 1px solid var(--bad-border); }
.inline-metrics {
    display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 9px; margin-bottom: 13px;
}
.inline-metric {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 10px 4px; border-radius: var(--radius-xs);
    background: var(--surface); border: 1px solid var(--border);
}
.inline-metric-val {
    font-size: 16px; font-weight: 800; color: var(--text);
    font-variant-numeric: tabular-nums;
}
.inline-metric-lab { font-size: 10.5px; color: var(--text-3); }
.diag-box {
    font-size: 12.5px; line-height: 1.75; color: var(--text-2);
    padding: 11px 13px; border-radius: var(--radius-xs);
    background: var(--surface); border: 1px solid var(--border);
    border-left: 3px solid var(--brand);
}
.inline-empty {
    display: flex; flex-direction: column; align-items: center;
    gap: 8px; padding: 16px; text-align: center;
    font-size: 12.5px; color: var(--text-3);
}
.inline-empty .spin { font-size: 20px; color: var(--brand); }

/* ---------- 测评面板 ---------- */
.exam-card { overflow: hidden; }
.exam-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    background: var(--surface); flex-wrap: wrap;
}
.exam-head h2 { font-size: 14.5px; }
.exam-tools { display: flex; align-items: center; gap: 6px; }
.exam-body { padding: 18px; }

.rule-block { display: grid; gap: 7px; margin-bottom: 14px; }
.rule-line {
    display: flex; align-items: flex-start; gap: 8px;
    font-size: 13px; line-height: 1.7; color: var(--text-2);
}
.rule-line .ico {
    color: var(--text-3); flex-shrink: 0;
    font-size: 12px; margin-top: 3px; width: 14px; text-align: center;
}
.rule-line strong { color: var(--text); }
.sample-box { font-size: 12.5px; color: var(--text-3); margin-top: 12px; }
.sample-box code {
    display: inline-block;
    background: var(--surface-3); color: var(--brand);
    border-radius: 6px; padding: 4px 10px;
    font-family: "SF Mono", "Courier New", Consolas, monospace;
    font-size: 12px; word-break: break-all; margin-top: 4px;
}
.divider { height: 1px; background: var(--border); border: 0; margin: 16px 0; }
.start-row {
    display: flex; justify-content: center; align-items: center;
    gap: 12px; flex-wrap: wrap; padding: 4px 0;
}

.stage-tip {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 13px; border-radius: var(--radius-xs);
    font-size: 12.5px; line-height: 1.6;
    background: var(--brand-soft); border: 1px solid var(--brand-border);
    color: var(--brand); margin-bottom: 13px;
    transition: background-color .3s ease, border-color .3s ease, color .3s ease;
}
.stage-tip .glyphicon { flex-shrink: 0; font-size: 12px; }
.stage-tip kbd {
    display: inline-block;
    background: var(--surface); border: 1px solid var(--border-strong);
    border-bottom-width: 2px; border-radius: 4px;
    padding: 0 6px; font-size: 11px;
    font-family: inherit; color: var(--text); margin: 0 2px;
}
.stage-tip.celebrate {
    background: var(--ok-soft); border-color: var(--ok-border); color: var(--ok);
    animation: tipPop .4s ease;
}
@keyframes tipPop {
    0% { transform: scale(.98); }
    60% { transform: scale(1.015); }
    100% { transform: scale(1); }
}

.stats-bar {
    display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    padding: 11px 15px; border-radius: var(--radius-sm);
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow-1); margin-bottom: 13px;
}
.progress-track {
    flex: 1 1 100%; height: 6px; border-radius: 3px;
    background: var(--surface-3); overflow: hidden; order: 1;
}
@media (min-width: 768px) { .progress-track { flex: 1 1 160px; order: 0; } }
.progress-fill {
    height: 100%; width: 0; border-radius: 3px;
    background: linear-gradient(90deg, var(--brand), var(--ok));
    transition: width .24s ease, background .4s ease;
}
.progress-fill.combo-2 { background: linear-gradient(90deg, var(--ok), var(--warn)); }
.progress-fill.combo-3 { background: linear-gradient(90deg, var(--warn), var(--bad)); }
.progress-fill.combo-4 {
    background: linear-gradient(90deg, var(--bad), var(--warn), var(--bad));
    animation: fireGlow 1s ease infinite;
}
@keyframes fireGlow {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, .45); }
    50% { box-shadow: 0 0 9px 2px rgba(239, 68, 68, .45); }
}
.stat { display: inline-flex; align-items: baseline; gap: 4px; white-space: nowrap; order: 2; }
.stat .glyphicon { font-size: 11px; color: var(--text-3); }
.stat-lab { font-size: 11px; color: var(--text-3); }
.stat-val {
    font-size: 14.5px; font-weight: 800; color: var(--text);
    font-variant-numeric: tabular-nums;
}
.stat.is-danger .stat-val { color: var(--bad); }
.stat.is-danger.warn .stat-val { animation: idleBlink 1s ease-in-out infinite; }
@keyframes idleBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: .45; }
}
.combo-badge {
    display: none; align-items: center; gap: 4px;
    order: 3; padding: 4px 11px; border-radius: 999px;
    font-size: 11.5px; font-weight: 800; color: #fff;
    background: linear-gradient(135deg, var(--warn), var(--bad));
    box-shadow: 0 3px 10px rgba(239, 68, 68, .3); white-space: nowrap;
}
.combo-badge .glyphicon { font-size: 10px; }
.combo-badge.is-show { display: inline-flex; }
.combo-badge.pop { animation: comboPop .26s ease; }
@keyframes comboPop {
    0% { transform: scale(.85); }
    55% { transform: scale(1.14); }
    100% { transform: scale(1); }
}
.combo-badge.milestone { animation: milestonePulse .7s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes milestonePulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, .65); }
    50% { transform: scale(1.3); box-shadow: 0 0 0 15px rgba(239, 68, 68, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.key-hint {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 13px; border-radius: var(--radius-xs);
    font-size: 12px; color: var(--brand);
    background: var(--brand-soft); border: 1px dashed var(--brand-border);
    margin-bottom: 13px;
}
.key-hint kbd {
    display: inline-block;
    background: var(--surface); border: 1px solid var(--border-strong);
    border-bottom-width: 2px; border-radius: 5px;
    padding: 1px 6px; font-size: 11px;
    font-family: inherit; color: var(--text);
}

/* 关卡1 字母卡片 */
.card-display {
    display: flex; flex-wrap: wrap; align-content: flex-start;
    gap: 8px 6px; padding: 18px 16px;
    border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
    min-height: 104px; margin-bottom: 13px;
    font-family: "SF Mono", "Courier New", Consolas, monospace;
    transition: background-color .3s ease, border-color .3s ease;
}
.card-display.pulse-ok { animation: pulseOk .35s ease; }
.card-display.pulse-bad { animation: pulseBad .35s ease; }
@keyframes pulseOk { 0% { background: rgba(16,185,129,.12); } 100% { background: var(--surface-2); } }
@keyframes pulseBad { 0% { background: rgba(239,68,68,.12); } 100% { background: var(--surface-2); } }
.char-card {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 42px; height: 54px; padding: 0 10px;
    font-size: 24px; font-weight: 700; line-height: 1;
    border-radius: 11px; border: 2px solid transparent;
    background: var(--surface); color: var(--text-3); user-select: none;
    transition: transform .16s ease, background-color .16s ease,
    border-color .16s ease, color .16s ease, box-shadow .16s ease;
}
.char-card.is-pending { background: var(--surface); border-color: var(--border); color: var(--text-3); }
.char-card.is-next {
    background: var(--brand-soft); border-color: var(--brand-border);
    color: var(--brand); opacity: .72;
}
.char-card.is-current {
    background: var(--brand-soft); border-color: var(--brand);
    color: var(--brand); transform: scale(1.08);
    animation: currentPulse 1.6s ease-in-out infinite;
}
@keyframes currentPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
    50% { box-shadow: 0 0 0 9px rgba(37, 99, 235, .05); }
}
.char-card.is-correct {
    background: var(--ok-soft); border-color: var(--ok); color: var(--ok);
    animation: popOk .32s cubic-bezier(.34, 1.56, .64, 1);
}
@keyframes popOk {
    0% { transform: scale(1); }
    55% { transform: scale(1.16); }
    100% { transform: scale(1); }
}
.char-card.is-wrong {
    background: var(--bad-soft); border-color: var(--bad); color: var(--bad);
    animation: shakeBad .38s ease;
}
@keyframes shakeBad {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}
.space-gap { display: inline-block; width: 12px; height: 54px; flex: 0 0 auto; }

/* 关卡2 音节田字格 */
.syllable-wrap {
    display: flex; flex-wrap: wrap; align-content: flex-start;
    gap: 22px 10px; padding: 24px 16px 20px;
    border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
    min-height: 130px; margin-bottom: 13px;
}
.syllable-card {
    display: inline-flex; flex-direction: column;
    align-items: center; width: 70px; flex-shrink: 0;
}
.syllable-py {
    display: inline-flex; align-items: center; justify-content: center;
    height: 24px; font-family: "SF Mono", "Courier New", Consolas, monospace;
    font-size: 17px; font-weight: 700; line-height: 1;
    letter-spacing: .5px; white-space: nowrap; margin-bottom: 5px;
    transition: color .15s ease, transform .15s ease; transform-origin: center;
}
.syl-char {
    display: inline-block; padding: 0 1px; border-radius: 3px;
    transition: color .15s ease, background-color .15s ease;
}
.syl-char.is-pending { color: var(--text-3); }
.syl-char.is-correct { color: var(--ok); }
.syl-char.is-current {
    color: var(--brand); background: rgba(37, 99, 235, .16);
    animation: sylPulse 1.2s ease-in-out infinite;
}
@keyframes sylPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, .35); }
    50% { box-shadow: 0 0 0 4px rgba(37, 99, 235, .06); }
}
.syl-char.is-wrong { color: var(--bad); background: rgba(239, 68, 68, .16); }
.syllable-tian {
    position: relative; width: 54px; height: 54px;
    border: 2px solid var(--border); border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface); overflow: hidden;
    transition: border-color .2s ease, background-color .2s ease,
    transform .2s ease, box-shadow .2s ease;
}
.syllable-tian::before,
.syllable-tian::after {
    content: ''; position: absolute; pointer-events: none; opacity: .5;
}
.syllable-tian::before { left: 0; right: 0; top: 50%; border-top: 1px dashed var(--border-strong); }
.syllable-tian::after  { top: 0; bottom: 0; left: 50%; border-left: 1px dashed var(--border-strong); }
.syllable-hz {
    position: relative; z-index: 1;
    font-size: 28px; font-weight: 600; line-height: 1; color: var(--text);
    font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
}
.syllable-card.is-current .syllable-py { color: var(--brand); }
.syllable-card.is-current .syllable-tian {
    border-color: var(--brand); background: var(--brand-soft);
    transform: translateY(-2px);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12), 0 5px 14px rgba(37, 99, 235, .16);
}
.syllable-card.is-next .syllable-tian {
    border-color: var(--brand-border); background: var(--brand-soft); opacity: .85;
}
.syllable-card.is-correct .syllable-tian { border-color: var(--ok); background: var(--ok-soft); }
.syllable-card.is-correct .syllable-hz  { color: var(--ok); }
.syllable-card.is-wrong .syllable-tian { border-color: var(--bad); background: var(--bad-soft); }
.syllable-card.is-wrong .syllable-hz   { color: var(--bad); }
.syllable-card.flash .syllable-tian { animation: completeFlash .55s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes completeFlash {
    0% { transform: scale(1); }
    40% { transform: scale(1.14); box-shadow: 0 0 0 8px rgba(16, 185, 129, .2); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

/* 关卡3 田字格 */
.tian-display {
    display: flex; flex-wrap: wrap; align-content: flex-start;
    gap: 12px 9px; padding: 18px 16px;
    border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
    min-height: 210px; max-height: 400px;
    overflow-y: auto; overflow-x: hidden;
    margin-bottom: 13px; cursor: text; scroll-behavior: smooth;
    transition: background-color .3s ease, border-color .3s ease;
}
.tian-display.pulse-ok { animation: pulseOk .35s ease; }
.tian-display.pulse-bad { animation: pulseBad .35s ease; }
.tian-pair {
    display: inline-flex; flex-direction: column;
    align-items: center; gap: 3px;
}
.tian-pinyin {
    display: block;
    font-family: "SF Mono", "Courier New", Consolas, monospace;
    font-size: 11px; font-weight: 600; line-height: 1;
    height: 14px; color: var(--text-3);
    max-width: 46px; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
    transition: color .15s ease;
}
.tian-pair.is-current .tian-pinyin { color: var(--brand); }
.tian-pair.is-correct .tian-pinyin { color: var(--ok); }
.tian-pair.is-wrong .tian-pinyin { color: var(--bad); }
.tian-cell {
    position: relative; width: 44px; height: 44px;
    border: 1.5px solid var(--border-strong); border-radius: 7px;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 600;
    background: var(--surface); color: var(--text); overflow: hidden;
    transition: border-color .18s ease, background-color .18s ease,
    color .18s ease, box-shadow .18s ease;
}
.tian-cell::before,
.tian-cell::after {
    content: ''; position: absolute; pointer-events: none; opacity: .45;
}
.tian-cell::before { left: 0; right: 0; top: 50%; border-top: 1px dashed var(--border-strong); }
.tian-cell::after  { top: 0; bottom: 0; left: 50%; border-left: 1px dashed var(--border-strong); }
.tian-cell.target {
    font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    color: var(--text-2); background: var(--surface-3);
}
.tian-pair.is-current .tian-cell.target { border-color: var(--brand-border); background: var(--brand-soft); color: var(--brand); }
.tian-pair.is-correct .tian-cell.target { border-color: var(--ok); color: var(--ok); }
.tian-pair.is-wrong .tian-cell.target { border-color: var(--bad); color: var(--bad); }
.tian-cell.input {
    font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", sans-serif;
    z-index: 1;
}
.tian-cell.input.is-current {
    border-color: var(--brand); border-width: 2px;
    background: var(--brand-soft);
    animation: tianPulse 1.4s ease-in-out infinite;
}
@keyframes tianPulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }
    50% { box-shadow: 0 0 0 8px rgba(37, 99, 235, .04); }
}
.tian-cell.input.is-correct {
    border-color: var(--ok); background: var(--ok-soft); color: var(--ok);
    animation: popOk .3s cubic-bezier(.34, 1.56, .64, 1);
}
.tian-cell.input.is-wrong {
    border-color: var(--bad); background: var(--bad-soft); color: var(--bad);
    animation: shakeBad .36s ease;
}
.tian-cursor {
    position: absolute; left: 50%; top: 22%; bottom: 22%;
    width: 2px; border-radius: 1px;
    background: var(--brand); transform: translateX(-50%);
    animation: caretBlink .9s step-end infinite;
}
@keyframes caretBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}
.ime-proxy {
    position: fixed; width: 2px; height: 2px;
    padding: 0; margin: 0; border: none; outline: none;
    background: transparent; color: transparent;
    caret-color: transparent; opacity: .01;
    resize: none; overflow: hidden;
    z-index: -1; pointer-events: none;
}

/* 图表 */
.charts {
    display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px;
}
.charts.single { grid-template-columns: 1fr; }
@media (max-width: 800px) { .charts { grid-template-columns: 1fr; } }
.chart-box { min-width: 0; }
.chart-title {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 700; color: var(--text-3); margin-bottom: 7px;
}
.chart-title .glyphicon { font-size: 11px; }
canvas.chart {
    display: block; width: 100%; height: auto;
    background: var(--canvas-bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: background-color .3s ease, border-color .3s ease;
}

/* FAQ */
.faq-list { display: grid; gap: 0; }
.faq-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.faq-item:first-child { padding-top: 4px; }
.faq-item:last-child { border-bottom: none; padding-bottom: 0; }
.faq-q {
    display: flex; align-items: flex-start; gap: 8px;
    font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 5px;
}
.faq-q .ico { color: var(--brand); font-size: 13px; margin-top: 3px; flex-shrink: 0; }
.faq-a { font-size: 13px; color: var(--text-3); line-height: 1.7; padding-left: 21px; }

/* 弹窗系统（tl- 前缀） */
.tl-modal {
    position: fixed; inset: 0; z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    padding: 16px; opacity: 0; visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}
.tl-modal.is-open { opacity: 1; visibility: visible; }
.tl-modal-backdrop {
    position: absolute; inset: 0; z-index: 0;
    background: rgba(9, 14, 25, .62);
    backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
}
.tl-modal-panel {
    position: relative; z-index: 1;
    width: 100%; max-width: 440px;
    max-height: calc(100vh - 32px);
    display: flex; flex-direction: column;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 18px; box-shadow: var(--shadow-3);
    transform: scale(.94) translateY(12px);
    transition: transform .26s cubic-bezier(.34, 1.4, .64, 1);
    overflow: hidden;
}
.tl-modal.is-open .tl-modal-panel { transform: scale(1) translateY(0); }
.tl-modal-panel.lg { max-width: 620px; }
.tl-modal-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 10px; padding: 15px 20px; border-bottom: 1px solid var(--border);
}
.tl-modal-head h3 { font-size: 15px; display: inline-flex; align-items: center; gap: 7px; }
.tl-modal-head h3 .glyphicon { color: var(--brand); font-size: 13px; }
.tl-modal-x {
    width: 30px; height: 30px; border-radius: 8px;
    border: 1px solid transparent; background: transparent;
    color: var(--text-3); font-size: 20px; line-height: 1;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    transition: background-color .16s ease, color .16s ease;
}
.tl-modal-x:hover { background: var(--surface-3); color: var(--text); }
.tl-modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.tl-modal-foot {
    padding: 14px 20px 16px; border-top: 1px solid var(--border);
    background: var(--surface-2);
    display: flex; flex-direction: column; gap: 10px;
}
.foot-actions {
    display: flex; justify-content: center; align-items: center;
    gap: 9px; flex-wrap: wrap;
}
.foot-hint {
    font-size: 11.5px; color: var(--text-3);
    text-align: center; line-height: 1.7; padding-top: 2px;
}
.foot-hint kbd {
    display: inline-block;
    background: var(--surface); border: 1px solid var(--border);
    border-bottom-width: 2px; border-radius: 4px;
    padding: 0 5px; font-size: 11px;
    font-family: inherit; color: var(--text-2); margin: 0 2px;
}

/* 结果弹窗 */
.result-hero {
    text-align: center; padding-bottom: 20px; margin-bottom: 20px;
    border-bottom: 1px solid var(--border); position: relative;
}
.result-grade {
    display: inline-flex; align-items: center; justify-content: center;
    width: 96px; height: 96px; border-radius: 26px;
    font-size: 52px; font-weight: 900; letter-spacing: 2px; line-height: 1;
    margin-bottom: 14px;
}
.result-grade.g-A { color: var(--ok); background: var(--ok-soft); border: 2px solid var(--ok-border); }
.result-grade.g-B { color: var(--warn); background: var(--warn-soft); border: 2px solid var(--warn-border); }
.result-grade.g-C { color: var(--bad); background: var(--bad-soft); border: 2px solid var(--bad-border); }
.result-grade.reveal { animation: gradeReveal .62s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes gradeReveal {
    0% { transform: scale(.35) rotate(-12deg); opacity: 0; }
    55% { transform: scale(1.14) rotate(4deg); opacity: 1; }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}
.result-verdict {
    font-size: 15px; font-weight: 700; color: var(--text);
    line-height: 1.65; margin-bottom: 8px;
}
.result-verdict .hl { color: var(--brand); }
.result-verdict .ok { color: var(--ok); }
.result-verdict .bad { color: var(--bad); }
.result-verdict .warn { color: var(--warn); }
.result-new-flag {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 11.5px; font-weight: 800; letter-spacing: .5px;
    color: #fff;
    background: linear-gradient(135deg, var(--gold), #f59e0b);
    padding: 5px 14px; border-radius: 999px;
    box-shadow: 0 5px 14px rgba(202, 138, 4, .4); margin-bottom: 12px;
    animation: ribbonPop .6s cubic-bezier(.34, 1.56, .64, 1);
}
.result-subject {
    font-size: 12px; color: var(--text-3);
    display: flex; align-items: center; justify-content: center;
    gap: 8px; flex-wrap: wrap;
}
.result-subject .chip {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 9px; border-radius: 999px;
    background: var(--surface-3); color: var(--text-2); font-weight: 600;
}
.result-subject .chip .glyphicon { font-size: 10px; }
.result-subject .chip.new-record {
    background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e;
}
.rgroup { margin-bottom: 18px; }
.rgroup:last-child { margin-bottom: 0; }
.rgroup-title {
    display: flex; align-items: center; gap: 7px;
    font-size: 12.5px; font-weight: 800; color: var(--text-3);
    letter-spacing: .5px; margin-bottom: 10px;
}
.rgroup-title .glyphicon { font-size: 11px; }
.rgroup-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.metric-grid {
    display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px;
}
@media (max-width: 560px) { .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.metric-cell {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 12px 5px; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
    min-height: 74px; justify-content: center;
}
.metric-cell .v {
    font-size: 19px; font-weight: 800; color: var(--text);
    line-height: 1.1; font-variant-numeric: tabular-nums;
}
.metric-cell .v .u { font-size: 11px; font-weight: 700; color: var(--text-3); margin-left: 2px; }
.metric-cell .k {
    font-size: 11px; color: var(--text-3);
    display: inline-flex; align-items: center; gap: 3px;
}
.metric-cell .k .glyphicon { font-size: 10px; }
.goal-list { display: grid; gap: 11px; }
.goal-item {
    display: grid; grid-template-columns: 76px 1fr auto;
    align-items: center; gap: 11px;
}
.goal-name {
    font-size: 12.5px; font-weight: 700; color: var(--text-2);
    display: inline-flex; align-items: center; gap: 4px;
}
.goal-name .glyphicon { font-size: 11px; color: var(--text-3); }
.goal-track {
    height: 8px; border-radius: 4px;
    background: var(--surface-3); overflow: hidden;
}
.goal-fill {
    height: 100%; width: 0; border-radius: 4px;
    transition: width .7s cubic-bezier(.34, 1.2, .64, 1);
}
.goal-fill.is-ok { background: linear-gradient(90deg, var(--ok), #34d399); }
.goal-fill.is-near { background: linear-gradient(90deg, var(--warn), #fbbf24); }
.goal-fill.is-low { background: linear-gradient(90deg, var(--bad), #f87171); }
.goal-val {
    font-size: 11.5px; font-weight: 700; color: var(--text-3);
    white-space: nowrap; font-variant-numeric: tabular-nums;
    min-width: 110px; text-align: right;
}
.goal-val .mark { font-weight: 800; }
.goal-val .mark.ok { color: var(--ok); }
.goal-val .mark.bad { color: var(--bad); }
.diag-card {
    padding: 13px 15px; border-radius: var(--radius-sm);
    background: var(--surface-2); border: 1px solid var(--border);
    border-left: 3px solid var(--brand);
    font-size: 12.5px; line-height: 1.8; color: var(--text-2);
}
.diag-card + .diag-card { margin-top: 9px; }
.diag-card.ok { border-left-color: var(--ok); }
.diag-card.warn { border-left-color: var(--warn); }
.diag-card strong { color: var(--text); }

/* 暂停遮罩 */
.pause-mask {
    position: fixed; inset: 0; z-index: 900;
    display: flex; align-items: center; justify-content: center;
    background: rgba(9, 14, 25, .8);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    opacity: 0; visibility: hidden;
    transition: opacity .2s ease, visibility .2s ease;
}
.pause-mask.is-open { opacity: 1; visibility: visible; }
.pause-box {
    text-align: center; padding: 34px 44px; border-radius: 22px;
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow-3); max-width: 92vw;
}
.pause-ico {
    font-size: 46px; color: var(--brand); margin-bottom: 10px;
    animation: pauseIco 1.6s ease-in-out infinite;
}
@keyframes pauseIco {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.09); }
}
.pause-title {
    font-size: 22px; font-weight: 900; color: var(--text);
    letter-spacing: 4px; margin-bottom: 7px;
}
.pause-desc { font-size: 13px; color: var(--text-2); margin-bottom: 5px; }
.pause-desc kbd {
    display: inline-block;
    background: var(--brand-soft); border: 1px solid var(--brand-border);
    border-bottom-width: 3px; border-radius: 6px;
    padding: 2px 9px; font-size: 12px;
    font-weight: 700; color: var(--brand); margin: 0 4px;
}
.pause-hint { font-size: 11.5px; color: var(--text-3); margin-bottom: 16px; }

/* 特效 */
.confetti {
    position: fixed; top: -24px;
    width: 10px; height: 10px; border-radius: 2px;
    pointer-events: none; z-index: 850;
    animation: confettiFall linear forwards;
}
@keyframes confettiFall {
    0% { transform: translateY(0) rotate(0) scale(1); opacity: 1; }
    100% { transform: translateY(106vh) rotate(760deg) scale(.55); opacity: 0; }
}
.burst {
    position: fixed; pointer-events: none; z-index: 851;
    font-size: 42px;
    animation: burstOut .95s ease-out forwards;
}
@keyframes burstOut {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(2.6); opacity: 0; }
}
.sparkle {
    position: fixed; pointer-events: none; z-index: 2002;
    font-size: 22px;
    animation: sparkleFly .9s ease-out forwards;
}
@keyframes sparkleFly {
    0% { transform: translate(-50%, -50%) scale(0); opacity: 0; }
    30% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1.8); opacity: 0; }
}

/* 页脚 */
.site-footer {
    margin-top: 30px; padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 12px; color: var(--text-3); line-height: 1.9;
}

/* 响应式 */
@media (max-width: 768px) {
    body { padding-top: 56px; }
    .header-row { height: 56px; }
    .site-header { height: 56px; }
    .brand-text { display: none; }
    .exam-body { padding: 14px; }
    .hero-card { padding: 20px 16px; }
    .card-display { padding: 13px 11px; gap: 6px 5px; }
    .char-card { min-width: 34px; height: 46px; font-size: 20px; padding: 0 7px; }
    .space-gap { width: 9px; height: 46px; }
    .syllable-card { width: 60px; }
    .syllable-tian { width: 46px; height: 46px; }
    .syllable-hz { font-size: 23px; }
    .syllable-py { font-size: 14px; height: 20px; }
    .syllable-wrap { gap: 18px 8px; padding: 16px 12px; }
    .tian-display { padding: 13px 11px; gap: 9px 6px; max-height: 320px; }
    .tian-cell { width: 36px; height: 36px; font-size: 18px; }
    .goal-item { grid-template-columns: 64px 1fr; }
    .goal-val { grid-column: 2; text-align: left; min-width: 0; }
    .start-row { gap: 10px; }
    .start-row .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
        scroll-behavior: auto !important;
    }
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong); border-radius: 5px;
    border: 2px solid var(--surface);
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 6px; }