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

html, body {
  height: 100%;
  overflow: hidden;
  background: #cdeeff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  color: #3a2a4a;
  -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(255, 255, 255, 0.75);
  border: 1px solid rgba(255,255,255,0.9);
  backdrop-filter: blur(6px);
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  color: #6a3f8a;
  box-shadow: 0 4px 14px rgba(120, 90, 180, 0.18);
}
.hud-chip.gold { color: #e0669a; }
.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(255,255,255,0.75);
  border: 1px solid rgba(255,255,255,0.9);
  color: #6a3f8a;
  display: grid; place-items: center;
  text-decoration: none;
  font-size: 18px; font-weight: 700;
  box-shadow: 0 4px 14px rgba(120, 90, 180, 0.18);
}

/* ---------- 通用面板/屏幕 ---------- */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 18px;
  background: radial-gradient(120% 90% at 50% 0%, rgba(255,220,240,0.75), rgba(180,220,255,0.85));
  backdrop-filter: blur(3px);
}
.panel {
  width: 100%;
  max-width: 380px;
  max-height: 92vh;
  overflow-y: auto;
  background: linear-gradient(165deg, #fff8fd, #fdeefc);
  border: 1px solid rgba(255,255,255,0.9);
  border-radius: 26px;
  padding: 22px 20px 24px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(150, 110, 190, 0.35);
}

.title-badge, .caught-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 5px 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffd3ec, #cfeaff);
  color: #7a3f9d;
}
.caught-badge {
  background: linear-gradient(90deg, #ffb3c6, #ffd8a8);
  color: #7a2b3a;
}

.game-title {
  margin: 12px 0 4px;
  font-size: 38px;
  letter-spacing: 1px;
  background: linear-gradient(90deg, #ff8fc7, #7fd6ff);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 4px 22px rgba(180,140,255,0.25);
}
.game-sub { color: #7a5f92; font-size: 14px; line-height: 1.6; margin-bottom: 16px; }

.how {
  text-align: left;
  background: rgba(160,120,220,0.06);
  border: 1px solid rgba(160,120,220,0.14);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 18px;
}
.how-row { font-size: 13.5px; color: #5f4877; padding: 5px 0; display: flex; gap: 10px; align-items: baseline; }
.how-row span { min-width: 78px; display: inline-block; }
.how-row b { color: #e0669a; margin-right: 4px; }

.big-btn {
  width: 100%;
  border: none;
  border-radius: 16px;
  padding: 15px;
  font-size: 19px;
  font-weight: 800;
  color: #5a2a52;
  background: linear-gradient(180deg, #ffd6ec, #ff9fc9);
  box-shadow: 0 8px 22px rgba(255,140,190,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: #9a86ae; }

/* ---------- 结束界面 ---------- */
.over-title { margin: 12px 0 16px; font-size: 26px; }
.result-row { display: flex; gap: 10px; margin-bottom: 12px; }
.result-box {
  flex: 1;
  background: rgba(160,120,220,0.07);
  border: 1px solid rgba(160,120,220,0.14);
  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; color: #5f4877; }
.result-box.hi { background: linear-gradient(180deg, rgba(255,159,201,0.22), rgba(255,210,236,0.1)); border-color: rgba(255,159,201,0.4); }
.result-box.hi b { color: #e0669a; }
.rb-label { font-size: 11px; color: #9a86ae; }
.rb-unit { font-size: 11px; color: #9a86ae; }
.best-line { min-height: 18px; font-size: 13px; color: #e0669a; margin-bottom: 14px; font-weight: 700; }
.over-actions { display: flex; flex-direction: column; gap: 10px; }
.ghost-btn {
  display: block;
  text-decoration: none;
  color: #7a5f92;
  border: 1px solid rgba(160,120,220,0.25);
  border-radius: 14px;
  padding: 12px;
  font-weight: 700;
  font-size: 15px;
}

/* ---------- 排行榜 ---------- */
.leaderboard { margin-top: 16px; text-align: left; }
.lb-title { font-size: 12px; color: #9a86ae; 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(160,120,220,0.05); }
.lb-row.me { background: rgba(255,159,201,0.18); }
.lb-rank { width: 22px; font-weight: 800; color: #e0669a; text-align: center; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #5f4877; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; color: #5f4877; }

/* ---------- 触屏按钮 ---------- */
#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.7);
  background: rgba(255,255,255,0.5);
  color: #6a3f8a; font-size: 22px; font-weight: 800;
  backdrop-filter: blur(4px);
  touch-action: none;
}
.tp:active { background: rgba(255,159,201,0.55); transform: scale(0.96); }
.tp-jump {
  width: 84px; height: 84px;
  font-size: 22px;
  background: rgba(255,159,201,0.45);
  border-color: rgba(255,159,201,0.7);
}

.caught-badge.win {
  background: linear-gradient(90deg, #b8f0c8, #fff3b0);
  color: #2a6a3a;
}

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