* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* 顶部提示 toast */
#toast {
  position: fixed;
  top: calc(28px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: 86vw;
  background: rgba(18, 38, 68, 0.94);
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  text-align: center;
  pointer-events: none;
}
#toast[hidden] {
  display: none;
}

html, body {
  height: 100%;
}

body {
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  background: #050a18;
  color: #e8eefc;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  touch-action: manipulation;
}

#app {
  height: 100%;
}

/* 页面容器：手机全屏，电脑居中竖栏 */
.view {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: 0 auto;
  max-width: 480px;
  display: none;
  flex-direction: column;
  background: linear-gradient(175deg, #0d3b63 0%, #0b2f52 52%, #081a33 100%);
  overflow: hidden;
}
.view.active {
  display: flex;
}
@media (min-width: 500px) {
  .view {
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.55);
  }
}

/* ---------- 首页 ---------- */
.home-inner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 30px 26px 40px;
  overflow-y: auto;
}

.title {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 4px;
  background: linear-gradient(120deg, #6fe6ff, #8fb6ff 55%, #ffcf7a);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 0 30px rgba(90, 200, 255, 0.25);
  margin-bottom: 4px;
}

.intro {
  width: 100%;
  max-width: 330px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px 18px;
}
.intro p {
  font-size: 14px;
  line-height: 1.9;
  color: #bcd2ea;
}
.intro p b {
  color: #fff;
  font-weight: 700;
}

.btn {
  border: none;
  width: 100%;
  max-width: 320px;
  padding: 15px 0;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.2s;
}
.btn:active {
  transform: scale(0.98);
}
.btn.primary {
  background: linear-gradient(135deg, #2ac6ff, #5b7bff);
  color: #fff;
  box-shadow: 0 6px 20px rgba(40, 160, 255, 0.35);
}
.btn.ghost {
  background: rgba(255, 255, 255, 0.08);
  color: #cfd8f2;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.btn.ghost:active {
  background: rgba(255, 255, 255, 0.14);
}

.settings-card {
  width: 100%;
  max-width: 320px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 14px 16px;
}
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.set-row + .set-row {
  margin-top: 12px;
}
.set-label {
  font-size: 14px;
  color: #bcd2ea;
  flex: 0 0 auto;
}
.set-toggle {
  width: 72px;
  padding: 8px 0;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  color: #cfd8f2;
  border: 1px solid rgba(255, 255, 255, 0.12);
}
.set-toggle.on {
  background: linear-gradient(135deg, #2ac6ff, #5b7bff);
  color: #fff;
  border: none;
}
.diff-seg {
  display: flex;
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 3px;
}
.diff-seg .seg {
  flex: 1;
  border: none;
  background: transparent;
  color: #9fb6d8;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 0;
  border-radius: 8px;
  cursor: pointer;
}
.diff-seg .seg.active {
  background: rgba(90, 160, 255, 0.28);
  color: #fff;
}

.best-card {
  width: 100%;
  max-width: 320px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  padding: 14px 18px;
}
.best-title {
  font-size: 13px;
  color: #7d9cc0;
  margin-bottom: 8px;
  letter-spacing: 2px;
}
.best-row {
  font-size: 15px;
  color: #fff;
}
.best-empty {
  color: #5b7da0;
  font-size: 13px;
}

/* ---------- 游戏页 ---------- */
#game {
  position: absolute;
  inset: 0;
  display: block;
  touch-action: none;
  cursor: pointer;
}

.hud {
  position: absolute;
  top: calc(10px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 12px;
  pointer-events: none;
  z-index: 5;
}
.hud-cell {
  background: rgba(0, 10, 30, 0.42);
  border-radius: 12px;
  padding: 6px 12px;
  min-width: 76px;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.hud-label {
  display: block;
  font-size: 11px;
  color: #9fc8e8;
  letter-spacing: 1px;
}
.hud-val {
  font-size: 20px;
  font-weight: 800;
  color: #fff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 12px rgba(80, 200, 255, 0.4);
}
.hud-btns {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.hud-btn {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: 50%;
  background: rgba(0, 10, 30, 0.42);
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
.hud-btn:active {
  background: rgba(0, 10, 30, 0.6);
}

/* 半透明摇杆（底部中间） */
#joy {
  position: absolute;
  bottom: calc(22px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.2);
  z-index: 6;
  touch-action: none;
  cursor: grab;
}
#joy-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  margin: -23px 0 0 -23px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.30);
  border: 2px solid rgba(255, 255, 255, 0.55);
  pointer-events: none;
  transition: transform 0.05s;
}

.hint {
  position: absolute;
  top: calc(64px + env(safe-area-inset-top));
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  color: #cfe4f6;
  letter-spacing: 3px;
  text-shadow: 0 1px 6px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.8s;
  pointer-events: none;
  z-index: 4;
}
.hint.show {
  opacity: 1;
}

/* ---------- 遮罩（暂停 / 结算） ---------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 8, 20, 0.62);
}
.overlay[hidden] {
  display: none;
}
.panel {
  width: min(86vw, 320px);
  background: linear-gradient(170deg, #16284a, #0d1b36);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 24px 22px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}
.panel h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: 2px;
}
.panel .btn {
  margin-top: 12px;
  font-size: 16px;
  padding: 13px 0;
}
.over-title {
  color: #ff7a6b;
}
.over-score {
  font-size: 44px;
  font-weight: 800;
  color: #ffd166;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 24px rgba(255, 209, 102, 0.35);
  margin: 14px 0 6px;
}
.over-sub {
  font-size: 14px;
  color: #9fc0de;
  margin-bottom: 8px;
}

/* ---------- 排行榜弹窗 ---------- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 6, 16, 0.72);
  z-index: 50;
  padding: 20px;
}
.modal[hidden] {
  display: none;
}
.modal-card {
  width: 100%;
  max-width: 430px;
  max-height: 82vh;
  background: linear-gradient(170deg, #14254a, #0c1932);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-title {
  font-size: 20px;
  font-weight: 700;
}
.icon-close {
  width: 34px;
  height: 34px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: #cfd8f2;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.tabs {
  display: flex;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  padding: 3px;
  margin-bottom: 10px;
}
.tab {
  flex: 1;
  border: none;
  background: transparent;
  color: #9fb6d8;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 0;
  border-radius: 8px;
  cursor: pointer;
}
.tab.active {
  background: rgba(90, 160, 255, 0.28);
  color: #fff;
}

.skin-tip {
  font-size: 14px;
  color: #bcd2ea;
  line-height: 1.8;
  margin: 6px 0 14px;
}

.lb-note {
  font-size: 12px;
  color: #7d9cc0;
  margin-bottom: 8px;
  line-height: 1.6;
}

.lb-body {
  overflow-y: auto;
  min-height: 0;
  flex: 1;
}
.lb-tip {
  padding: 36px 0;
  text-align: center;
  color: #8ba6c8;
  font-size: 14px;
  line-height: 1.8;
}
.lb-head {
  display: grid;
  grid-template-columns: 46px 1fr 150px;
  gap: 8px;
  padding: 8px 10px;
  font-size: 12px;
  color: #7d9cc0;
  position: sticky;
  top: 0;
  background: #101d3a;
  z-index: 1;
}
.lb-row {
  display: grid;
  grid-template-columns: 46px 1fr 150px;
  align-items: center;
  gap: 8px;
  padding: 11px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 14px;
}
.lb-rank {
  color: #8ba6c8;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.lb-rank.t1 { color: #ffd700; }
.lb-rank.t2 { color: #d7dde5; }
.lb-rank.t3 { color: #cd7f32; }
.lb-score {
  color: #fff;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.lb-meta {
  text-align: right;
  font-size: 12px;
  color: #7d9cc0;
  font-variant-numeric: tabular-nums;
}

/* 全局榜行：名次 | 头像+昵称 | 分数 */
.lb-row.global {
  grid-template-columns: 46px 1fr 110px;
}
.lb-head.global {
  grid-template-columns: 46px 1fr 110px;
}
.lb-user {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
}
.lb-avatar {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  object-fit: cover;
  vertical-align: middle;
}
.lb-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #cfd8f2;
}
.lb-row.mine {
  background: rgba(90, 160, 255, 0.12);
}
