/* =========================================================================
 * style.css — 地鼠键盘 Mole Typer
 *   --u  : 键位基准单位（1u），随视口自适应
 *   --rise: 键帽被地鼠顶起的高度（单位 u），由 JS 写到具体键上
 * ========================================================================= */

:root {
  --gap-ratio: 0.085;
  --travel: 0.13;
  /* 键盘之外的「机身开销」：HUD + 提词器 + 页脚。下面手机断点会把它收窄，
     否则手机上会按桌面的 300px 白扣一截高度，把键压小（站长反馈的根因之一） */
  --chrome-h: 300px;

  --bg-0: #0b0e13;
  --bg-1: #141922;
  --ink: #e8edf5;
  --ink-dim: #8b95a6;
  --good: #3ee08f;
  --warn: #ffcf5c;
  --bad: #ff5c5c;
  --blue: #3b82f6;
}

/* 键位基准单位由 .board 上的 --board-units（最宽一行的 u 数，JS 写入）决定：
   手机切到紧凑配列时 --board-units 变小，键自动变大占满屏宽。
   --board-slack 是"最宽一行之外再留多少 u"的呼吸量，--board-pad 是键盘两侧留白，
   两者都在下面的手机断点里被收窄，好把省下的横向空间让给键本身 */
.board {
  --board-units: 20.5;
  --board-rows: 6;
  --board-pad: 26px;
  --board-slack: 0.9;
  /* 键高 = u × --key-ratio。ratio 拆成「基准 × 倍率」两层：
       --key-base  桌面 0.92 / 手机 1.15（媒体查询里改，见下方手机断点）
       --key-scale 站长在配置里调的按键大小（JS 写在元素内联样式上）
     拆两层是必须的：JS 只能写内联样式，而内联会盖掉媒体查询里的值 ——
     若 JS 直接写 --key-ratio，手机上就会被按桌面的基准算，键反而变矮。 */
  --key-base: 0.92;
  --key-scale: 1;
  --key-ratio: calc(var(--key-base) * var(--key-scale));
  --u: max(17px, min(46px,
        calc((100vw - var(--board-pad)) / (var(--board-units) + var(--board-slack))),
        calc((100vh - var(--chrome-h)) / (var(--board-rows) * var(--key-ratio)))));
  --gap: calc(var(--u) * var(--gap-ratio));
  --key-h: calc(var(--u) * var(--key-ratio));
  --cap-h: calc(var(--u) * 0.7);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  min-height: 100%;
  background: var(--bg-0);
  color: var(--ink);
  font-family: "Nunito", "Quicksand", ui-rounded, "Segoe UI", system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* 整体在视口里垂直居中：文本区紧贴键盘上方，缩短视线往返距离 */
body { min-height: 100vh; display: flex; flex-direction: column; }

body::before {
  content: ''; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(900px 520px at 50% -10%, rgba(59,130,246,.22), transparent 65%),
    radial-gradient(700px 420px at 12% 105%, rgba(168,85,247,.15), transparent 60%),
    radial-gradient(700px 420px at 88% 100%, rgba(16,185,129,.13), transparent 60%);
}

.app {
  position: relative; z-index: 1;
  margin: auto;                 /* 垂直+水平居中，内容超高时不会被裁掉 */
  width: 100%; max-width: 1500px;
  padding: 10px 18px 14px;
}
.app.shaking { animation: appShake .26s ease-out; }
@keyframes appShake {
  0%   { transform: translate3d(0,0,0); }
  20%  { transform: translate3d(calc(var(--shake,3px) * -1), calc(var(--shake,3px) * .5), 0); }
  45%  { transform: translate3d(var(--shake,3px), calc(var(--shake,3px) * -.6), 0); }
  70%  { transform: translate3d(calc(var(--shake,3px) * -.6), 0, 0); }
  100% { transform: translate3d(0,0,0); }
}

/* ============================ HUD ============================ */
.hud {
  display: flex; align-items: center; justify-content: space-between; gap: 18px;
  padding: 10px 16px; border-radius: 16px;
  background: linear-gradient(180deg, rgba(30,37,48,.92), rgba(18,22,29,.92));
  border: 1px solid rgba(255,255,255,.07);
  box-shadow: 0 10px 30px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,255,255,.05);
}
.hud-group { display: flex; align-items: center; gap: 20px; }
.stat { display: flex; flex-direction: column; line-height: 1.15; }
.stat-label { font-size: 11px; letter-spacing: .16em; color: var(--ink-dim); text-transform: uppercase; }
.stat-value { font-size: 24px; font-weight: 800; font-variant-numeric: tabular-nums; }
.stat-best .stat-value { font-size: 18px; color: var(--warn); }

.timer-wrap { flex: 1; max-width: 460px; text-align: center; }
.timer {
  font-size: 40px; font-weight: 900; font-variant-numeric: tabular-nums;
  letter-spacing: .02em;
  text-shadow: 0 0 22px rgba(59,130,246,.5);
  transition: color .2s;
}
.timer.urgent { color: var(--bad); text-shadow: 0 0 26px rgba(255,60,60,.75); animation: urgentPulse .7s infinite; }
/* 狂热鼠潮：倒计时冻结 */
.timer.frozen { color: #ffc46a; text-shadow: 0 0 26px rgba(255,170,70,.85); }
.timer.frozen::after { content: ' ❄'; font-size: .5em; vertical-align: super; }
.timer-fill.frozen { background: linear-gradient(90deg,#ffdc6a,#ff8a3d,#ff4d4d); box-shadow: 0 0 20px rgba(255,140,60,.9); }
@keyframes urgentPulse { 50% { transform: scale(1.06); } }
.timer-bar {
  height: 10px; margin-top: 4px; border-radius: 99px; overflow: hidden;
  background: rgba(255,255,255,.08); box-shadow: inset 0 1px 3px rgba(0,0,0,.5);
}
.timer-fill {
  height: 100%; width: 100%; border-radius: 99px;
  background: linear-gradient(90deg, #22d3ee, #3b82f6 45%, #a855f7);
  transition: width .1s linear, background .3s;
  box-shadow: 0 0 16px rgba(59,130,246,.65);
}
.timer-fill.low { background: linear-gradient(90deg, #ff7a45, #ff3d3d); box-shadow: 0 0 18px rgba(255,60,60,.8); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.12);
  background: linear-gradient(180deg, #262d38, #171c24);
  color: var(--ink); font-size: 17px; line-height: 1;
  transition: transform .12s, box-shadow .2s, opacity .2s;
}
.icon-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(0,0,0,.5); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn.off { opacity: .45; }

/* ========================= 文本区（提词器） ========================= */
/* 待输入字符永远停在 focusRatio 处，整行文本向左滑走：
   视线只在「文本焦点 ↔ 键盘」之间上下移动，不需要横向追光标 */
.text-panel {
  position: relative;
  margin: 8px 0 0; padding: 6px 20px 5px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(22,27,35,.85), rgba(13,16,21,.85));
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
.text-viewport {
  position: relative; overflow: hidden;
  /* 字号定在这里，行高与高度共用同一个 em，避免文字被裁切 */
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", Consolas, "Courier New", monospace;
  font-size: clamp(19px, 2.1vw, 32px);
  line-height: 1.55;
  height: 1.55em;
  -webkit-mask-image: linear-gradient(90deg, transparent 0, #000 5%, #000 90%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0, #000 5%, #000 90%, transparent 100%);
}
.text-viewport.wrong-shake { animation: wrongShake .26s; }
.text-viewport.blocked-shake { animation: blockedShake .38s; }
/* 焦点位（待输入字符停留的地方）的淡标记 */
.focus-mark {
  position: absolute; left: calc(var(--focus-ratio, .46) * 100%); top: 14%; bottom: 14%; width: 2px;
  transform: translateX(-1px); border-radius: 2px; pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(120,170,255,.35), transparent);
}
.text-track {
  position: absolute; left: 0; top: 0;
  white-space: nowrap; will-change: transform;
  font: inherit; line-height: inherit;
  letter-spacing: .01em;
  transition: transform .13s cubic-bezier(.2,.7,.3,1);
}
.ch { color: #6c7686; border-radius: 5px; transition: color .12s, background .12s, box-shadow .2s; }
.ch.sp { display: inline-block; min-width: .34em; }
.ch.done { color: #2b7d52; }
.ch.done.sp { border-bottom: 2px solid rgba(47,169,107,.4); }
.ch.cur {
  color: #fff; background: linear-gradient(180deg, #4f8ef7, #2563eb);
  box-shadow: 0 0 22px rgba(59,130,246,.75); padding: 0 .1em;
  animation: curPulse 1.1s ease-in-out infinite;
}
@keyframes curPulse { 50% { box-shadow: 0 0 34px rgba(59,130,246,1); } }
.text-viewport.urgent .ch.cur { background: linear-gradient(180deg,#ff7a45,#e11d48); box-shadow: 0 0 24px rgba(255,60,60,.8); }
@keyframes wrongShake {
  0%,100% { transform: translateX(0); } 25% { transform: translateX(-9px); }
  50% { transform: translateX(7px); } 75% { transform: translateX(-4px); }
}
@keyframes blockedShake {
  0%,100% { transform: translateX(0); } 15% { transform: translateX(-6px) rotate(-.4deg); }
  35% { transform: translateX(6px) rotate(.4deg); } 55% { transform: translateX(-4px); }
  75% { transform: translateX(3px); }
}

.text-meta {
  margin: 0 0 3px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  font-size: 11.5px; color: var(--ink-dim); letter-spacing: .04em;
}
.text-meta .dot { opacity: .4; }

/* 得分挪到提词器正上方：原来在最顶端 HUD 的左下角，
   离视线中心太远，打一局要专门抬头看分数 */
.score-row {
  display: flex; align-items: baseline; gap: 5px;
  margin: 0 0 1px; line-height: 1.05;
}
.score-value {
  font-size: clamp(19px, 2vw, 27px); font-weight: 900;
  color: var(--warn); font-variant-numeric: tabular-nums;
  text-shadow: 0 0 16px rgba(255,207,92,.35);
  transition: transform .12s; display: inline-block;
}
.score-value.bump { animation: scoreBump .22s ease-out; }
@keyframes scoreBump {
  0%   { transform: scale(1); }
  45%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}
.score-label { font-size: 11.5px; color: var(--ink-dim); letter-spacing: .1em; }

/* 狂热期间：提词器区域整体换成醒目大字 */
.text-panel.frenzy-text .text-viewport,
.text-panel.frenzy-text .text-meta { visibility: hidden; }
.frenzy-banner {
  position: absolute; left: 0; right: 0;
  top: 42%; transform: translateY(-50%) scale(.9);
  display: none; flex-direction: column; align-items: center; gap: 2px;
  pointer-events: none; text-align: center; z-index: 3;
}
.frenzy-banner.show { display: flex; animation: bannerIn .4s cubic-bezier(.2,1.6,.4,1) both; }
.fb-title {
  font-size: clamp(26px, 3.6vw, 52px); font-weight: 900; letter-spacing: .04em;
  color: #fff3c0;
  text-shadow: 0 0 18px rgba(255,140,40,1), 0 0 40px rgba(255,80,20,.9), 0 3px 0 #a03000;
  animation: bannerPulse .42s ease-in-out infinite alternate;
}
.fb-sub {
  font-size: clamp(13px, 1.5vw, 20px); font-weight: 800; letter-spacing: .18em;
  color: #ffd08a; text-shadow: 0 0 14px rgba(255,120,40,.9);
}
@keyframes bannerIn {
  0%   { opacity: 0; transform: translateY(-50%) scale(.6); }
  70%  { opacity: 1; transform: translateY(-50%) scale(1.08); }
  100% { opacity: 1; transform: translateY(-50%) scale(1); }
}
@keyframes bannerPulse {
  to { transform: scale(1.06); filter: brightness(1.2); }
}

/* 连击条：打对字推进 / 停手消退 / 攒满触发狂热 */
.combo-wrap {
  position: relative; display: flex; align-items: center; gap: 10px;
  margin-top: 3px; height: 13px;
}
.combo-bar {
  flex: 1; height: 6px; border-radius: 99px; overflow: hidden;
  background: rgba(255,255,255,.07);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.5);
}
.combo-fill {
  height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, #3d7fd6, #4aa3d8);
  transition: width .12s linear, background .3s;
  box-shadow: 0 0 10px rgba(74,163,216,.5);
}
.combo-wrap[data-hot="mid"] .combo-fill {
  background: linear-gradient(90deg, #4aa3d8, #d8a24a);
  box-shadow: 0 0 12px rgba(216,162,74,.6);
}
.combo-wrap[data-hot="high"] .combo-fill {
  background: linear-gradient(90deg, #d8a24a, #e0653f);
  box-shadow: 0 0 16px rgba(224,101,63,.75);
}
.combo-tag {
  font-size: 11px; font-weight: 800; letter-spacing: .06em;
  color: var(--ink-dim); white-space: nowrap; font-variant-numeric: tabular-nums;
  transition: color .2s;
}
.combo-wrap[data-hot="high"] .combo-tag { color: #e0a05a; }
.combo-wrap[data-hot="high"] { animation: comboReady .7s ease-in-out infinite alternate; }
@keyframes comboReady { to { filter: brightness(1.25); } }
/* 狂热中：连击条变成倒计时条，整体放大跳动 */
.combo-wrap.frenzy .combo-fill {
  background: linear-gradient(90deg, #fff3a0, #ff8a3d 55%, #ff2d2d);
  box-shadow: 0 0 30px rgba(255,120,40,1), 0 0 60px rgba(255,60,30,.6);
}
.combo-wrap.frenzy .combo-tag {
  color: #fff0b8; font-size: 13px; text-shadow: 0 0 16px rgba(255,120,40,1);
  animation: frenzyTag .38s ease-in-out infinite alternate;
}
.combo-wrap.frenzy .combo-bar {
  height: 11px; box-shadow: 0 0 22px rgba(255,120,40,.8), inset 0 1px 3px rgba(0,0,0,.5);
}
.combo-wrap.frenzy { animation: frenzyRow .38s ease-in-out infinite alternate; }
@keyframes frenzyTag { to { transform: scale(1.1); } }
@keyframes frenzyRow { to { filter: brightness(1.3); } }

.blocked-toast {
  position: absolute; right: 14px; top: 50%;
  padding: 6px 13px; border-radius: 99px; font-size: 12.5px; font-weight: 800;
  background: linear-gradient(180deg,#ff6b6b,#d92d20); color: #fff;
  box-shadow: 0 8px 22px rgba(217,45,32,.5);
  opacity: 0; transform: translate(8px, -50%) scale(.92); pointer-events: none;
  transition: opacity .18s, transform .18s;
}
.blocked-toast.show { opacity: 1; transform: translate(0, -50%) scale(1); animation: blockedShake .4s; }

/* ---------- 狂热鼠潮全屏表现（要"疯狂"，不是含蓄） ---------- */
.frenzy-layer {
  position: fixed; inset: 0; pointer-events: none; z-index: 880;
  opacity: 0; transition: opacity .3s;
  background:
    radial-gradient(120% 90% at 50% 50%, transparent 26%, rgba(255,90,40,.42) 66%, rgba(210,20,20,.72) 100%);
}
/* 跑马灯斜纹：狂热的"速度感"来源 */
.frenzy-layer::before {
  content: ''; position: absolute; inset: -30%;
  background: repeating-linear-gradient(58deg,
    rgba(255,190,80,.16) 0 18px, transparent 18px 46px);
  animation: frenzyStripe 1.1s linear infinite;
  opacity: .85;
}
/* 边缘脉冲环 */
.frenzy-layer::after {
  content: ''; position: absolute; inset: 0;
  box-shadow: inset 0 0 90px 24px rgba(255,70,30,.55), inset 0 0 220px 60px rgba(200,20,20,.35);
  animation: frenzyRing .55s ease-in-out infinite alternate;
}
.frenzy-layer.on { opacity: 1; }
.frenzy-layer[data-phase="loop"] { animation: frenzyPulse .5s ease-in-out infinite; }
.frenzy-layer[data-phase="out"] { animation: frenzyOut .6s ease-out forwards; }
@keyframes frenzyPulse {
  0%, 100% { opacity: .82; }
  50%      { opacity: 1; }
}
@keyframes frenzyStripe { to { transform: translateX(-64px); } }
@keyframes frenzyRing {
  to { box-shadow: inset 0 0 130px 34px rgba(255,110,40,.75), inset 0 0 300px 90px rgba(220,30,20,.5); }
}
/* 狂热期间整个键盘底盘灯转成红金，跟着一起脉动 */
html.frenzy-on .board-case::after {
  background: linear-gradient(90deg,#ffe36a,#ff8a3d,#ff2d2d,#ff8a3d,#ffe36a);
  opacity: 1; animation: frenzyRow .4s ease-in-out infinite alternate;
}
html.frenzy-on .board-case { box-shadow: 0 0 0 2px rgba(255,120,40,.55), 0 calc(var(--u) * .35) calc(var(--u) * .7) rgba(0,0,0,.62); }
@keyframes frenzyOut { from { opacity: 1; } to { opacity: 0; } }

/* ========================= 键盘 ========================= */
.board-wrap { display: flex; justify-content: center; margin-top: 6px; }
.board { position: relative; }

.board-case {
  position: relative;
  padding: calc(var(--u) * .42) calc(var(--u) * .45) calc(var(--u) * .62);
  border-radius: calc(var(--u) * .3);
  background:
    linear-gradient(180deg, #343b46 0%, #232932 8%, #1a1f27 62%, #10141a 100%);
  box-shadow:
    0 calc(var(--u) * .35) calc(var(--u) * .7) rgba(0,0,0,.62),
    0 2px 0 rgba(255,255,255,.06) inset,
    0 calc(var(--u) * -.06) 0 rgba(255,255,255,.04) inset;
}
/* 底盘灯 */
.board-case::after {
  content: ''; position: absolute; left: 6%; right: 6%; bottom: calc(var(--u) * -.1);
  height: calc(var(--u) * .3); border-radius: 99px; filter: blur(calc(var(--u) * .22));
  background: linear-gradient(90deg,#22d3ee,#3b82f6,#a855f7,#ec4899,#f59e0b,#22d3ee);
  opacity: .5; z-index: -1;
}

.board-inner { display: flex; flex-direction: column; gap: calc(var(--gap) * 1.8); }
.kb-row { display: flex; gap: var(--gap); }
.kb-body { display: flex; gap: calc(var(--u) * .48); }
.kb-rows { display: flex; flex-direction: column; gap: var(--gap); }
.kb-numpad {
  display: grid;
  grid-template-columns: repeat(4, calc(var(--u) - var(--gap)));
  grid-auto-rows: var(--key-h);
  gap: var(--gap);
}

.key {
  position: relative;
  width: calc(var(--w, 1) * var(--u) - var(--gap));
  height: var(--key-h);
  flex: 0 0 auto;
}
.kb-spacer { width: calc(var(--w, 1) * var(--u) - var(--gap)); flex: 0 0 auto; }

/* --- 键位底座（轴体井） --- */
.key-base {
  position: absolute; inset: 0;
  border-radius: calc(var(--u) * .13);
  background: linear-gradient(180deg, #232830 0%, #12161c 72%);
  box-shadow:
    inset 0 calc(var(--u) * .04) calc(var(--u) * .1) rgba(0,0,0,.95),
    inset 0 calc(var(--u) * -.02) 0 rgba(255,255,255,.05),
    0 1px 0 rgba(255,255,255,.05);
  overflow: hidden;
}
.switch-stem {
  position: absolute; left: 50%; bottom: 9%;
  width: 34%; height: 24%; transform: translateX(-50%);
  border-radius: calc(var(--u) * .04);
  background: linear-gradient(180deg, #7c848f, #4a515b);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.4);
}
.switch-stem::after {
  content: ''; position: absolute; inset: 34% 26% -6% 26%;
  background: #2c313a; border-radius: 2px;
}

/* --- 键帽 --- */
.cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: var(--cap-h); z-index: 2;
  border-radius: calc(var(--u) * .15);
  background: linear-gradient(180deg, #fdfefe 0%, #eceff4 42%, #d5dae2 100%);
  box-shadow:
    0 0 0 1px rgba(10,14,20,.5),
    0 calc(var(--u) * .055) 0 #a9b0ba,
    0 calc(var(--u) * .085) calc(var(--u) * .12) rgba(0,0,0,.5),
    inset 0 1px 0 rgba(255,255,255,.95),
    inset 0 calc(var(--u) * -.035) calc(var(--u) * .05) rgba(0,0,0,.13);
  display: flex; align-items: center; justify-content: center;
  transform: translateY(calc(var(--u) * var(--rise, 0) * -1));
  transition: transform .26s cubic-bezier(.2, 1.5, .45, 1), box-shadow .16s;
  will-change: transform;
}
.key.pressed .cap {
  transform: translateY(calc(var(--u) * (var(--travel) + var(--press-extra, 0) - var(--rise, 0))));
  transition-duration: .03s; transition-timing-function: linear;
  box-shadow:
    0 0 0 1px rgba(10,14,20,.5),
    0 calc(var(--u) * .018) 0 #a9b0ba,
    0 calc(var(--u) * .03) calc(var(--u) * .05) rgba(0,0,0,.55),
    inset 0 1px 0 rgba(255,255,255,.6);
}
/* 砸中地鼠：键帽再猛地下压一下（大地鼠更夸张） */
.key.smash .cap {
  transform: translateY(calc(var(--u) * (var(--travel) + var(--press-extra, 0) * 1.8 - var(--rise, 0))));
  transition-duration: .05s;
  box-shadow: 0 0 0 1px rgba(10,14,20,.5), 0 calc(var(--u) * .01) 0 #a9b0ba,
              0 0 calc(var(--u) * .5) var(--hp-soft, rgba(255,90,90,.6)),
              inset 0 1px 0 rgba(255,255,255,.5);
}
.cap-label {
  font-size: calc(var(--u) * .27); font-weight: 800; color: #2b323c;
  letter-spacing: .01em; line-height: 1; user-select: none;
}
.cap-sub {
  position: absolute; top: calc(var(--u) * .07); right: calc(var(--u) * .08);
  font-size: calc(var(--u) * .17); font-weight: 700; color: #7b8593; line-height: 1;
  user-select: none;
}

/* 键帽配色
   视觉层级：亮绿=现在必须按的键  >  暗金/暗青=大小写状态  >  淡玫瑰=Esc（不抢焦点） */
.key.k-mod .cap { background: linear-gradient(180deg, #e8ebf0, #d3d8e0 45%, #b9c0ca); }
.key.k-nav .cap { background: linear-gradient(180deg, #dfe4ea, #c6ccd6 50%, #aab2bd); }
/* Esc：保留一点暖色，但压到很淡，不与大小写状态抢视线 */
.key.k-accent-red .cap { background: linear-gradient(180deg, #ddd0ce, #c4b1ae 48%, #a89490); }
.key.k-accent-red .cap-label { color: #4c3f3d; }
.key.k-space .cap { background: linear-gradient(180deg, #f7f9fc, #e2e6ec 50%, #ccd2da); }
.key.k-num .cap { background: linear-gradient(180deg, #e4e8ee, #ccd2da 48%, #b2b9c4); }
.key.k-num .cap-sub { display: none; }

/* ============ 大小写状态（要一眼看见：高饱和 + 发光 + 呼吸） ============ */
/* Shift 正在按住：亮青色键帽 + 明显辉光 */
.key.shift-down .cap {
  background: linear-gradient(180deg, #7fe6df, #2fb8b0 50%, #1a8f89);
  box-shadow: 0 0 0 2px rgba(10,14,20,.5), 0 calc(var(--u) * .055) 0 #14756f,
              0 calc(var(--u) * .085) calc(var(--u) * .12) rgba(0,0,0,.5),
              0 0 calc(var(--u) * .55) rgba(47,184,176,.95),
              inset 0 1px 0 rgba(255,255,255,.85);
}
.key.shift-down .cap-label { color: #052f2d; }
/* CapsLock 指示灯（只有 Caps 键有） */
.cap-led {
  position: absolute; left: 50%; bottom: calc(var(--u) * .07);
  width: calc(var(--u) * .13); height: calc(var(--u) * .13);
  margin-left: calc(var(--u) * -.065); border-radius: 50%;
  background: #4a5058; box-shadow: inset 0 1px 2px rgba(0,0,0,.6);
  transition: background .2s, box-shadow .2s;
  z-index: 5; pointer-events: none;
}
/* CapsLock 开启：整个键帽变亮琥珀色 + 灯亮到刺眼 + 持续呼吸 */
.board-inner.caps-on .key[data-code="CapsLock"] .cap {
  background: linear-gradient(180deg, #ffd76e, #f5a623 50%, #d98200);
  box-shadow: 0 0 0 2px rgba(10,14,20,.5), 0 calc(var(--u) * .055) 0 #b06a00,
              0 calc(var(--u) * .085) calc(var(--u) * .12) rgba(0,0,0,.5),
              0 0 calc(var(--u) * .6) rgba(255,180,40,.95),
              inset 0 1px 0 rgba(255,255,255,.8);
  animation: capsGlow 1.5s ease-in-out infinite;
}
.board-inner.caps-on .key[data-code="CapsLock"] .cap-label { color: #3d2400; font-weight: 900; }
.board-inner.caps-on .key[data-code="CapsLock"] .cap-led {
  background: #fff3c4;
  box-shadow: 0 0 calc(var(--u) * .3) rgba(255,220,120,1), inset 0 0 3px rgba(255,255,255,.9);
}
@keyframes capsGlow {
  0%, 100% { filter: brightness(1); }
  50%      { filter: brightness(1.22); }
}

/* 有效大写：**只让 Caps 与 Shift 带颜色**，字母键保持原样 ——
   给 26 个字母上色会把整个键盘变成调色板，反而看不清哪个是状态键。 */
.board-inner.upper-on .key[data-code="ShiftLeft"] .cap,
.board-inner.upper-on .key[data-code="ShiftRight"] .cap {
  background: linear-gradient(180deg, #7fe6df, #2fb8b0 50%, #1a8f89);
  box-shadow: 0 0 0 2px rgba(10,14,20,.5), 0 calc(var(--u) * .055) 0 #14756f,
              0 calc(var(--u) * .085) calc(var(--u) * .12) rgba(0,0,0,.5),
              0 0 calc(var(--u) * .55) rgba(47,184,176,.95),
              inset 0 1px 0 rgba(255,255,255,.85);
  animation: capsGlow 1.5s ease-in-out infinite;
}
.board-inner.upper-on .key[data-code="ShiftLeft"] .cap-label,
.board-inner.upper-on .key[data-code="ShiftRight"] .cap-label { color: #052f2d; font-weight: 900; }

/* 大小写状态胶囊（文本区左上角）：大写时变成醒目的琥珀底 */
.case-chip {
  display: inline-flex; align-items: center; gap: 3px;
  padding: 1px 9px; border-radius: 99px; font-weight: 900; font-size: 11px;
  letter-spacing: .06em;
  color: #8d97a6; background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.09);
  transition: color .18s, background .18s, border-color .18s, transform .18s;
}
.case-chip[data-on="upper"] {
  color: #3d2400; background: linear-gradient(180deg, #ffd76e, #f5a623);
  border-color: #ffd76e; transform: scale(1.06);
  box-shadow: 0 0 14px rgba(255,190,60,.75);
  animation: capsGlow 1.5s ease-in-out infinite;
}
.case-chip[data-caps="1"] {
  color: #3d2400; background: linear-gradient(180deg, #ffd76e, #f5a623);
  border-color: #ffd76e; transform: scale(1.06);
  box-shadow: 0 0 14px rgba(255,190,60,.75);
}

/* 下一个待按键：绿色呼吸 */
.key.next-key .cap {
  box-shadow:
    0 0 0 2px #45e0a0,
    0 calc(var(--u) * .055) 0 #a9b0ba,
    0 calc(var(--u) * .085) calc(var(--u) * .12) rgba(0,0,0,.5),
    0 0 calc(var(--u) * .45) rgba(69,224,160,.85),
    inset 0 1px 0 rgba(255,255,255,.95);
  animation: nextPulse 1.05s ease-in-out infinite;
}
@keyframes nextPulse { 50% { filter: brightness(1.14); } }
/* 下一个键正好被地鼠占住：红色告警 */
.key.has-mole.next-key .cap {
  box-shadow:
    0 0 0 2px #ff5c5c, 0 0 calc(var(--u) * .5) rgba(255,70,70,.9),
    inset 0 1px 0 rgba(255,255,255,.95);
}

/* 打对 / 打错 / 失灵 */
/* 打对：和"被地鼠砸中闪红光"同等的覆盖面积，只是换成绿色。
   以前只有一圈引导光，敲得越快越看不出来，反馈太弱。 */
.key.key-good .cap {
  background: linear-gradient(180deg, #d8ffe9, #a6f2c6 50%, #63d894);
  box-shadow: 0 0 0 2px #2fbf7c, 0 0 calc(var(--u) * .6) rgba(62,224,143,.95),
              inset 0 1px 0 rgba(255,255,255,.85);
  animation: goodFlash .22s ease-out;
}
.key.key-good .cap-label { color: #06421f; }
@keyframes goodFlash {
  0%   { filter: brightness(1.65); }
  100% { filter: brightness(1); }
}
/* 打错：同样铺满，红 */
.key.key-wrong .cap {
  background: linear-gradient(180deg, #ffd9d9, #ffb0b0 50%, #ff8a8a);
  box-shadow: 0 0 0 2px var(--bad), 0 0 calc(var(--u) * .6) rgba(255,60,60,.95);
  animation: blockedShake .26s;
}
.key.key-wrong .cap-label { color: #5a0000; }
.key.blocked { animation: blockedShake .4s; z-index: 30; }
.key.blocked .cap {
  box-shadow: 0 0 0 2px #ff4d4d, 0 0 calc(var(--u) * .6) rgba(255,50,50,.95);
  background: linear-gradient(180deg, #ffd5d5, #ffb3b3 50%, #ff8f8f);
}
.key.blocked::after {
  content: '✕';
  position: absolute; left: 50%; top: calc(var(--u) * -.34); transform: translateX(-50%);
  font-size: calc(var(--u) * .3); font-weight: 900; color: #ff5252;
  text-shadow: 0 0 12px rgba(255,60,60,.9);
  animation: xPop .4s ease-out;
  pointer-events: none; z-index: 40;
}
@keyframes xPop { 0% { opacity: 0; transform: translateX(-50%) scale(.4); } 60% { opacity: 1; transform: translateX(-50%) scale(1.4); } 100% { opacity: 0; transform: translateX(-50%) scale(1); } }

/* 地鼠被敲跑时键帽回弹 */
.key.cap-rebound .cap { animation: capRebound .4s cubic-bezier(.2,1.6,.4,1); }
@keyframes capRebound { 0% { transform: translateY(calc(var(--u) * -.5)); } 55% { transform: translateY(calc(var(--u) * .03)); } 100% { transform: translateY(0); } }
.key.cap-drop .cap { animation: capDrop .38s ease-in; }
@keyframes capDrop { 0% { transform: translateY(calc(var(--u) * -.24)); } 100% { transform: translateY(0); } }

/* 剩余敲击提示：颜色分档 + 点数
   绿 = 快走了 / 橙 = 还要几下 / 红 = 大块头；点数一眼可数，超过上限退回数字 */
.key-badge {
  position: absolute; right: calc(var(--u) * .015); bottom: calc(var(--u) * .015);
  height: calc(var(--u) * .2);
  padding: 0 calc(var(--u) * .05);
  display: none; align-items: center; gap: calc(var(--u) * .035);
  border-radius: 99px; z-index: 6;
  background: rgba(10,13,18,.92);
  box-shadow: 0 0 0 1.5px var(--hp-soft, rgba(255,90,90,.55)), 0 0 calc(var(--u) * .18) var(--hp-faint, rgba(255,90,90,.3));
  font-size: calc(var(--u) * .18); font-weight: 900; line-height: 1;
  color: var(--hp-color, #ff5c5c);
  font-variant-numeric: tabular-nums;
  transition: box-shadow .15s, color .15s;
}
.key-badge.show { display: flex; }
.key-badge .pip {
  display: block;
  width: calc(var(--u) * .12); height: calc(var(--u) * .12);
  border-radius: 50%;
  background: var(--hp-color, #ff5c5c);
  box-shadow: 0 0 calc(var(--u) * .075) var(--hp-color, #ff5c5c);
}
/* 点数放不下时退回数字：数字版留一点内边距 */
.key-badge.numeric {
  min-width: calc(var(--u) * .3); justify-content: center;
  padding: 0 calc(var(--u) * .06);
}
/* 只剩最后一下：加一圈跳动，配合鬼脸 */
.key.has-mole[data-hp="1"] .key-badge { animation: badgePulse .55s ease-in-out infinite alternate; }
@keyframes badgePulse { to { transform: scale(1.16); } }

/* ========================= 地鼠 ========================= */
.mole-layer {
  position: absolute; left: -32%; right: -32%; bottom: 0;
  height: calc(var(--u) * 2.7);
  overflow: hidden; pointer-events: none; z-index: 1;
}
.mole {
  position: absolute; bottom: 0; left: 50%;
  width: calc(var(--u) * var(--mw, .9));
  height: calc(var(--u) * var(--mh, .95));
  margin-left: calc(var(--u) * var(--mw, .9) / -2);
  transform-origin: bottom center;
  animation: moleRise .3s cubic-bezier(.2, 1.7, .4, 1) both;
}
.mole-art { width: 100%; height: 100%; animation: moleBob 1.9s ease-in-out infinite; transform-origin: bottom center; }
.mole-svg {
  width: 100%; height: 100%; display: block;
  filter:
    drop-shadow(0 calc(var(--u) * .035) calc(var(--u) * .05) rgba(0,0,0,.55))
    drop-shadow(0 0 calc(var(--u) * .09) var(--hp-color, rgba(0,0,0,0)));
}
@keyframes moleRise {
  0%   { transform: translateY(100%) scaleY(.55); }
  55%  { transform: translateY(-7%) scaleY(1.08); }
  100% { transform: translateY(0) scaleY(1); }
}
@keyframes moleBob {
  0%, 100% { transform: translateY(0) scale(1, 1); }
  50%      { transform: translateY(-3%) scale(1.02, .98); }
}
/* 命中挤压：用 --hit-k 控制幅度，大地鼠（胖嘟嘟）压得更狠、弹得更久 */
.mole.hit .mole-art { animation: moleHit .24s ease-out; }
.mole[data-size="large"].hit .mole-art { animation: moleHit .34s cubic-bezier(.2,.9,.3,1.2); }
@keyframes moleHit {
  0%   { transform: scale(1, 1); }
  22%  { transform: scale(calc(1 + .16 * var(--hit-k, 1)), calc(1 - .16 * var(--hit-k, 1))) translateY(calc(4% * var(--hit-k, 1))); }
  52%  { transform: scale(calc(1 - .1 * var(--hit-k, 1)), calc(1 + .1 * var(--hit-k, 1))) translateX(-5%); }
  78%  { transform: scale(calc(1 + .05 * var(--hit-k, 1)), calc(1 - .05 * var(--hit-k, 1))) translateX(5%); }
  100% { transform: scale(1, 1); }
}
.mole.leaving { animation: moleDive .3s ease-in both; }
@keyframes moleDive {
  0%   { transform: translateY(0) rotate(0) scale(1); opacity: 1; }
  100% { transform: translateY(102%) rotate(16deg) scale(.66); opacity: .2; }
}
.mole.leaving[data-leave="escape"] { animation: moleEscape .3s ease-in both; }
@keyframes moleEscape {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  100% { transform: translateY(104%) scaleY(.8) scaleX(1.1); opacity: .15; }
}
/* 让路（待输键被堵太久，地鼠主动缩回去） */
.mole.leaving[data-leave="yield"] { animation: moleYield .34s ease-in both; }
@keyframes moleYield {
  0%   { transform: translateY(0) rotate(0) scaleY(1); opacity: 1; }
  35%  { transform: translateY(-6%) scaleY(1.08); }
  100% { transform: translateY(106%) rotate(-12deg) scale(.7); opacity: .15; }
}

/* 表情切换 */
.mole .g-arms-up, .mole .g-eyes-hurt, .mole .g-eyes-grimace,
.mole .g-mouth-hurt, .mole .g-mouth-grimace { display: none; }

.mole[data-mood="hurt"] .g-arms-down,
.mole[data-mood="hurt"] .g-eyes-idle,
.mole[data-mood="hurt"] .g-mouth-idle { display: none; }
.mole[data-mood="hurt"] .g-arms-up,
.mole[data-mood="hurt"] .g-eyes-hurt,
.mole[data-mood="hurt"] .g-mouth-hurt { display: block; }

.mole[data-mood="grimace"] .g-arms-down,
.mole[data-mood="grimace"] .g-eyes-idle,
.mole[data-mood="grimace"] .g-mouth-idle { display: none; }
.mole[data-mood="grimace"] .g-arms-up,
.mole[data-mood="grimace"] .g-eyes-grimace,
.mole[data-mood="grimace"] .g-mouth-grimace { display: block; }

/* 有地鼠的键：井里透出「剩余敲击数」档位颜色的光，键帽整体上浮 */
.key.has-mole { z-index: 20; }
.key.has-mole .key-base {
  box-shadow:
    inset 0 calc(var(--u) * .04) calc(var(--u) * .1) rgba(0,0,0,.95),
    inset 0 0 calc(var(--u) * .3) var(--hp-faint, rgba(255,80,80,.35)),
    0 0 calc(var(--u) * .26) var(--hp-soft, rgba(255,70,70,.3));
}
.key.pressed { z-index: 25; }
/* 有地鼠时键帽也沾一点档位色 */
.key.has-mole .cap { box-shadow: 0 0 0 1.5px var(--hp-soft, rgba(255,90,90,.5)), 0 calc(var(--u) * .055) 0 #a9b0ba, 0 calc(var(--u) * .085) calc(var(--u) * .12) rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.9); }

/* ========================= 页脚 ========================= */
.footer-hint {
  margin-top: 14px; display: flex; gap: 22px; justify-content: center; flex-wrap: wrap;
  font-size: 12.5px; color: var(--ink-dim);
}
.footer-hint b {
  display: inline-block; padding: 1px 7px; border-radius: 6px; margin-right: 4px;
  background: rgba(255,255,255,.09); color: var(--ink); font-size: 11.5px;
}

/* ========================= FX ========================= */
.fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 900; }
.fx-float {
  position: fixed; transform: translate(-50%, -100%);
  font-size: 15px; font-weight: 900; white-space: nowrap;
  color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.8);
  animation: floatUp .95s cubic-bezier(.2,.8,.3,1) forwards;
}
.fx-float.fx-score { color: #ffd76a; font-size: 20px; }
.fx-float.fx-hit { color: #ff9a9a; font-size: 13px; }
.fx-float.fx-time { color: #6ee7b7; font-size: 15px; }
.fx-float.fx-bad { color: #ff6b6b; font-size: 17px; }
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -40%) scale(.7); }
  22%  { opacity: 1; transform: translate(-50%, -115%) scale(1.12); }
  100% { opacity: 0; transform: translate(-50%, -260%) scale(1); }
}
.fx-burst { position: fixed; transform: translate(-50%, -50%); width: 0; height: 0; }
.fx-burst .burst-star {
  position: absolute; left: 0; top: 0; font-size: 18px; color: #ffd76a;
  text-shadow: 0 0 10px rgba(255,200,80,.95);
  animation: burstOut .58s ease-out forwards;
}
.fx-burst .burst-star:nth-child(1) { --dx: -26px; --dy: -22px; }
.fx-burst .burst-star:nth-child(2) { --dx: 26px;  --dy: -20px; }
.fx-burst .burst-star:nth-child(3) { --dx: -20px; --dy: 20px; }
.fx-burst .burst-star:nth-child(4) { --dx: 22px;  --dy: 18px; }
.fx-burst.big .burst-star { font-size: 26px; color: #ffe08a; }
@keyframes burstOut {
  0%   { opacity: 0; transform: translate(0,0) scale(.3) rotate(0deg); }
  35%  { opacity: 1; }
  100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.3) rotate(140deg); }
}

.toast-layer {
  position: fixed; left: 50%; top: 16px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 960; pointer-events: none;
}
.toast {
  padding: 8px 16px; border-radius: 99px; font-size: 13px; font-weight: 800;
  background: linear-gradient(180deg, #2b3441, #1b212b); color: var(--ink);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 10px 26px rgba(0,0,0,.55);
  animation: toastIn .26s cubic-bezier(.2,1.5,.4,1);
  transition: opacity .28s, transform .28s;
}
.toast.good { background: linear-gradient(180deg,#2fbf7c,#178a53); color: #fff; }
.toast.warn { background: linear-gradient(180deg,#ff9f43,#e07b12); color: #241300; }
.toast.frenzy {
  background: linear-gradient(180deg,#ff8a3d,#d92d20); color: #fff;
  font-size: 15px; box-shadow: 0 10px 30px rgba(217,45,32,.7), 0 0 30px rgba(255,140,60,.6);
}

/* ========================= 开始界面的模式/难度选择 ========================= */
.start-options { margin: 0 0 16px; display: flex; flex-direction: column; gap: 12px; }
.opt-row { display: flex; flex-direction: column; gap: 7px; }
.opt-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.opt-label {
  font-size: 12px; font-weight: 900; letter-spacing: .14em; color: #93a3b8;
  padding: 2px 9px; border-radius: 6px; background: rgba(255,255,255,.06);
}
.opt-desc { font-size: 12.5px; color: var(--ink-dim); }
.seg {
  display: inline-flex; padding: 3px; gap: 3px; border-radius: 12px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
  align-self: flex-start;
}
.seg-btn {
  padding: 7px 14px; border: 0; border-radius: 9px; cursor: pointer;
  font-family: inherit; font-size: 13px; font-weight: 800; color: var(--ink-dim);
  background: transparent; transition: background .16s, color .16s, box-shadow .16s;
}
.seg-btn:hover { color: var(--ink); background: rgba(255,255,255,.05); }
.seg-btn.on {
  color: #dbe7ff; background: linear-gradient(180deg,#3a6fd8,#2a55ab);
  box-shadow: 0 4px 14px rgba(42,85,171,.5);
}
.toast.out { opacity: 0; transform: translateY(-10px) scale(.94); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.9); } }

/* ========================= 遮罩 / 弹窗 ========================= */
.overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center; padding: 24px;
  background: rgba(6,9,13,.82); backdrop-filter: blur(6px);
  opacity: 0; pointer-events: none; transition: opacity .24s;
}
.overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  width: min(620px, 100%); max-height: 92vh; overflow: auto;
  padding: 28px 30px; border-radius: 22px;
  background: linear-gradient(180deg, #1c2330, #12161d);
  border: 1px solid rgba(255,255,255,.1);
  box-shadow: 0 30px 80px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.06);
  transform: translateY(14px) scale(.97); transition: transform .26s cubic-bezier(.2,1.2,.4,1);
}
.overlay.show .modal { transform: none; }
.modal-small { width: min(400px, 100%); text-align: center; }
.modal-title { margin: 0 0 6px; font-size: 30px; font-weight: 900; letter-spacing: .01em; }
.modal-title .en { font-size: 17px; color: var(--blue); letter-spacing: .06em; }
.modal-sub { margin: 0 0 16px; color: var(--ink-dim); font-size: 14px; line-height: 1.6; }
.modal-tip { margin: 14px 0 0; font-size: 12.5px; color: var(--ink-dim); }

/* 开场白：用聊天的口气讲清楚玩法，别甩一屏规则 */
.intro-lead {
  margin: 4px 0 8px; font-size: 21px; font-weight: 900; letter-spacing: .01em;
  color: #ffd76e; text-shadow: 0 0 20px rgba(255,207,92,.35);
}
.intro-body {
  margin: 0 0 10px; font-size: 14.5px; line-height: 1.95; color: #c7d0dd;
}
.intro-body b { color: #ffd76e; font-weight: 900; }
.intro-cta {
  margin: 0 0 18px; font-size: 14.5px; font-weight: 800; color: #7fd4a8;
}
@media (max-width: 900px) {
  .intro-lead { font-size: 18px; }
  .intro-body { font-size: 13px; line-height: 1.85; }
  .intro-cta { font-size: 13px; margin-bottom: 14px; }
}
.modal-actions { display: flex; gap: 12px; flex-wrap: wrap; }

.btn {
  padding: 12px 24px; border-radius: 13px; cursor: pointer;
  font-size: 15px; font-weight: 800; font-family: inherit;
  color: var(--ink); background: linear-gradient(180deg,#2c3541,#1d232c);
  border: 1px solid rgba(255,255,255,.12);
  transition: transform .12s, box-shadow .2s, filter .2s;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 26px rgba(0,0,0,.5); }
.btn:active { transform: translateY(0); }
.btn-primary {
  background: linear-gradient(180deg,#4f8ef7,#2563eb); border-color: #7aa9ff;
  box-shadow: 0 10px 26px rgba(37,99,235,.5);
}
.btn-primary:hover { filter: brightness(1.08); }

.final-score { display: flex; align-items: baseline; gap: 14px; margin: 8px 0 18px; flex-wrap: wrap; }
.final-score-label { font-size: 13px; letter-spacing: .18em; color: var(--ink-dim); text-transform: uppercase; }
.final-score-value {
  font-size: 56px; font-weight: 900; color: var(--warn); line-height: 1;
  text-shadow: 0 0 30px rgba(255,207,92,.45); font-variant-numeric: tabular-nums;
}
.new-record {
  padding: 4px 12px; border-radius: 99px; font-size: 12px; font-weight: 900;
  background: linear-gradient(180deg,#ffd76a,#f0a500); color: #3a2600;
  opacity: 0; transform: scale(.8); transition: opacity .2s, transform .2s;
}
.new-record.show { opacity: 1; transform: scale(1); animation: badgePulse .6s infinite alternate; }

.result-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px 18px; margin-bottom: 22px;
}
.rg-row {
  display: flex; justify-content: space-between; gap: 10px;
  padding: 8px 12px; border-radius: 10px; font-size: 13.5px;
  background: rgba(255,255,255,.045); color: var(--ink-dim);
}
.rg-row b { color: var(--ink); font-variant-numeric: tabular-nums; }

/* ========================= 设置面板 ========================= */
.panel-mask {
  position: fixed; inset: 0; z-index: 1000; background: rgba(6,9,13,.6);
  opacity: 0; pointer-events: none; transition: opacity .24s;
}
.panel-mask.show { opacity: 1; pointer-events: auto; }
.panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(430px, 92vw); z-index: 1001;
  display: flex; flex-direction: column;
  background: linear-gradient(180deg,#1a2029,#10151b);
  border-left: 1px solid rgba(255,255,255,.1);
  box-shadow: -24px 0 60px rgba(0,0,0,.6);
  transform: translateX(102%); transition: transform .3s cubic-bezier(.2,.9,.3,1);
}
.panel.open { transform: none; }
.panel-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid rgba(255,255,255,.08);
}
.panel-head h2 { margin: 0; font-size: 18px; }
.panel-body { flex: 1; overflow-y: auto; padding: 14px 18px 20px; }
.set-section {
  margin: 18px 0 8px; font-size: 12px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--blue);
}
.set-section:first-child { margin-top: 0; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 0; font-size: 13.5px; color: #c3ccd9;
  border-bottom: 1px dashed rgba(255,255,255,.06);
}
.set-row-bool { cursor: pointer; }
.set-row-select { cursor: pointer; }
.set-row-info { cursor: default; }
.set-row.set-disabled { opacity: .42; }
.set-note {
  margin-left: 8px; font-size: 10.5px; letter-spacing: .04em;
  color: var(--ink-dim); border: 1px solid rgba(255,255,255,.14);
  padding: 1px 6px; border-radius: 99px; white-space: nowrap;
}
.set-static {
  font-size: 12.5px; font-weight: 700; color: #93a3b8; text-align: right;
  max-width: 62%; line-height: 1.45;
}
.set-input select {
  max-width: 190px; padding: 7px 9px; border-radius: 9px;
  font-family: inherit; font-size: 12.5px; font-weight: 700; color: var(--ink);
  background: #0d1116; border: 1px solid rgba(255,255,255,.13);
}
.set-input select:focus { outline: 2px solid var(--blue); border-color: transparent; }
.set-input input[type="number"] {
  width: 92px; padding: 7px 10px; border-radius: 9px; text-align: right;
  font-family: inherit; font-size: 14px; font-weight: 700; color: var(--ink);
  background: #0d1116; border: 1px solid rgba(255,255,255,.13);
}
.set-input input[type="number"]:focus { outline: 2px solid var(--blue); border-color: transparent; }
.set-input input[type="checkbox"] {
  appearance: none; -webkit-appearance: none;
  position: relative; width: 42px; height: 23px; border-radius: 99px; cursor: pointer;
  background: #262e39; border: 1px solid rgba(255,255,255,.14);
  transition: background .2s, border-color .2s;
}
.set-input input[type="checkbox"]::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 17px; height: 17px; border-radius: 50%; background: #7c8695;
  transition: transform .2s, background .2s;
}
.set-input input[type="checkbox"]:checked { background: #2563eb; border-color: #7aa9ff; }
.set-input input[type="checkbox"]:checked::after { transform: translateX(19px); background: #fff; }
.panel-foot {
  display: flex; gap: 10px; padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
}

/* ========================= 手机 / 触屏 ========================= */
/* 触摸时不要有 300ms 延时、不要双击缩放、不要长按选中 */
.board, .key, .cap { touch-action: manipulation; }
.key, .cap, .cap-label {
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.key { cursor: pointer; }

/* 紧凑配列（手机）：行居中、键更大、去掉底盘外多余的装饰 */
.kb-body-compact { gap: 0; }
.kb-rows-compact, .board-inner.compact .kb-rows { align-items: center; }
.kb-row-compact { justify-content: center; }
.kb-row-space { margin-top: calc(var(--gap) * 0.6); }
.board-inner.compact .key { cursor: pointer; }
.board-inner.compact .cap-label { font-size: calc(var(--u) * 0.32); }

/* 触屏设备：键帽加高一点更好点，按下去的回弹更明显 */
html.is-touch .cap {
  transition: transform .1s cubic-bezier(.2, 1.5, .45, 1), box-shadow .16s;
}
html.is-touch .key.pressed .cap {
  transform: translateY(calc(var(--u) * (var(--travel) * 1.6 + var(--press-extra, 0) - var(--rise, 0))));
}
html.is-touch .key-base { border-radius: calc(var(--u) * .16); }
html.is-touch .cap { border-radius: calc(var(--u) * .18); }

@media (max-width: 900px) {
  /* 手机上的机身开销实测（390×56X 视口）：HUD 63 + 提词器 99 + 页脚 17 ≈ 180，
     再留一点余量给开始/结算弹层的安全区，取 205px。桌面那个 300px 是给宽屏
     的一行到底布局留的，手机上照搬等于白扔 100px 高度 */
  :root { --chrome-h: 205px; }
  /* ===== 手机：键位必须做到「正常手机打字」的尺寸 =====
     站长反馈手机端按键太小按不准。旧版三处叠加把键压到了 30px 上下：
       1) --board-pad 26px + --board-slack 0.9 白吃了一截横向空间；
       2) --chrome-h 恒为 300px，手机上顶部 HUD + 提词器其实矮得多，白白扣掉高度；
       3) --key-ratio 0.92 让键比宽还矮，触控面进一步缩水。
     现在：收窄留白与 chrome 高度，把 --key-ratio 抬到 1.15（键比宽高一点，
     与真机键盘一致——iPhone 字母键约 35×42）。390px 宽的手机上 --u 落在
     ~35px，键约 35×40px，已是 10 列配列在该屏宽下的物理上限
     （真机键盘也是这个数，44px 见方的触控建议值只在列数更少时才能满足）。 */
  .board {
    --board-pad: 14px;
    --board-slack: 0.5;
    --key-base: 1.15;
  }
  /* 手机上：HUD 留顶部，文本区+键盘一起沉到底部 —— 落在拇指可及区，
     同时保持"文本紧贴键盘"，视线不用在屏幕上下两端来回跑 */
  .app { padding: 6px 8px 4px; height: 100vh; display: flex; flex-direction: column; }
  .text-panel { margin-top: auto; }
  .board-wrap { padding-bottom: 2px; }
  .hud { padding: 6px 10px; border-radius: 12px; gap: 8px; }
  .hud-group { gap: 10px; }
  .stat-value { font-size: 17px; }
  .stat-label { font-size: 9.5px; letter-spacing: .1em; }
  .stat-best { display: none; }
  .timer { font-size: 26px; }
  .icon-btn { width: 32px; height: 32px; font-size: 15px; }
  .text-panel { padding: 5px 12px 4px; }
  .text-meta { font-size: 10px; gap: 6px; }
  .text-meta #meta-pool { display: none; }
  .combo-tag { font-size: 10px; }
  .footer-hint { font-size: 10.5px; gap: 10px; margin-top: 6px; }
  .modal { padding: 20px 18px; border-radius: 18px; }
  .modal-title { font-size: 22px; }
  .seg-btn { padding: 8px 10px; font-size: 12px; }
  .board-case { padding: calc(var(--u) * .3) calc(var(--u) * .3) calc(var(--u) * .45); }
  /* 紧凑配列在手机上是主角：键帽文字跟着键一起放大，远看也读得清 */
  .board-inner.compact .cap-label { font-size: calc(var(--u) * 0.38); }
  .board-inner.compact .cap-sub { font-size: calc(var(--u) * 0.2); }
  /* 多出来的行会把键盘撑高：行间距收一点，保证 6 行仍落在拇指区 */
  .kb-rows-compact, .board-inner.compact .kb-rows { gap: calc(var(--gap) * 0.85); }
}

/* 竖屏手机：底盘灯低调一点，别抢视线 */
@media (max-width: 560px) {
  .board-case::after { opacity: .3; }
  .blocked-toast { font-size: 11px; padding: 5px 10px; right: 8px; }
}
