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

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

#game-root { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.hidden { display: none !important; }

/* ---------- 顶栏 ---------- */
#topbar {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  background: #131a2e;
  border-bottom: 1px solid rgba(120, 150, 255, 0.18);
}
.tb-btn {
  width: 32px; height: 32px; flex: none;
  border-radius: 9px;
  border: 1px solid rgba(120, 150, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: #eaf0ff; font-size: 16px; cursor: pointer;
}
.tb-title { flex: 1; font-size: 15px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-right { flex: none; }
.tb-chip { font-size: 11.5px; color: rgba(234, 240, 255, 0.7); }

/* ---------- 画面 ---------- */
#view { position: relative; flex: 1; min-height: 0; }
#scene { display: block; width: 100%; height: 100%; }
#scene3d { display: none; width: 100%; height: 100%; touch-action: none; }
body.play3d #scene { display: none; }
body.play3d #scene3d { display: block; }

/* Keep the platform's friends / profile buttons away from JUMP while running. */
body.playing .fr-fab { display: none !important; }

/* The avatar picker sits on the menu, not over the course. */
.panel-avatar {
  position: fixed;
  top: 56px; left: 12px;
  z-index: 25;
  min-height: 34px;
  max-width: calc(100vw - 96px);
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(110, 231, 168, 0.4);
  background: rgba(13, 18, 32, 0.85);
  color: #bff7d6;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.panel-avatar:active { background: rgba(110, 231, 168, 0.2); }

/* ---------- 造关卡工具栏 ---------- */
#build-bar {
  flex: none;
  background: #131a2e;
  border-top: 1px solid rgba(120, 150, 255, 0.18);
  padding: 8px 8px max(8px, env(safe-area-inset-bottom));
}
.palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 5px;
  padding-bottom: 6px;
}
.tool {
  min-width: 0;
  border-radius: 11px;
  border: 1.5px solid rgba(120, 150, 255, 0.25);
  background: rgba(255, 255, 255, 0.05);
  color: #eaf0ff;
  padding: 6px 2px 5px;
  cursor: pointer;
  line-height: 1.2;
}
.tool span { display: block; font-size: 18px; }
.tool i {
  display: block; font-style: normal; font-size: 9px;
  color: rgba(234, 240, 255, 0.65); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tool.on { border-color: #6ee7a8; background: rgba(110, 231, 168, 0.16); }
.tool.on i { color: #6ee7a8; }

.build-actions { display: flex; gap: 6px; margin-top: 4px; }
.sm-btn {
  flex: 1;
  border-radius: 10px;
  border: 1px solid rgba(120, 150, 255, 0.28);
  background: rgba(255, 255, 255, 0.06);
  color: #eaf0ff;
  padding: 9px 4px;
  font-size: 12.5px; font-weight: 700;
  cursor: pointer;
}
.sm-btn.go { border-color: #6ee7a8; color: #0d1220; background: #6ee7a8; }

/* ---------- 触屏按钮 ---------- */
#pad {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 150px;
  padding: 0 18px max(14px, env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: flex-end;
  pointer-events: none;
}
.pad-left { display: flex; gap: 12px; }
.pbtn {
  width: 66px; height: 66px;
  border-radius: 50%;
  border: 1.5px solid rgba(120, 150, 255, 0.4);
  background: rgba(19, 26, 46, 0.72);
  color: #eaf0ff;
  font-size: 20px; font-weight: 700;
  pointer-events: auto;
  cursor: pointer;
  touch-action: none;
}
.pbtn:active { background: rgba(110, 231, 168, 0.4); }
.pbtn.jump { width: 84px; height: 84px; border-color: rgba(110, 231, 168, 0.6); font-size: 17px; }

#play-hud {
  position: absolute;
  top: 8px; left: 50%;
  transform: translateX(-50%);
  display: flex; gap: 12px; align-items: center;
  background: rgba(13, 18, 32, 0.78);
  border: 1px solid rgba(120, 150, 255, 0.28);
  border-radius: 999px;
  padding: 5px 15px;
  font-size: 13px; font-weight: 700;
  font-variant-numeric: tabular-nums;
}
#ph-live { font-size: 11.5px; font-weight: 600; color: #ffd47d; }

/* ---------- 面板 ---------- */
.screen {
  position: absolute; inset: 0;
  display: grid; place-items: center;
  padding: 16px;
  background: radial-gradient(circle at 50% 30%, rgba(30, 44, 82, 0.93), rgba(6, 9, 18, 0.97));
  z-index: 20;
  overflow-y: auto;
}
.panel {
  position: relative;
  width: min(420px, 100%);
  background: linear-gradient(170deg, #1a2340, #101730);
  border: 1px solid rgba(120, 150, 255, 0.25);
  border-radius: 20px;
  padding: 20px 18px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.panel.wide { width: min(480px, 100%); }
.title-badge {
  display: inline-block;
  background: rgba(110, 231, 168, 0.14);
  border: 1px solid rgba(110, 231, 168, 0.5);
  color: #6ee7a8;
  border-radius: 999px; padding: 5px 15px;
  font-size: 13px; font-weight: 700; margin-bottom: 12px;
}
.game-title { font-size: 25px; margin-bottom: 8px; color: #fff; }
.game-sub { font-size: 13px; line-height: 1.75; color: rgba(234, 240, 255, 0.72); margin-bottom: 18px; }
.panel-title { font-size: 19px; margin-bottom: 10px; color: #fff; }

.big-btn {
  width: 100%; border: none; border-radius: 14px;
  padding: 14px; font-size: 16px; font-weight: 800;
  color: #0d1220;
  background-color: #6ee7a8;
  background-image: linear-gradient(160deg, #9bf4c4, #43c98a);
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(67, 201, 138, 0.28);
}
.big-btn:active { transform: translateY(1px); }
.ghost-btn {
  display: block; width: 100%; margin-top: 9px;
  border: 1px solid rgba(120, 150, 255, 0.3);
  border-radius: 13px; padding: 11px;
  font-size: 14px; font-weight: 600;
  color: #eaf0ff; background: transparent; cursor: pointer;
  text-decoration: none;
}
.mobile-tip { margin-top: 12px; font-size: 11.5px; color: rgba(234, 240, 255, 0.62); line-height: 1.6; }

/* 关卡列表 */
.tabs { display: flex; gap: 6px; margin-bottom: 11px; }
.tab {
  flex: 1; border-radius: 999px;
  border: 1px solid rgba(120, 150, 255, 0.28);
  background: transparent; color: rgba(234, 240, 255, 0.7);
  padding: 7px 4px; font-size: 12.5px; font-weight: 700; cursor: pointer;
}
.tab.on { border-color: #6ee7a8; color: #6ee7a8; background: rgba(110, 231, 168, 0.12); }

.obby-list { max-height: 46vh; overflow-y: auto; margin-bottom: 12px; display: flex; flex-direction: column; gap: 7px; }
.obby-row {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(120, 150, 255, 0.2);
  border-radius: 13px;
  padding: 9px 11px;
  text-align: left;
  color: #eaf0ff;
  cursor: pointer;
  width: 100%;
}
.obby-row:active { background: rgba(110, 231, 168, 0.12); }
.obby-main { flex: 1; min-width: 0; }
.obby-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obby-meta { font-size: 11px; color: rgba(234, 240, 255, 0.6); margin-top: 2px; }
.obby-meta .live { color: #ffd47d; font-weight: 700; }
.obby-go { flex: none; font-size: 12px; font-weight: 700; color: #6ee7a8; }
.obby-edit {
  flex: none; border: 1px solid rgba(120,150,255,0.3); background: transparent;
  color: rgba(234,240,255,0.8); border-radius: 8px; padding: 5px 8px; font-size: 11px; cursor: pointer;
}
.list-empty { text-align: center; color: rgba(234, 240, 255, 0.6); padding: 18px 8px; font-size: 13px; }

/* 结算 */
.over-badge {
  display: inline-block;
  background: rgba(110, 231, 168, 0.14);
  border: 1px solid rgba(110, 231, 168, 0.5);
  color: #6ee7a8;
  border-radius: 999px; padding: 5px 15px;
  font-size: 13px; font-weight: 700; margin-bottom: 12px;
}
.over-badge.pb { background: rgba(255, 212, 125, 0.16); border-color: rgba(255, 212, 125, 0.6); color: #ffd47d; }
.over-title { font-size: 21px; margin-bottom: 12px; color: #fff; }
.result-row { display: flex; gap: 10px; margin-bottom: 12px; }
.result-box {
  flex: 1;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(120, 150, 255, 0.2);
  border-radius: 13px; padding: 11px 6px;
}
.result-box.hi { border-color: rgba(110, 231, 168, 0.5); }
.rb-label { display: block; font-size: 11px; color: rgba(234, 240, 255, 0.6); margin-bottom: 3px; }
.result-box b { font-size: 23px; font-variant-numeric: tabular-nums; }
.result-box.hi b { color: #6ee7a8; }
.rb-unit { font-size: 11px; opacity: 0.6; }

.leaderboard { margin-bottom: 14px; text-align: left; font-size: 12.5px; }
.lb-title { font-size: 13px; font-weight: 700; color: #6ee7a8; margin-bottom: 7px; text-align: center; }
.lb-row { display: flex; align-items: center; gap: 8px; padding: 5px 9px; border-radius: 8px; color: rgba(234, 240, 255, 0.85); }
.lb-row:nth-child(odd) { background: rgba(255, 255, 255, 0.04); }
.lb-rank { width: 20px; font-weight: 700; opacity: 0.7; }
.lb-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-val { font-variant-numeric: tabular-nums; font-weight: 700; }
.lb-empty { text-align: center; color: rgba(234, 240, 255, 0.6); padding: 8px; }

.toast {
  position: absolute;
  left: 50%; top: 16%;
  transform: translateX(-50%);
  background: rgba(13, 18, 32, 0.93);
  border: 1px solid rgba(120, 150, 255, 0.42);
  border-radius: 12px;
  padding: 10px 17px;
  font-size: 13.5px; font-weight: 700;
  z-index: 30; pointer-events: none;
  text-align: center; max-width: 84vw;
}
