* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: #1b2430; color: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", sans-serif;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}
#stage { position: fixed; inset: 0; overflow: hidden; }
#gl { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

/* ---------- 顶部 HUD ---------- */
.hud-top {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 0;
  pointer-events: none; z-index: 5;
}
.hud-left { display: flex; flex-direction: column; gap: 6px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 10px 0 6px; border-radius: 13px;
  font-size: 12px; font-weight: 700; letter-spacing: .2px;
  background: rgba(18, 26, 38, .55);
  border: 1px solid rgba(255, 255, 255, .18);
  box-shadow: 0 3px 10px rgba(0, 0, 0, .25);
  backdrop-filter: blur(6px);
}
.chip .mp-icon { font-size: 15px; }
.chip.lv { color: #FFD36B; }
.chip.coin { color: #FFC24B; }

.hud-mid { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; padding-top: 2px; }
.level-name {
  font-size: 12px; font-weight: 700; color: #fff;
  padding: 3px 12px; border-radius: 11px;
  background: rgba(18, 26, 38, .55);
  border: 1px solid rgba(255, 255, 255, .16);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .4);
  white-space: nowrap;
}
.bar {
  position: relative; width: min(46vw, 220px); height: 9px; border-radius: 6px;
  background: rgba(10, 16, 24, .6);
  border: 1px solid rgba(255, 255, 255, .2);
  overflow: hidden;
}
.bar-fill {
  position: absolute; inset: 0 auto 0 0; width: 0%;
  background: linear-gradient(90deg, #FFB05C, #FF8A3D 60%, #FF6B2C);
  border-radius: 6px; transition: width .12s linear;
  box-shadow: 0 0 8px rgba(255, 138, 61, .7);
}
.bar-flag {
  position: absolute; top: -3px; right: -2px; font-size: 11px; line-height: 1;
  color: #fff; opacity: .9;
}

.hud-right { display: flex; gap: 6px; pointer-events: auto; }
.icon-btn, .tool-btn {
  width: 34px; height: 34px; border-radius: 11px; border: 1px solid rgba(255, 255, 255, .2);
  background: rgba(18, 26, 38, .55); color: #fff; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .28); backdrop-filter: blur(6px);
  transition: transform .1s ease, background .15s ease;
}
.icon-btn:active, .tool-btn:active { transform: scale(.9); background: rgba(255, 138, 61, .8); }

/* ---------- 左上工具 ---------- */
.hud-tools {
  position: absolute; left: 12px; top: calc(78px + env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 8px; z-index: 5;
}
.tool-btn { width: 36px; height: 36px; border-radius: 12px; }

/* ---------- 速度滑块 ---------- */
.speed-rail {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 5;
}
.speed-label, .speed-val {
  font-size: 10px; font-weight: 700; color: #fff; opacity: .85;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
}
.speed-track {
  position: relative; width: 12px; height: 132px; border-radius: 8px;
  background: rgba(10, 16, 24, .55); border: 1px solid rgba(255, 255, 255, .22);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, .4);
  touch-action: none;
}
.speed-fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 50%;
  border-radius: 8px; background: linear-gradient(180deg, #FFD36B, #FF8A3D);
  box-shadow: 0 0 10px rgba(255, 138, 61, .6);
}
.speed-knob {
  position: absolute; left: 50%; bottom: 50%; width: 26px; height: 26px;
  margin-left: -13px; margin-bottom: -13px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff, #FFD9B8 60%, #FF8A3D);
  border: 2px solid #fff; box-shadow: 0 3px 10px rgba(0, 0, 0, .35);
}

/* ---------- 右侧药水 ---------- */
.hud-potions {
  position: absolute; right: 12px; top: calc(78px + env(safe-area-inset-top));
  display: flex; flex-direction: column; gap: 10px; z-index: 5;
}
.potion {
  position: relative; width: 46px; height: 46px; border-radius: 15px;
  border: 1px solid rgba(255, 255, 255, .24);
  background: linear-gradient(160deg, rgba(255, 138, 61, .9), rgba(214, 84, 30, .92));
  color: #fff; font-size: 22px; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 5px 14px rgba(0, 0, 0, .3), inset 0 1px 0 rgba(255, 255, 255, .35);
  transition: transform .1s ease;
}
.potion:active { transform: scale(.92); }
.potion.on { background: linear-gradient(160deg, #FFD36B, #FF9F2E); box-shadow: 0 0 16px rgba(255, 200, 80, .8); }
.potion-tag {
  position: absolute; right: -3px; top: -5px; font-size: 9px; font-weight: 800;
  background: #fff; color: #E2551F; border-radius: 7px; padding: 1px 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .3);
}
.potion-time {
  position: absolute; bottom: -6px; left: 50%; transform: translateX(-50%);
  font-size: 9px; font-weight: 700; color: #fff; background: rgba(10, 16, 24, .7);
  border-radius: 6px; padding: 0 4px; white-space: nowrap;
}

/* ---------- 轮盘 ---------- */
.joy {
  position: absolute; left: 74px; bottom: calc(26px + env(safe-area-inset-bottom));
  width: 108px; height: 108px; border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, rgba(255, 255, 255, .1), rgba(10, 16, 24, .42));
  border: 1px solid rgba(255, 255, 255, .22);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .3), inset 0 0 18px rgba(0, 0, 0, .25);
  z-index: 6; touch-action: none;
}
.joy-ring {
  position: absolute; inset: 14px; border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, .22);
}
.joy-knob {
  position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px 0 0 -23px;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
  background: radial-gradient(circle at 35% 30%, #FFD9B8, #FF8A3D 65%, #E2551F);
  border: 2px solid rgba(255, 255, 255, .85);
  box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
  transition: transform .06s linear;
}

/* ---------- 冲刺 ---------- */
.dash {
  position: absolute; right: 22px; bottom: calc(30px + env(safe-area-inset-bottom));
  width: 84px; height: 84px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .8);
  background: radial-gradient(circle at 35% 28%, #FFD36B, #FF8A3D 55%, #E2551F);
  color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 1px; box-shadow: 0 8px 20px rgba(226, 85, 31, .5), inset 0 2px 0 rgba(255, 255, 255, .4);
  z-index: 6; overflow: hidden; transition: transform .1s ease;
}
.dash:active { transform: scale(.93); }
.dash .mp-icon { font-size: 26px; }
.dash-txt { font-size: 11px; font-weight: 800; letter-spacing: .5px; }
.dash-cd {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0%;
  background: rgba(10, 16, 24, .45); transition: height .1s linear;
}

/* ---------- 盲盒弹窗 ---------- */
.sheet-mask {
  position: absolute; inset: 0; z-index: 20; display: none;
  align-items: flex-end; justify-content: center;
  background: rgba(8, 12, 18, .5); backdrop-filter: blur(2px);
}
.sheet-mask.show { display: flex; }
.sheet {
  width: 100%; max-width: 520px; padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  border-radius: 22px 22px 0 0;
  background: linear-gradient(180deg, #FFF8F0, #FFEBD8);
  border-top: 2px solid #FFD9B8;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, .35);
  animation: sheetUp .26s cubic-bezier(.2, .9, .3, 1.2);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 12px; }
.sheet-title { font-size: 16px; font-weight: 800; color: #4A2A12; }
.sheet-sub { font-size: 11px; color: #A87A55; }
.slimes { display: flex; gap: 10px; }
.slime {
  flex: 1; border: none; background: transparent; padding: 0;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  transition: transform .12s ease;
}
.slime:active { transform: scale(.94); }
.slime-body {
  width: 100%; aspect-ratio: 1 / 1; max-height: 84px; border-radius: 18px 18px 22px 22px;
  position: relative; box-shadow: inset 0 -8px 0 rgba(0, 0, 0, .12), 0 6px 14px rgba(0, 0, 0, .18);
}
.slime-body::before {
  content: ""; position: absolute; left: 22%; top: 26%; width: 16%; height: 16%;
  border-radius: 50%; background: rgba(255, 255, 255, .9);
  box-shadow: 26% 0 0 rgba(255, 255, 255, .9);
}
.slime-body::after {
  content: ""; position: absolute; left: 50%; top: 52%; width: 34%; height: 12%;
  transform: translateX(-50%); border-radius: 0 0 10px 10px;
  background: rgba(0, 0, 0, .22);
}
.slime.purple .slime-body { background: linear-gradient(160deg, #C9A6FF, #8B5CF6); }
.slime.pink .slime-body { background: linear-gradient(160deg, #FFC0DA, #FF6FA5); }
.slime.green .slime-body { background: linear-gradient(160deg, #B6F09C, #4FC46A); }
.slime-name { font-size: 11px; font-weight: 700; color: #6B4326; }
.sheet-close {
  margin-top: 12px; width: 100%; height: 40px; border-radius: 12px; border: none;
  background: rgba(74, 42, 18, .08); color: #7A5233; font-size: 13px; font-weight: 700;
}
.sheet-close:active { background: rgba(74, 42, 18, .16); }

/* ---------- 通用弹层 ---------- */
.modal-mask {
  position: absolute; inset: 0; z-index: 30; display: none;
  align-items: center; justify-content: center; padding: 20px;
  background: rgba(8, 12, 18, .55); backdrop-filter: blur(3px);
}
.modal-mask.show { display: flex; }
.modal {
  width: 100%; max-width: 340px; padding: 18px;
  border-radius: 20px; background: linear-gradient(180deg, #FFF8F0, #FFEBD8);
  border: 2px solid #FFD9B8; box-shadow: 0 16px 40px rgba(0, 0, 0, .4);
  color: #4A2A12; animation: pop .22s cubic-bezier(.2, .9, .3, 1.3);
}
@keyframes pop { from { transform: scale(.86); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.modal h3 { margin: 0 0 8px; font-size: 17px; font-weight: 800; }
.modal p { margin: 0 0 14px; font-size: 13px; line-height: 1.6; color: #7A5233; }
.modal-row { display: flex; gap: 10px; }
.modal-btn {
  flex: 1; height: 42px; border-radius: 13px; border: none;
  font-size: 14px; font-weight: 800; color: #fff;
  background: linear-gradient(180deg, #FFA95C, #FF8A3D);
  box-shadow: 0 5px 14px rgba(255, 138, 61, .45), inset 0 1px 0 rgba(255, 255, 255, .4);
}
.modal-btn.ghost { background: rgba(74, 42, 18, .1); color: #7A5233; box-shadow: none; }
.modal-btn:active { transform: scale(.96); }
.modal-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }
.modal-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 13px; background: rgba(255, 255, 255, .7);
  border: 1px solid #FFE0C4; font-size: 13px; font-weight: 700;
}
.modal-item .mp-icon { font-size: 18px; color: #FF8A3D; }
.modal-item .val { margin-left: auto; color: #A87A55; font-weight: 700; }

/* ---------- 封面 ---------- */
.cover {
  position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  padding: 20px; background: radial-gradient(circle at 50% 30%, rgba(255, 138, 61, .35), rgba(12, 18, 26, .82) 70%);
  backdrop-filter: blur(4px); transition: opacity .3s ease;
}
.cover.hide { opacity: 0; pointer-events: none; }
.cover-card {
  width: 100%; max-width: 360px; padding: 22px 20px; border-radius: 24px; text-align: center;
  background: linear-gradient(180deg, rgba(255, 250, 244, .97), rgba(255, 233, 214, .97));
  border: 2px solid #FFD9B8; box-shadow: 0 20px 50px rgba(0, 0, 0, .45);
  animation: pop .3s cubic-bezier(.2, .9, .3, 1.3);
}
.cover-badge {
  display: inline-block; padding: 3px 12px; border-radius: 10px; font-size: 11px; font-weight: 800;
  color: #fff; background: linear-gradient(90deg, #FFB05C, #FF8A3D);
  box-shadow: 0 4px 10px rgba(255, 138, 61, .4);
}
.cover-title { margin: 10px 0 6px; font-size: 24px; font-weight: 900; color: #4A2A12; letter-spacing: -.5px; }
.cover-desc { margin: 0 0 14px; font-size: 12.5px; line-height: 1.6; color: #8A5F3D; }
.cover-tips { display: flex; flex-direction: column; gap: 7px; margin-bottom: 16px; }
.cover-tips span {
  display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 12px;
  background: rgba(255, 255, 255, .75); border: 1px solid #FFE0C4;
  font-size: 12px; font-weight: 700; color: #6B4326; text-align: left;
}
.cover-tips .mp-icon { font-size: 17px; color: #FF8A3D; }
.cover-btn {
  width: 100%; height: 50px; border-radius: 16px; border: none; color: #fff;
  font-size: 17px; font-weight: 900; letter-spacing: 1px;
  background: linear-gradient(180deg, #FFB05C, #FF7A2C);
  box-shadow: 0 8px 22px rgba(255, 122, 44, .5), inset 0 2px 0 rgba(255, 255, 255, .45);
}
.cover-btn:active { transform: scale(.97); }

/* ---------- toast ---------- */
.toast {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%) scale(.9);
  padding: 10px 18px; border-radius: 14px; font-size: 13px; font-weight: 800;
  background: rgba(18, 26, 38, .88); color: #fff; border: 1px solid rgba(255, 255, 255, .2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4); opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease; z-index: 50; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }

@media (max-height: 420px) {
  .joy { width: 92px; height: 92px; left: 66px; bottom: calc(18px + env(safe-area-inset-bottom)); }
  .joy-knob { width: 40px; height: 40px; margin: -20px 0 0 -20px; }
  .dash { width: 72px; height: 72px; bottom: calc(20px + env(safe-area-inset-bottom)); }
  .speed-track { height: 100px; }
}
