* { 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%;
}

#flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(circle at 50% 55%, rgba(255,255,255,.9), rgba(255,150,200,.45) 55%, rgba(255,120,180,0) 78%);
  z-index: 4;
}

.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: #b32c62; }
.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.42), rgba(180,220,255,0.58));
  backdrop-filter: blur(2px);
}
.panel {
  position: relative;
  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, #e0468e, #2b9fd4);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 4px 22px rgba(180,140,255,0.25);
}
.game-sub { color: #6b5182; 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: #b32c62; 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); }

.panel-avatar {
  position: absolute;
  top: 13px; left: 13px;
  border: 1px solid rgba(160,120,220,.28);
  background: rgba(255,255,255,.78);
  color: #6a3f8a;
  border-radius: 999px;
  padding: 7px 10px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  min-height: 34px;
  z-index: 2;
}
.panel-avatar:active { background: #fff; }

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

@media (max-height: 900px), (max-width: 480px) {
  .panel { padding: 16px 18px 18px; border-radius: 22px; }
  .game-title { font-size: 31px; margin: 8px 0 2px; }
  .game-sub { font-size: 13px; line-height: 1.45; margin-bottom: 11px; }
  .how { padding: 9px 12px; margin-bottom: 12px; }
  .how-row { font-size: 12.5px; padding: 3px 0; }
  .race-box { margin-top: 8px; }
  .race-join { margin-top: 6px; }
  .mobile-tip { margin-top: 7px; }
  .big-btn { padding: 13px; font-size: 17px; }
}
@media (max-width: 480px) {
  /* leave room for the platform's social buttons in the bottom corner */
  #lb-start { margin-bottom: 40px; }
}

/* ---------- 结束界面 ---------- */
.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: #6b5182; 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: #b32c62; 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 {
  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);
}
/* analogue thumbstick for 3D movement */
.joy {
  pointer-events: auto;
  position: relative;
  width: 112px; height: 112px;
  border-radius: 50%;
  background: rgba(255,255,255,0.24);
  border: 2px solid rgba(255,255,255,0.62);
  backdrop-filter: blur(5px);
  touch-action: none;
  box-shadow: inset 0 0 22px rgba(120,90,180,0.12);
}
.joy-ring {
  position: absolute; inset: 18px;
  border-radius: 50%;
  border: 1.5px dashed rgba(255,255,255,0.55);
}
.joy-knob {
  position: absolute; left: 50%; top: 50%;
  width: 52px; height: 52px; margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,0.95), rgba(255,190,225,0.92));
  border: 1px solid rgba(255,255,255,0.95);
  box-shadow: 0 5px 16px rgba(120,80,160,0.32);
  will-change: transform;
}

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

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

/* ---------- racing together ---------- */
.race-box { margin-top: 12px; }
.race-join { display: flex; gap: 6px; margin-top: 8px; }
.race-join input {
  flex: 1; min-width: 0; border-radius: 12px; padding: 10px 12px;
  border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.9);
  color: #3a2a4a; font-size: 14px; font-family: inherit; text-transform: uppercase;
}
.ghost-btn.small { flex: none; padding: 10px 14px; font-size: 13px; margin-top: 0; }
.race-note { margin-top: 8px; font-size: 12px; color: #6b4a7a; min-height: 16px; line-height: 1.5; }
.race-badge {
  background: rgba(255,255,255,.85); color: #7a3a5a; border-radius: 999px;
  padding: 5px 12px; font-size: 12px; font-weight: 800; margin-right: 8px; white-space: nowrap;
}
.hidden { display: none !important; }

/* ---------- server browser ---------- */
.srv-list { max-height: 46vh; overflow-y: auto; margin-bottom: 12px; display: flex; flex-direction: column; gap: 7px; }
.srv-row {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: rgba(255,255,255,.55); border: 1px solid rgba(255,255,255,.7);
  border-radius: 14px; padding: 10px 12px; text-align: left; cursor: pointer;
  color: #5a3a6a; font-family: inherit;
}
.srv-row:active { background: rgba(255,255,255,.85); }
.srv-main { flex: 1; min-width: 0; }
.srv-main { display: block; }
.srv-name { display: block; font-size: 14px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv-meta { display: block; font-size: 11.5px; opacity: .75; margin-top: 2px; }
.srv-go { flex: none; font-size: 12.5px; font-weight: 800; color: #c23a72; }
.srv-full .srv-go { color: #9a8aa8; }
.srv-empty { text-align: center; font-size: 13px; color: #7a5f92; padding: 18px 8px; }

#race-name { text-transform: none; }

/* Keep the platform's friends / profile buttons clear of JUMP and the stick
   while a run is in progress. They come back on the menu and the results. */
body.playing .fr-fab { display: none !important; }
