/* ===== 数据库王国 · 全局样式(RPG 手作风) ===== */
:root {
  --bg: #0f101a;
  --bg2: #181a28;
  --card: #1e2132;
  --card2: #272b40;
  --line: #34395580;
  --line-solid: #343955;
  --ink: #e9e6da;
  --ink-dim: #9d9bb4;
  --gold: #e8c268;
  --gold-deep: #b8934a;
  --green: #7ecf96;
  --red: #e88484;
  --blue: #82aaf0;
  --purple: #b48ef0;
  --accent: #e8c268;
  --radius: 4px;
  --mono: "Cascadia Code", Consolas, "JetBrains Mono", monospace;
  --serif: "Source Han Serif SC", "Noto Serif SC", "SimSun", serif;
  --kai: "KaiTi", "STKaiti", "楷体", var(--serif);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { scrollbar-color: #3a3f5c var(--bg); }
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #33374e; border-radius: 5px; border: 2px solid var(--bg); }
::selection { background: #e8c26840; }

body {
  background:
    radial-gradient(1100px 500px at 85% -5%, #2b234d66 0%, transparent 60%),
    radial-gradient(900px 480px at -5% 105%, #16324255 0%, transparent 55%),
    repeating-linear-gradient(0deg, transparent 0 2px, #ffffff02 2px 4px),
    var(--bg);
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  line-height: 1.75;
  min-height: 100vh;
}
/* 星幕 */
body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(1px 1px at 12% 22%, #ffffff2e 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 12%, #ffe9b52b 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 55% 38%, #ffffff1e 50%, transparent 51%),
    radial-gradient(1px 1px at 32% 74%, #ffffff22 50%, transparent 51%),
    radial-gradient(1px 1px at 90% 62%, #ffe9b520 50%, transparent 51%),
    radial-gradient(1.2px 1.2px at 8% 88%, #ffffff1c 50%, transparent 51%),
    radial-gradient(1px 1px at 45% 8%, #ffffff26 50%, transparent 51%),
    radial-gradient(1px 1px at 68% 85%, #ffffff19 50%, transparent 51%);
}
#app { max-width: 1080px; margin: 0 auto; padding: 0 16px; min-height: 100vh; display: flex; flex-direction: column; position: relative; z-index: 1; }

/* ---- 顶栏 ---- */
#topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 13px 4px; position: sticky; top: 0; z-index: 50;
  background: linear-gradient(#0f101af2, #0f101ae6);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, transparent, #e8c26855 30%, #e8c26855 70%, transparent) 1;
}
.brand {
  font-family: var(--serif); font-size: 1.3rem; font-weight: 900; letter-spacing: 3px;
  cursor: pointer; color: var(--gold);
  text-shadow: 0 0 22px #e8c26833;
  transition: text-shadow .25s;
}
.brand:hover { text-shadow: 0 0 14px #e8c26890; }
.topbar-right { display: flex; gap: 9px; align-items: center; }
.stat {
  background: linear-gradient(180deg, #232638, #1b1e2d);
  border: 1px solid var(--line-solid); border-radius: 3px;
  padding: 3px 13px; font-size: .84rem; color: var(--ink-dim);
  box-shadow: inset 0 1px 0 #ffffff0a, 0 1px 3px #00000040;
  font-family: var(--mono);
}
.wraith-btn { cursor: pointer; transition: .2s; }
.wraith-btn:hover { border-color: var(--purple); color: var(--purple); }
.wraith-btn.has-wraiths { border-color: #b48ef088; color: var(--purple); animation: pulse 2.4s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 #b48ef04d; } 50% { box-shadow: 0 0 0 7px transparent; } }

#screen { flex: 1; padding: 26px 0 44px; }
#foot {
  text-align: center; color: #4e526e; font-size: .76rem; padding: 16px 0 22px;
  border-top: 1px solid transparent;
  border-image: linear-gradient(90deg, transparent, #343955 30%, #343955 70%, transparent) 1;
  letter-spacing: 1px;
}

/* ---- 经验飘字 ---- */
.toast {
  position: fixed; top: 64px; right: 28px; z-index: 99;
  font-family: var(--mono); font-weight: 700; font-size: 1.05rem; color: var(--gold);
  text-shadow: 0 0 12px #e8c26866; pointer-events: none;
  animation: toast-fly 1.4s ease-out forwards;
}
@keyframes toast-fly {
  0% { opacity: 0; transform: translateY(14px) scale(.8); }
  18% { opacity: 1; transform: translateY(0) scale(1.12); }
  30% { transform: scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-30px); }
}

/* ---- 地图 ---- */
.map-hero { text-align: center; margin: 10px 0 30px; }
.map-hero h1 {
  font-family: var(--serif); font-size: 2.3rem; font-weight: 900; color: var(--gold);
  letter-spacing: 10px; text-indent: 10px;
  text-shadow: 0 2px 0 #00000066, 0 0 34px #e8c26838;
}
.map-hero .hero-ornament {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  color: #b8934a; font-size: .8rem; margin: 6px 0 10px; letter-spacing: 2px;
}
.map-hero .hero-ornament::before, .map-hero .hero-ornament::after {
  content: ''; height: 1px; width: 120px;
  background: linear-gradient(90deg, transparent, #b8934a99);
}
.map-hero .hero-ornament::after { background: linear-gradient(270deg, transparent, #b8934a99); }
.map-hero p { color: var(--ink-dim); max-width: 620px; margin: 0 auto; font-size: .92rem; font-family: var(--kai); }
.map-hero p b { color: var(--gold); font-weight: 700; }

.map-layout { display: grid; grid-template-columns: 1fr 296px; gap: 22px; align-items: start; }
@media (max-width: 860px) { .map-layout { grid-template-columns: 1fr; } }
.map-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 13px; }

.terr {
  background: linear-gradient(165deg, #22263a, #191c2b 70%);
  border: 1px solid var(--line-solid); border-radius: var(--radius);
  border-top: 2px solid var(--accent);
  padding: 14px 15px 12px; cursor: pointer; position: relative;
  transition: transform .18s, box-shadow .18s, border-color .18s;
  overflow: hidden;
}
.terr::after { /* 斜光 */
  content: ''; position: absolute; top: 0; left: -70%; width: 50%; height: 100%;
  background: linear-gradient(100deg, transparent, #ffffff08, transparent);
  transition: left .45s ease;
}
.terr:hover { transform: translateY(-3px); border-color: color-mix(in srgb, var(--accent) 65%, #343955); box-shadow: 0 10px 26px #00000059, 0 0 0 1px color-mix(in srgb, var(--accent) 25%, transparent); }
.terr:hover::after { left: 120%; }
.terr.locked { opacity: .42; cursor: not-allowed; filter: saturate(.4); }
.terr.locked:hover { transform: none; box-shadow: none; border-color: var(--line-solid); }
.terr .t-icon {
  width: 46px; height: 46px; display: flex; align-items: center; justify-content: center;
  font-size: 1.55rem; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--accent) 22%, #1a1d2c), #14161f 75%);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, #343955);
  box-shadow: inset 0 0 12px #00000080, 0 0 10px color-mix(in srgb, var(--accent) 16%, transparent);
}
.terr .t-name { font-family: var(--serif); font-weight: 900; font-size: 1.02rem; margin-top: 9px; letter-spacing: 1px; }
.terr .t-sub { color: var(--ink-dim); font-size: .76rem; margin-top: 2px; min-height: 2.3em; line-height: 1.5; }
.terr .t-prog { margin-top: 10px; }
.bar { height: 6px; background: #101220; border-radius: 99px; overflow: hidden; border: 1px solid #2c3048; position: relative; }
.bar > i {
  display: block; height: 100%; border-radius: 99px; transition: width .5s ease;
  background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 75%, #446), var(--accent));
  box-shadow: 0 0 8px color-mix(in srgb, var(--accent) 55%, transparent);
}
.terr .t-pct { font-size: .7rem; color: var(--ink-dim); margin-top: 5px; display: flex; justify-content: space-between; font-family: var(--mono); }
.terr .t-badge { position: absolute; top: 9px; right: 11px; font-size: 1.05rem; filter: drop-shadow(0 1px 2px #000); }
.terr.boss { border-top-color: #d05656; background: linear-gradient(165deg, #33202c, #1a151f 70%); }

.side-card {
  background: linear-gradient(180deg, #1f2233, #1a1c2b);
  border: 1px solid var(--line-solid); border-radius: var(--radius); padding: 15px 16px; margin-bottom: 13px;
  box-shadow: 0 2px 10px #00000030;
}
.side-card h3 {
  font-family: var(--serif); font-size: .95rem; color: var(--gold); margin-bottom: 8px; letter-spacing: 2px;
  display: flex; align-items: center; gap: 8px;
}
.side-card h3::after { content: ''; flex: 1; height: 1px; background: linear-gradient(90deg, #b8934a66, transparent); }
.side-card .hint { color: var(--ink-dim); font-size: .78rem; line-height: 1.6; }
#radar-wrap svg { width: 100%; height: auto; display: block; }

/* ---- 章节页 ---- */
.ch-head { display: flex; align-items: center; gap: 13px; margin-bottom: 16px; flex-wrap: wrap; }
.ch-head .back {
  cursor: pointer; color: var(--ink-dim); border: 1px solid var(--line-solid); border-radius: 3px;
  padding: 3px 12px; font-size: .82rem; background: linear-gradient(180deg, #232638, #1b1e2d);
  transition: .15s; box-shadow: 0 1px 3px #00000040;
}
.ch-head .back:hover { color: var(--gold); border-color: #b8934a88; }
.ch-head h2 { font-family: var(--serif); font-size: 1.35rem; font-weight: 900; letter-spacing: 2px; }
.ch-head .ch-sub { color: var(--ink-dim); font-size: .82rem; }

.stage-bar { display: flex; gap: 6px; margin: 2px 0 18px; flex-wrap: wrap; }
.stage-dot {
  width: 24px; height: 7px; background: #14161f; border: 1px solid #2c3048;
  transform: skewX(-18deg); transition: .25s;
}
.stage-dot.done { background: var(--green); border-color: var(--green); box-shadow: 0 0 6px #7ecf9655; }
.stage-dot.cur { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 8px #e8c26877; animation: cur-blink 1.6s infinite; }
.stage-dot.wrong { background: #a04b5e; border-color: #a04b5e; }
@keyframes cur-blink { 50% { box-shadow: 0 0 3px #e8c26833; } }

/* ---- 题卡:金角羊皮卷 ---- */
.qcard {
  background: linear-gradient(170deg, #202335 0%, #1c1f30 100%);
  border: 1px solid var(--line-solid); border-radius: var(--radius);
  padding: 24px 26px; animation: fadein .35s ease; position: relative;
  box-shadow: 0 6px 24px #00000038;
}
.qcard::before, .qcard::after {
  content: ''; position: absolute; width: 14px; height: 14px; pointer-events: none;
  border: 2px solid #b8934a;
}
.qcard::before { top: -2px; left: -2px; border-right: none; border-bottom: none; }
.qcard::after { bottom: -2px; right: -2px; border-left: none; border-top: none; }
@keyframes fadein { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.story {
  background: linear-gradient(160deg, #262038cc, #1e1c2ccc);
  border: 1px solid #3a3355; border-left: 3px solid var(--purple); border-radius: 3px;
  padding: 12px 16px; margin-bottom: 16px; color: #d5cdec; font-size: .98rem;
  font-family: var(--kai);
}
.story .npc { color: var(--purple); font-weight: 700; font-family: var(--serif); letter-spacing: 1px; }
.teach {
  background: #1d2a24cc; border: 1px solid #2c4a38; border-left: 3px solid var(--green); border-radius: 3px;
  padding: 12px 16px; margin-bottom: 16px; font-size: .9rem;
}
.teach b, .teach strong { color: var(--green); }
.qtitle { font-size: 1.02rem; font-weight: 600; margin-bottom: 14px; white-space: pre-wrap; }
.qtitle .tag {
  font-size: .68rem; background: linear-gradient(180deg, #2b2612, #221e10);
  border: 1px solid #b8934a66; color: var(--gold); border-radius: 2px;
  padding: 2px 9px; margin-right: 8px; vertical-align: 2px; letter-spacing: 1px; font-family: var(--serif);
}

/* 选项 */
.opts { display: grid; gap: 9px; }
.opt {
  border: 1px solid var(--line-solid); border-radius: 3px; padding: 10px 14px;
  cursor: pointer; background: linear-gradient(180deg, #1e2132, #1a1d2b);
  transition: border-color .15s, background .15s, transform .1s; font-size: .94rem;
  position: relative;
}
.opt:hover { border-color: var(--blue); background: #20253c; transform: translateX(3px); }
.opt.sel { border-color: var(--gold); background: #2a2734; }
.opt.right { border-color: var(--green); background: #1e352a; box-shadow: inset 0 0 18px #7ecf9612; }
.opt.wrong { border-color: var(--red); background: #372430; animation: shake .3s; }
.opt.dim { opacity: .5; pointer-events: none; }
.opt .key { display: inline-block; width: 1.7em; color: var(--gold-deep); font-weight: 700; font-family: var(--serif); }

/* 配对 */
.match-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.match-col { display: grid; gap: 8px; align-content: start; }
.mitem {
  border: 1px solid var(--line-solid); border-radius: 3px; padding: 8px 12px; cursor: pointer;
  background: linear-gradient(180deg, #1e2132, #1a1d2b); font-size: .88rem; transition: .15s;
}
.mitem:hover { border-color: var(--blue); }
.mitem.sel { border-color: var(--gold); background: #2a2734; box-shadow: 0 0 8px #e8c26833; }
.mitem.paired { opacity: .45; pointer-events: none; border-color: #2c4a38; }
.mitem.flash-wrong { border-color: var(--red); animation: shake .3s; }
@keyframes shake { 0%,100%{transform:none} 25%{transform:translateX(-5px)} 75%{transform:translateX(5px)} }

/* 排序 */
.order-pool, .order-seq { display: flex; flex-wrap: wrap; gap: 8px; min-height: 46px; border: 1px dashed #3a3f5c; border-radius: 3px; padding: 8px; margin-bottom: 10px; }
.order-seq { border-style: solid; background: #12141f; box-shadow: inset 0 2px 8px #00000059; }
.chip {
  border: 1px solid var(--line-solid); background: linear-gradient(180deg, #272b40, #20233570);
  border-radius: 3px; padding: 5px 12px; cursor: pointer; font-size: .87rem; font-family: var(--mono);
  transition: .15s; box-shadow: 0 2px 4px #00000040;
}
.chip:hover { border-color: var(--gold); transform: translateY(-2px); }
.order-label { font-size: .76rem; color: var(--ink-dim); margin-bottom: 4px; letter-spacing: 1px; }

/* 闭包计算器 */
.attr-row { display: flex; flex-wrap: wrap; gap: 9px; margin: 10px 0; }
.attr-chip {
  border: 1px solid var(--line-solid); background: linear-gradient(180deg, #1e2132, #191c2b);
  border-radius: 3px; padding: 7px 16px; cursor: pointer; font-family: var(--mono); font-size: 1rem;
  transition: .15s; box-shadow: 0 2px 4px #00000040;
}
.attr-chip:hover { border-color: var(--gold-deep); transform: translateY(-2px); }
.attr-chip.on {
  border-color: var(--gold); background: linear-gradient(180deg, #37301b, #2a2515);
  color: var(--gold); box-shadow: 0 0 10px #e8c26840, inset 0 1px 0 #ffffff14;
}
.closure-log {
  background: #101220; border: 1px solid var(--line-solid); border-left: 3px solid var(--blue);
  border-radius: 3px; padding: 12px 14px; font-family: var(--mono); font-size: .85rem; margin-top: 10px; white-space: pre-wrap;
  box-shadow: inset 0 2px 10px #00000059;
}
.closure-log .ok { color: var(--green); } .closure-log .no { color: var(--red); }

/* 关系代数除法沙盒 */
.div-top { display: flex; gap: 20px; flex-wrap: wrap; align-items: flex-start; }
.div-r { flex: 0 0 auto; }
.div-builder { flex: 1; min-width: 240px; }
.div-cap { color: var(--ink-dim); font-size: .82rem; margin: 4px 0; }
.div-cap b { color: var(--gold); }
.div-task {
  background: #101220; border: 1px solid var(--line-solid); border-left: 3px solid var(--gold);
  border-radius: 3px; padding: 9px 12px; margin-top: 10px; font-size: .86rem; line-height: 1.6;
}
.div-dyn { margin-top: 14px; }
.iset-panel { margin-bottom: 4px; }
.iset-row {
  display: flex; align-items: center; gap: 9px; flex-wrap: wrap;
  padding: 5px 10px; margin: 5px 0; background: #171927;
  border: 1px solid var(--line); border-radius: 4px; transition: .2s;
}
.iset-row.hit { border-color: var(--green); background: #16241c; box-shadow: 0 0 8px #7ecf9622; }
.iset-name { font-family: var(--mono); font-weight: 700; color: var(--blue); min-width: 2.4em; }
.iset-arrow { color: var(--ink-dim); font-size: .74rem; }
.iset-list { display: flex; gap: 5px; flex-wrap: wrap; flex: 1; }
.iset {
  display: inline-block; padding: 1px 9px; border-radius: 10px; border: 1px solid #3a3f5c;
  background: #1d2033; font-family: var(--mono); font-size: .8rem; color: var(--ink-dim);
}
.iset.need { border-color: var(--green); color: var(--green); background: #1a2a1f; box-shadow: 0 0 6px #7ecf9633; }
.verdict { font-size: .78rem; font-weight: 700; padding: 1px 9px; border-radius: 10px; white-space: nowrap; }
.verdict.ok { color: var(--green); background: #16241c; }
.verdict.no { color: var(--red); background: #241618; }
.div-quotient { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.div-quotient .div-cap { margin: 0; }
.qres { font-family: var(--mono); font-size: 1.05rem; color: var(--gold); font-weight: 700; }
.qres.empty { color: var(--ink-dim); }
.div-identity { margin-top: 14px; font-size: .82rem; line-height: 1.5; }
.div-msg { margin-top: 10px; }
.div-hint { font-size: .84rem; line-height: 1.6; padding: 8px 12px; border-radius: 3px; }
.div-hint.no { color: var(--red); background: #241618; border: 1px solid #4a2a2e; }

/* 可串行化前趋图沙盒 */
.sch-body { display: flex; gap: 22px; flex-wrap: wrap; align-items: flex-start; }
.sch-timeline { flex: 0 0 auto; min-width: 220px; }
.sch-op {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 8px; margin: 5px 0; background: #171927;
  border: 1px solid var(--line); border-radius: 4px;
}
.sch-op.shake { animation: sch-shake .35s; border-color: var(--red); }
@keyframes sch-shake {
  0%, 100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); }
}
.sch-badge {
  font-family: var(--mono); font-weight: 700; font-size: .82rem;
  border: 1px solid; border-radius: 10px; padding: 1px 9px;
}
.sch-act { font-family: var(--mono); font-size: .92rem; color: var(--ink); flex: 1; }
.sch-act.w { color: var(--gold); }
.sch-ctrl { display: flex; gap: 3px; }
.sch-mv {
  background: #232741; border: 1px solid var(--line-solid); color: var(--ink-dim);
  border-radius: 3px; width: 26px; height: 24px; cursor: pointer; font-size: .72rem; line-height: 1;
  transition: .15s;
}
.sch-mv:hover:not(:disabled) { border-color: var(--gold-deep); color: var(--gold); }
.sch-mv:disabled { opacity: .3; cursor: default; }
.sch-graph { flex: 1; min-width: 260px; }
.sch-graph svg { max-width: 100%; }
.sch-verdict { margin-top: 8px; font-size: .88rem; line-height: 1.6; padding: 8px 12px; border-radius: 3px; }
.sch-verdict.ok { color: var(--green); background: #16241c; border: 1px solid #2c5a3a; }
.sch-verdict.no { color: var(--red); background: #241618; border: 1px solid #4a2a2e; }
.sch-verdict b { color: inherit; }
.fd-list {
  font-family: var(--mono); background: #101220; border: 1px solid var(--line-solid); border-radius: 3px;
  padding: 10px 14px; margin: 8px 0; font-size: .92rem; box-shadow: inset 0 2px 8px #00000047;
  white-space: pre-wrap;
}

/* 填空 */
.blank-input {
  background: #101220; border: 1px solid var(--line-solid); border-radius: 3px;
  color: var(--ink); padding: 9px 12px; font-family: var(--mono); font-size: .95rem; width: 100%;
  box-shadow: inset 0 2px 8px #00000047;
}
.blank-input:focus { outline: none; border-color: var(--blue); box-shadow: inset 0 2px 8px #00000047, 0 0 0 3px #82aaf01f; }

/* SQL 控制台 */
.sql-wrap { margin-top: 6px; }
.sql-editor {
  width: 100%; min-height: 112px; resize: vertical;
  background: #0d0e17; color: #d8e2ff; border: 1px solid var(--line-solid); border-radius: 3px;
  font-family: var(--mono); font-size: .92rem; padding: 12px 14px; line-height: 1.55;
  box-shadow: inset 0 2px 12px #00000066;
}
.sql-editor:focus { outline: none; border-color: var(--blue); box-shadow: inset 0 2px 12px #00000066, 0 0 0 3px #82aaf01a; }
.sql-toolbar { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; align-items: center; }
.schema-box {
  background: #101220; border: 1px solid var(--line-solid); border-left: 3px solid var(--blue);
  border-radius: 3px; padding: 10px 14px; font-family: var(--mono); font-size: .8rem; color: var(--ink-dim); margin-bottom: 12px;
}
.schema-box b { color: var(--blue); font-weight: 600; }
.schema-box u { color: var(--gold); }
.result-area { margin-top: 12px; }
.sql-err {
  color: var(--red); font-family: var(--mono); font-size: .85rem; background: #2b1b24;
  border: 1px solid #5c3040; border-radius: 3px; padding: 8px 12px; white-space: pre-wrap;
}

/* 数据表 */
.rel-table { border-collapse: collapse; font-size: .84rem; font-family: var(--mono); margin: 6px 0; box-shadow: 0 2px 8px #00000030; }
.rel-table caption { caption-side: top; text-align: left; color: var(--gold); font-size: .8rem; padding-bottom: 3px; font-weight: 700; font-family: var(--serif); letter-spacing: 1px; }
.rel-table th { background: linear-gradient(180deg, #2b2f47, #252940); color: var(--blue); padding: 4px 12px; border: 1px solid #3a3f5c; font-weight: 600; }
.rel-table td { padding: 3px 12px; border: 1px solid #2e3350; color: var(--ink); background: #171927; }
.rel-table tr:nth-child(even) td { background: #1d2033; }
.tbl-row { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.tbl-scroll { overflow-x: auto; }

/* 按钮 */
.btn {
  display: inline-block; border-radius: 3px; padding: 9px 22px;
  font-size: .92rem; cursor: pointer; font-family: inherit; font-weight: 700; letter-spacing: 1px;
  transition: transform .1s, filter .15s, box-shadow .15s;
  border: 1px solid transparent;
}
.btn:active { transform: translateY(2px); }
.btn-gold {
  background: linear-gradient(180deg, #f0cd74, #cfa14e);
  border-color: #8a6a2c; color: #241c06;
  box-shadow: 0 3px 0 #7a5d26, 0 5px 12px #00000059, inset 0 1px 0 #ffffff59;
  text-shadow: 0 1px 0 #ffffff40;
}
.btn-gold:hover { filter: brightness(1.07); }
.btn-gold:active { box-shadow: 0 1px 0 #7a5d26, 0 2px 6px #00000059, inset 0 1px 0 #ffffff59; }
.btn-blue {
  background: linear-gradient(180deg, #8fb2f2, #5f84cf);
  border-color: #33508f; color: #0b1226;
  box-shadow: 0 3px 0 #2c447c, 0 5px 12px #00000059, inset 0 1px 0 #ffffff4d;
}
.btn-blue:hover { filter: brightness(1.07); }
.btn-blue:active { box-shadow: 0 1px 0 #2c447c, 0 2px 6px #00000059, inset 0 1px 0 #ffffff4d; }
.btn-ghost {
  background: linear-gradient(180deg, #23263880, #1b1e2d80);
  border: 1px solid var(--line-solid); color: var(--ink-dim);
  box-shadow: 0 2px 6px #00000033;
}
.btn-ghost:hover { border-color: #b8934a88; color: var(--gold); }
.btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* 反馈 */
.feedback { margin-top: 16px; border-radius: 3px; padding: 13px 16px; font-size: .92rem; animation: fb-pop .3s ease; position: relative; }
@keyframes fb-pop { 0% { opacity: 0; transform: scale(.96); } 70% { transform: scale(1.012); } 100% { opacity: 1; transform: scale(1); } }
.feedback.good { background: #1c3226cc; border: 1px solid #2f6b45; box-shadow: inset 0 0 24px #7ecf960f; }
.feedback.bad { background: #33202acc; border: 1px solid #6b2f45; }
.feedback .fb-title { font-weight: 900; margin-bottom: 4px; font-family: var(--serif); letter-spacing: 2px; font-size: 1.02rem; }
.feedback.good .fb-title { color: var(--green); text-shadow: 0 0 12px #7ecf9640; }
.feedback.bad .fb-title { color: var(--red); }
.feedback .explain { color: #d8d5ea; white-space: pre-wrap; }
.feedback .explain code, .qtitle code, .teach code, .story code, .opt code, .lesson-content code {
  font-family: var(--mono); background: #0d0e17; border: 1px solid #2e3350;
  border-radius: 3px; padding: 1px 6px; font-size: .88em; color: #9ec1ff;
}
.next-row { margin-top: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* 章节结算 */
.clear-card { text-align: center; padding: 48px 20px; }
.clear-card .big { font-size: 3.2rem; animation: clear-bounce .6s ease; filter: drop-shadow(0 0 24px #e8c26859); }
@keyframes clear-bounce { 0% { transform: scale(0) rotate(-20deg); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
.clear-card h2 { font-family: var(--serif); color: var(--gold); margin: 10px 0 6px; letter-spacing: 3px; font-size: 1.5rem; }
.clear-card p { color: var(--ink-dim); font-family: var(--kai); }
.clear-stats { display: flex; justify-content: center; gap: 22px; margin: 20px 0; flex-wrap: wrap; }
.clear-stats .cs {
  background: linear-gradient(180deg, #23263a, #1b1e2d); border: 1px solid var(--line-solid);
  border-top: 2px solid var(--gold-deep); border-radius: 3px; padding: 10px 24px;
  box-shadow: 0 4px 12px #00000040;
}
.clear-stats .cs b { display: block; font-size: 1.5rem; color: var(--gold); font-family: var(--serif); }
.clear-stats .cs span { font-size: .74rem; color: var(--ink-dim); letter-spacing: 1px; }

/* BOSS 战 */
.boss-bars { display: grid; gap: 8px; margin-bottom: 18px; }
.hp-row { display: flex; align-items: center; gap: 10px; font-size: .82rem; }
.hp-row .who { width: 110px; text-align: right; color: var(--ink-dim); font-family: var(--serif); letter-spacing: 1px; }
.hp-row .bar { flex: 1; height: 15px; border-radius: 2px; }
.hp-row .bar > i { border-radius: 2px; background: linear-gradient(180deg, #e86a6a, #a03a50); box-shadow: 0 0 10px #e0565659; }
.hp-row.player .bar > i { background: linear-gradient(180deg, #8fd8a3, #3f9d68); box-shadow: 0 0 10px #7ecf9659; }
.boss-avatar { text-align: center; font-size: 3.4rem; margin-bottom: 6px; filter: drop-shadow(0 0 22px #e0565666); animation: boss-float 3s ease-in-out infinite; }
@keyframes boss-float { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-7px); } }

/* 怨灵簿 */
.wraith-item {
  display: flex; justify-content: space-between; align-items: center;
  background: linear-gradient(170deg, #241f33, #1b1826); border: 1px solid #3a3355;
  border-left: 3px solid var(--purple); border-radius: 3px; padding: 10px 16px; margin-bottom: 8px;
}
.wraith-item .w-name { font-size: .92rem; }
.wraith-item .w-meta { color: var(--ink-dim); font-size: .76rem; font-family: var(--mono); }
.empty-tip { text-align: center; color: var(--ink-dim); padding: 46px 0; font-family: var(--kai); font-size: 1.05rem; }

/* SVG 语法树 */
.tree-box { background: #101220; border: 1px solid var(--line-solid); border-radius: 3px; padding: 8px; margin: 10px 0; overflow-x: auto; box-shadow: inset 0 2px 10px #00000047; }
.tree-box svg { display: block; margin: 0 auto; }
.tree-caption { text-align: center; color: var(--ink-dim); font-size: .78rem; margin-top: 2px; font-family: var(--kai); }

/* 讲堂 */
.lesson-content h3 {
  font-family: var(--serif); color: var(--gold); font-size: 1.25rem; font-weight: 900;
  margin-bottom: 14px; letter-spacing: 2px; padding-bottom: 10px;
  border-bottom: 1px solid transparent;
  border-image: linear-gradient(90deg, #b8934a88, transparent 65%) 1;
}
.lesson-content h4 {
  color: var(--blue); font-size: 1rem; margin: 20px 0 8px; font-weight: 700;
  padding-left: 10px; border-left: 3px solid var(--blue);
}
.lesson-content p { margin: 8px 0; font-size: .94rem; }
.lesson-content ul, .lesson-content ol { margin: 8px 0 8px 1.5em; font-size: .94rem; }
.lesson-content li { margin: 5px 0; }
.lesson-content .formula {
  background: #101220; border: 1px solid var(--line-solid); border-radius: 3px;
  padding: 11px 16px; margin: 12px 0; font-family: var(--mono); font-size: .93rem; text-align: center;
  box-shadow: inset 0 2px 8px #00000047; line-height: 1.9;
}
.lesson-content table.def-table { border-collapse: collapse; margin: 10px 0; font-size: .87rem; width: 100%; box-shadow: 0 2px 8px #00000030; }
.lesson-content table.def-table th { background: linear-gradient(180deg, #2b2f47, #252940); color: var(--blue); padding: 6px 12px; border: 1px solid #3a3f5c; text-align: left; }
.lesson-content table.def-table td { padding: 6px 12px; border: 1px solid #2e3350; vertical-align: top; background: #171927; }
.lesson-content table.def-table tr:nth-child(even) td { background: #1d2033; }
.lesson-content pre.fd-list { line-height: 1.6; }

kbd { font-family: var(--mono); background: var(--card2); border: 1px solid var(--line-solid); border-bottom-width: 2px; border-radius: 3px; padding: 0 6px; font-size: .85em; }
.muted { color: var(--ink-dim); }
.gold { color: var(--gold); }
.hl-green { color: var(--green); }
.hl-red { color: var(--red); }
