/* =========================================================================
 * 氨基酸闯关游戏 — 样式
 * 设计方向：「暗室荧光成像 · 分子代码」
 *   - 视觉叙事：凝胶电泳成像仪里，被荧光标记的分子在暗室中发光
 *   - 分类色 = 荧光标记色；氨基酸字母/缩写/密码子 = 分子代码（等宽字体）
 *   - Signature：结构式 SVG 的荧光发光
 * ========================================================================= */

:root {
  /* 暗室背景 */
  --lab: #070a14;
  --gel: #0e1425;        /* 凝胶面板 */
  --plate: #121a2f;      /* 卡片 */
  --plate-2: #17203a;    /* 次级面板/选项 */
  --line: #233050;       /* 描边 */
  --line-hi: #33507a;    /* 高亮描边 */

  /* 文字 */
  --text: #eef2fc;
  --muted: #a3afc8;

  /* 主强调色（正确 / 确认 / 主按钮，青绿，饱和 <80%） */
  --fluor: #4ade9b;
  --fluor-dim: #1fa97c;
  --fluor-tint: rgba(74, 222, 155, 0.12);
  --gold: #eec25f;
  --danger: #ef6478;

  /* 分类标记色（内容语义色，降饱和） */
  --np: #93a5c4;   /* 非极性 */
  --ar: #e9bd54;   /* 芳香 */
  --po: #57bfee;   /* 极性 */
  --ac: #e96a7e;   /* 酸性 */
  --ba: #aa8cf0;   /* 碱性 */

  /* 字体 */
  --font-body: -apple-system, BlinkMacSystemFont, "PingFang SC", "Segoe UI", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --radius: 12px;
  --shadow: 0 10px 32px rgba(0, 0, 0, 0.45);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
}

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

html, body {
  height: 100%;
  font-family: var(--font-body);
  background: var(--lab);
  background-image:
    radial-gradient(1100px 520px at 50% -8%, rgba(63, 201, 255, 0.07) 0%, transparent 62%),
    radial-gradient(900px 500px at 100% 0%, rgba(63, 240, 168, 0.05) 0%, transparent 55%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }

:focus-visible { outline: 2px solid var(--fluor); outline-offset: 2px; border-radius: 4px; }

/* 分子代码（等宽） */
.code, .build-btn .c3, .build-btn .c1, .build-chip .c1, .build-chip .c3,
.spell-letter, .build-target b, .opt .code {
  font-family: var(--font-mono);
  letter-spacing: 0.02em;
}

/* ---------- 应用外壳 ---------- */
#app { max-width: 760px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; padding: 0 16px 44px; }

/* ---------- SVG 图标统一规格 ---------- */
.brand .logo svg { width: 20px; height: 20px; color: var(--fluor); }
.stat .ico { display: flex; align-items: center; }
.stat .ico svg { width: 13px; height: 13px; }
.combo-badge { display: flex; align-items: center; justify-content: flex-end; gap: 3px; }
.combo-badge svg { width: 13px; height: 13px; }
.hearts .h { display: flex; align-items: center; }
.hearts .h svg { width: 17px; height: 17px; color: var(--danger); }
.fb-ico { display: flex; align-items: center; }
.fb-ico svg { width: 19px; height: 19px; }
.feedback.correct .fb-ico { color: var(--fluor); }
.feedback.wrong .fb-ico { color: var(--danger); }
.result-xp .ico { display: flex; align-items: center; }
.result-xp .ico svg { width: 16px; height: 16px; color: var(--gold); }
/* 锁定角标：挂在 node 上（气泡右上角），不与序号重叠、不受气泡 40% 透明度影响 */
.node .lock {
  position: absolute; top: -5px; left: calc(50% + 15px);
  width: 22px; height: 22px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--plate-2); border: 1.5px solid var(--line-hi);
  z-index: 2;
}
.node .lock svg { width: 12px; height: 12px; color: #7e8db0; }

/* ---------- 顶栏 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 0; margin: 0 -16px 10px; padding-left: 16px; padding-right: 16px;
  background: rgba(7, 10, 20, 0.82); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; letter-spacing: .5px; }
.brand .logo {
  font-size: 22px; width: 38px; height: 38px; display: flex; align-items: center; justify-content: center;
  border-radius: 10px; background: var(--plate); border: 1px solid var(--line);
}
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.stat-row { display: flex; gap: 8px; }
.stat {
  display: flex; align-items: center; gap: 6px;
  background: var(--plate); border: 1px solid var(--line);
  padding: 6px 12px; border-radius: 999px; font-weight: 700; font-size: 13px;
}
.stat .ico { font-size: 14px; }
.stat.xp .ico { color: var(--gold); }
.stat.streak .ico { color: #ff9600; animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.14); } }

/* ---------- 首页 ---------- */
.home-hero {
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 20px;
  padding: 26px 0 6px; text-align: left;
}
.home-hero .hero-text h1 { font-size: 26px; font-weight: 900; letter-spacing: .5px; line-height: 1.25; }
.home-hero .hero-text h1 .accent { color: var(--fluor); }
.home-hero .hero-text p { color: var(--muted); margin-top: 8px; font-size: 14px; line-height: 1.65; max-width: 34ch; }
.home-hero .hero-orb {
  width: 96px; height: 96px; flex: none;
  border-radius: 22px; background: var(--plate); border: 1px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  box-shadow: inset 0 0 18px rgba(63, 240, 168, 0.07);
}
.home-hero .hero-orb .structure-svg { filter: drop-shadow(0 0 5px rgba(150, 200, 255, 0.25)); }

.unit { margin-top: 28px; }
.unit-head { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; }
.unit-head .u-icon {
  width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 800; letter-spacing: 1px;
  font-family: var(--font-mono); color: var(--text);
  background: var(--plate); border: 1px solid var(--line);
}
.unit-head .u-title { font-weight: 800; font-size: 16px; letter-spacing: .3px; }
.unit-head .u-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.path { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; }
.node {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 86px;
  animation: node-in .45s var(--spring) backwards;
  animation-delay: calc(var(--i, 0) * 55ms);
}
@keyframes node-in { from { opacity: 0; transform: translateY(14px) scale(.85); } }
.node .bubble {
  width: 56px; height: 56px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; font-weight: 800; color: #fff; font-family: var(--font-mono);
  background: var(--plate); border: 2px solid var(--line-hi);
  transition: transform .2s var(--spring), box-shadow .2s ease, border-color .2s ease;
  position: relative;
}
.node .bubble .d3 { font-size: 13px; font-weight: 900; letter-spacing: .5px; color: var(--ba); }
.node .bubble .check {
  position: absolute; right: -2px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--fluor); color: #04251a; display: none; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 900; border: 2px solid var(--lab);
}
.node.done .bubble .check { display: flex; }
.node.unlocked .bubble { cursor: pointer; border-color: #2c4770; box-shadow: 0 4px 14px rgba(0,0,0,.4); }
.node.unlocked .bubble:hover { transform: translateY(-3px) scale(1.05); border-color: var(--fluor); }
.node.locked .bubble { opacity: .4; border-color: var(--line); }
.node .stars { display: flex; gap: 2px; height: 14px; }
.node .stars .s { color: #33405e; font-size: 12px; }
.node .stars .s.on { color: var(--gold); }
.node .lbl { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.3; max-width: 88px; }

.node.glow .bubble { border-color: #6d4fd6; }
.node.current .bubble { animation: pulse 1.8s infinite; }
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 222, 155, .35); }
  50% { box-shadow: 0 0 0 10px rgba(74, 222, 155, 0); }
}

/* ---------- 关卡进行中 ---------- */
.level-top { display: flex; align-items: center; gap: 12px; padding: 10px 0 6px; }
.btn-back {
  width: 38px; height: 38px; border-radius: 10px; background: var(--plate);
  border: 1px solid var(--line); font-size: 15px; flex: none; color: var(--muted);
}
.btn-back:hover { color: var(--text); border-color: var(--line-hi); }
.progress-wrap { flex: 1; }
.progress-bar { height: 10px; background: var(--gel); border-radius: 999px; overflow: hidden; border: 1px solid var(--line); }
.progress-fill {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--fluor-dim), var(--fluor));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: width .4s var(--spring);
  position: relative; overflow: hidden;
}
.progress-fill::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255, 255, 255, 0.28) 50%, transparent 60%);
  transform: translateX(-100%);
  animation: shimmer 2.4s ease-in-out infinite;
}
@keyframes shimmer { 55%, 100% { transform: translateX(100%); } }
.progress-label { font-size: 11px; color: var(--muted); margin-top: 4px; }
.hearts { display: flex; gap: 3px; font-size: 16px; }
.hearts .h { transition: transform .2s, opacity .2s, filter .2s; }
.hearts .h.lost { opacity: .18; filter: grayscale(1); }
.combo-badge { font-size: 12px; font-weight: 800; color: #ff9600; min-width: 40px; text-align: right; }

.card {
  background: var(--plate); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 22px; margin-top: 14px;
  box-shadow: var(--shadow);
}
.q-prompt { font-size: 19px; font-weight: 700; line-height: 1.55; text-align: center; }
.q-prompt .prompt-html { margin-top: 12px; }
.q-tag {
  display: inline-block; font-size: 12px; color: var(--muted);
  background: var(--plate-2); border: 1px solid var(--line);
  padding: 3px 10px; border-radius: 999px; margin-bottom: 10px;
}

/* ---------- 结构式（Signature：荧光发光） ---------- */
.struct-big { display: flex; justify-content: center; padding: 12px 0; }
.structure-svg { filter: drop-shadow(0 0 5px rgba(150, 200, 255, 0.22)); }
.structure-svg .bond { stroke: #e3e9f7; stroke-width: 3; stroke-linecap: round; }
.structure-svg .bond.db { stroke-width: 2.4; }
.structure-svg .atom { stroke: none; }
.structure-svg .atom-label {
  font-weight: 900; text-anchor: middle; dominant-baseline: central;
  font-family: var(--font-mono);
}
.structure-svg .atom-label[data-el="N"] { filter: drop-shadow(0 0 4px rgba(80,140,255,.55)); }
.structure-svg .atom-label[data-el="O"] { filter: drop-shadow(0 0 4px rgba(255,90,70,.55)); }
.structure-svg .atom-label[data-el="S"] { filter: drop-shadow(0 0 4px rgba(255,214,10,.5)); }
.structure-svg .aromatic-ring { fill: none; stroke: #c8d4f0; stroke-width: 1.8; stroke-dasharray: 3 2; }
.structure-svg .backbone-label { font-size: 15px; fill: #ffd60a; font-weight: 800; }
.structure-svg .backbone-label.r-label { fill: #3fc9ff; }

/* 教学用骨架大图 */
.backbone-svg { overflow: visible; display: block; }
.backbone-svg .bond { stroke: #eef2fc; stroke-width: 4; stroke-linecap: round; }
.backbone-svg .atom-label { font-weight: 900; }
.backbone-svg .backbone-label { font-size: 16px; font-weight: 800; fill: #ffd60a; filter: drop-shadow(0 1px 2px rgba(0,0,0,.7)); }
.backbone-svg .backbone-label.r-label { fill: #3fc9ff; }

/* ---------- 选项 ---------- */
.options { display: grid; gap: 10px; margin-top: 18px; }
.options.cols-2 { grid-template-columns: 1fr 1fr; }
.options.cols-4 { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.opt {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px;
  background: var(--plate-2); border: 2px solid var(--line); border-radius: 13px;
  font-size: 16px; font-weight: 600; text-align: left;
  transition: transform .18s var(--spring), border-color .18s ease, background .18s ease;
}
.opt:hover { border-color: var(--line-hi); background: #1b2644; }
.opt:active { transform: scale(0.98); }
.opt .opt-key { color: var(--muted); font-weight: 700; margin-right: 2px; font-family: var(--font-mono); font-size: 14px; }
.opt .opt-svg { display: flex; justify-content: center; flex: none; }
.opt.correct { border-color: var(--fluor); background: var(--fluor-tint); box-shadow: inset 0 0 0 1px rgba(74, 222, 155, 0.35); animation: pop .3s; }
.opt.wrong { border-color: var(--danger); background: rgba(239, 100, 120, 0.12); animation: shake .4s; }
.opt.disabled { pointer-events: none; }
.opt.dim { opacity: .4; }
@keyframes pop { 0% { transform: scale(1); } 50% { transform: scale(1.03); } 100% { transform: scale(1); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

/* ---------- 配对 ---------- */
.match-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 18px; }
.match-side { display: flex; flex-direction: column; gap: 8px; }
.match-item {
  padding: 12px 14px; background: var(--plate-2); border: 2px solid var(--line);
  border-radius: 12px; font-size: 15px; font-weight: 600; text-align: center;
  transition: transform .18s var(--spring), border-color .18s ease, background .18s ease;
}
.match-item.sel { border-color: var(--po); background: rgba(63,201,255,.12); }
.match-item.done { opacity: .32; pointer-events: none; }
.match-item:hover:not(.done) { border-color: var(--line-hi); }
.match-item .m-code { font-family: var(--font-mono); color: var(--po); font-size: 18px; font-weight: 800; }

/* ---------- 分类桶 ---------- */
.sort-buckets { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.sort-bucket {
  flex: 1; min-width: 120px; padding: 10px; border-radius: 14px; text-align: center;
  background: var(--plate-2); border: 2px dashed var(--line-hi); min-height: 72px;
  transition: all .15s;
}
.sort-bucket .b-name { font-size: 13px; font-weight: 700; }
.sort-bucket .b-items { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 8px; }
.sort-bucket.hover { border-color: var(--fluor); background: var(--fluor-tint); }
.sort-bucket.correct { border-color: var(--fluor); box-shadow: inset 0 0 0 1px rgba(74, 222, 155, 0.35); }
.sort-bucket.wrong { border-color: var(--danger); }
.sort-pool { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 18px; }
.sort-item {
  padding: 10px 14px; background: var(--plate-2); border: 2px solid var(--line);
  border-radius: 12px; font-weight: 600; cursor: pointer;
  transition: transform .18s var(--spring), border-color .18s ease;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.sort-item:hover { border-color: var(--line-hi); }
.sort-item:active { transform: scale(0.97); }
.sort-item.sel { border-color: var(--po); box-shadow: inset 0 0 0 1px rgba(87, 191, 238, 0.4); }
.sort-item.placed { opacity: .3; pointer-events: none; }
.sort-item .si-svg { pointer-events: none; }

/* ---------- 输入 ---------- */
.type-box { display: flex; gap: 10px; justify-content: center; margin-top: 18px; }
.type-box input {
  background: var(--gel); border: 2px solid var(--line); border-radius: 12px;
  padding: 13px 16px; font-size: 20px; font-weight: 800; color: var(--text);
  text-align: center; width: 180px; letter-spacing: 3px; text-transform: uppercase; outline: none;
  font-family: var(--font-mono);
}
.type-box input:focus { border-color: var(--po); box-shadow: inset 0 0 0 1px rgba(87, 191, 238, 0.4); }
.btn-primary {
  background: var(--fluor); color: #04251a; font-weight: 800; font-size: 15px;
  padding: 13px 22px; border-radius: 12px;
  box-shadow: 0 3px 0 var(--fluor-dim), inset 0 1px 0 rgba(255, 255, 255, 0.3);
  transition: all .1s ease;
}
.btn-primary:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--fluor-dim), inset 0 1px 0 rgba(255, 255, 255, 0.3); }
.btn-primary:disabled { opacity: .4; box-shadow: none; }

/* ---------- 反馈条 ---------- */
.feedback { margin-top: 16px; padding: 14px 16px; border-radius: 12px; font-size: 14px; display: none; }
.feedback.show { display: flex; }
.feedback.correct { background: var(--fluor-tint); border: 1px solid rgba(74, 222, 155, 0.4); }
.feedback.wrong { background: rgba(239, 100, 120, 0.12); border: 1px solid rgba(239, 100, 120, 0.4); }
.feedback .fb-ico { margin-right: 10px; font-size: 20px; }
.feedback .fb-txt b { color: var(--text); }
.feedback .fb-txt .fb-key { color: var(--fluor); white-space: nowrap; font-weight: 800; }
.continue-row { margin-top: 16px; display: flex; justify-content: center; }

/* ---------- 3D 宿主 ---------- */
.three3d-host {
  width: 100%; height: 300px; border-radius: 12px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #1a2545, #0a1122 72%);
  border: 1px solid var(--line); margin-top: 14px;
  box-shadow: inset 0 0 30px rgba(0,0,0,.4);
}
.three3d-host canvas { display: block; touch-action: none; }
.three3d-fallback { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 14px; padding: 20px; text-align: center; }
.three3d-tip { text-align: center; color: var(--muted); font-size: 13px; margin-top: 8px; }

/* ---------- 拼单词 ---------- */
.spell-letters { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.spell-letter {
  display: flex; flex-direction: column; align-items: center;
  background: var(--plate-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 8px 4px; min-width: 54px;
}
.spell-letter { font-size: 24px; font-weight: 900; color: var(--po); }
.spell-letter small { font-size: 10px; color: var(--muted); font-weight: 500; font-family: var(--font-body); }

/* ---------- 多肽构建 ---------- */
.build-target { text-align: center; font-size: 15px; color: var(--muted); margin-top: 8px; }
.build-target b { color: var(--gold); font-size: 20px; letter-spacing: 3px; }
.build-seq { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; min-height: 46px; margin-top: 12px; }
.build-chip { padding: 8px 13px; background: var(--plate-2); border: 2px solid var(--line); border-radius: 10px; font-weight: 800; font-size: 15px; animation: pop .25s; }
.build-chip .c1 { color: var(--po); font-size: 11px; display: block; font-weight: 700; font-family: var(--font-mono); }
.build-chip .c3 { font-family: var(--font-mono); }
.build-pool { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 14px; }
.build-btn { padding: 9px 12px; background: var(--plate-2); border: 2px solid var(--line); border-radius: 10px; font-weight: 700; font-size: 14px; transition: transform .18s var(--spring), border-color .18s ease; }
.build-btn:hover { border-color: var(--line-hi); transform: translateY(-2px); }
.build-btn:active { transform: translateY(0) scale(0.96); }
.build-btn .c3 { color: var(--po); font-weight: 800; }
.build-btn .c1 { color: var(--muted); font-size: 11px; margin-left: 4px; }
.build-actions { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.btn-ghost { padding: 8px 16px; background: var(--plate-2); border: 1px solid var(--line); border-radius: 10px; font-weight: 600; font-size: 13px; color: var(--muted); }
.btn-ghost:hover { color: var(--text); border-color: var(--line-hi); }

/* ---------- 结果页 ---------- */
.result-wrap { text-align: center; padding-top: 44px; }
.result-stars { font-size: 54px; letter-spacing: 6px; }
.result-stars .s { opacity: .18; filter: grayscale(1); }
.result-stars .s.on { opacity: 1; filter: none; color: var(--gold); animation: star-pop .5s var(--spring); }
@keyframes star-pop { 0% { transform: scale(0); } 70% { transform: scale(1.4); } 100% { transform: scale(1); } }
.result-title { font-size: 26px; font-weight: 900; margin-top: 14px; }
.result-sub { color: var(--muted); margin-top: 6px; font-size: 14px; }
.result-xp {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 18px;
  font-size: 20px; font-weight: 900; color: var(--gold); font-family: var(--font-mono);
  background: var(--plate); border: 1px solid var(--line); padding: 10px 22px; border-radius: 999px;
}
.result-actions { display: flex; gap: 12px; justify-content: center; margin-top: 26px; }

.confetti { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 99; overflow: hidden; }
.confetti span { position: absolute; width: 10px; height: 10px; top: -20px; border-radius: 2px; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .6; } }

/* 提示 / 文本教学页 */
.hint-note { text-align: center; color: var(--muted); font-size: 14px; margin-top: 14px; line-height: 1.65; }
.text-body { font-size: 16px; line-height: 1.8; color: var(--text); text-align: center; }
.text-body p { margin-bottom: 8px; }
.text-body strong { color: var(--fluor); }
.text-svg { display: flex; justify-content: center; margin-top: 16px; }

/* 减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* 响应式 */
@media (max-width: 560px) {
  .options.cols-2 { grid-template-columns: 1fr; }
  .q-prompt { font-size: 17px; }
  .three3d-host { height: 240px; }
  .node { width: 72px; }
  .node .bubble { width: 50px; height: 50px; font-size: 17px; }
  /* hero 单列坍缩：结构式 orb 置顶，文字左对齐 */
  .home-hero { grid-template-columns: 1fr; gap: 14px; }
  .home-hero .hero-orb { order: -1; }
}
