:root {
  --bg: #0a0d12;
  --panel: rgba(16, 20, 28, 0.82);
  --line: rgba(255, 255, 255, 0.1);
  --text: #eef2f7;
  --muted: #8b96a8;
  --accent: #ff3b30;
  --accent-2: #ffd60a;
  --radius: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- 通用按钮 ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 18px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.2s ease, border-color 0.2s ease;
  font-family: inherit;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn:hover { background: rgba(255, 255, 255, 0.12); }
.btn:active { transform: scale(0.97); }

.btn.primary {
  background: linear-gradient(135deg, #ff5a3c, #ff2d55);
  border-color: transparent;
  box-shadow: 0 8px 24px rgba(255, 59, 48, 0.32);
}

.btn.primary:hover { background: linear-gradient(135deg, #ff6a4c, #ff3d65); }

.btn.accent {
  background: linear-gradient(135deg, #ffd60a, #ffb300);
  border-color: transparent;
  color: #241c00;
  box-shadow: 0 8px 24px rgba(255, 190, 10, 0.25);
}

.btn.ghost { background: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); }

/* ---------- 登录 / 注册 ---------- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background:
    radial-gradient(900px 500px at 15% 0%, rgba(255, 59, 48, 0.16), transparent 60%),
    radial-gradient(700px 500px at 85% 100%, rgba(255, 214, 10, 0.08), transparent 60%),
    #0a0d12;
}

.auth-wrap { width: 100%; max-width: 420px; }

.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  padding: 38px 32px 30px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(14px);
}

.brand-mark {
  display: flex;
  gap: 5px;
  width: 44px;
  margin-bottom: 20px;
}

.brand-mark span {
  width: 100%;
  height: 8px;
  border-radius: 2px;
  background: var(--text);
  opacity: 0.9;
}

.brand-mark span:nth-child(2) { background: var(--accent); opacity: 1; }
.brand-mark span:nth-child(3) { background: var(--accent-2); opacity: 1; }

.auth-card h1 {
  margin: 0 0 8px;
  font-size: 30px;
  letter-spacing: 1px;
}

.auth-card .sub {
  margin: 0 0 26px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.auth-card form { display: flex; flex-direction: column; gap: 16px; }

.auth-card label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.auth-card input {
  height: 48px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 15px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.auth-card input:focus {
  border-color: rgba(255, 59, 48, 0.7);
  box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.15);
}

.auth-card .btn.primary {
  height: 50px;
  font-size: 16px;
  margin-top: 6px;
}

.error {
  margin: 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(255, 59, 48, 0.12);
  border: 1px solid rgba(255, 59, 48, 0.35);
  color: #ff8f87;
  font-size: 13px;
}

.switch {
  margin: 22px 0 0;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}

.switch a { color: var(--accent-2); text-decoration: none; font-weight: 600; }
.switch a:hover { text-decoration: underline; }

/* ---------- 游戏页 ---------- */
.game-page { overflow: hidden; height: 100vh; }

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  background: #8fd3ff;
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px 20px;
}

.hud-bottom { pointer-events: auto; }

.hud-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.pill {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(10, 13, 18, 0.66);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.4px;
}

.pill b {
  font-size: 20px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.pill em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

.pill.best b { color: var(--accent-2); }

.hud-bottom {
  display: flex;
  gap: 10px;
  padding-bottom: 2px;
}

.hud-bottom form { margin: 0; }

/* ---------- 排行榜浮层 ---------- */
.leaderboard {
  position: fixed;
  top: 18px;
  right: 20px;
  width: 262px;
  padding: 18px 18px 14px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(12px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  font-size: 13px;
}

.leaderboard header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.leaderboard h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: 1px;
}

.my-rank {
  font-size: 11px;
  color: var(--accent-2);
  font-weight: 700;
}

.leaderboard ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 44vh;
  overflow: auto;
}

.leaderboard li {
  display: grid;
  grid-template-columns: 26px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px 8px;
  border-radius: 8px;
  color: #c9d2df;
}

.leaderboard li:nth-child(odd) { background: rgba(255, 255, 255, 0.035); }
.leaderboard li.me { background: rgba(255, 59, 48, 0.16); color: #fff; }
.leaderboard li.loading { display: block; color: var(--muted); text-align: center; padding: 16px 0; }

.leaderboard .no {
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.leaderboard li:nth-child(1) .no { color: var(--accent-2); }
.leaderboard li:nth-child(2) .no { color: #dfe6f0; }
.leaderboard li:nth-child(3) .no { color: #e6a46b; }

.leaderboard .who {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard .score {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.leaderboard footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 11px;
  color: var(--muted);
}

.leaderboard footer a { color: var(--accent-2); text-decoration: none; }

/* ---------- 提示与 toast ---------- */
.tip {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(10, 13, 18, 0.66);
  border: 1px solid var(--line);
  color: #d7dee8;
  font-size: 12px;
  line-height: 1.9;
  text-align: center;
  backdrop-filter: blur(10px);
  transition: opacity 0.8s ease;
  pointer-events: none;
  white-space: nowrap;
}

.tip b { color: var(--accent-2); font-weight: 700; }
.tip.hide { opacity: 0; }

.toast {
  position: fixed;
  left: 50%;
  top: 88px;
  transform: translate(-50%, -12px);
  padding: 11px 22px;
  border-radius: 999px;
  background: rgba(10, 13, 18, 0.85);
  border: 1px solid rgba(255, 214, 10, 0.5);
  color: var(--accent-2);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 排行榜页 ---------- */
.board-page {
  padding: 48px 20px 72px;
  background:
    radial-gradient(800px 400px at 50% 0%, rgba(255, 59, 48, 0.12), transparent 60%),
    #0a0d12;
  min-height: 100vh;
}

.board-wrap { max-width: 760px; margin: 0 auto; }

.board-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  letter-spacing: 4px;
  color: var(--accent);
  font-weight: 700;
}

.board-head h1 { margin: 0 0 8px; font-size: 34px; letter-spacing: 1px; }

.board-head .sub { margin: 0; color: var(--muted); font-size: 13px; }

.board-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
  font-size: 14px;
}

.board-table th {
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--muted);
  padding: 0 18px 8px;
}

.board-table td {
  background: rgba(255, 255, 255, 0.045);
  padding: 15px 18px;
}

.board-table tr td:first-child { border-radius: 12px 0 0 12px; }
.board-table tr td:last-child { border-radius: 0 12px 12px 0; }

.board-table tbody tr.me td {
  background: rgba(255, 59, 48, 0.16);
  box-shadow: inset 0 0 0 1px rgba(255, 59, 48, 0.35);
}

.board-table .rank {
  width: 76px;
  font-weight: 800;
  font-size: 17px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.board-table tr:nth-child(1) .rank { color: var(--accent-2); }
.board-table tr:nth-child(2) .rank { color: #dfe6f0; }
.board-table tr:nth-child(3) .rank { color: #e6a46b; }

.board-table .name { font-weight: 600; }

.board-table .tag {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  vertical-align: middle;
}

.board-table .laps {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.board-table .empty {
  text-align: center;
  color: var(--muted);
  padding: 40px 0;
}

@media (max-width: 860px) {
  .leaderboard { display: none; }
  .hud { padding: 12px; }
  .pill { padding: 7px 12px; }
  .pill b { font-size: 16px; }
  .tip { display: none; }
}
