/* BrainGain Web —— 深色主题样式表 */
:root {
  --bg: #0d1117;
  --bg-2: #131a24;
  --bg-3: #1a2330;
  --line: #24303f;
  --fg: #e6edf3;
  --fg-dim: #8b98a8;
  --accent: #4ade80;
  --accent-2: #60a5fa;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 12px;
  --maxw: 1120px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Noto Sans SC", Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html { color-scheme: dark; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.3; margin: 1.6em 0 .6em; }
h1 { font-size: 2rem; margin-top: .4em; }
h2 { font-size: 1.32rem; }
h3 { font-size: 1.05rem; }

p { margin: .7em 0; }
ul, ol { padding-left: 1.3em; }
li { margin: .3em 0; }

code {
  font-family: var(--mono);
  font-size: .88em;
  background: var(--bg-3);
  padding: .12em .4em;
  border-radius: 5px;
  color: #a5d6ff;
}

.dim { color: var(--fg-dim); }
.small { font-size: .86rem; }
.ok { color: var(--accent); }
.up { color: var(--accent); }
.down { color: var(--bad); }

/* ---------- 布局骨架 ---------- */
main {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 1.6rem 1.2rem 4rem;
}

.site-header {
  border-bottom: 1px solid var(--line);
  background: rgba(13, 17, 23, .92);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 50;
}
.site-header {
  display: flex; align-items: center; gap: 1.4rem;
  padding: .7rem 1.2rem;
  max-width: var(--maxw); margin: 0 auto;
}
.brand {
  display: flex; align-items: center; gap: .5rem;
  color: var(--fg); font-weight: 700; font-size: 1.02rem;
}
.brand:hover { text-decoration: none; }
.brand svg { color: var(--accent); }
.brand em { color: var(--fg-dim); font-style: normal; font-weight: 500; }
.site-nav { display: flex; gap: 1rem; flex-wrap: wrap; margin-left: auto; }
.site-nav a { color: var(--fg-dim); font-size: .92rem; }
.site-nav a:hover { color: var(--fg); text-decoration: none; }

.site-footer {
  border-top: 1px solid var(--line);
  margin-top: 3rem;
  padding: 1.6rem 1.2rem 2.4rem;
  max-width: var(--maxw); margin-left: auto; margin-right: auto;
  display: flex; justify-content: space-between; gap: 2rem; flex-wrap: wrap;
  font-size: .88rem;
}
.site-footer p { margin: .3em 0; }

/* ---------- 首页 ---------- */
.hero { padding: 1.4rem 0 .4rem; }
.hero h1 { font-size: 2.3rem; }
.lede { font-size: 1.06rem; color: #c3ced9; max-width: 62ch; }

.hero-actions { display: flex; gap: .7rem; flex-wrap: wrap; margin: 1.2rem 0 2rem; }

.btn {
  display: inline-block;
  padding: .55rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg-2);
  color: var(--fg);
  font: inherit; font-size: .92rem;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--bg-3); border-color: #32425a; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06210f; font-weight: 600; }
.btn.primary:hover { background: #5ae08e; }
.btn.small { padding: .3rem .7rem; font-size: .82rem; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.grid-stats, .stats-inline {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: .8rem; margin: 1.6rem 0;
}
.stat {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: .9rem 1rem;
  display: flex; flex-direction: column;
}
.stat .n { font-size: 1.55rem; font-weight: 700; color: var(--accent); line-height: 1.2; }
.stat .l { font-size: .84rem; color: var(--fg-dim); }

.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1rem 0; }
@media (max-width: 720px) { .compare { grid-template-columns: 1fr; } }
.cmp-col {
  background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem 1.2rem;
}
.cmp-col h3 { margin-top: .2em; }
.cmp-col.bad { border-left: 3px solid var(--bad); }
.cmp-col.good { border-left: 3px solid var(--accent); }
.cmp-col ul { margin: .5em 0; font-size: .93rem; }

.domain-groups { display: grid; gap: 1rem; }
.domain-group h3 { display: flex; align-items: center; gap: .5rem; }
.domain-group h3::before {
  content: ''; width: 9px; height: 9px; border-radius: 50%;
  background: var(--d, var(--accent));
}

.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .5rem 0; }
.chips.small .chip { font-size: .76rem; padding: .12rem .5rem; }
.chip {
  display: inline-block;
  font-size: .82rem; padding: .2rem .6rem;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--chip, #888) 45%, transparent);
  background: color-mix(in srgb, var(--chip, #888) 14%, transparent);
  color: color-mix(in srgb, var(--chip, #888) 70%, white);
}
.chip:hover { text-decoration: none; border-color: var(--chip, #888); }

.pill {
  display: inline-block; font-size: .74rem; padding: .1rem .5rem;
  border-radius: 6px; background: var(--bg-3); color: var(--fg-dim);
  border: 1px solid var(--line);
}
.cat-memory { color: #c4b5fd; } .cat-focus { color: #6ee7b7; }
.cat-math { color: #93c5fd; } .cat-problem-solving { color: #fcd34d; }
.cat-language { color: #f9a8d4; } .cat-popular { color: #fdba74; }

.game-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: .9rem; margin: 1rem 0;
}
.game-card {
  display: block; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1rem;
  color: var(--fg); transition: border-color .15s, transform .15s;
}
.game-card:hover { border-color: #32425a; transform: translateY(-2px); text-decoration: none; }
.game-card-top { display: flex; justify-content: space-between; align-items: center; }
.game-card h3 { margin: .5em 0 .1em; font-size: 1.05rem; }
.game-card p { margin: .2em 0; }
.game-mech { font-size: .86rem; color: var(--fg-dim); min-height: 2.6em; }

.engine-box { margin-top: 2rem; }
.code {
  background: #0a0e14; border: 1px solid var(--line); border-radius: 10px;
  padding: .9rem 1rem; overflow-x: auto;
  font-family: var(--mono); font-size: .82rem; line-height: 1.6;
  color: #c9d1d9; white-space: pre-wrap; word-break: break-word;
}

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; margin: 1rem 0; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .5rem .7rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--fg-dim); font-weight: 600; background: var(--bg-2); white-space: nowrap; }
tbody tr:hover { background: rgba(255, 255, 255, .02); }

/* ---------- 游戏详情 ---------- */
.crumbs { font-size: .86rem; color: var(--fg-dim); margin-bottom: .8rem; }
.game-detail header { border-bottom: 1px solid var(--line); padding-bottom: 1rem; }
.game-detail header h1 { margin-top: .5em; }
.ability-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .9rem; }
.ability-card {
  display: block; background: var(--bg-2); border: 1px solid var(--line);
  border-left: 3px solid var(--d, var(--accent));
  border-radius: var(--radius); padding: 1rem; color: var(--fg);
}
.ability-card:hover { text-decoration: none; border-color: #32425a; border-left-color: var(--d, var(--accent)); }
.ability-card h3 { margin: 0 0 .3em; font-size: 1rem; }
.ability-card p { font-size: .9rem; color: var(--fg-dim); margin: .3em 0; }
.play-cta { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.prov { border-top: 1px solid var(--line); padding-top: .8rem; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: .5rem; }

/* ---------- 游戏运行 ---------- */
body.playing main { max-width: 960px; }
.play-shell { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.play-hud {
  display: flex; justify-content: space-between; align-items: center;
  padding: .6rem 1rem; border-bottom: 1px solid var(--line); background: var(--bg-3);
}
.hud-left { display: flex; gap: .7rem; align-items: baseline; }
.hud-game { font-weight: 600; }
.hud-tier { font-size: .84rem; }
.hud-right { display: flex; gap: 1rem; align-items: baseline; }
.hud-timer {
  font-family: var(--mono); font-size: 1.15rem; font-weight: 700;
  padding: .1rem .5rem; border-radius: 6px; transition: background .2s;
}
.hud-timer.warn { color: var(--warn); }
.hud-score { font-family: var(--mono); color: var(--fg-dim); }
.flash-ok { background: rgba(74, 222, 128, .28); }
.flash-bad { background: rgba(248, 113, 113, .28); }
.play-stage { padding: 1.2rem; min-height: 340px; display: flex; flex-direction: column; justify-content: center; }
.play-foot { padding: .6rem 1rem; border-top: 1px solid var(--line); display: flex; gap: 1rem; align-items: center; }
.loading { color: var(--fg-dim); text-align: center; padding: 2rem; }
.error-box { text-align: center; padding: 1.5rem; }

.result-panel {
  margin-top: 1.2rem; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 1.2rem;
}
.result-panel h2 { margin-top: 0; }
.res-rows { display: grid; gap: .3rem; margin: .8rem 0; }
.res-row { display: flex; justify-content: space-between; gap: 1rem; padding: .3rem 0; border-bottom: 1px dashed var(--line); }
.deltas { display: grid; gap: .3rem; margin: .6rem 0; }
.delta { display: grid; grid-template-columns: 1fr auto auto; gap: .8rem; align-items: baseline; font-size: .92rem; }
.delta-val { font-family: var(--mono); font-weight: 700; }
.res-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1rem; }

/* ---------- 1. Hidden Pairs ---------- */
.hp-banner { text-align: center; font-weight: 600; color: var(--warn); min-height: 1.8em; margin-bottom: .8rem; }
.hp-grid {
  display: grid; gap: .5rem; margin: 0 auto; width: 100%;
  max-width: calc(var(--cols) * 78px);
}
.hp-cell {
  all: unset; cursor: pointer; aspect-ratio: 1;
  perspective: 600px; border-radius: 9px;
}
.hp-inner {
  position: relative; display: block; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform .28s;
}
.hp-face, .hp-back {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  border-radius: 9px; backface-visibility: hidden;
  font-size: clamp(18px, 4.4vw, 32px);
}
.hp-face { background: linear-gradient(160deg, #2b3a52, #1e2a3b); border: 1px solid #33445e; }
.hp-back { background: linear-gradient(160deg, #1b2534, #141c28); border: 1px solid var(--line); transform: rotateY(180deg); }
.hp-cell.face-down .hp-inner { transform: rotateY(180deg); }
.hp-cell.up .hp-inner, .hp-cell.matched .hp-inner { transform: rotateY(0deg); }
.hp-cell.matched .hp-face { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(74, 222, 128, .35) inset; }
.hp-cell.hint .hp-face { animation: pulse 0.6s ease-in-out 2; }
@keyframes pulse { 50% { box-shadow: 0 0 0 3px var(--warn) inset; } }

/* ---------- 2. Spot the Number ---------- */
.stn-target { text-align: center; margin-bottom: 1.2rem; }
.stn-target-label { display: block; font-size: .84rem; color: var(--fg-dim); }
.stn-target-value {
  display: inline-block; font-family: var(--mono); font-size: 2.2rem; font-weight: 700;
  letter-spacing: .12em; color: var(--accent-2); padding: .2rem .8rem;
  border: 1px dashed #32425a; border-radius: 10px; margin-top: .3rem;
}
.stn-grid { display: grid; gap: .7rem; max-width: 560px; margin: 0 auto; }
.stn-opt {
  font-family: var(--mono); font-size: 1.5rem; letter-spacing: .1em;
  padding: .9rem; cursor: pointer; border-radius: 10px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--fg);
  transition: background .15s, border-color .15s;
}
.stn-opt:hover { background: #22303f; border-color: #3c5169; }
.stn-opt.ok { border-color: var(--accent); background: rgba(74, 222, 128, .16); }
.stn-opt.bad { border-color: var(--bad); background: rgba(248, 113, 113, .16); }
.stn-note { text-align: center; margin-top: 1rem; min-height: 1.4em; }

/* ---------- 3. True Colors ---------- */
.tc-prompt { text-align: center; color: var(--fg-dim); font-size: .86rem; }
.tc-word {
  text-align: center; font-size: clamp(2.6rem, 11vw, 5rem); font-weight: 800;
  letter-spacing: .06em; margin: 1rem 0 1.4rem; line-height: 1.1;
}
.tc-word.pop { animation: pop .3s ease-out; }
@keyframes pop { from { transform: scale(.9); opacity: .4; } to { transform: scale(1); opacity: 1; } }
.tc-hint { text-align: center; min-height: 1.6em; color: var(--warn); font-weight: 600; }
.tc-choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .6rem; margin-top: 1.2rem; }
.tc-btn {
  padding: .8rem; font: inherit; font-weight: 600; cursor: pointer;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--fg);
  border-radius: 10px; letter-spacing: .04em;
}
.tc-btn:hover { background: #22303f; }
.tc-btn.ok { border-color: var(--accent); background: rgba(74, 222, 128, .16); }
.tc-btn.bad { border-color: var(--bad); background: rgba(248, 113, 113, .16); }

/* ---------- 4. Math Check ---------- */
.mc-counter { text-align: center; }
.mc-eq {
  text-align: center; font-family: var(--mono);
  font-size: clamp(1.4rem, 5.6vw, 2.4rem); font-weight: 700;
  margin: 1.2rem 0 1.6rem; letter-spacing: .04em; word-break: break-word;
}
.mc-eq.pop { animation: pop .28s ease-out; }
.mc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; max-width: 520px; margin: 0 auto; }
.mc-btn {
  padding: 1rem; font: inherit; font-size: 1.05rem; font-weight: 600;
  cursor: pointer; border-radius: 10px;
  background: var(--bg-3); border: 1px solid var(--line); color: var(--fg);
}
.mc-btn:hover:not(:disabled) { background: #22303f; }
.mc-btn.ok-btn:hover:not(:disabled) { border-color: var(--accent); }
.mc-btn.bad-btn:hover:not(:disabled) { border-color: var(--bad); }
.mc-btn:disabled { opacity: .5; cursor: default; }
.mc-feedback { text-align: center; min-height: 1.8em; margin-top: 1rem; color: var(--warn); }

/* ---------- 5. Single Stroke ---------- */
.ss-wrap { display: flex; flex-direction: column; align-items: center; }
.ss-canvas {
  width: 100%; max-width: 720px; height: auto; aspect-ratio: 3 / 2;
  background: #0a0e14; border: 1px solid var(--line); border-radius: 10px;
  touch-action: none; cursor: crosshair;
}
.ss-status { margin-top: .8rem; color: var(--fg-dim); font-size: .9rem; text-align: center; }

/* ---------- 6. Word List ---------- */
.wl-wrap { display: grid; grid-template-columns: 1fr 168px; gap: 1.2rem; align-items: start; }
@media (max-width: 680px) { .wl-wrap { grid-template-columns: 1fr; } }
.wl-grid {
  display: grid; gap: 3px; touch-action: none; user-select: none;
  max-width: 560px;
}
.wl-cell {
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
  background: var(--bg-3); border-radius: 5px; cursor: pointer;
  font-weight: 700; font-family: var(--mono);
  font-size: clamp(12px, calc(26px - var(--n) * 1px), 20px);
  transition: background .1s;
}
.wl-cell.sel { background: #2f4f6f; color: #fff; }
.wl-cell.found { background: rgba(74, 222, 128, .26); color: #d7ffe6; }
.wl-cell.hint { animation: pulse 0.7s ease-in-out 2; }
.wl-side h3 { margin-top: 0; font-size: .92rem; color: var(--fg-dim); }
.wl-words { list-style: none; padding: 0; margin: 0; }
.wl-words li {
  font-family: var(--mono); font-size: .9rem; padding: .22rem .5rem;
  border-radius: 5px; background: var(--bg-3); margin-bottom: .25rem;
}
.wl-words li.done { background: rgba(74, 222, 128, .2); color: var(--accent); text-decoration: line-through; }

/* ---------- 每日训练 ---------- */
.daily-box { margin-top: 1.2rem; }
.daily-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.pbar { flex: 1; min-width: 140px; height: 8px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.pbar.big { height: 10px; margin-top: .5rem; }
.pbar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.daily-list { display: grid; gap: .6rem; margin: 1rem 0; }
.daily-item {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .9rem 1rem; background: var(--bg-2); border: 1px solid var(--line);
  border-radius: var(--radius); color: var(--fg);
}
.daily-item:hover { border-color: #32425a; text-decoration: none; }
.daily-item.done { border-color: rgba(74, 222, 128, .4); background: rgba(74, 222, 128, .07); }
.di-main { display: flex; flex-direction: column; }
.di-meta { display: flex; gap: .6rem; align-items: center; }
.daily-mini { display: grid; gap: .35rem; }
.mini-item {
  display: flex; justify-content: space-between; padding: .45rem .7rem;
  background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--fg); font-size: .9rem;
}
.mini-item:hover { text-decoration: none; border-color: #32425a; }
.mini-item.done { border-color: rgba(74, 222, 128, .4); }

/* ---------- 个人画像 ---------- */
.profile-section { margin-top: 2rem; }
.profile { display: grid; gap: 1rem; }
.rating-bars { display: grid; gap: .3rem; }
.rating-row {
  display: grid; grid-template-columns: 150px 1fr 54px 52px 48px;
  gap: .6rem; align-items: center; font-size: .86rem;
}
@media (max-width: 640px) {
  .rating-row { grid-template-columns: 110px 1fr 48px 44px; }
  .rating-row .rr-rounds { display: none; }
}
.rr-name { font-family: var(--mono); font-size: .78rem; color: var(--fg-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rr-bar { height: 7px; background: var(--bg-3); border-radius: 999px; overflow: hidden; }
.rr-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); border-radius: 999px; }
.rr-val { font-family: var(--mono); text-align: right; }
.rr-delta { font-family: var(--mono); text-align: right; }

/* ---------- 素材缺口清单 ---------- */
.prio { padding: .4rem 0; border-bottom: 1px solid var(--line); }
.prio-P0 { color: var(--bad); }
.prio-P1 { color: var(--warn); }
.prio-P2 { color: var(--accent-2); }
.prio-P3 { color: var(--fg-dim); }
.gap-list { display: grid; gap: .6rem; margin: .8rem 0 1.6rem; }
.gap { background: var(--bg-2); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.gap summary {
  cursor: pointer; padding: .8rem 1rem; display: flex; gap: .7rem; align-items: center;
  flex-wrap: wrap; list-style: none;
}
.gap summary::-webkit-details-marker { display: none; }
.gap summary::before { content: '▸'; color: var(--fg-dim); transition: transform .15s; }
.gap[open] summary::before { transform: rotate(90deg); }
.gap-title { font-weight: 600; flex: 1; min-width: 120px; }
.gap-status { font-size: .84rem; }
.gap-body {
  margin: 0; padding: .2rem 1rem 1rem 2.2rem;
  display: grid; grid-template-columns: 78px 1fr; gap: .3rem .8rem;
  font-size: .9rem;
}
.gap-body dt { color: var(--fg-dim); }
.gap-body dd { margin: 0; }

.callout { border-radius: var(--radius); padding: .9rem 1.1rem; margin: 1rem 0; border: 1px solid var(--line); background: var(--bg-2); }
.callout.warn { border-left: 3px solid var(--warn); }
.callout ul { margin: .4em 0 0; }

.path li { margin: .5em 0; }
.limits li { margin: .5em 0; }

.notfound { text-align: center; padding: 4rem 1rem; }
.notfound h1 { font-size: 4rem; margin: 0; color: var(--fg-dim); }

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
