* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #1a2a3a;
  font-family: "PingFang SC", "Microsoft YaHei", "Segoe UI", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none; touch-action: none; }
canvas { display: block; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10;
  color: #fff; text-shadow: 0 2px 6px rgba(0,0,0,.6); }
.score { position: absolute; top: 18px; left: 22px; font-size: 34px; font-weight: 800;
  background: rgba(0,0,0,.35); padding: 8px 18px; border-radius: 14px;
  backdrop-filter: blur(4px); letter-spacing: 1px; }
.combo { position: absolute; top: 80px; left: 22px; font-size: 26px; font-weight: 900;
  color: #ffd166; display: none; text-shadow: 0 0 12px rgba(255,209,102,.8); }
.timer { position: absolute; top: 18px; right: 22px; font-size: 30px; font-weight: 700;
  background: rgba(0,0,0,.35); padding: 8px 20px; border-radius: 14px;
  backdrop-filter: blur(4px); font-variant-numeric: tabular-nums; }
.timer.low { color: #ff6b6b; animation: pulse 1s infinite; }
@keyframes pulse { 50% { transform: scale(1.08); } }
.goal { position: absolute; top: 72px; right: 22px; font-size: 16px;
  background: rgba(0,0,0,.3); padding: 6px 14px; border-radius: 12px; }
.sprint { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  width: 220px; text-align: center; font-size: 13px; opacity: .9; }
.sprint .bar { height: 10px; background: rgba(0,0,0,.4); border-radius: 6px;
  overflow: hidden; margin-top: 6px; border: 1px solid rgba(255,255,255,.25); }
.sprint .fill { height: 100%; width: 100%; border-radius: 6px;
  background: linear-gradient(90deg, #ffd166, #ff9f43); transition: width .1s linear; }
.hint { position: absolute; bottom: 26px; left: 50%; transform: translateX(-50%);
  font-size: 13px; color: rgba(255,255,255,.85); background: rgba(0,0,0,.3);
  padding: 6px 14px; border-radius: 20px; white-space: nowrap; }
#itemBars { position: absolute; bottom: 84px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 10px; }
.itemBar { min-width: 120px; text-align: center; font-size: 13px; font-weight: 700;
  background: rgba(0,0,0,.4); border-radius: 10px; padding: 5px 10px;
  border: 1px solid rgba(255,255,255,.25); }
.itemBar .bar { height: 6px; background: rgba(255,255,255,.25); border-radius: 4px;
  overflow: hidden; margin-top: 4px; }
.itemBar .fill { height: 100%; background: #7dd3fc; width: 100%; }

/* ---------- 覆盖层（菜单/结算/暂停） ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; display: flex;
  align-items: center; justify-content: center; background: rgba(10,18,28,.55);
  backdrop-filter: blur(6px); }
.panel { background: linear-gradient(160deg, #fffdf5, #ffe8c9);
  border-radius: 24px; padding: 36px 48px; text-align: center;
  box-shadow: 0 24px 80px rgba(0,0,0,.5); max-width: 620px; max-height: 92vh; overflow-y: auto; }
.panel h1 { font-size: 42px; margin-bottom: 6px; }
.panel .sub { color: #a05a00; font-weight: 700; margin-bottom: 14px; font-size: 17px; }
.panel p { color: #5a4632; line-height: 1.9; font-size: 15px; margin-bottom: 8px; }
.panel .keys { display: inline-block; background: #3a4a5a; color: #fff;
  padding: 2px 10px; border-radius: 8px; font-weight: 700; margin: 0 2px; }
.btn { margin: 8px 6px 0; font-size: 19px; font-weight: 800; color: #fff; border: none;
  cursor: pointer; padding: 12px 36px; border-radius: 40px;
  background: linear-gradient(135deg, #ff9f43, #ff6b2b);
  box-shadow: 0 8px 24px rgba(255,107,43,.45); transition: transform .12s, box-shadow .12s; }
.btn:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 12px 30px rgba(255,107,43,.6); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: linear-gradient(135deg, #64748b, #475569);
  box-shadow: 0 8px 24px rgba(71,85,105,.45); }
.btn.small { font-size: 15px; padding: 8px 22px; }
.hidden { display: none !important; }
.final-score { font-size: 56px; font-weight: 900; color: #ff6b2b; margin: 4px 0; }
.stat-line { font-size: 14px; color: #7a6248; margin: 2px 0; }
.foot { margin-top: 14px; font-size: 12px; color: #b39a7a; }

/* 模式/难度/皮肤选择 */
.sel-row { display: flex; gap: 10px; justify-content: center; margin: 10px 0; flex-wrap: wrap; }
.sel { background: #fff; border: 2px solid #e5d5bd; color: #5a4632; font-size: 15px;
  font-weight: 700; padding: 10px 18px; border-radius: 14px; cursor: pointer;
  transition: all .15s; }
.sel:hover { border-color: #ff9f43; }
.sel.on { border-color: #ff6b2b; background: #fff3e0; color: #d9660f; }
.skin { width: 74px; height: 74px; border-radius: 16px; border: 3px solid #e5d5bd;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  font-size: 30px; margin: 4px; transition: all .15s; position: relative; }
.skin:hover { transform: scale(1.05); }
.skin.on { border-color: #ff6b2b; box-shadow: 0 0 0 3px rgba(255,107,43,.25); }
.skin.locked { opacity: .5; cursor: not-allowed; }
.skin .cost { position: absolute; font-size: 11px; background: #3a4a5a; color: #ffd166;
  padding: 1px 7px; border-radius: 8px; margin-top: 46px; }

/* 成就 */
#achList { text-align: left; margin: 12px 0; }
.ach { display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin: 6px 0;
  background: #fff; border-radius: 12px; border: 2px solid #e5d5bd; font-size: 14px; }
.ach .ic { font-size: 24px; }
.ach.done { border-color: #ffd166; background: #fffbe8; }
.ach .desc { flex: 1; color: #5a4632; }
.ach .st { color: #b39a7a; font-size: 12px; }

/* 成就解锁 toast */
#toast { position: fixed; top: 18px; left: 50%; transform: translateX(-50%) translateY(-80px);
  background: linear-gradient(135deg, #ffd166, #ff9f43); color: #5a3d00; font-weight: 900;
  padding: 12px 26px; border-radius: 30px; z-index: 40; font-size: 17px;
  box-shadow: 0 10px 30px rgba(255,159,67,.5); transition: transform .3s ease; }
#toast.show { transform: translateX(-50%) translateY(0); }

/* 连击飘字 */
.float-num { position: fixed; z-index: 30; font-weight: 900; color: #ffd166;
  font-size: 30px; text-shadow: 0 2px 8px rgba(0,0,0,.6); pointer-events: none;
  animation: floatUp .8s ease-out forwards; }
@keyframes floatUp { from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-60px) scale(1.3); } }

/* 倒计时低血条红晕 */
#lowVignette { position: fixed; inset: 0; z-index: 9; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(255,40,40,.35));
  animation: vignPulse 1s infinite; }
@keyframes vignPulse { 50% { opacity: .4; } }

/* 触屏摇杆 */
#touch { position: fixed; inset: 0; z-index: 15; display: none; pointer-events: none; }
#stick { position: absolute; width: 110px; height: 110px; border-radius: 50%;
  background: rgba(255,255,255,.12); border: 2px solid rgba(255,255,255,.3);
  pointer-events: none; }
#stick .knob { position: absolute; left: 50%; top: 50%; width: 48px; height: 48px;
  margin: -24px 0 0 -24px; border-radius: 50%; background: rgba(255,255,255,.35); }
#btnSprint { position: absolute; right: 26px; bottom: 30px; width: 86px; height: 86px;
  border-radius: 50%; background: rgba(255,107,43,.5); border: 2px solid rgba(255,255,255,.5);
  color: #fff; font-size: 16px; font-weight: 800; pointer-events: auto; }
#btnPause { position: absolute; right: 26px; top: 26px; width: 46px; height: 46px;
  border-radius: 12px; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.3);
  color: #fff; font-size: 20px; pointer-events: auto; }
