/* ══════════════════════════════════════════════════════
   生字打字岛 · 样式
   ══════════════════════════════════════════════════════ */

:root {
  --bg:        #fff8f0;
  --bg-2:      #fdf1e3;
  --card:      #ffffff;
  --ink:       #33291f;
  --ink-2:     #6f6154;
  --ink-3:     #a5968a;
  --line:      #f2e5d6;
  --accent:    #ff8a4c;
  --accent-d:  #e56b2c;
  --green:     #3fb984;
  --green-d:   #2c9468;
  --blue:      #4a9df8;
  --pink:      #ff7ba9;
  --yellow:    #ffc531;
  --red:       #ef5350;

  --r-lg: 26px;
  --r-md: 18px;
  --r-sm: 12px;

  --sh-1: 0 2px 4px rgba(120, 84, 50, .05), 0 8px 24px rgba(120, 84, 50, .07);
  --sh-2: 0 4px 10px rgba(120, 84, 50, .08), 0 16px 40px rgba(120, 84, 50, .10);

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Source Han Sans SC", sans-serif;
  --font-kai: "Kaiti SC", "STKaiti", "KaiTi", "楷体", "Songti SC", serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body { height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--bg);
  background-image:
    radial-gradient(circle at 12% 8%,  rgba(255, 197, 49, .16), transparent 42%),
    radial-gradient(circle at 88% 4%,  rgba(255, 123, 169, .13), transparent 40%),
    radial-gradient(circle at 78% 92%, rgba(63, 185, 132, .12), transparent 44%),
    radial-gradient(circle at 8% 88%,  rgba(74, 157, 248, .10), transparent 40%);
  background-attachment: fixed;
  overflow: hidden;
}

.app { height: 100%; position: relative; }

/* ───────────── 屏幕切换 ───────────── */
.screen {
  position: absolute;
  inset: 0;
  display: none;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
}
.screen.is-active { display: block; animation: screenIn .34s cubic-bezier(.22,1,.36,1); }

@keyframes screenIn {
  from { opacity: 0; transform: translateY(14px) scale(.99); }
  to   { opacity: 1; transform: none; }
}

/* ══════════════ 首页 ══════════════ */
.home-wrap {
  max-width: 1080px;
  margin: 0 auto;
  padding: 28px 22px 40px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 24px;
}

.brand-mark {
  width: 56px; height: 56px;
  flex: none;
  border-radius: 18px;
  background: linear-gradient(145deg, #ffa564, var(--accent));
  color: #fff;
  font-family: var(--font-kai);
  font-size: 32px;
  line-height: 56px;
  text-align: center;
  box-shadow: 0 6px 16px rgba(255, 138, 76, .38);
  transform: rotate(-4deg);
}

.brand-text h1 {
  font-size: 26px;
  letter-spacing: .5px;
  font-weight: 800;
}
.brand-text p {
  font-size: 13px;
  color: var(--ink-3);
  margin-top: 3px;
  letter-spacing: .4px;
}

.sound-btn { margin-left: auto; }
.sound-btn .ico-off { display: none; }
.sound-btn.is-off .ico-on { display: none; }
.sound-btn.is-off .ico-off { display: block; }
.sound-btn svg { display: block; }

.icon-btn {
  width: 44px; height: 44px;
  border: none;
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--sh-1);
  color: var(--ink-2);
  font-size: 18px;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
}
.icon-btn:hover { transform: translateY(-1px); box-shadow: var(--sh-2); }
.icon-btn:active { transform: scale(.95); }

.home-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}
.col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.panel {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 18px 18px 20px;
  box-shadow: var(--sh-1);
  min-width: 0;
}

.panel-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-2);
  margin-bottom: 14px;
  letter-spacing: .3px;
}
.panel-label i {
  width: 20px; height: 20px;
  flex: none;
  border-radius: 7px;
  background: var(--bg-2);
  color: var(--accent);
  font-style: normal;
  font-size: 12px;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
}

/* 课本 tabs */
/* 六个册（2上/2下/3上/3下/4上/4下）→ 一行三个，两行 */
.book-tabs { display: flex; flex-wrap: wrap; gap: 8px; }

.book-tab {
  flex: 1 1 calc(33.333% - 6px);
  min-width: 90px;
  border: 2px solid var(--line);
  background: #fff;
  border-radius: var(--r-md);
  padding: 11px 9px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  transition: all .18s;
}
.book-tab b { display: block; font-size: 14px; color: var(--ink); white-space: nowrap; }
.book-tab small { display: block; font-size: 10.5px; color: var(--ink-3); margin-top: 3px; white-space: nowrap; }
.book-tab:hover { border-color: #ffd0b3; }
.book-tab.is-on {
  border-color: var(--accent);
  background: #fff6ef;
  box-shadow: 0 4px 14px rgba(255, 138, 76, .18);
}
.book-tab.is-on b { color: var(--accent-d); }

/* chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips-sub { margin-top: 10px; }
.chips-sub:empty { margin-top: 0; }

.chip {
  border: 2px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all .16s;
  white-space: nowrap;
}
.chip:hover { border-color: #ffd0b3; color: var(--ink); }
.chip.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 4px 12px rgba(255, 138, 76, .3);
}
.chip.is-lesson {
  border-style: dashed;
  font-weight: 500;
  font-size: 12px;
}
.chip.is-lesson.is-on { border-style: solid; }

.range-summary {
  margin-top: 14px;
  font-size: 12px;
  color: var(--ink-3);
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}
.range-summary b { color: var(--accent-d); font-size: 14px; }

/* 难度卡 */
.level-cards, .mode-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.mode-cards { grid-template-columns: repeat(2, 1fr); }

.level-card, .mode-card {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: var(--r-md);
  padding: 14px 10px 12px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: all .18s;
}
.level-card:hover, .mode-card:hover { border-color: #ffd0b3; transform: translateY(-2px); }
.level-card.is-on, .mode-card.is-on {
  border-color: var(--accent);
  background: #fff6ef;
  box-shadow: 0 6px 18px rgba(255, 138, 76, .18);
}
.lv-stars {
  display: block;
  font-size: 12px;
  color: var(--yellow);
  letter-spacing: 1px;
  margin-bottom: 6px;
  text-shadow: 0 1px 0 #e8a900;
}
.level-card b, .mode-card b { display: block; font-size: 15px; color: var(--ink); }
.level-card small, .mode-card small {
  display: block; font-size: 11px; color: var(--ink-3); margin-top: 4px; line-height: 1.4;
}
.mode-ico {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  margin: 0 auto 7px;
  border-radius: 11px;
  background: #fff1e6;
  color: var(--accent-d);
  font-size: 19px;
  font-weight: 800;
  font-family: var(--font-kai);
}
.mode-ico.is-latin {
  background: #eaf4ff;
  color: #2f7fd4;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 13px;
  letter-spacing: .5px;
}
.mode-card.is-on .mode-ico { transform: scale(1.06); }

/* 开始按钮 */
.start-btn {
  width: 100%;
  border: none;
  border-radius: var(--r-lg);
  background: linear-gradient(145deg, #ffa564, var(--accent));
  color: #fff;
  padding: 18px;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 8px 22px rgba(255, 138, 76, .38), inset 0 -3px 0 rgba(0,0,0,.10);
  transition: transform .14s, box-shadow .14s;
  position: relative;
  overflow: hidden;
}
.start-btn span { display: block; font-size: 19px; font-weight: 800; letter-spacing: 2px; }
.start-btn em {
  display: block;
  font-style: normal;
  font-size: 11.5px;
  opacity: .9;
  margin-top: 5px;
  letter-spacing: .3px;
}
.start-btn:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgba(255,138,76,.45), inset 0 -3px 0 rgba(0,0,0,.10); }
.start-btn:active { transform: translateY(1px) scale(.99); }
.start-btn:disabled { opacity: .45; cursor: not-allowed; transform: none; }

/* 底部成绩条 */
.home-foot { margin-top: 20px; }
.record-strip {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--ink-3);
}
.record-strip:empty { display: none; }
.record-pill {
  background: var(--card);
  border-radius: 999px;
  padding: 8px 14px;
  box-shadow: var(--sh-1);
  display: flex;
  align-items: center;
  gap: 7px;
}
.record-pill b { color: var(--ink); font-size: 13px; }
.record-pill .rp-stars { color: var(--yellow); letter-spacing: 1px; }

/* ══════════════ 游戏页 ══════════════ */
.game-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 20px 26px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
}

.hud { display: flex; align-items: center; gap: 14px; }

.hud-progress { flex: 1; display: flex; align-items: center; gap: 10px; }
.bar {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: #f5e9db;
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(120,84,50,.10);
}
.bar i {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffc531, var(--accent));
  transition: width .35s cubic-bezier(.22,1,.36,1);
}
#progressText { font-size: 12px; font-weight: 700; color: var(--ink-2); white-space: nowrap; }

.hud-stats { display: flex; gap: 16px; }
.stat { text-align: center; min-width: 52px; }
.stat b {
  display: block;
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.stat small { display: block; font-size: 10px; color: var(--ink-3); margin-top: 1px; }
.combo-stat b { color: var(--ink-3); }
.combo-stat.is-hot b { color: var(--accent); }

/* 舞台 */
.stage {
  position: relative;
  background: var(--card);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-1);
  padding: 26px 24px 22px;
  flex: 0 1 auto;
  min-height: 360px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  overflow: hidden;
}

.stage-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 45%, rgba(63,185,132,.20), transparent 62%);
  transition: opacity .4s;
}
.stage-glow.flash { animation: glowFlash .7s ease-out; }
@keyframes glowFlash {
  0%   { opacity: 0; }
  25%  { opacity: 1; }
  100% { opacity: 0; }
}

.prompt-hint {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 12px;
  color: var(--ink-3);
  letter-spacing: .8px;
  font-weight: 600;
}

/* 听读音：放在提示行里，不额外占高度 */
.speak-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border: 1.5px solid #ffd7bd;
  background: #fff8f2;
  color: var(--accent-d);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .3px;
  padding: 3px 9px 3px 7px;
  border-radius: 999px;
  cursor: pointer;
  transition: all .16s;
  flex: none;
}
.speak-btn:hover { background: #fff0e4; border-color: var(--accent); }
.speak-btn:active { transform: scale(.94); }
.speak-btn.is-on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.speak-btn[hidden] { display: none; }

@media (max-width: 560px) {
  .prompt-hint { gap: 7px; font-size: 11px; }
  .speak-btn { padding: 3px 8px 3px 6px; font-size: 11px; }
}

.hint-toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translate(-50%, -8px);
  background: #fff2f2;
  color: var(--red);
  border: 1px solid #ffdcdc;
  border-radius: 999px;
  padding: 7px 16px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s, transform .22s;
  z-index: 3;
}
.hint-toast.is-on { opacity: 1; transform: translate(-50%, 0); }

.hanzi {
  font-family: var(--font-kai);
  font-size: clamp(48px, 9vw, 84px);
  line-height: 1.25;
  letter-spacing: .12em;
  color: var(--ink);
  text-align: center;
  word-break: break-all;
  max-width: 100%;
  transition: transform .2s;
}
.hanzi.is-long { font-size: clamp(24px, 4.2vw, 40px); line-height: 1.7; letter-spacing: .06em; text-align: left; }

.pinyin-line {
  font-size: clamp(16px, 2.4vw, 24px);
  color: var(--accent-d);
  letter-spacing: .06em;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0 .55em;
  font-variant-numeric: tabular-nums;
}
.pinyin-line.is-long {
  font-size: clamp(12px, 1.6vw, 16px);
  color: var(--ink-3);
  gap: 0 .35em;
  max-width: 100%;
  line-height: 1.9;
}
.pinyin-line .syl { display: inline-block; transition: color .2s, opacity .2s; }
.pinyin-line .syl.done { color: var(--green); }
.pinyin-line .syl.now { color: var(--accent); transform: translateY(-2px); }

/* 汉字模式：拼音本身就是题目，要放大 */
.pinyin-line.is-big {
  font-size: clamp(26px, 4.6vw, 46px);
  color: var(--ink);
  font-weight: 700;
  letter-spacing: .04em;
  gap: 0 .5em;
}
.pinyin-line.is-big.is-long {
  font-size: clamp(14px, 2.1vw, 21px);
  line-height: 2;
  color: var(--ink-2);
  font-weight: 600;
}

/* 字母格 */
.type-track {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 6px 10px;
  margin-top: 6px;
  min-height: 52px;
  max-width: 100%;
}
.type-track.is-long { gap: 5px 7px; }

/* 每个字的字母归成一组，一眼看出这串字母对应哪个字 */
.syl-group {
  display: flex;
  gap: 3px;
  padding: 3px;
  border-radius: 12px;
  background: #fffaf4;
  box-shadow: inset 0 0 0 1px #f6ebde;
}
.type-track.is-long .syl-group { padding: 2px; border-radius: 8px; }

.cell {
  width: 30px; height: 42px;
  border-radius: 9px;
  background: #faf3ea;
  border-bottom: 3px solid #ecdfd0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 19px;
  font-weight: 700;
  color: var(--ink-3);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  transition: all .12s;
  text-transform: lowercase;
}
.type-track.is-long .cell { width: 20px; height: 30px; font-size: 14px; border-radius: 7px; }

.cell.done {
  background: #e6f7ef;
  border-bottom-color: var(--green);
  color: var(--green-d);
}
.cell.now {
  background: #fff3e9;
  border-bottom-color: var(--accent);
  color: var(--accent-d);
  box-shadow: 0 0 0 2px rgba(255,138,76,.25);
  animation: cellPulse 1.1s ease-in-out infinite;
}
@keyframes cellPulse {
  0%,100% { transform: translateY(0); }
  50%     { transform: translateY(-3px); }
}
.cell.bad {
  background: #ffe9e9;
  border-bottom-color: var(--red);
  color: var(--red);
  animation: shake .28s;
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  25%     { transform: translateX(-4px); }
  75%     { transform: translateX(4px); }
}

/* 汉字输入框 */
.ime-box { display: none; width: 100%; max-width: 460px; }
.ime-box.is-on { display: block; }
#imeInput {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: var(--r-md);
  padding: 14px 18px;
  font-size: 24px;
  font-family: var(--font-kai);
  text-align: center;
  color: var(--ink);
  background: #fffdfa;
  outline: none;
  letter-spacing: .1em;
  transition: border-color .18s, box-shadow .18s;
}
#imeInput:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255,138,76,.14);
}
#imeInput.is-bad { border-color: var(--red); animation: shake .28s; }
#imeInput.is-done { border-color: var(--green); background: #f2fbf6; }

.finger-hint {
  font-size: 12.5px;
  color: var(--ink-3);
  letter-spacing: .4px;
  min-height: 18px;
}
.finger-hint b { color: var(--accent-d); }

.skip-btn {
  border: none;
  background: none;
  font-family: inherit;
  font-size: 12px;
  color: var(--ink-3);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 8px;
  opacity: .8;
  transition: all .15s;
}
.skip-btn:hover { background: #f7efe6; color: var(--ink-2); opacity: 1; }

/* ───────────── 虚拟键盘 ───────────── */
.kb {
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: center;
  padding: 4px 0 2px;
  user-select: none;
}

.kb-row { display: flex; gap: 6px; }
.kb-row:nth-child(2) { padding-left: 16px; }
.kb-row:nth-child(3) { padding-left: 34px; }

.key {
  width: 46px; height: 46px;
  border-radius: 11px;
  background: #fff;
  border: 1px solid var(--line);
  border-bottom: 3px solid #e8dacb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-2);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  text-transform: uppercase;
  transition: transform .08s, background .15s, color .15s, box-shadow .15s;
  position: relative;
}
.key::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 10px;
  background: currentColor;
  opacity: .055;
}

/* 指法配色 */
.key[data-f="1"] { --fc: #ff9db0; }
.key[data-f="2"] { --fc: #ffb98a; }
.key[data-f="3"] { --fc: #ffd76e; }
.key[data-f="4"] { --fc: #8fd9a8; }
.key[data-f="5"] { --fc: #7fc4f5; }
.key[data-f="6"] { --fc: #b39ddb; }
.key[data-f="7"] { --fc: #f48fb1; }
.key[data-f="8"] { --fc: #a5d6a7; }
.key { color: var(--ink-2); }
.key::after {
  content: "";
  position: absolute;
  left: 8px; right: 8px; bottom: 4px;
  height: 3px;
  border-radius: 2px;
  background: var(--fc, #ddd);
  opacity: .55;
}

.key.is-next {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent-d);
  border-bottom-color: var(--accent-d);
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 8px 18px rgba(255, 138, 76, .42);
  z-index: 2;
}
.key.is-next::after { background: #fff; opacity: .8; }
.key.is-next::before { opacity: 0; }

.key.is-hit { background: #e6f7ef; color: var(--green-d); transform: scale(.92); }
.key.is-miss { background: #ffe9e9; color: var(--red); transform: scale(.92); }

/* ══════════════ 结算页 ══════════════ */
.result-wrap {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 20px;
}

.result-card {
  width: 100%;
  max-width: 520px;
  background: var(--card);
  border-radius: 30px;
  box-shadow: var(--sh-2);
  padding: 32px 28px 26px;
  text-align: center;
  animation: popIn .45s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.9) translateY(20px); }
  to   { opacity: 1; transform: none; }
}

.stars { display: flex; justify-content: center; gap: 8px; margin-bottom: 14px; height: 48px; }
.star {
  font-size: 40px;
  color: #f0e3d4;
  line-height: 1;
  transform: scale(.6);
  opacity: 0;
  animation: starPop .5s cubic-bezier(.34,1.56,.64,1) forwards;
}
.star.on { color: var(--yellow); text-shadow: 0 3px 0 #e8a900, 0 6px 14px rgba(232,169,0,.35); }
@keyframes starPop {
  to { transform: scale(1); opacity: 1; }
}

.result-card h2 { font-size: 24px; margin-bottom: 6px; }
.result-sub { font-size: 13px; color: var(--ink-3); margin-bottom: 22px; }

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  background: #fdf7f0;
  border-radius: var(--r-md);
  padding: 16px 8px;
  margin-bottom: 18px;
}
.rstat b {
  display: block;
  font-size: 19px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.rstat small { display: block; font-size: 10.5px; color: var(--ink-3); margin-top: 3px; }

.mistakes {
  text-align: left;
  margin-bottom: 20px;
  display: none;
}
.mistakes.is-on { display: block; }
.mistakes h4 {
  font-size: 12px;
  color: var(--ink-3);
  font-weight: 700;
  margin-bottom: 8px;
  letter-spacing: .4px;
}
.mistake-list { display: flex; flex-wrap: wrap; gap: 8px; }
.mistake-item {
  background: #fff5f5;
  border: 1px solid #ffdede;
  border-radius: 10px;
  padding: 6px 11px;
  font-size: 13px;
  color: var(--red);
}
.mistake-item b { font-family: var(--font-kai); font-size: 15px; }
.mistake-item small { color: var(--ink-3); font-size: 10.5px; margin-left: 5px; }

.result-actions { display: flex; gap: 10px; }
.btn {
  flex: 1;
  border: none;
  border-radius: var(--r-md);
  padding: 15px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .14s, box-shadow .14s;
}
.btn-primary {
  background: linear-gradient(145deg, #ffa564, var(--accent));
  color: #fff;
  box-shadow: 0 6px 18px rgba(255,138,76,.35), inset 0 -3px 0 rgba(0,0,0,.09);
}
.btn-ghost {
  background: #f7efe6;
  color: var(--ink-2);
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: scale(.98); }

/* ══════════════ 响应式 ══════════════ */
@media (max-width: 860px) {
  .home-grid { grid-template-columns: minmax(0, 1fr); }
  .home-wrap { padding: 20px 16px 32px; }
  .brand-mark { width: 48px; height: 48px; font-size: 27px; line-height: 48px; border-radius: 15px; }
  .brand-text h1 { font-size: 22px; }
  .key { width: 36px; height: 38px; font-size: 12.5px; border-radius: 9px; }
  .kb-row:nth-child(2) { padding-left: 12px; }
  .kb-row:nth-child(3) { padding-left: 24px; }
  .kb { gap: 5px; }
  .kb-row { gap: 4px; }
  .stage { padding: 20px 14px 18px; min-height: 240px; }
  .game-wrap { padding: 14px 14px 18px; }
  .hud-stats { gap: 10px; }
  .stat b { font-size: 17px; }
}

@media (max-width: 520px) {
  .key { width: 30px; height: 34px; font-size: 11px; }
  .kb-row:nth-child(2) { padding-left: 8px; }
  .kb-row:nth-child(3) { padding-left: 16px; }
  .cell { width: 25px; height: 36px; font-size: 16px; }
  .result-grid { grid-template-columns: repeat(2, 1fr); gap: 14px; }
  .level-cards { grid-template-columns: 1fr 1fr; }
  .level-card:nth-child(3) { grid-column: span 2; }
}

@media (max-height: 700px) {
  .stage { min-height: 200px; padding: 16px; gap: 8px; }
  .hanzi { font-size: clamp(38px, 7vw, 60px); }
  .key { height: 40px; }
}

/* ══════════════ 机甲伙伴 ══════════════ */
.mascot {
  position: relative;
  width: 146px;
  pointer-events: none;
  z-index: 2;
}
.mascot::before {
  content: "";
  position: absolute;
  left: 50%; top: 52%;
  width: 160%; height: 124%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(74, 157, 248, .18), transparent 68%);
  pointer-events: none;
  z-index: -1;
  transition: opacity .3s;
}
.mascot.is-power::before,
.mascot.is-transform::before {
  background: radial-gradient(circle, rgba(56, 225, 255, .34), transparent 68%);
}
.stage > .mascot {
  position: absolute;
  right: 10px;
  bottom: 2px;
}

.bot {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 160 / 200;
  overflow: visible;
}

.bot-wrap {
  transform-origin: 50% 92%;
  animation: botFloat 3.4s ease-in-out infinite;
}
@keyframes botFloat {
  0%, 100% { transform: translateY(0) rotate(0); }
  50%      { transform: translateY(-5px) rotate(-1.2deg); }
}

.bot-eyes {
  transform-box: fill-box;
  transform-origin: center;
  animation: botBlink 5.2s infinite;
}
@keyframes botBlink {
  0%, 92%, 100% { transform: scaleY(1); }
  95.5%         { transform: scaleY(.1); }
}

.bot-core {
  transform-box: fill-box;
  transform-origin: center;
  animation: corePulse 2.6s ease-in-out infinite;
}
@keyframes corePulse {
  0%, 100% { transform: scale(1); opacity: .95; }
  50%      { transform: scale(1.1); opacity: 1; }
}

.bot-arm { transform-box: fill-box; transform-origin: 50% 0%; }

/* 能量环 */
.bot-ring {
  position: absolute;
  left: 50%; top: 46%;
  width: 118%; aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%) scale(.25);
  border-radius: 50%;
  border: 3px solid rgba(56, 225, 255, .85);
  opacity: 0;
  pointer-events: none;
}
@keyframes ringOut {
  0%   { transform: translate(-50%, -50%) scale(.3); opacity: .9; }
  100% { transform: translate(-50%, -50%) scale(1.55); opacity: 0; }
}

/* 粒子 */
.spark {
  position: absolute;
  left: 50%; top: 46%;
  width: 8px; height: 8px;
  border-radius: 2px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* 台词气泡 */
.bot-say {
  position: absolute;
  right: 100%; bottom: 58%;
  margin-right: 10px;
  background: #fff;
  border: 2px solid #ffd7bd;
  border-radius: 14px;
  padding: 7px 13px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
  opacity: 0;
  transform: translateY(6px) scale(.88);
  transition: opacity .2s, transform .24s cubic-bezier(.34, 1.56, .64, 1);
  box-shadow: 0 4px 14px rgba(120, 84, 50, .13);
}
.bot-say::after {
  content: "";
  position: absolute;
  right: -8px; top: 50%;
  margin-top: -7px;
  border: 7px solid transparent;
  border-left-color: #ffd7bd;
}
.bot-say.is-on { opacity: 1; transform: none; }

/* 反应动作 */
.mascot.is-cheer .bot-wrap { animation: botCheer .62s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes botCheer {
  0%   { transform: translateY(0) scale(1); }
  35%  { transform: translateY(-16px) scale(1.08); }
  65%  { transform: translateY(0) scale(.95); }
  100% { transform: translateY(0) scale(1); }
}
.mascot.is-cheer .bot-arm-l { animation: armL .55s ease-out; }
.mascot.is-cheer .bot-arm-r { animation: armR .55s ease-out; }
@keyframes armL {
  0% { transform: rotate(0); } 40% { transform: rotate(-46deg); } 100% { transform: rotate(0); }
}
@keyframes armR {
  0% { transform: rotate(0); } 40% { transform: rotate(46deg); } 100% { transform: rotate(0); }
}

.mascot.is-power .bot-wrap { animation: botPower .85s ease-out; }
@keyframes botPower {
  0%   { transform: scale(1); }
  25%  { transform: scale(.9); }
  50%  { transform: scale(1.13); }
  100% { transform: scale(1); }
}
.mascot.is-power .bot-core { animation: coreFlash .9s ease-out; }
@keyframes coreFlash {
  0%   { transform: scale(1); opacity: .9; }
  30%  { transform: scale(1.75); opacity: 1; }
  60%  { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.mascot.is-power .bot-ring { animation: ringOut .9s ease-out; }

.mascot.is-transform { perspective: 600px; }
.mascot.is-transform .bot-wrap { animation: botTransform 1.15s cubic-bezier(.4, 0, .2, 1); }
@keyframes botTransform {
  0%   { transform: rotateY(0deg) scale(1); }
  22%  { transform: rotateY(90deg) scale(.82); }
  45%  { transform: rotateY(180deg) scale(1.16); }
  70%  { transform: rotateY(290deg) scale(.94); }
  100% { transform: rotateY(360deg) scale(1); }
}
.mascot.is-transform .bot-eyes { animation: none; filter: brightness(2.2); }
.mascot.is-transform .bot-ring { animation: ringOut 1.2s ease-out; }

.mascot.is-oops .bot-wrap { animation: botOops .45s ease-out; }
@keyframes botOops {
  0%, 100% { transform: translateX(0) rotate(0); }
  25%      { transform: translateX(-4px) rotate(-3deg); }
  75%      { transform: translateX(4px) rotate(3deg); }
}

/* 结算页：机器人站在星星上方 */
.mascot--result {
  width: 150px;
  margin: -10px auto 0;
}
.mascot--result .bot-say { display: none; }

@media (max-width: 860px) {
  .stage > .mascot { width: 88px; right: 2px; bottom: 0; }
  .bot-say { font-size: 11.5px; padding: 6px 10px; }
  .mascot--result { width: 112px; }
}

@media (max-width: 560px) {
  .stage > .mascot { width: 68px; right: 0; bottom: 0; }
  .bot-say { font-size: 11px; padding: 5px 9px; margin-right: 7px; bottom: 62%; }
  .mascot--result { width: 96px; }
}

/* 首页：机甲在左下角招呼 */
.home-bot-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 0 0 8px;
}
.home-bot-row .mascot { width: 108px; flex: none; }
.home-tip {
  position: relative;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  background: #fff;
  border: 2px solid #ffd7bd;
  border-radius: 14px;
  padding: 8px 14px;
  box-shadow: 0 4px 14px rgba(120, 84, 50, .10);
  white-space: nowrap;
}
.home-tip::after {
  content: "";
  position: absolute;
  left: -8px; top: 50%;
  margin-top: -7px;
  border: 7px solid transparent;
  border-right-color: #ffd7bd;
}

/* 超频模式：连击 20 以上，机甲变金 */
.mascot.is-super .bot-eyes rect { fill: #ffc531; }
.mascot.is-super .bot-core { animation-duration: 1.1s; filter: drop-shadow(0 0 6px #ff8a4c); }
.mascot.is-super::before {
  background: radial-gradient(circle, rgba(255, 176, 40, .40), transparent 68%);
}
.mascot.is-super .bot {
  filter: drop-shadow(0 0 7px rgba(255, 170, 40, .55));
}

/* ══════════════ 机甲涂装（CSS 变量驱动） ══════════════ */
.mascot {
  --bot-hi: #9dbcff;
  --bot-lo: #3358d8;
  --bot-arm-hi: #6b97f5;
  --bot-arm-lo: #2b49b8;
  --bot-eye: #38e1ff;
  --bot-sh: #5b86f0;
  --bot-core-a: #fff6d6;
  --bot-core-b: #ffc531;
  --bot-core-c: #ff7a35;
  --bot-glow: 74, 157, 248;
}
.mascot[data-mecha="crimson"] {
  --bot-hi: #ffb08a; --bot-lo: #c9342a;
  --bot-arm-hi: #ff8a6a; --bot-arm-lo: #a82a20;
  --bot-eye: #ffd24a; --bot-sh: #f2624a;
  --bot-core-a: #fff3d0; --bot-core-b: #ffb03a; --bot-core-c: #ff3b1f;
  --bot-glow: 255, 110, 70;
}
.mascot[data-mecha="jade"] {
  --bot-hi: #a8f0c8; --bot-lo: #1f9e6a;
  --bot-arm-hi: #7fe0b0; --bot-arm-lo: #148a58;
  --bot-eye: #7dffc4; --bot-sh: #4cc98a;
  --bot-core-a: #f0fff4; --bot-core-b: #6ef0a0; --bot-core-c: #1fc070;
  --bot-glow: 60, 220, 150;
}
.mascot[data-mecha="violet"] {
  --bot-hi: #c9a8ff; --bot-lo: #6a2fd8;
  --bot-arm-hi: #b48aff; --bot-arm-lo: #5a22c0;
  --bot-eye: #d9b3ff; --bot-sh: #8f5cf0;
  --bot-core-a: #f6ecff; --bot-core-b: #c78bff; --bot-core-c: #8a2fe0;
  --bot-glow: 150, 90, 240;
}

.mascot .b-hi { stop-color: var(--bot-hi); }
.mascot .b-lo { stop-color: var(--bot-lo); }
.mascot .a-hi { stop-color: var(--bot-arm-hi); }
.mascot .a-lo { stop-color: var(--bot-arm-lo); }
.mascot .c-a  { stop-color: var(--bot-core-a); }
.mascot .c-b  { stop-color: var(--bot-core-b); }
.mascot .c-c  { stop-color: var(--bot-core-c); }
.mascot .eye  { fill: var(--bot-eye); }
.mascot .crest { fill: var(--bot-eye); }
.mascot .sh   { fill: var(--bot-sh); }
.mascot .core-ring { stroke: var(--bot-core-b); }
.mascot .trim { fill: var(--bot-core-c); }
.mascot .ground { fill: var(--bot-lo); }
.mascot .eye-ring { fill: none; stroke: var(--bot-eye); }

/* ── 外形部件：同一套 SVG，按 data-mecha 只显示对应那台 ── */
.mascot .vp { display: none; }
.mascot[data-mecha="blue"] .vp-blue,
.mascot[data-mecha="crimson"] .vp-crimson,
.mascot[data-mecha="jade"] .vp-jade,
.mascot[data-mecha="violet"] .vp-violet,
.mascot[data-mecha="blue"] .vp-base,
.mascot[data-mecha="crimson"] .vp-base,
.mascot[data-mecha="violet"] .vp-base { display: inline; }

.mascot::before {
  background: radial-gradient(circle, rgba(var(--bot-glow), .18), transparent 68%);
}

/* 缩略图 */
.mascot--thumb { width: 62px; }
.mascot--thumb::before { display: none; }
.mascot--thumb .thumb-wrap { width: 100%; }

/* ══════════════ 机甲库 ══════════════ */
.hangar {
  margin-top: 18px;
  background: var(--card);
  border-radius: var(--r-lg);
  padding: 16px 18px 18px;
  box-shadow: var(--sh-1);
}
.hangar-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.hangar-head h3 {
  font-size: 14px; font-weight: 800; color: var(--ink-2); letter-spacing: .3px;
}
.core-count {
  margin-left: auto;
  display: flex; align-items: center; gap: 7px;
  font-size: 12px; font-weight: 600; color: var(--ink-3);
  background: #fff6e8; border-radius: 999px; padding: 6px 14px;
}
.core-count b { color: var(--accent-d); font-size: 15px; font-variant-numeric: tabular-nums; }
.core-ico {
  width: 14px; height: 14px; flex: none; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff6d6, #ffc531 55%, #ff8a4c);
  box-shadow: 0 0 8px rgba(255, 180, 60, .65);
}

.mecha-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.mecha {
  border: 2px solid var(--line);
  background: #fff;
  border-radius: var(--r-md);
  padding: 10px 6px 12px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  position: relative;
  transition: all .18s;
}
.mecha:hover { border-color: #ffd0b3; transform: translateY(-2px); }
.mecha.is-on {
  border-color: var(--accent);
  background: #fff6ef;
  box-shadow: 0 6px 18px rgba(255, 138, 76, .18);
}
.mecha.is-locked { cursor: not-allowed; }
.mecha.is-locked:hover { transform: none; border-color: var(--line); }
.mecha.is-locked .mascot--thumb { filter: grayscale(1); opacity: .5; }
.mecha b { display: block; font-size: 14px; margin-top: 2px; color: var(--ink); }
.mecha small { display: block; font-size: 10.5px; color: var(--ink-3); margin-top: 2px; }
.mecha.is-locked small { color: #c08a5e; }
.mecha.is-on small { color: var(--accent-d); font-weight: 700; }
.mecha .lock-ico {
  position: absolute; top: 6px; right: 8px;
  font-size: 11px; color: var(--ink-3); line-height: 1;
}

/* 结算页：能量核心 / 解锁提示 */
.core-earn {
  display: none;
  align-items: center; justify-content: center; gap: 8px;
  background: #fff6e8;
  border-radius: var(--r-md);
  padding: 11px;
  margin-bottom: 14px;
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-d);
}
.core-earn.is-on { display: flex; animation: popIn .45s cubic-bezier(.34, 1.56, .64, 1); }
.core-earn .core-ico { width: 16px; height: 16px; }

.unlock-banner {
  display: none;
  margin-bottom: 14px;
  border-radius: var(--r-md);
  padding: 12px 16px;
  background: linear-gradient(135deg, #fff3e0, #ffe9f2);
  border: 2px dashed #ffc9a3;
  text-align: left;
}
.unlock-banner.is-on {
  display: flex;
  align-items: center;
  gap: 10px;
  animation: popIn .5s cubic-bezier(.34, 1.56, .64, 1);
}
.unlock-banner .unlock-thumb { width: 54px; flex: none; }
.unlock-banner .unlock-text { min-width: 0; }
.unlock-banner h4 { font-size: 11.5px; color: var(--accent-d); letter-spacing: 1px; font-weight: 700; }
.unlock-banner b { display: block; font-size: 19px; margin-top: 2px; color: var(--ink); }
.unlock-banner small { display: block; font-size: 11px; color: var(--ink-3); margin-top: 2px; }

@media (max-width: 860px) {
  .mecha-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mascot--thumb { width: 54px; }
}

/* ══════════════ 机甲技能 ══════════════ */
/* 护盾（紫雷） */
.shield-bar {
  position: absolute;
  top: 14px;
  left: 16px;
  display: none;
  gap: 5px;
  z-index: 3;
}
.shield-bar.is-on { display: flex; }

.shield-pip {
  width: 11px;
  height: 15px;
  border-radius: 5px 5px 7px 7px;
  background: linear-gradient(180deg, #d8b6ff, #7b3ee0);
  box-shadow: 0 0 7px rgba(150, 90, 240, .55);
  transition: background .28s, opacity .28s, transform .28s;
}
.shield-pip.is-used {
  background: #ece3d7;
  box-shadow: none;
  transform: scale(.82);
  opacity: .6;
}
.shield-pip.just-used { animation: shieldPop .42s cubic-bezier(.34, 1.56, .64, 1); }
@keyframes shieldPop {
  0%   { transform: scale(1.35); box-shadow: 0 0 14px rgba(150, 90, 240, .9); }
  100% { transform: scale(.82); box-shadow: none; }
}

/* 机甲库里的技能小标签 */
.skill-chip {
  display: inline-block;
  margin-top: 5px;
  font-size: 10px;
  font-weight: 700;
  color: #7a5bc0;
  background: #f2ecff;
  border-radius: 6px;
  padding: 2px 7px;
  letter-spacing: .2px;
  white-space: nowrap;
}
.mecha.is-locked .skill-chip { color: var(--ink-3); background: #f4eee7; }

.skill-note {
  margin-top: 13px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
  font-size: 12px;
  line-height: 1.65;
  color: var(--ink-3);
}
.skill-note b { color: var(--ink-2); margin-right: 6px; }

/* 超频状态的连击计数 */
.combo-stat.is-super b { color: #ff5a3c; text-shadow: 0 0 10px rgba(255, 90, 60, .45); }
.combo-stat.is-super small { color: #ff5a3c; font-weight: 800; }
@keyframes comboBeat {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.12); }
}
.combo-stat.is-super b { animation: comboBeat 1.1s ease-in-out infinite; }

/* 结算页：本局技能战绩 */
.skill-used {
  display: none;
  margin: 12px auto 0;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #7a5bc0;
  background: #f5efff;
  border-radius: 999px;
  padding: 6px 14px;
  width: fit-content;
  max-width: 100%;
}
.skill-used.is-on { display: flex; }
.skill-used .su-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: linear-gradient(180deg, #d8b6ff, #7b3ee0);
  box-shadow: 0 0 6px rgba(150, 90, 240, .6);
}

/* 长句子：字母格换行后，机甲缩到角落让位，避免压住最后一排字母 */
.stage.is-crowd .type-track { padding-right: 104px; }
.stage.is-crowd > .mascot { width: 96px; right: 6px; bottom: 0; }

@media (max-width: 860px) {
  .stage.is-crowd .type-track { padding-right: 74px; }
  .stage.is-crowd > .mascot { width: 66px; right: 2px; }
}

@media (max-width: 560px) {
  .stage.is-crowd .type-track { padding-right: 56px; }
  .stage.is-crowd > .mascot { width: 52px; right: 0; }
}


