* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  background: #05060a;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #f2f3ff;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#game-root {
  position: fixed;
  inset: 0;
  overflow: hidden;
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
}

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  padding: max(12px, env(safe-area-inset-top)) 14px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  z-index: 5;
}
.hud-left { display: flex; gap: 8px; }
.hud-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(8, 10, 20, 0.62);
  border: 1px solid rgba(255,255,255,0.14);
  backdrop-filter: blur(6px);
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
}
.hud-chip.gold { color: #ffd54a; }
.chip-ico { font-size: 15px; }
.chip-unit { font-size: 12px; opacity: 0.7; margin-left: 1px; }
.hud-back {
  pointer-events: auto;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(8,10,20,0.62);
  border: 1px solid rgba(255,255,255,0.14);
  color: #fff;
  display: grid; place-items: center;
  text-decoration: none;
  font-size: 18px; font-weight: 700;
}

/* ---------- 抓捕进度条 ---------- */
#catch-wrap {
  position: absolute;
  left: 14px; right: 14px;
  bottom: max(14px, env(safe-area-inset-bottom));
  z-index: 5;
  pointer-events: none;
  display: flex; align-items: center; gap: 10px;
}
.catch-label { font-size: 13px; font-weight: 800; color: #ff7a7a; white-space: nowrap; text-shadow: 0 1px 4px #000; }
.catch-bar {
  flex: 1;
  height: 12px;
  border-radius: 999px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  overflow: hidden;
}
#catch-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, #33d17a, #ffd23f 55%, #ff3b3b);
  transition: width 0.12s linear;
}

/* ---------- 通用面板/屏幕 ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: radial-gradient(120% 90% at 50% 0%, rgba(20,24,48,0.55), rgba(3,4,8,0.82));
  backdrop-filter: blur(3px);
}
.panel {
  width: 100%;
  max-width: 380px;
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(165deg, #191c2e, #0d0f1a);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 22px;
  padding: 22px 20px 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
}

.title-badge, .caught-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 5px 14px;
  border-radius: 999px;
  background: repeating-linear-gradient(45deg, #ffcf33 0 12px, #1a1a1a 12px 24px);
  color: #1a1a1a;
  -webkit-text-stroke: 0.4px #1a1a1a;
  text-shadow: 0 1px 0 rgba(255,255,255,0.4);
}
.caught-badge {
  background: repeating-linear-gradient(45deg, #ff4b4b 0 12px, #1a1a1a 12px 24px);
  color: #fff;
  -webkit-text-stroke: 0;
  text-shadow: 0 1px 3px #000;
}

.game-title {
  margin: 12px 0 4px;
  font-size: 40px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #ff8f3f, #ffd23f);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 4px 22px rgba(255,150,60,0.25);
}
.game-sub { color: #c7cbe6; font-size: 14px; line-height: 1.6; margin-bottom: 16px; }

.how {
  text-align: left;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.how-row { font-size: 13.5px; color: #d7daf0; padding: 5px 0; display: flex; gap: 10px; align-items: baseline; }
.how-row span { min-width: 62px; display: inline-block; }
.how-row b { color: #ffd23f; margin-right: 4px; }

.big-btn {
  width: 100%;
  border: none;
  border-radius: 14px;
  padding: 15px;
  font-size: 19px;
  font-weight: 800;
  color: #1a1200;
  background: linear-gradient(180deg, #ffd23f, #ff9f2e);
  box-shadow: 0 8px 22px rgba(255,160,50,0.4);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}
.big-btn:active { transform: translateY(2px) scale(0.99); filter: brightness(1.05); }

.mobile-tip { margin-top: 10px; font-size: 12px; color: #8b8fb0; }

/* ---------- 结束界面 ---------- */
.over-title { margin: 12px 0 16px; font-size: 26px; }
.result-row { display: flex; gap: 10px; margin-bottom: 12px; }
.result-box {
  flex: 1;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.09);
  border-radius: 14px;
  padding: 12px 6px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.result-box b { font-size: 24px; font-variant-numeric: tabular-nums; }
.result-box.hi { background: linear-gradient(180deg, rgba(255,210,63,0.18), rgba(255,160,46,0.08)); border-color: rgba(255,200,60,0.35); }
.result-box.hi b { color: #ffd23f; }
.rb-label { font-size: 11px; color: #9fa3c4; }
.rb-unit { font-size: 11px; color: #9fa3c4; }
.best-line { min-height: 18px; font-size: 13px; color: #ffd23f; margin-bottom: 14px; font-weight: 700; }
.over-actions { display: flex; flex-direction: column; gap: 10px; }
.ghost-btn {
  display: block;
  text-decoration: none;
  color: #c7cbe6;
  border: 1px solid rgba(255,255,255,0.16);
  border-radius: 14px;
  padding: 12px;
  font-weight: 700;
  font-size: 15px;
}

/* ---------- 排行榜 ---------- */
.leaderboard { margin-top: 16px; text-align: left; }
.lb-title { font-size: 12px; color: #9fa3c4; letter-spacing: 1px; margin-bottom: 6px; text-align: center; }
.lb-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 9px; font-size: 13.5px;
}
.lb-row:nth-child(even) { background: rgba(255,255,255,0.035); }
.lb-row.me { background: rgba(255,210,63,0.14); }
.lb-rank { width: 22px; font-weight: 800; color: #ffd23f; text-align: center; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #dfe2f5; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- 触屏按钮 ---------- */
#touch-pad {
  position: absolute;
  inset: auto 0 0 0;
  bottom: max(48px, calc(env(safe-area-inset-bottom) + 34px));
  padding: 0 18px;
  display: flex; justify-content: space-between; align-items: center;
  z-index: 6;
  pointer-events: none;
}
.tp-side { display: flex; gap: 14px; pointer-events: none; }
.tp {
  pointer-events: auto;
  width: 66px; height: 66px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.2);
  background: rgba(10,12,24,0.42);
  color: #fff; font-size: 22px; font-weight: 800;
  backdrop-filter: blur(4px);
  touch-action: none;
}
.tp:active { background: rgba(255,210,63,0.4); transform: scale(0.96); }
.tp-jump {
  width: 84px; height: 84px;
  font-size: 22px;
  background: rgba(255,160,46,0.32);
  border-color: rgba(255,200,90,0.5);
}

.caught-badge.win {
  background: repeating-linear-gradient(45deg, #33d17a 0 12px, #0d3a22 12px 24px);
  color: #fff; -webkit-text-stroke: 0; text-shadow: 0 1px 3px #000;
}

@media (hover: none) and (pointer: coarse) {
  #touch-pad:not(.hidden) { display: flex; }
}
