/* =========================================================================
   《茶杯犬跑酷 / Cupdog Dash》— UI 样式
   奶油白 + 薄荷 + 蜜桃 + 玫瑰 + 金 / 大圆角 / 毛玻璃 / 柔和多层阴影
   无外部字体、无外部图片，所有图形均由 CSS 或内联 SVG 绘制。
   ========================================================================= */

:root {
  --cream: #fff8ec;
  --cream-2: #fff1dd;
  --cream-3: #fbe3cb;
  --ink: #4a3f39;
  --ink-2: #6d5c5119;
  --ink-soft: rgba(74, 63, 57, 0.62);
  --ink-faint: rgba(74, 63, 57, 0.16);
  --mint: #5ec2a6;
  --mint-deep: #3fa98c;
  --mint-soft: #d9f2ea;
  --peach: #ffab8f;
  --peach-deep: #f08a68;
  --rose: #e9879d;
  --rose-deep: #d76a83;
  --gold: #f0bd63;
  --gold-deep: #d99f3f;
  --cocoa: #8a5a3b;
  --cookie: #e2ab5c;
  --cookie-dark: #b5733a;
  --chip: #74431f;
  --fur: #ffffff;
  --fur-shade: #eef1f7;
  --ear: #fff5f7;

  --glass: rgba(255, 248, 236, 0.7);
  --glass-strong: rgba(255, 250, 242, 0.88);
  --stroke: rgba(255, 255, 255, 0.72);

  --sh-1: 0 1px 2px rgba(122, 84, 58, 0.1);
  --sh-2: 0 4px 10px rgba(122, 84, 58, 0.12), 0 1px 2px rgba(122, 84, 58, 0.08);
  --sh-3: 0 12px 26px rgba(122, 84, 58, 0.16), 0 3px 8px rgba(122, 84, 58, 0.1);
  --sh-4: 0 24px 54px -14px rgba(122, 84, 58, 0.34), 0 8px 18px rgba(122, 84, 58, 0.12);

  --r-sm: 14px;
  --r-md: 18px;
  --r-lg: 24px;
  --r-xl: 28px;

  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 0.72, 0.24, 1);

  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  --font-num: ui-rounded, "SF Pro Rounded", -apple-system, "PingFang SC",
    "Segoe UI", sans-serif;
}

/* ---------------------------------------------------------------- 基础 */
*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
  text-rendering: optimizeLegibility;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#app {
  position: fixed;
  inset: 0;
  overflow: hidden;
  isolation: isolate;
  background: radial-gradient(120% 90% at 50% 0%, #fffdf7 0%, var(--cream) 42%, #fbe8d4 100%);
}

#app > canvas,
#app canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  /* 全屏手势：禁用浏览器默认的滚动/缩放，否则滑动会被吃掉 */
  touch-action: none;
  -ms-touch-action: none;
}

/* 覆盖层默认不接收指针事件 */
#hud-root,
#ui-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

#hud-root {
  z-index: 5;
}

#ui-root {
  z-index: 20;
}

/* 可交互元素单独开启 */
button,
.btn,
.toggle {
  pointer-events: auto;
  font-family: inherit;
  cursor: pointer;
  border: 0;
  background: none;
  color: inherit;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

/* =========================================================================
   HUD
   ========================================================================= */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) calc(env(safe-area-inset-right, 0px) + 18px)
    10px calc(env(safe-area-inset-left, 0px) + 18px);
  pointer-events: none;
  transition: opacity 0.24s var(--ease-out), transform 0.24s var(--ease-out);
}

.hud.hidden {
  opacity: 0;
  transform: translateY(-12px);
}

.hud-left,
.hud-right,
.hud-powerups {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: 0;
}

.hud-left {
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}

/* ---- 分数 ---- */
.hud-score {
  display: flex;
  align-items: baseline;
  gap: 8px;
  max-width: 100%;
  min-width: 0;
  padding: 6px 16px 6px 14px;
  border-radius: var(--r-md);
  background: var(--glass);
  border: 1px solid var(--stroke);
  box-shadow: var(--sh-2), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
  backdrop-filter: blur(14px) saturate(1.15);
}

.hud-score-label {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--ink-soft);
  text-transform: uppercase;
  transform: translateY(-1px);
}

.hud-score-val {
  font-family: var(--font-num);
  font-size: 34px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-shadow: 0 1px 0 #fff, 0 2px 0 rgba(240, 189, 99, 0.35), 0 6px 12px rgba(122, 84, 58, 0.16);
  min-width: 2ch;
  display: inline-block;
  transform-origin: 20% 70%;
  transition: color 0.3s var(--ease-out);
}

.hud-score-val.bump {
  animation: num-bump 0.34s var(--ease-pop);
}

.hud-mult {
  display: none;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.01em;
  color: #fff;
  background: linear-gradient(160deg, var(--gold), var(--rose));
  box-shadow: 0 3px 8px rgba(217, 106, 131, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}

.hud-mult.on {
  display: inline-flex;
  animation: pop-in 0.3s var(--ease-pop);
}

/* ---- 金币 / 距离 / 茶点 ---- */
.hud-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.hud-coins,
.hud-dist,
.hud-teas {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 12px 0 8px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  box-shadow: var(--sh-1), inset 0 1px 0 rgba(255, 255, 255, 0.9);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-size: 14px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.hud-coins {
  padding-left: 7px;
  transition: transform 0.2s var(--ease-pop);
}

.hud-teas.off {
  display: none;
}

.hud-coins.bump {
  animation: coin-bump 0.36s var(--ease-pop);
}

.hud-coins-val,
.hud-dist-val {
  font-variant-numeric: tabular-nums;
  min-width: 1.4ch;
}

.hud-dist {
  color: var(--ink-soft);
  font-weight: 700;
}

.hud-dist .unit {
  font-size: 11px;
  font-weight: 800;
  opacity: 0.72;
  letter-spacing: 0.04em;
}

/* 纯 CSS 饼干图标 */
.coin-ico {
  position: relative;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 26%, #f8d89a 0%, var(--cookie) 48%, var(--cookie-dark) 100%);
  box-shadow:
    inset 0 -2px 3px rgba(116, 67, 31, 0.34),
    inset 0 2px 2px rgba(255, 255, 255, 0.6),
    0 2px 4px rgba(140, 90, 40, 0.28);
}

.coin-ico::before {
  content: "";
  position: absolute;
  left: 26%;
  top: 24%;
  width: 3.5px;
  height: 3.5px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 28%, #8a5a3b 0%, #74431f 72%, #5c3316 100%);
  box-shadow:
    6px 2px 0 -0.2px var(--chip),
    1px 7px 0 -0.6px #5e3618,
    7px 8px 0 -0.6px var(--chip),
    3px 11px 0 -1.1px #5e3618,
    9px 4px 0 -1.2px var(--chip);
  opacity: 0.92;
}

.coin-ico.big {
  width: 22px;
  height: 22px;
}

/* 茶点（小茶杯）图标 */
.cup-ico {
  position: relative;
  width: 13px;
  height: 11px;
  border-radius: 2px 2px 6px 6px;
  background: linear-gradient(180deg, #fffdf7, #e6d7c2);
  box-shadow: inset 0 0 0 1px rgba(164, 138, 110, 0.55), inset 0 -1px 2px rgba(122, 84, 58, 0.24),
    0 1px 2px rgba(122, 84, 58, 0.2);
}

.cup-ico::after {
  content: "";
  position: absolute;
  right: -4.5px;
  top: 2px;
  width: 5px;
  height: 5px;
  border: 1.5px solid #b79a78;
  border-left-color: transparent;
  border-radius: 50%;
}

/* ---- 道具条 ---- */
.hud-powerups {
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  max-width: 46vw;
}

.hud-powerups.bump {
  animation: num-bump 0.42s var(--ease-pop);
}

.powerup-chip {
  --c: var(--mint);
  --p: 100;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 12px 0 5px;
  border-radius: 999px;
  background: var(--glass-strong);
  border: 1px solid var(--stroke);
  box-shadow: var(--sh-2), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(14px) saturate(1.2);
  backdrop-filter: blur(14px) saturate(1.2);
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
  transform-origin: 80% 50%;
  animation: chip-in 0.36s var(--ease-pop) both;
  will-change: transform, opacity;
}

.powerup-chip::after {
  /* 彩色外发光 */
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: 0 0 0 2px rgba(94, 194, 166, 0.28), 0 6px 14px rgba(94, 194, 166, 0.2);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--c) 45%, transparent),
    0 6px 14px color-mix(in srgb, var(--c) 32%, transparent);
  opacity: 0.9;
  z-index: -1;
}

.powerup-chip.leaving {
  animation: chip-out 0.2s var(--ease-out) both;
}

.powerup-chip .pu-ring {
  position: relative;
  flex: 0 0 auto;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #fffdf7;
}

.powerup-chip .ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(
    from -90deg,
    var(--c) calc(var(--p) * 1%),
    rgba(74, 63, 57, 0.17) 0
  );
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 4px), #000 calc(100% - 3.5px));
}

.powerup-chip .pu-ico {
  position: relative;
  width: 14px;
  height: 14px;
  display: block;
  color: var(--c);
  filter: drop-shadow(0 1px 1px rgba(74, 63, 57, 0.22));
}

.powerup-chip .chip-time {
  min-width: 2.1ch;
  font-size: 12.5px;
  color: var(--ink);
}

.powerup-chip.low .chip-time {
  color: var(--rose-deep);
  animation: pulse-soft 0.7s ease-in-out infinite;
}

@keyframes chip-in {
  0% {
    opacity: 0;
    transform: translateX(16px) scale(0.7);
  }
  60% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes chip-out {
  0% {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateX(10px) scale(0.72);
  }
}

@keyframes pulse-soft {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.45;
  }
}

@keyframes num-bump {
  0% {
    transform: scale(1);
  }
  35% {
    transform: scale(1.14);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes coin-bump {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.16) rotate(-4deg);
  }
  65% {
    transform: scale(0.97) rotate(2deg);
  }
  100% {
    transform: scale(1);
  }
}

/* ---- 连击弹出 ---- */
.combo-pop {
  position: absolute;
  left: 50%;
  top: 41%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  font-family: var(--font-num);
  font-size: 44px;
  font-weight: 900;
  letter-spacing: -0.04em;
  color: #efa24f;
  text-shadow:
    0 2px 0 #b9762f,
    0 5px 0 #94591f,
    0 12px 22px rgba(150, 90, 40, 0.42);
  opacity: 0;
  white-space: nowrap;
}

.combo-pop.play {
  animation: combo-in 0.9s var(--ease-pop) both;
}

@keyframes combo-in {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5) rotate(-6deg);
  }
  22% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.12) rotate(2deg);
  }
  45% {
    transform: translate(-50%, -50%) scale(1) rotate(-1deg);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -92%) scale(0.96);
  }
}

/* ---- Toast ---- */
.toast-layer {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 96px);
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  z-index: 8;
  width: max-content;
  max-width: 86vw;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.9);
  border: 1px solid var(--stroke);
  box-shadow: var(--sh-3), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  -webkit-backdrop-filter: blur(16px) saturate(1.2);
  backdrop-filter: blur(16px) saturate(1.2);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--ink);
  white-space: nowrap;
  animation: toast-in 0.36s var(--ease-pop) both;
}

.toast.out {
  animation: toast-out 0.42s var(--ease-out) both;
}

.toast .toast-sub {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
}

.toast .toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 3px rgba(94, 194, 166, 0.22);
  flex: 0 0 auto;
}

@keyframes toast-in {
  0% {
    opacity: 0;
    transform: translateY(-14px) scale(0.88);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-out {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-10px) scale(0.94);
  }
}

/* ---- 受击红边 ---- */
.hit-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  box-shadow:
    inset 0 0 80px 8px rgba(233, 110, 100, 0.5),
    inset 0 0 22px 2px rgba(214, 70, 70, 0.4);
  background: radial-gradient(
    120% 90% at 50% 50%,
    transparent 56%,
    rgba(226, 96, 88, 0.22) 100%
  );
}

.hit-vignette.on {
  animation: hit-flash 0.5s var(--ease-out) both;
}

@keyframes hit-flash {
  0% {
    opacity: 0;
  }
  14% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.hud.shake {
  animation: shake 0.4s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* 面板全局鼓励性闪一下（捡到道具） */
.power-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(
    80% 60% at 50% 8%,
    rgba(240, 189, 99, 0.4),
    transparent 62%
  );
}

.power-glow.on {
  animation: power-glow 0.7s var(--ease-out) both;
}

@keyframes power-glow {
  0% {
    opacity: 0;
  }
  22% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

/* 飞向计分板的饼干 */
.coin-fly {
  position: absolute;
  left: 50%;
  top: 58%;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, #f8d89a 0%, var(--cookie) 48%, var(--cookie-dark) 100%);
  box-shadow:
    inset 0 -2px 3px rgba(116, 67, 31, 0.34),
    inset 0 2px 2px rgba(255, 255, 255, 0.6),
    0 3px 8px rgba(140, 90, 40, 0.3);
  pointer-events: none;
  opacity: 0;
  animation: coin-fly 0.62s var(--ease-out) both;
}

@keyframes coin-fly {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.4);
  }
  20% {
    opacity: 1;
    transform: translate(calc(-50% + var(--dx, 0px) * 0.15), -34px) scale(1.05);
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--dx, -120px)), var(--dy, -280px)) scale(0.42);
  }
}

/* ---- 桌面键位提示 ---- */
.key-hint {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
  transform: translateX(-50%);
  display: none;
  align-items: center;
  gap: 10px;
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(255, 248, 236, 0.56);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: var(--sh-1);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-soft);
  letter-spacing: 0.01em;
  white-space: nowrap;
  pointer-events: none;
}

.key-hint kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 5px;
  margin: 0 2px;
  border-radius: 6px;
  background: #fffdf7;
  border: 1px solid rgba(122, 84, 58, 0.16);
  box-shadow: 0 1.5px 0 rgba(122, 84, 58, 0.16);
  font-family: var(--font);
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
  text-align: center;
}

.key-hint .sep {
  opacity: 0.4;
}

/* =========================================================================
   触屏层 v3 —— 无按钮，全屏手势
   屏幕上没有任何操作控件；只有首次几局会浮现一次手势提示，随后彻底消失。
   每次手势识别成功，在对应边缘闪一层极淡的光作为反馈。
   ========================================================================= */
.touch-controls {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 7;
}

/* ---- 手势提示（不是按钮，纯展示，不接收指针事件） ---- */
.gesture-hint {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 18%);
  transform: translate(-50%, 12px) scale(0.96);
  display: grid;
  gap: 9px;
  padding: 16px 22px 14px;
  border-radius: 22px;
  background: rgba(255, 250, 242, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.52);
  box-shadow:
    0 10px 28px rgba(74, 63, 57, 0.12),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  -webkit-backdrop-filter: blur(10px) saturate(1.1);
  backdrop-filter: blur(10px) saturate(1.1);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.42s ease, transform 0.42s var(--ease-out), visibility 0.42s;
  pointer-events: none;
}

.touch-controls.learn .gesture-hint {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, 0) scale(1);
}

.gh-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.gh-text {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--ink);
  white-space: nowrap;
}

.gh-tip {
  margin: 4px 0 0;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--ink-soft);
  text-align: center;
  white-space: nowrap;
}

/* 用纯 CSS 画箭头，不依赖图标字体 */
.gh-arrow {
  width: 13px;
  height: 13px;
  border-top: 2.6px solid var(--peach-deep);
  border-left: 2.6px solid var(--peach-deep);
  border-radius: 2px 0 0 0;
  flex: none;
}

.gh-arrow.l { transform: rotate(-45deg); }
.gh-arrow.r { transform: rotate(135deg); }
.gh-arrow.u { transform: rotate(45deg); border-color: var(--mint-deep); }
.gh-arrow.d { transform: rotate(225deg); border-color: var(--mint-deep); }

.touch-controls.learn .gh-arrow.u {
  animation: gh-bob-up 1.5s ease-in-out infinite;
}

.touch-controls.learn .gh-arrow.d {
  animation: gh-bob-down 1.5s ease-in-out infinite;
}

@keyframes gh-bob-up {
  0%, 100% { transform: rotate(45deg) translate(0, 0); }
  50% { transform: rotate(45deg) translate(2px, 2px); }
}

@keyframes gh-bob-down {
  0%, 100% { transform: rotate(225deg) translate(0, 0); }
  50% { transform: rotate(225deg) translate(2px, 2px); }
}

.touch-controls.locked .gesture-hint {
  opacity: 0;
  visibility: hidden;
}

/* ---- 手势边缘泛光：唯一的手感反馈，没有实体按钮 ---- */
.gesture-fx {
  position: fixed;
  inset: 0;
  display: none;
  pointer-events: none;
  z-index: 6;
  overflow: hidden;
}

.gesture-fx.on {
  display: block;
}

.gesture-fx i {
  position: absolute;
  opacity: 0;
  transition: opacity 0.26s ease;
  will-change: opacity;
}

.gesture-fx i.on {
  opacity: 1;
}

.gf-l {
  left: 0; top: 0; bottom: 0; width: 26%;
  background: linear-gradient(90deg, rgba(255, 178, 148, 0.5), rgba(255, 178, 148, 0));
}
.gf-r {
  right: 0; top: 0; bottom: 0; width: 26%;
  background: linear-gradient(270deg, rgba(255, 178, 148, 0.5), rgba(255, 178, 148, 0));
}
.gf-u {
  top: 0; left: 0; right: 0; height: 20%;
  background: linear-gradient(180deg, rgba(120, 214, 188, 0.42), rgba(120, 214, 188, 0));
}
.gf-d {
  bottom: 0; left: 0; right: 0; height: 20%;
  background: linear-gradient(0deg, rgba(120, 214, 188, 0.42), rgba(120, 214, 188, 0));
}

@media (hover: hover) and (pointer: fine) {
  .key-hint {
    display: flex;
  }
}

@media (hover: none), (pointer: coarse) {
  .touch-controls {
    display: block;
  }
  .key-hint {
    display: none;
  }
}

/* JS 兜底：某些 Android WebView 的 hover / pointer 媒体查询不准 */
.touch-controls.is-touch {
  display: block;
}

body.has-touch .key-hint {
  display: none;
}

/* 横屏：提示上移一点，别压住角色的脚下 */
@media (hover: none) and (orientation: landscape), (pointer: coarse) and (orientation: landscape) {
  .gesture-hint {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 12%);
    padding: 11px 18px 10px;
    gap: 6px;
  }

  .gh-text {
    font-size: 12px;
  }
}

/* =========================================================================
   屏幕 / 界面
   ========================================================================= */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 22px) 20px
    calc(env(safe-area-inset-bottom, 0px) + 22px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.26s var(--ease-out), visibility 0.26s;
  overflow: hidden;
}

.screen.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* 背景柔光 */
.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(70% 52% at 50% 8%, rgba(255, 255, 255, 0.86), transparent 70%),
    radial-gradient(60% 50% at 12% 88%, rgba(94, 194, 166, 0.24), transparent 72%),
    radial-gradient(60% 52% at 88% 82%, rgba(233, 135, 157, 0.22), transparent 72%),
    linear-gradient(180deg, rgba(255, 248, 236, 0.62), rgba(255, 238, 216, 0.72));
  -webkit-backdrop-filter: blur(6px) saturate(1.05);
  backdrop-filter: blur(6px) saturate(1.05);
  pointer-events: none;
}

.screen.pause::before {
  background:
    radial-gradient(70% 60% at 50% 40%, rgba(255, 252, 245, 0.16), transparent 72%),
    linear-gradient(180deg, rgba(48, 39, 34, 0.46), rgba(40, 32, 28, 0.58));
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}

.screen-inner {
  position: relative;
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  animation: fade-in 0.4s var(--ease-out) both;
}

/* ---- 面板 ---- */
.panel {
  position: relative;
  width: 100%;
  padding: 22px 24px;
  border-radius: var(--r-lg);
  background: linear-gradient(170deg, rgba(255, 253, 247, 0.94), rgba(255, 245, 231, 0.84));
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--sh-4), inset 0 1px 0 #fff;
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  backdrop-filter: blur(18px) saturate(1.15);
}

.panel.flush {
  background: none;
  border: 0;
  box-shadow: none;
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  padding: 0;
}

.screen.show .panel,
.screen.show .screen-inner > .panel {
  animation: pop-in 0.5s var(--ease-pop) both;
}

/* ---- 标题 ---- */
.title {
  margin: 0;
  font-size: clamp(34px, 7.6vw, 54px);
  font-weight: 900;
  line-height: 1.06;
  letter-spacing: -0.02em;
  text-align: center;
  background: linear-gradient(180deg, #ffd79a 0%, #f5ac67 52%, #e88a5c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: transparent;
  filter: drop-shadow(0 2px 0 #c9805a) drop-shadow(0 4px 0 #a9663f)
    drop-shadow(0 10px 12px rgba(140, 88, 55, 0.32));
  animation: float 4.6s ease-in-out infinite;
}

.subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--mint-deep);
  text-transform: uppercase;
  opacity: 0.92;
  text-align: center;
}

.subtitle.rose {
  color: var(--rose-deep);
}

/* ---- 按钮 ---- */
.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 26px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.02em;
  color: var(--ink);
  background: #fffdf7;
  box-shadow: var(--sh-2), inset 0 1px 0 #fff;
  transition: transform 0.12s var(--ease-out), box-shadow 0.16s ease, background 0.16s ease;
  overflow: hidden;
}

.btn:hover {
  background: #fff;
  box-shadow: var(--sh-3), inset 0 1px 0 #fff;
}

.btn:active {
  transform: scale(0.955);
  box-shadow: var(--sh-1), inset 0 2px 6px rgba(122, 84, 58, 0.16);
}

.btn:focus-visible {
  outline: 3px solid rgba(94, 194, 166, 0.55);
  outline-offset: 3px;
}

.btn.primary {
  min-height: 56px;
  padding: 0 44px;
  font-size: 18px;
  letter-spacing: 0.06em;
  color: #fff;
  background: linear-gradient(165deg, #74d3b7 0%, var(--mint) 46%, var(--mint-deep) 100%);
  box-shadow:
    0 10px 22px rgba(63, 169, 140, 0.42),
    0 3px 8px rgba(63, 169, 140, 0.3),
    inset 0 2px 0 rgba(255, 255, 255, 0.55),
    inset 0 -3px 8px rgba(28, 106, 86, 0.22);
  text-shadow: 0 1px 2px rgba(24, 88, 72, 0.3);
}

.btn.primary::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.42), transparent 46%);
  pointer-events: none;
}

.btn.primary:hover {
  background: linear-gradient(165deg, #82ddc1 0%, #66cbae 46%, #46b092 100%);
  box-shadow:
    0 14px 28px rgba(63, 169, 140, 0.46),
    0 3px 8px rgba(63, 169, 140, 0.32),
    inset 0 2px 0 rgba(255, 255, 255, 0.6);
}

.btn.primary:active {
  box-shadow: 0 4px 12px rgba(63, 169, 140, 0.4), inset 0 3px 10px rgba(28, 106, 86, 0.28);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.5);
  color: var(--ink);
  box-shadow: inset 0 0 0 1.5px rgba(74, 63, 57, 0.12), 0 2px 6px rgba(122, 84, 58, 0.08);
}

.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1.5px rgba(74, 63, 57, 0.18), var(--sh-2);
}

.btn.warm {
  color: #fff;
  background: linear-gradient(165deg, #ffc3ae, var(--peach) 50%, var(--peach-deep));
  box-shadow: 0 8px 18px rgba(240, 138, 104, 0.36), inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

.btn-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  width: 100%;
  margin-top: 4px;
}

.btn-row .btn {
  flex: 0 1 auto;
}

.btn-row.stack {
  flex-direction: column;
  align-items: stretch;
}

.btn-row.stack .btn {
  width: 100%;
}

/* ---- 徽章 / 标签 ---- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #fff;
  background: linear-gradient(140deg, var(--mint), var(--mint-deep));
  box-shadow: 0 4px 10px rgba(63, 169, 140, 0.32);
}

.badge.gold {
  background: linear-gradient(140deg, var(--gold), var(--gold-deep));
  box-shadow: 0 4px 12px rgba(217, 159, 63, 0.38);
}

.badge.new-best {
  padding: 6px 18px;
  font-size: 13px;
  letter-spacing: 0.18em;
  background: linear-gradient(140deg, #ffd88f, var(--gold) 45%, #e08f5c);
  box-shadow: 0 6px 18px rgba(224, 143, 92, 0.44), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  animation: pulse 1.5s ease-in-out infinite;
}

.best-tag {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  right: calc(env(safe-area-inset-right, 0px) + 18px);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 15px;
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--sh-2), inset 0 1px 0 #fff;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
  z-index: 3;
  pointer-events: auto;
}

.best-tag b {
  font-family: var(--font-num);
  font-size: 15px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--ink);
}

/* ---- 数据统计 ---- */
.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  width: 100%;
  margin: 4px 0 2px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 11px 6px;
  border-radius: var(--r-sm);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.9), 0 2px 6px rgba(122, 84, 58, 0.06);
}

.stat .stat-k {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink-soft);
  white-space: nowrap;
}

.stat .stat-v {
  font-family: var(--font-num);
  font-size: 21px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}

.stat .stat-v small {
  font-size: 11px;
  font-weight: 800;
  opacity: 0.5;
  margin-left: 1px;
  letter-spacing: 0;
}

.stat.accent .stat-v {
  color: var(--mint-deep);
}

.stat.accent-gold .stat-v {
  color: var(--gold-deep);
}

/* ---- 开始界面 ---- */
.start-inner {
  gap: 10px;
  max-width: 480px;
}

.logo-wrap {
  position: relative;
  width: 132px;
  height: 132px;
  display: grid;
  place-items: center;
  margin-bottom: -6px;
  animation: float 4.2s ease-in-out infinite;
}

.logo-wrap::before {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(255, 255, 255, 0.95), rgba(255, 232, 202, 0.5) 58%, transparent 72%);
  box-shadow: 0 18px 34px -10px rgba(180, 126, 88, 0.3);
  z-index: 0;
}

.logo-dog {
  position: relative;
  width: 100%;
  height: 100%;
  z-index: 1;
  overflow: visible;
  filter: drop-shadow(0 8px 12px rgba(160, 108, 74, 0.22));
}

.logo-shadow {
  position: absolute;
  left: 50%;
  bottom: -14px;
  width: 84px;
  height: 14px;
  transform: translateX(-50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(160, 108, 74, 0.26), transparent);
  animation: shadow-breathe 4.2s ease-in-out infinite;
}

@keyframes shadow-breathe {
  0%,
  100% {
    transform: translateX(-50%) scale(1);
    opacity: 0.9;
  }
  50% {
    transform: translateX(-50%) scale(0.86);
    opacity: 0.6;
  }
}

.howto {
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--r-md);
}

.howto-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}

.howto-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.howto-item .keys {
  display: inline-flex;
  gap: 3px;
  flex: 0 0 auto;
}

.howto-item kbd {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 5px;
  border-radius: 7px;
  background: #fffdf7;
  border: 1px solid rgba(122, 84, 58, 0.14);
  box-shadow: 0 2px 0 rgba(122, 84, 58, 0.14);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 900;
  color: var(--ink);
}

.howto-item.expand {
  grid-column: 1 / -1;
}

.howto-item .cookie-mini {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 26%, #f8d89a, var(--cookie) 50%, var(--cookie-dark));
  box-shadow: inset 0 -2px 3px rgba(116, 67, 31, 0.3);
}

/* ---- 结算界面 ---- */
.over-inner {
  max-width: 460px;
}

.over-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}

.score-big {
  font-family: var(--font-num);
  font-size: clamp(52px, 15vw, 76px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: -0.05em;
  font-variant-numeric: tabular-nums;
  text-align: center;
  color: var(--ink);
  text-shadow: 0 2px 0 #fff, 0 6px 0 rgba(240, 189, 99, 0.4), 0 14px 24px rgba(160, 108, 74, 0.18);
  margin: 2px 0 6px;
}

.score-big.new-best {
  color: var(--gold-deep);
  text-shadow: 0 2px 0 #fff, 0 6px 0 rgba(255, 214, 140, 0.7), 0 14px 26px rgba(217, 159, 63, 0.32);
}

.reason {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
  margin: 8px 0 12px;
  letter-spacing: 0.01em;
}

.reason b {
  color: var(--rose-deep);
}

.new-best-row {
  display: flex;
  justify-content: center;
  min-height: 26px;
  margin: 8px 0 12px;
}

/* ---- 暂停界面 ---- */
.pause-inner {
  max-width: 380px;
  gap: 12px;
}

.pause-title {
  margin: 0;
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-align: center;
  color: #fffdf7;
  text-shadow: 0 2px 0 rgba(58, 44, 36, 0.42), 0 12px 26px rgba(30, 22, 18, 0.5);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--r-md);
  background: rgba(255, 255, 255, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.85);
}

.toggle-label {
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: var(--ink);
}

.toggle {
  position: relative;
  width: 52px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: rgba(74, 63, 57, 0.18);
  box-shadow: inset 0 2px 4px rgba(74, 63, 57, 0.16);
  transition: background 0.2s ease;
}

.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(180deg, #fff, #f6ece0);
  box-shadow: 0 2px 5px rgba(74, 63, 57, 0.28);
  transition: transform 0.24s var(--ease-pop);
}

.toggle[aria-pressed="true"] {
  background: linear-gradient(140deg, #74d3b7, var(--mint-deep));
}

.toggle[aria-pressed="true"]::after {
  transform: translateX(22px);
}

.toggle:active::after {
  width: 28px;
}

/* =========================================================================
   动画
   ========================================================================= */
@keyframes float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
}

@keyframes pop-in {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.94);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  15% {
    transform: translate3d(-6px, 2px, 0) rotate(-0.4deg);
  }
  30% {
    transform: translate3d(5px, -2px, 0) rotate(0.35deg);
  }
  45% {
    transform: translate3d(-4px, 1px, 0) rotate(-0.25deg);
  }
  60% {
    transform: translate3d(3px, -1px, 0);
  }
  80% {
    transform: translate3d(-2px, 1px, 0);
  }
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 6px 18px rgba(224, 143, 92, 0.44), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  }
  50% {
    transform: scale(1.07);
    box-shadow: 0 10px 26px rgba(224, 143, 92, 0.58), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  }
}

/* =========================================================================
   响应式
   ========================================================================= */
@media (max-width: 780px) {
  body {
    font-size: 14px;
  }

  .hud {
    gap: 8px;
    padding: calc(env(safe-area-inset-top, 0px) + 10px) calc(env(safe-area-inset-right, 0px) + 12px)
      8px calc(env(safe-area-inset-left, 0px) + 12px);
  }

  .hud-score {
    padding: 4px 12px 4px 10px;
    border-radius: var(--r-sm);
  }

  .hud-score-val {
    font-size: 26px;
  }

  .hud-score-label {
    font-size: 9px;
    letter-spacing: 0.12em;
  }

  .hud-coins,
  .hud-dist,
  .hud-teas {
    height: 26px;
    padding: 0 10px 0 6px;
    font-size: 12.5px;
    gap: 5px;
  }

  .coin-ico {
    width: 15px;
    height: 15px;
  }

  .powerup-chip {
    height: 31px;
    padding: 0 9px 0 4px;
    font-size: 11.5px;
    gap: 5px;
  }

  .powerup-chip .pu-ring {
    width: 22px;
    height: 22px;
  }

  .powerup-chip .pu-ico {
    width: 13px;
    height: 13px;
  }

  .hud-powerups {
    max-width: 52vw;
    gap: 6px;
  }

  .panel {
    padding: 18px 16px;
    border-radius: var(--r-md);
  }

  .title {
    font-size: clamp(30px, 8.6vw, 40px);
  }

  .subtitle {
    font-size: 10.5px;
    letter-spacing: 0.34em;
    text-indent: 0.34em;
  }

  .logo-wrap {
    width: 104px;
    height: 104px;
  }

  .btn {
    min-height: 42px;
    padding: 0 20px;
    font-size: 14px;
  }

  .btn.primary {
    min-height: 50px;
    padding: 0 32px;
    font-size: 16.5px;
  }

  .howto-list {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .howto-item {
    font-size: 12.5px;
  }

  .stats {
    gap: 6px;
  }

  .stat {
    padding: 9px 4px;
  }

  .stat .stat-v {
    font-size: 18px;
  }

  .stat .stat-k {
    font-size: 10px;
  }

  .combo-pop {
    font-size: 34px;
  }

  .toast-layer {
    top: calc(env(safe-area-inset-top, 0px) + 96px);
  }

  .toast {
    font-size: 12.5px;
    padding: 7px 15px;
  }

  .gesture-hint {
    bottom: calc(env(safe-area-inset-bottom, 0px) + 15%);
    padding: 13px 18px 12px;
    gap: 7px;
  }

  .gh-text {
    font-size: 12.5px;
  }

  .score-big {
    font-size: clamp(46px, 16vw, 64px);
  }

  .pause-title {
    font-size: 25px;
  }
}

/* 横屏手机 / 矮屏：压缩 HUD 与界面 */
/* 窄屏：茶点次要指标让位给道具条 */
@media (max-width: 560px) {
  .hud-teas {
    display: none;
  }

  .hud-meta {
    gap: 6px;
    flex-wrap: nowrap;
  }

  .hud-coins,
  .hud-dist {
    height: 25px;
    padding: 0 9px 0 6px;
    font-size: 12px;
  }

  .hud-score {
    padding: 4px 10px;
  }

  .hud-score-label {
    display: none;
  }

  .hud-score-val {
    font-size: 23px;
  }

  .hud-powerups {
    max-width: 47vw;
    gap: 5px;
  }
}

@media (max-height: 520px) {
  .hud {
    padding-top: calc(env(safe-area-inset-top, 0px) + 6px);
    gap: 6px;
  }

  .hud-left {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }

  .hud-score {
    padding: 2px 10px;
  }

  .hud-score-val {
    font-size: 22px;
  }

  .hud-score-label {
    display: none;
  }

  .hud-meta {
    gap: 6px;
  }

  .hud-coins,
  .hud-dist,
  .hud-teas {
    height: 24px;
    font-size: 12px;
  }

  .powerup-chip {
    height: 28px;
  }

  .powerup-chip .pu-ring {
    width: 20px;
    height: 20px;
  }

  .panel {
    padding: 12px 14px;
    border-radius: var(--r-md);
  }

  .screen {
    padding: 8px 12px;
  }

  .screen-inner {
    gap: 6px;
    max-width: 620px;
  }

  .title {
    font-size: 26px;
  }

  .logo-wrap {
    width: 64px;
    height: 64px;
    margin-bottom: 0;
  }

  .subtitle {
    font-size: 9px;
    letter-spacing: 0.3em;
  }

  .howto {
    padding: 8px 12px;
  }

  .howto-list {
    grid-template-columns: repeat(2, 1fr);
    gap: 4px 10px;
  }

  .howto-item {
    font-size: 12px;
  }

  .btn.primary {
    min-height: 42px;
    font-size: 15px;
    padding: 0 28px;
  }

  .btn {
    min-height: 36px;
    font-size: 13px;
    padding: 0 16px;
  }

  .score-big {
    font-size: 40px;
  }

  .stat .stat-v {
    font-size: 16px;
  }

  .toast-layer {
    top: calc(env(safe-area-inset-top, 0px) + 56px);
  }

  .combo-pop {
    font-size: 28px;
    top: 36%;
  }
}

@media (prefers-reduced-motion: reduce) {
  .title,
  .logo-wrap,
  .logo-shadow,
  .badge.new-best {
    animation: none !important;
  }
  .screen.show .panel {
    animation: fade-in 0.2s ease both;
  }
}


/* ============================================================
   集成层补充：桌面端首屏采用「左文案 / 右角色」的构图
   —— 3D 角色由 canvas 渲染在右侧，面板左移让出视觉焦点
   ============================================================ */
@media (min-width: 960px) {
  .screen[data-screen="start"] .screen-inner {
    margin-right: 26%;
  }
  .screen[data-screen="start"]::before {
    background:
      radial-gradient(40% 56% at 22% 48%, rgba(255, 251, 244, 0.96), rgba(255, 248, 236, 0.52) 50%, rgba(255, 248, 236, 0.06) 74%),
      radial-gradient(40% 40% at 88% 30%, rgba(255, 236, 214, 0.18), transparent 70%),
      linear-gradient(180deg, rgba(255, 248, 236, 0.28), rgba(255, 238, 216, 0.12));
    -webkit-backdrop-filter: saturate(1.04);
    backdrop-filter: saturate(1.04);
  }
}


/* 竖屏主界面：3D 角色在上半屏，面板贴底 */
@media (max-aspect-ratio: 85/100) {
  .screen[data-screen="start"] {
    align-items: flex-end;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 4vh);
  }

  .screen[data-screen="start"] .start-inner {
    gap: 10px;
  }

  .screen[data-screen="start"] .logo-wrap {
    display: none;
  }

  .screen[data-screen="start"]::before {
    background: linear-gradient(
      180deg,
      rgba(255, 248, 236, 0) 0%,
      rgba(255, 248, 236, 0) 54%,
      rgba(255, 246, 235, 0.72) 68%,
      rgba(255, 238, 216, 0.92) 100%
    );
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

/* =========================================================================
   特技 / 连锁 / 茶会冲刺
   ========================================================================= */

/* ---- 冲刺：屏幕边缘泛光 ---- */
.rush-glow {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.45s ease;
  z-index: 1;
}

.rush-glow::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(56% 40% at 0% 0%, rgba(240, 189, 99, 0.5), transparent 68%),
    radial-gradient(56% 40% at 100% 0%, rgba(233, 135, 157, 0.42), transparent 68%),
    radial-gradient(56% 44% at 0% 100%, rgba(94, 194, 166, 0.34), transparent 70%),
    radial-gradient(56% 44% at 100% 100%, rgba(240, 189, 99, 0.38), transparent 70%);
}

.rush-glow.on {
  opacity: 1;
  animation: rush-pulse 1.8s ease-in-out infinite;
}

.rush-glow.pulse {
  animation: rush-flash 0.7s var(--ease-out) both;
}

@keyframes rush-pulse {
  0%, 100% { transform: scale(1); opacity: 0.82; }
  50% { transform: scale(1.025); opacity: 1; }
}

@keyframes rush-flash {
  0% { opacity: 0; }
  30% { opacity: 1; }
  100% { opacity: 1; }
}

/* ---- 冲刺：顶部横幅 ---- */
.rush-banner {
  position: absolute;
  top: 21%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px 7px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(240, 189, 99, 0.95), rgba(233, 135, 157, 0.9));
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  box-shadow: 0 8px 20px rgba(210, 150, 60, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.6);
  pointer-events: none;
  overflow: hidden;
  z-index: 9;
}

.rush-banner.off {
  display: none;
}

.rush-title {
  position: relative;
  z-index: 1;
}

.rush-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  display: block;
  width: 100%;
  height: 3px;
  background: rgba(255, 255, 255, 0.9);
  transform-origin: left center;
  transform: scaleX(1);
}

/* ---- 特技弹字 ---- */
.trick-layer {
  position: absolute;
  left: 0;
  right: 0;
  top: 33%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 8;
}

.trick-pop {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  padding: 6px 15px;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.88);
  border: 1.5px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 20px rgba(74, 63, 57, 0.16), inset 0 1px 0 rgba(255, 255, 255, 0.7);
  color: var(--ink);
  white-space: nowrap;
  /* 不用 both：即使动画没跑（后台标签 / 降级渲染），弹字也必须可见，
     1.2s 后由 JS 移除节点 */
  animation: trick-pop 1.2s var(--ease-out);
}

.trick-pop.big {
  background: linear-gradient(135deg, rgba(255, 247, 226, 0.97), rgba(255, 226, 186, 0.95));
  border-color: rgba(240, 189, 99, 0.85);
  box-shadow: 0 10px 26px rgba(210, 150, 60, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.trick-name {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.trick-pts {
  font-size: 13px;
  font-weight: 800;
  color: var(--mint-deep);
}

.trick-pop.big .trick-pts {
  color: var(--gold-deep);
}

.trick-mul {
  font-size: 11px;
  font-weight: 800;
  color: var(--rose-deep);
  opacity: 0.85;
}

@keyframes trick-pop {
  0% { opacity: 0; transform: translateY(16px) scale(0.82); }
  16% { opacity: 1; transform: translateY(0) scale(1.06); }
  28% { transform: translateY(0) scale(1); }
  72% { opacity: 1; transform: translateY(-6px) scale(1); }
  100% { opacity: 0; transform: translateY(-30px) scale(0.96); }
}

/* ---- 连锁 ---- */
.chain-chip {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgba(255, 250, 242, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.82);
  box-shadow: 0 2px 8px rgba(122, 84, 58, 0.12);
  font-size: 11px;
  font-weight: 800;
  color: var(--ink);
  overflow: hidden;
  pointer-events: none;
}

.chain-chip.off {
  display: none;
}

.chain-word {
  opacity: 0.6;
  letter-spacing: 0.08em;
}

.chain-num {
  font-size: 12.5px;
  color: var(--rose-deep);
  font-variant-numeric: tabular-nums;
}

.chain-chip.hot {
  background: linear-gradient(135deg, rgba(255, 244, 222, 0.94), rgba(255, 222, 192, 0.9));
  border-color: rgba(240, 189, 99, 0.7);
}

.chain-chip.hot .chain-num {
  color: var(--gold-deep);
}

.chain-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  display: block;
  width: 100%;
  height: 2.5px;
  background: linear-gradient(90deg, var(--mint), var(--gold));
  transform-origin: left center;
  transform: scaleX(0);
}

/* ---- 结算第二行统计 ---- */
.stats-2 {
  margin-top: 6px;
}

.stats-2 .stat-k {
  font-size: 10.5px;
}

@media (max-width: 560px) {
  .trick-layer {
    top: 29%;
    gap: 4px;
  }

  .trick-pop {
    padding: 5px 11px;
    gap: 6px;
  }

  .trick-name {
    font-size: 12.5px;
  }

  .trick-pts {
    font-size: 12px;
  }

  .rush-banner {
    font-size: 11px;
    padding: 5px 13px 6px;
  }

  .chain-chip {
    height: 20px;
    font-size: 10px;
  }
}

/* =========================================================================
   每局任务
   ========================================================================= */
.mission-track {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 2px;
  max-width: min(280px, 62vw);
  transition: opacity 0.3s ease;
}

/* 折叠态：只留 3 个圆点，不挡视野 */
.mission-track.collapsed {
  flex-direction: row;
  gap: 6px;
  margin-top: 4px;
}

.mission-track.collapsed .ms-text,
.mission-track.collapsed .ms-val,
.mission-track.collapsed .ms-bar {
  display: none;
}

.ms-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 4px 9px 5px;
  border-radius: 11px;
  background: rgba(255, 250, 242, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 2px 8px rgba(122, 84, 58, 0.1);
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  pointer-events: none;
}

.ms-dot {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(74, 63, 57, 0.22);
  box-shadow: inset 0 0 0 1px rgba(74, 63, 57, 0.14);
  transition: background 0.25s ease, transform 0.25s var(--ease-pop);
}

.ms-row.done .ms-dot {
  background: linear-gradient(135deg, var(--gold), var(--gold-deep));
  transform: scale(1.18);
}

.ms-text {
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.86;
}

.ms-row.done .ms-text {
  opacity: 0.5;
  text-decoration: line-through;
  text-decoration-color: rgba(74, 63, 57, 0.28);
}

.ms-val {
  flex: none;
  font-size: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--ink-soft);
}

.ms-row.done .ms-val {
  color: var(--gold-deep);
}

.ms-bar {
  position: absolute;
  left: 0;
  bottom: 0;
  display: block;
  width: 100%;
  height: 2px;
  background: rgba(74, 63, 57, 0.08);
}

.ms-bar > b {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--mint), var(--gold));
  transform-origin: left center;
  transform: scaleX(0);
  transition: transform 0.25s ease;
}

/* =========================================================================
   升级工坊
   ========================================================================= */
.wallet-tag {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 16px);
  left: calc(env(safe-area-inset-left, 0px) + 18px);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.84);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--sh-2), inset 0 1px 0 #fff;
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  font-size: 13px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  z-index: 3;
}

.wallet-tag.shake {
  animation: wallet-shake 0.45s var(--ease-out);
}

@keyframes wallet-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  45% { transform: translateX(4px); }
  70% { transform: translateX(-2px); }
}

/* 金币图标：纯 CSS 画的饼干 */
.coin-mini {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 32% 32%, #8a5a2f 0 1.2px, transparent 1.6px),
    radial-gradient(circle at 66% 44%, #8a5a2f 0 1.2px, transparent 1.6px),
    radial-gradient(circle at 44% 70%, #8a5a2f 0 1.2px, transparent 1.6px),
    radial-gradient(circle at 50% 42%, #f6d79b, #e2ab5c 62%, #c98f45);
  box-shadow: inset 0 0 0 1px rgba(140, 96, 44, 0.35);
  flex: none;
}

.btn-row.sub {
  margin-top: 8px;
}

.btn.small {
  min-height: 34px;
  font-size: 12.5px;
  padding: 0 16px;
}

.upgrade-sheet {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -46%) scale(0.94);
  width: min(360px, calc(100vw - 40px));
  max-height: 72vh;
  overflow-y: auto;
  padding: 16px 16px 18px;
  border-radius: var(--r-lg);
  background: rgba(255, 252, 246, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.9);
  box-shadow: var(--sh-4), inset 0 1px 0 #fff;
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  backdrop-filter: blur(18px) saturate(1.15);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.24s var(--ease-out), transform 0.24s var(--ease-out), visibility 0.24s;
  z-index: 6;
}

.upgrade-sheet.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.us-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 12px;
}

.us-title {
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--ink);
}

.us-sub {
  flex: 1 1 auto;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-soft);
}

.us-close {
  flex: none;
  width: 28px;
  height: 28px;
  min-height: 0;
  padding: 0;
  border-radius: 9px;
  font-size: 13px;
  line-height: 1;
  color: var(--ink-soft);
  background: rgba(74, 63, 57, 0.06);
}

.upgrade-row {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    'top dots'
    'buy buy';
  align-items: center;
  gap: 6px 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(74, 63, 57, 0.06);
}

.upgrade-row:last-child {
  margin-bottom: 0;
}

.ur-top {
  grid-area: top;
  display: flex;
  align-items: baseline;
  gap: 7px;
  min-width: 0;
}

.ur-name {
  font-size: 13px;
  font-weight: 900;
  color: var(--ink);
  white-space: nowrap;
}

.ur-desc {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ur-dots {
  grid-area: dots;
  display: flex;
  gap: 4px;
}

.ur-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(74, 63, 57, 0.14);
}

.ur-dot.on {
  background: linear-gradient(135deg, var(--mint), var(--mint-deep));
}

.ur-buy {
  grid-area: buy;
  min-height: 32px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--ink);
  background: linear-gradient(135deg, var(--gold), #f3cf8d);
  border: 1px solid rgba(255, 255, 255, 0.7);
  box-shadow: 0 3px 10px rgba(210, 150, 60, 0.24);
  transition: transform 0.1s var(--ease-out), opacity 0.18s;
}

.ur-buy:active {
  transform: scale(0.97);
}

.ur-buy.poor {
  opacity: 0.55;
  background: rgba(74, 63, 57, 0.1);
  box-shadow: none;
}

.ur-buy:disabled {
  opacity: 0.45;
  background: rgba(74, 63, 57, 0.08);
  box-shadow: none;
  cursor: default;
}

@media (max-width: 560px) {
  .wallet-tag {
    top: calc(env(safe-area-inset-top, 0px) + 12px);
    left: calc(env(safe-area-inset-left, 0px) + 12px);
    padding: 6px 12px;
    font-size: 12px;
  }

  .mission-track {
    max-width: 70vw;
  }

  .upgrade-sheet {
    max-height: 66vh;
    padding: 14px 13px 15px;
  }
}
