/* Jelly 1024 · 果冻合并 —— 样式
 * 深色氛围底（三层景深）+ 海报级插画 + 记分牌主角化 + 圆体数字
 * 设计原则：信息只有两级（一个巨大主角 + 一排小辅助），绝不平均用力
 */

/* 圆体数字字体（本地嵌入，运行时不联网；仅 latin/数字子集，中文走系统字体回退）
 * 来源：Google Fonts · Nunito（OFL，许可见 assets/fonts/Nunito-OFL.txt） */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 700 900;
  font-display: swap;
  src: url('../assets/fonts/nunito-latin.woff2') format('woff2');
}

:root {
  --bg-1: #150a2c;
  --bg-2: #241241;
  --panel: rgba(255, 255, 255, 0.10);
  --panel-line: rgba(255, 255, 255, 0.20);
  --ink: #ffffff;
  --ink-dim: rgba(255, 255, 255, 0.68);
  --ink-faint: rgba(255, 255, 255, 0.42);
  --accent: #ffd24a;
  --accent-2: #ff8fb8;
  --radius: 20px;
  --font: "Nunito", "PingFang SC", "Microsoft YaHei UI", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  --num: "Nunito", "PingFang SC", "Microsoft YaHei UI", system-ui, sans-serif;
  --mono: "SF Mono", "Consolas", "Microsoft YaHei", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(168deg, var(--bg-1) 0%, var(--bg-2) 52%, #341a4d 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

/* ==================== 背景三层景深 ==================== */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background: linear-gradient(168deg, var(--bg-1) 0%, var(--bg-2) 52%, #341a4d 100%);
}

/* 远层：海报插画。压暗、略降饱和，退到后面去 */
.bg-art {
  position: absolute;
  inset: -3%;
  background: url('../assets/bg/jelly-world.jpg') center center / cover no-repeat;
  opacity: 0.78;
  filter: saturate(1.05) brightness(0.70) blur(0.4px);
}

/* 中层：大面积柔和彩色光斑 + 中央压暗（保证玩法区文字可读） */
.bg-glow {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(54% 60% at 50% 44%,
      rgba(15, 5, 32, 0.84) 0%, rgba(15, 5, 32, 0.56) 48%, rgba(15, 5, 32, 0) 100%),
    radial-gradient(40% 34% at 9% 12%, rgba(255, 150, 215, 0.34), transparent 72%),
    radial-gradient(44% 36% at 94% 16%, rgba(110, 200, 255, 0.30), transparent 74%),
    radial-gradient(50% 40% at 84% 94%, rgba(255, 205, 105, 0.24), transparent 76%),
    radial-gradient(46% 38% at 10% 90%, rgba(140, 255, 215, 0.22), transparent 76%);
}

/* 近层：极轻颗粒噪点，消除"平渐变塑料感" */
.bg-grain {
  position: absolute;
  inset: 0;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 160px 160px;
}

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

/* ==================== 顶部 HUD ==================== */
.hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 13px 20px;
  /* 刘海屏 / 灵动岛：HUD 不能钻到状态栏下面去（env 在不支持的浏览器里返回 0） */
  padding-top: calc(13px + env(safe-area-inset-top, 0px));
  padding-left: calc(20px + env(safe-area-inset-left, 0px));
  padding-right: calc(20px + env(safe-area-inset-right, 0px));
  background: linear-gradient(180deg, rgba(19, 8, 38, 0.74), rgba(19, 8, 38, 0.30));
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  backdrop-filter: blur(14px) saturate(1.1);
  box-shadow: 0 12px 34px rgba(8, 2, 20, 0.42);
}

.hud-left { flex: 0 0 auto; }
.hud-center { flex: 1 1 auto; display: flex; justify-content: center; }
.hud-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ---- Logo ---- */
.logo { display: flex; align-items: center; gap: 11px; }

.logo-ball {
  position: relative;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #e8f1ff 5%, #6093f5 32%, #3d72d6 74%, #1f4aa8 100%);
  box-shadow:
    inset 0 -3px 6px rgba(20, 40, 100, 0.42),
    0 0 0 2px rgba(255, 255, 255, 0.42),
    0 6px 16px rgba(60, 110, 230, 0.38),
    0 10px 26px rgba(6, 2, 16, 0.44);
  flex: 0 0 auto;
}

/* 小高光，让 logo 也「布灵布灵」 */
.logo-ball::after {
  content: '';
  position: absolute;
  left: 25%;
  top: 18%;
  width: 34%;
  height: 24%;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  transform: rotate(-22deg);
  filter: blur(0.3px);
}

/* logo 也是只史莱姆：一对小眼睛（用 <i> 的 before/after 画两只眼，
   跟罐子里的球用同一套语言 —— 不然顶上一颗没脸的球会很突兀） */
.logo-ball i {
  position: absolute;
  inset: 0;
}

.logo-ball i::before,
.logo-ball i::after {
  content: '';
  position: absolute;
  top: 46%;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #ffffff 22%, #2a1740 30%, #2a1740 100%);
  box-shadow: 0 0 0 0.5px rgba(90, 45, 0, 0.35);
}

.logo-ball i::before { left: 22%; }
.logo-ball i::after { right: 22%; }

.logo-text b {
  display: block;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.6px;
  line-height: 1.1;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
}

.logo-text small {
  display: block;
  font-size: 10px;
  color: var(--ink-faint);
  letter-spacing: 1.8px;
  text-transform: uppercase;
}

/* ---- 模式切换（塑料玩具质感：带「厚度」） ---- */
.mode-switch {
  display: inline-flex;
  padding: 4px;
  gap: 4px;
  background: rgba(0, 0, 0, 0.30);
  border-radius: 999px;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.42),
    inset 0 -1px 0 rgba(255, 255, 255, 0.10);
}

.mode-switch button {
  border: 0;
  background: transparent;
  color: var(--ink-dim);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 800;
  padding: 7px 17px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s, color 0.18s, transform 0.14s, box-shadow 0.14s;
  white-space: nowrap;
}

.mode-switch button:hover { color: var(--ink); }

.mode-switch button.on {
  background: linear-gradient(180deg, #ffe07a, #ffb03a);
  color: #4a2a05;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 3px 0 rgba(160, 88, 6, 0.55),
    0 6px 14px rgba(255, 170, 50, 0.34);
}

.mode-switch button.on:active { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 1px 0 rgba(160, 88, 6, 0.5); }

/* ---- 记分牌：得分是唯一主角 ---- */
.scoreboard {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 5px 10px 6px 18px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.135), rgba(255, 255, 255, 0.05));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.30),
    inset 0 -1px 0 rgba(0, 0, 0, 0.22),
    0 3px 0 rgba(30, 14, 56, 0.50),
    0 12px 30px rgba(10, 3, 24, 0.36);
  transition: gap 0.24s ease;
}

/* 收起态：只留「得分」，连击 / 下一个折进 ▾ */
.scoreboard.mini { gap: 0; padding-right: 8px; }
.scoreboard.mini .score-mini { display: none; }
.scoreboard.mini .score-toggle { transform: rotate(180deg); }

.score-toggle {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.62);
  background: rgba(255, 255, 255, 0.10);
  cursor: pointer;
  transition: transform 0.24s ease, background 0.16s, color 0.16s;
}
.score-toggle:hover { background: rgba(255, 255, 255, 0.2); color: #fff; }

.score-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1;
}

.score-k {
  font-size: 10px;
  letter-spacing: 1.8px;
  color: rgba(255, 255, 255, 0.50);
  margin-bottom: 3px;
}

.score-v {
  display: block;
  font-family: var(--num);
  font-size: 34px;
  font-weight: 900;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  text-shadow:
    0 2px 0 rgba(122, 62, 0, 0.45),
    0 0 20px rgba(255, 198, 74, 0.48);
  transform-origin: 50% 62%;
}

/* 每次加分弹一下 —— 动效只挂在「事件」上 */
.score-v.bump { animation: score-bump 0.42s cubic-bezier(0.22, 1.5, 0.36, 1); }

@keyframes score-bump {
  0% { transform: scale(1); }
  32% { transform: scale(1.22); }
  100% { transform: scale(1); }
}

.score-mini {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding-left: 14px;
  border-left: 1px dashed rgba(255, 255, 255, 0.16);
}

.mini { display: flex; align-items: baseline; gap: 7px; }

.mini-k {
  font-size: 10px;
  letter-spacing: 0.6px;
  color: rgba(255, 255, 255, 0.40);
  min-width: 30px;
}

.mini-v {
  font-family: var(--num);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  min-width: 26px;
}

#hud-combo { color: var(--ink-dim); transition: color 0.2s, transform 0.2s; }
#hud-combo.on {
  color: #ff8fb8;
  transform: scale(1.16);
  text-shadow: 0 0 14px rgba(255, 140, 190, 0.6);
}

.next-val { font-weight: 900; }

.next-val.rank-0 { color: #ffd0e4; }
.next-val.rank-1 { color: #ffd0a8; }
.next-val.rank-2 { color: #fff0b8; }
.next-val.rank-3 { color: #c8f0b8; }
.next-val.rank-4 { color: #b8ecd8; }
.next-val.rank-5 { color: #b8dcff; }
.next-val.rank-6 { color: #c4bcf0; }
.next-val.rank-7 { color: #d8c0f0; }
.next-val.rank-8 { color: #e8a8d8; }
.next-val.rank-9 { color: #a878c8; }
.next-val.rank-10 { color: #7858a0; }

/* ---- 按钮 ---- */
.hud-btns { display: flex; gap: 8px; }

.icon-btn {
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-dim);
  border: 0;
  border-radius: 13px;
  padding: 8px 13px;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.07));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.26),
    inset 0 -1px 0 rgba(0, 0, 0, 0.20),
    0 2px 0 rgba(30, 14, 56, 0.48),
    0 4px 12px rgba(10, 3, 24, 0.28);
  transition: background 0.18s, color 0.18s, transform 0.14s, box-shadow 0.14s;
  white-space: nowrap;
}

.icon-btn:hover {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.12));
  color: var(--ink);
  transform: translateY(-1px);
}

.icon-btn:active {
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.20),
    inset 0 -1px 0 rgba(0, 0, 0, 0.16),
    0 1px 0 rgba(30, 14, 56, 0.46),
    0 2px 6px rgba(10, 3, 24, 0.24);
}
.icon-btn.off { opacity: 0.5; }

/* ==================== 舞台 ==================== */
.stage {
  flex: 1 1 auto;
  display: flex;
  min-height: 0;
  gap: 16px;
  padding: 14px 20px 20px;
}

.stage-canvas {
  flex: 1 1 auto;
  position: relative;
  z-index: 0;
  isolation: isolate;      /* 自建层叠上下文，让下面的 -1 层只退到画布之后 */
  min-width: 0;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* 中景：罐子背后只打一层柔光。
   刻意不加边框、不用圆角矩形 —— 罐子自己已经是那个"框"，
   再套一层同心的框就会变成双框（之前就是这么翻车的） */
.stage-canvas::before {
  content: '';
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 47%;
  width: min(118%, 860px);
  height: 92%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(50% 46% at 50% 48%,
    rgba(160, 126, 255, 0.17), rgba(120, 90, 220, 0.07) 55%, transparent 76%);
  filter: blur(12px);
  pointer-events: none;
}

/* 接地阴影：主体与台面之间的那一小块暗，最能「落地」。
   注意：罐子的托盘已经在画布内画了自己的落影，这一层只补一圈很散的
   环境遮蔽（而不是第二道硬接触影）—— 两道硬影会互相打架。 */
.stage-canvas::after {
  content: '';
  position: absolute;
  z-index: -1;
  left: 50%;
  bottom: 5%;
  width: min(88%, 620px);
  height: 54px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(50% 50% at 50% 50%, rgba(0, 0, 0, 0.34), rgba(0, 0, 0, 0) 76%);
  filter: blur(12px);
  pointer-events: none;
}

#stage {
  display: block;
  touch-action: none;
  cursor: crosshair;
  /* 兜底：画布的 width/height 属性（480×760）在 JS 设置内联尺寸前会生效，
     小屏上比容器大 → 撑大容器 → 再测量又更大，尺寸会互相推着往上长。
     加这条把初始状态钉在容器内，打断这个正反馈。 */
  max-width: 100%;
  max-height: 100%;
}

/* 首次提示 */
.hint {
  position: absolute;
  left: 50%;
  top: 42%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 17px 28px;
  background: linear-gradient(180deg, rgba(38, 18, 70, 0.86), rgba(24, 11, 46, 0.90));
  border-radius: 20px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.20),
    0 20px 44px rgba(5, 2, 14, 0.52);
  backdrop-filter: blur(8px);
  pointer-events: none;
  transition: opacity 0.45s, transform 0.45s;
  text-align: center;
  max-width: 84%;
}

.hint b { font-size: 17px; font-weight: 900; letter-spacing: 1px; }
.hint span { font-size: 12.5px; color: var(--ink-dim); line-height: 1.6; }

.hint.gone {
  opacity: 0;
  transform: translate(-50%, -58%) scale(0.94);
}

/* Toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 12px);
  padding: 10px 20px;
  background: linear-gradient(180deg, rgba(38, 18, 70, 0.92), rgba(24, 11, 46, 0.94));
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
  opacity: 0;
  pointer-events: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.20), 0 14px 32px rgba(5, 2, 14, 0.5);
  transition: opacity 0.22s, transform 0.22s;
  white-space: nowrap;
}

.toast.on {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* ==================== 侧栏 ==================== */
.side {
  flex: 0 0 236px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding-right: 2px;
}

.card {
  border-radius: var(--radius);
  padding: 14px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.115), rgba(255, 255, 255, 0.045));
  backdrop-filter: blur(10px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18),
    0 3px 0 rgba(30, 14, 56, 0.44),
    0 16px 34px rgba(8, 2, 20, 0.34);
}

.card-h {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 1.8px;
  color: var(--ink-faint);
  margin-bottom: 10px;
  text-transform: uppercase;
}

.target-line {
  font-family: var(--num);
  font-size: 22px;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.5px;
  line-height: 1.2;
  text-shadow: 0 2px 0 rgba(122, 62, 0, 0.35);
}

.target-max {
  font-size: 12px;
  color: var(--ink-dim);
  margin-top: 6px;
}

.target-max b {
  font-family: var(--num);
  color: #fff;
  font-size: 15px;
  font-weight: 900;
}

.target-hint {
  font-size: 11.5px;
  color: var(--ink-faint);
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed rgba(255, 255, 255, 0.14);
  line-height: 1.55;
}

/* 道具：三颗一次性救急按钮。用量写在右侧徽标里，用完变灰不再可点 */
.tools-note {
  font-size: 9px;
  letter-spacing: 0.4px;
  color: rgba(255, 255, 255, 0.34);
  text-transform: none;
  margin-left: 3px;
}

.tools {
  display: flex;
  flex-direction: row;
  gap: 8px;
}

/* 道具只留图标：名字与说明进 title / aria-label，次数挂在右上角角标 */
.tool {
  position: relative;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 13px;
  font-family: var(--font);
  color: #fff;
  cursor: pointer;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.07));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.26),
    inset 0 -1px 0 rgba(0, 0, 0, 0.16),
    0 2px 0 rgba(30, 14, 56, 0.42);
  transition: background 0.16s, transform 0.12s, opacity 0.2s;
}

.tool:hover:not(:disabled) {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.10));
  transform: translateY(-1px);
}

.tool:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -1px 0 rgba(0, 0, 0, 0.14),
    0 1px 0 rgba(30, 14, 56, 0.40);
}

.tool-ico {
  display: block;
  font-size: 19px;
  line-height: 1;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
}

/* 次数角标：贴在图标右上角 */
.tool-n {
  position: absolute;
  top: -5px;
  right: -5px;
  min-width: 17px;
  height: 17px;
  line-height: 17px;
  text-align: center;
  border-radius: 999px;
  font-family: var(--num);
  font-size: 10.5px;
  font-weight: 900;
  color: #4a2a05;
  background: linear-gradient(180deg, #ffe07a, #ffb03a);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.66), 0 2px 6px rgba(255, 170, 50, 0.32);
}

.tool.used { opacity: 0.38; cursor: default; }

.tool.used .tool-n {
  color: rgba(255, 255, 255, 0.60);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

/* 合并链 */
.chain {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.chain-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 7px;
  border-radius: 9px;
  opacity: 0.40;
  transition: opacity 0.25s, background 0.25s, transform 0.25s;
}

.chain-item.done { opacity: 1; }
.chain-item.cur {
  background: rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transform: translateX(2px);
}

.chain-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: #666;
  box-shadow: inset 0 -2px 3px rgba(0, 0, 0, 0.30), inset 0 2px 2px rgba(255, 255, 255, 0.55);
}

.chain-item[data-rank="0"] .chain-dot { background: #ffd0e4; }
.chain-item[data-rank="1"] .chain-dot { background: #ffd0a8; }
.chain-item[data-rank="2"] .chain-dot { background: #fff0b8; }
.chain-item[data-rank="3"] .chain-dot { background: #c8f0b8; }
.chain-item[data-rank="4"] .chain-dot { background: #b8ecd8; }
.chain-item[data-rank="5"] .chain-dot { background: #b8dcff; }
.chain-item[data-rank="6"] .chain-dot { background: #c4bcf0; }
.chain-item[data-rank="7"] .chain-dot { background: #d8c0f0; }
.chain-item[data-rank="8"] .chain-dot { background: #e8a8d8; }
.chain-item[data-rank="9"] .chain-dot { background: #a878c8; }
.chain-item[data-rank="10"] .chain-dot { background: #7858a0; }

.chain-val {
  font-family: var(--num);
  font-size: 13px;
  font-weight: 800;
  color: var(--ink-dim);
  font-variant-numeric: tabular-nums;
}

.chain-item.done .chain-val { color: #fff; }

/* ---- 果冻手感滑块 ---- */
.feel-now {
  float: right;
  font-size: 9px;
  letter-spacing: 0.4px;
  color: var(--accent);
  text-transform: none;
}

.feel-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  border-radius: 999px;
  outline: none;
  cursor: pointer;
  background: linear-gradient(90deg, rgba(255, 158, 199, 0.55), rgba(110, 198, 240, 0.55));
  box-shadow:
    inset 0 2px 4px rgba(0, 0, 0, 0.34),
    inset 0 -1px 0 rgba(255, 255, 255, 0.14);
}

/* 滑块手柄：做成一颗粒子，和罐子里的球同一套语言 */
.feel-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fffbe8 6%, #ffd24a 40%, #e8951a 100%);
  box-shadow:
    inset 0 -2px 3px rgba(120, 60, 0, 0.40),
    0 0 0 2px rgba(255, 255, 255, 0.30),
    0 3px 9px rgba(6, 2, 14, 0.46);
  cursor: grab;
}

.feel-range::-webkit-slider-thumb:active { cursor: grabbing; }

.feel-range::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #fffbe8 6%, #ffd24a 40%, #e8951a 100%);
  box-shadow:
    inset 0 -2px 3px rgba(120, 60, 0, 0.40),
    0 0 0 2px rgba(255, 255, 255, 0.30),
    0 3px 9px rgba(6, 2, 14, 0.46);
  cursor: grab;
}

.feel-scale {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 10px;
  color: var(--ink-faint);
}

/* 按键说明 */
.keys {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 11.5px;
  color: var(--ink-dim);
}

.keys li { display: flex; align-items: center; gap: 4px; }

kbd {
  display: inline-block;
  min-width: 20px;
  text-align: center;
  padding: 2px 5px;
  font-family: var(--mono);
  font-size: 10.5px;
  color: #fff;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(0, 0, 0, 0.26));
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.22), 0 2px 0 rgba(0, 0, 0, 0.3);
  border-radius: 6px;
}

/* ==================== 结算弹窗 ==================== */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(14, 5, 30, 0.70);
  backdrop-filter: blur(7px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s;
  z-index: 50;
  padding: 20px;
}

.overlay.on { opacity: 1; pointer-events: auto; }

.modal {
  position: relative;
  width: min(404px, 92vw);
  padding: 28px 26px 24px;
  text-align: center;
  background: linear-gradient(165deg, rgba(78, 42, 122, 0.98), rgba(38, 20, 66, 0.99));
  border-radius: 26px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 30px 74px rgba(0, 0, 0, 0.56),
    0 0 0 1px rgba(255, 255, 255, 0.10);
  transform: translateY(14px) scale(0.96);
  transition: transform 0.32s cubic-bezier(0.22, 1.2, 0.36, 1);
}

/* 关闭：结算页挡着看不见罐子里的战果，得让人能先关掉看两眼再叫回来 */
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  font-family: var(--font);
  font-size: 14px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.62);
  cursor: pointer;
  background: rgba(255, 255, 255, 0.10);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  transition: background 0.16s, color 0.16s, transform 0.16s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.20);
  color: #fff;
  transform: scale(1.08);
}

.modal-close:active { transform: scale(0.94); }

/* 结算关掉之后，给一个「点画面能叫回来」的提示 */
.rv-hint {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.86);
  background: linear-gradient(180deg, rgba(38, 18, 70, 0.90), rgba(24, 11, 46, 0.92));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 10px 26px rgba(5, 2, 14, 0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s, transform 0.22s;
  white-space: nowrap;
}

.rv-hint.on { opacity: 1; transform: translateX(-50%) translateY(-4px); }

.overlay.on .modal { transform: translateY(0) scale(1); }

.result-icon {
  font-size: 46px;
  line-height: 1;
  margin-bottom: 10px;
  animation: pop 0.5s cubic-bezier(0.22, 1.4, 0.36, 1);
}

@keyframes pop {
  0% { transform: scale(0.3) rotate(-18deg); opacity: 0; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}

.result-title {
  margin: 0 0 6px;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0.5px;
}

.result-desc {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--ink-dim);
  line-height: 1.6;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  margin-bottom: 14px;
}

.stat-cell {
  padding: 9px 3px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.05));
  border-radius: 12px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    inset 0 -1px 0 rgba(0, 0, 0, 0.16),
    0 2px 0 rgba(30, 14, 56, 0.40);
}

.stat-cell span {
  display: block;
  font-size: 9.5px;
  color: var(--ink-faint);
  margin-bottom: 3px;
}

.stat-cell b {
  font-family: var(--num);
  font-size: 16px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.grade-badge {
  display: inline-block;
  width: 46px;
  height: 46px;
  line-height: 46px;
  border-radius: 50%;
  font-family: var(--num);
  font-size: 23px;
  font-weight: 900;
  margin-bottom: 16px;
  color: #4a2a05;
  background: linear-gradient(180deg, #ffe9a8, #ffb03a);
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.7),
    0 8px 20px rgba(255, 180, 60, 0.44);
}

.grade-badge.grade-D {
  color: #fff;
  background: linear-gradient(180deg, #a8aebe, #6b7086);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.4), 0 8px 20px rgba(120, 130, 160, 0.36);
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 800;
  padding: 11px 24px;
  border-radius: 14px;
  border: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.08));
  color: #fff;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.26),
    inset 0 -1px 0 rgba(0, 0, 0, 0.20),
    0 3px 0 rgba(30, 14, 56, 0.50),
    0 4px 12px rgba(6, 2, 14, 0.34);
  transition: transform 0.16s, background 0.16s, box-shadow 0.16s;
}

.btn:hover { background: linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.13)); transform: translateY(-1px); }
.btn:active {
  transform: translateY(2px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.20),
    inset 0 -1px 0 rgba(0, 0, 0, 0.16),
    0 1px 0 rgba(30, 14, 56, 0.46),
    0 2px 8px rgba(6, 2, 14, 0.30);
}

.btn-primary {
  background: linear-gradient(180deg, #ffe07a, #ffa63a);
  color: #4a2a05;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.75),
    0 4px 0 rgba(168, 92, 6, 0.5),
    0 10px 24px rgba(255, 175, 60, 0.40);
}

.btn-primary:hover { background: linear-gradient(180deg, #ffe995, #ffb457); }

/* ==================== 面板可收起 / 移动端抽屉 ==================== */
/* 桌面：右侧栏可以整列收掉，画布占满；移动端：侧栏变成底部抽屉，
   默认只露一条把手，往下滑开。 */

/* 桌面收起侧栏的开关。它活在 HUD 的按钮组里（跟音效/暂停一排）——
   早先做成悬浮按钮，不管摆在哪都会压住侧栏卡片或画布，挪进 HUD 最干净。 */
.panel-toggle {
  min-width: 34px;
  padding: 7px 10px;
  font-size: 15px;
  line-height: 1;
}

/* 移动端抽屉里的一格容器；桌面端模式切换留在 HUD，这里空着 */
.drawer-top { display: none; }

/* 抽屉把手（移动端） */
.drawer-handle {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}
.drawer-pill {
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.32);
}
.drawer-label {
  font-size: 11px;
  letter-spacing: 1.6px;
  color: rgba(255, 255, 255, 0.46);
}

/* ==================== 响应式 ==================== */
@media (min-width: 901px) {
  .side {
    flex: 0 0 236px;
    overflow-x: hidden;
    overflow-y: auto;
    transition: flex-basis 0.3s cubic-bezier(0.22, 0.9, 0.28, 1),
                opacity 0.2s ease;
  }
  body.panel-collapsed .side {
    flex-basis: 0;
    opacity: 0;
    pointer-events: none;
  }
}

@media (max-width: 900px) {
  /* 手机屏幕最贵的是高度。原来 HUD 折三行（logo / 记分牌 / 模式切换）吃掉
     一百多像素，罐子被压矮，几颗球就顶到警戒线。
     现在改成：HUD 脱离布局流，变成画布顶上一条 40px 的薄浮层，只留
     得分 + 音效 + 暂停；logo 和模式切换收进底部抽屉。 */
  .hud {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 30;
    flex-wrap: nowrap;
    gap: 8px;
    padding: calc(6px + env(safe-area-inset-top, 0px)) 10px 6px;
    background: linear-gradient(180deg, rgba(19, 8, 38, 0.92), rgba(19, 8, 38, 0.55) 68%, rgba(19, 8, 38, 0));
    border-bottom: 0;
    box-shadow: none;
    backdrop-filter: blur(10px) saturate(1.05);
    pointer-events: none;
  }
  .hud > * { pointer-events: auto; }
  .hud-left { display: none; }          /* logo 整块收掉 */
  .hud-center { display: none; }        /* 模式切换挪进抽屉 */
  /* 得分贴左上（游戏 HUD 的惯常位置），操作按钮贴右上，中间自然空出来 */
  .hud-right { margin-left: 0; width: 100%; gap: 6px; justify-content: space-between; }

  .scoreboard { padding: 2px 6px 3px 10px; gap: 6px; border-radius: 12px; }
  .score-k { font-size: 9px; margin-bottom: 1px; }
  .score-v { font-size: 20px; text-shadow: 0 1px 0 rgba(122, 62, 0, 0.45); }
  .mini-v { font-size: 12px; }
  .score-toggle { width: 20px; height: 20px; font-size: 11px; }
  .icon-btn { padding: 6px 8px; font-size: 12px; }

  /* 顶部让出浮层高度（浮层约 40px + 状态栏），底部让出抽屉把手 + 手机横条 */
  .stage {
    flex-direction: column;
    padding: calc(44px + env(safe-area-inset-top, 0px)) 8px calc(44px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }

  .side {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    flex: none;
    /* 抽屉里原来是横排 + 横向滚动 —— 一屏根本放不下四张卡，
       滑到中间时两边都被裁掉，看着像「坏了」。
       改成换行网格：所有卡片一屏可见，内容再多也只在抽屉内部纵向滚。 */
    flex-direction: row;
    flex-wrap: wrap;
    align-content: flex-start;
    overflow-x: hidden;
    overflow-y: auto;
    max-height: 72vh;
    gap: 10px;
    padding: 38px 12px calc(14px + env(safe-area-inset-bottom, 0px));
    margin: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.13);
    border-radius: 20px 20px 0 0;
    background: linear-gradient(180deg, rgba(30, 15, 58, 0.97), rgba(16, 7, 34, 0.99));
    box-shadow: 0 -18px 46px rgba(6, 2, 18, 0.62);
    /* 收起时只露出把手那一小条（把手 36px + 2px 余量） */
    transform: translateY(calc(100% - 40px));
    transition: transform 0.32s cubic-bezier(0.22, 0.9, 0.28, 1);
    -webkit-overflow-scrolling: touch;
  }
  body.panel-open .side { transform: translateY(0); }
  .drawer-handle { display: flex; }

  /* 抽屉第一格：模式切换（从 HUD 挪下来，省高度），独占一行 */
  .drawer-top {
    display: flex;
    flex: 0 0 100%;
    align-items: center;
    gap: 8px;
  }
  .drawer-top .mode-switch { padding: 3px; gap: 3px; }
  .drawer-top .mode-switch button { font-size: 12px; padding: 6px 14px; }

  /* 两列网格：目标 + 道具并排，手感滑块和合并链各占一整行 */
  .side .card { flex: 1 1 calc(50% - 5px); min-width: 0; }
  .card-feel, .card-chain { flex-basis: 100%; }
  .card-feel { min-width: 0; }
  .card-chain { min-width: 0; }
  .card-keys { display: none; }
  .chain { flex-direction: row; flex-wrap: wrap; }
  .chain-item { padding: 2px 4px; }

  /* 移动端不需要这个按钮 —— 底部抽屉把手本身就是开关，
     HUD 一排放不下第三个按钮 */
  .panel-toggle { display: none; }
}

@media (max-width: 560px) {
  .logo-text small { display: none; }
  .icon-btn { padding: 7px 9px; font-size: 11px; }
  .hud-btns { gap: 6px; }
  .mode-switch button { font-size: 12px; padding: 6px 13px; }
  .score-v { font-size: 22px; }
  .score-k, .mini-k { font-size: 9px; }
  .stat-grid { grid-template-columns: repeat(3, 1fr); }
  .hint b { font-size: 15px; }
  .hint span { font-size: 11.5px; }
}
