/* ============================================================
 * 森林飞鸟 · 样式（本地 Demo）
 * ============================================================ */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(circle at 30% 0%, #1d4a30, #060f0a 70%);
  color: #eef7e7;
  font-family: system-ui, "Microsoft YaHei", sans-serif;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

.stage { position: fixed; inset: 0; }
#game { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---------------- HUD ---------------- */
.hud {
  position: absolute; left: 0; right: 0; top: 0;
  padding: 14px 16px 0;
  pointer-events: none;
  opacity: 0; transition: opacity .2s;
  max-width: 560px; margin: 0 auto;
}
.hud.live { opacity: 1; }
.hud-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.hud-score { display: flex; align-items: baseline; gap: 4px; text-shadow: 0 3px 10px rgba(0,0,0,.55); }
.hud-score b { font-size: 44px; line-height: 1; color: #fff6d8; }
.hud-score span { font-size: 13px; color: #d8eac9; }
.hud-left { display: flex; flex-direction: column; gap: 3px; }
.hud-meta { display: flex; gap: 14px; text-shadow: 0 2px 8px rgba(0,0,0,.55); }
.hud-meta span { font-size: 12px; color: #c3dcb6; }
.hud-meta .tagmode {
  font-size: 11px; font-weight: 700; color: #cdeba0;
  padding: 1px 7px; border-radius: 99px; background: #ffffff1f;
}
.hud-meta b { font-size: 13px; color: #ffe9a8; font-variant-numeric: tabular-nums; }
.hud-side { display: grid; grid-template-columns: repeat(2, auto); gap: 2px 14px; text-align: right; }
.hud-side div { display: flex; align-items: baseline; gap: 5px; justify-content: flex-end; }
.hud-side label { font-size: 11px; color: #b9cfb3; }
.hud-side b { font-size: 13px; color: #eaf6df; }
.hud-biome { display: flex; align-items: baseline; gap: 10px; margin-top: 8px; }
.hud-biome b { font-size: 17px; color: #ffeaa0; text-shadow: 0 3px 10px rgba(0,0,0,.6); }
.hud-biome span { font-size: 11.5px; color: rgba(230,245,220,.72); }
.hud-hint { margin: 8px 0 0; font-size: 11px; color: rgba(230,245,220,.6); }

/* 本地测试用：无敌开关。躲在 HUD 里，所以只在一局跑着的时候才点得到 */
.god-btn {
  margin-left: 8px; padding: 3px 10px; border-radius: 99px; cursor: pointer;
  border: 1px solid #bde3a544; background: #0b1f14cc; color: #9db7a1;
  font-family: inherit; font-size: 11px; font-weight: 700;
}
.hud.live .god-btn { pointer-events: auto; }
.god-btn:hover { color: #dff0d6; }
.god-btn.on {
  background: linear-gradient(180deg, #ffe9a8, #f2c94c); color: #4a3607;
  border-color: #ffe9a8;
}

/* ---------------- 遮罩层 & 面板 ---------------- */
.overlay {
  position: absolute; inset: 0; z-index: 20;
  display: grid; place-items: center;
  padding: 16px;
  background: rgba(3, 10, 7, .68);
  backdrop-filter: blur(7px);
  overflow-y: auto;
}
.overlay.hidden { display: none; }
.panel {
  width: min(430px, 100%);
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  padding: 20px;
  border: 1px solid #bde3a544;
  border-radius: 16px;
  background: #0e261a;
  box-shadow: 0 22px 60px rgba(0,0,0,.5);
}
.panel.narrow { text-align: center; }
.panel h1 { margin: 0; font-size: 24px; color: #f3e3a8; line-height: 1.25; }
.panel h1 em { display: block; font-size: 13px; font-style: normal; letter-spacing: 2px; color: #a9d875; }
.panel h2 { margin: 0 0 4px; font-size: 19px; color: #f3e3a8; }
.panel .sub { margin: 6px 0 14px; font-size: 12.5px; color: #9db7a1; }

/* ---------------- 模式切换（金币 / 距离） ---------------- */
.modes { display: flex; gap: 8px; margin: 0 0 8px; }
.mode-btn {
  flex: 1; padding: 9px 10px; border: 1px solid #bde3a544; border-radius: 10px;
  background: #0b1f14; color: #cfe3c8; cursor: pointer; font-family: inherit; font-size: 13px;
  transition: background .15s, border-color .15s, color .15s;
}
.mode-btn:hover { background: #143223; }
.mode-btn.active { background: #2c6b3f; border-color: #a9d875; color: #f4ffe9; font-weight: 700; }
.mode-hint { margin: 0 0 12px; font-size: 11.5px; color: #9db7a1; line-height: 1.55; }
.loginline { margin: 0 0 12px; padding: 7px 10px; border-radius: 9px; font-size: 11.5px; line-height: 1.5; }
.loginline.off { color: #e8c98a; background: rgba(124, 92, 47, 0.18); border: 1px solid rgba(232, 201, 138, 0.28); }
.loginline.on { color: #a9d875; background: rgba(169, 216, 117, 0.1); border: 1px solid rgba(169, 216, 117, 0.24); }
.loginline b { color: #dff2c6; }
.loginline a { color: #f3d48a; text-decoration: underline; text-underline-offset: 2px; }

/* ---------------- 数据行 ---------------- */
.rows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.rows > div { padding: 9px 11px; border: 1px solid #bde3a52e; border-radius: 10px; background: #0b1f14; }
.rows label { display: block; font-size: 11px; color: #8fae8b; margin-bottom: 3px; }
.rows b { font-size: 15px; color: #eaf6df; }

/* ---------------- 赛道码 ---------------- */
/* 赛道上不再展示赛道码（每局都是新赛道），这里只留回放小按钮的通用样式 */
.mini {
  padding: 7px 11px; border: 1px solid #bde3a544; border-radius: 9px;
  background: #173b27; color: #dff0d6; cursor: pointer; font-size: 12px; font-family: inherit;
}
.mini:hover { background: #1e4b32; }

/* ---------------- 榜单预览 ---------------- */
.top3, .history { margin-bottom: 12px; }
.top3 label, .history label { display: block; font-size: 11px; color: #8fae8b; margin-bottom: 6px; }
.top3 ol { list-style: none; margin: 0; padding: 0; }
.top3 li { display: flex; align-items: center; gap: 9px; padding: 6px 9px; border-radius: 9px; background: #0b1f14; margin-bottom: 5px; font-size: 13px; }
.top3 li b { width: 18px; color: #a9d875; }
.top3 li span { flex: 1; color: #dff0d6; }
.top3 li em { font-style: normal; color: #ffeaa0; font-weight: 700; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 3px 9px; border-radius: 99px; background: #173b27; color: #cfe3c8; font-size: 12px; }
.dim { color: #7d9782; font-size: 12px; }

/* ---------------- 按钮 ---------------- */
.primary {
  width: 100%; padding: 13px; border: none; border-radius: 12px;
  background: linear-gradient(180deg, #b6e284, #8fc45c); color: #16301b;
  font-size: 15px; font-weight: 800; cursor: pointer; font-family: inherit;
  box-shadow: 0 8px 20px rgba(169,216,117,.22);
}
.primary:active { transform: translateY(1px); }
.ghost {
  width: 100%; padding: 10px; margin-top: 8px; border: 1px solid #bde3a544; border-radius: 11px;
  background: #143222; color: #dff0d6; font-size: 13.5px; cursor: pointer; font-family: inherit;
}
.ghost:hover { background: #1b4129; }
/* 排行榜入口：主菜单里最显眼的一个（比"开始"更显眼一点，但不抢焦点） */
.board-btn {
  width: 100%; padding: 12px; margin-top: 10px; border-radius: 12px;
  border: 1px solid #ffe9a866; background: linear-gradient(180deg, #2f6b41, #1b4527);
  color: #ffeaa0; font-size: 14px; font-weight: 800; cursor: pointer; font-family: inherit;
  box-shadow: inset 0 0 0 1px #ffe9a81f, 0 8px 18px rgba(0,0,0,.28);
}
.board-btn:hover { background: linear-gradient(180deg, #3a7f4e, #235533); }
.btnrow { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin-top: 8px; }
.btnrow.two { grid-template-columns: repeat(2, 1fr); }
.btnrow .ghost { margin-top: 0; padding: 10px 6px; font-size: 12.5px; }

/* ---------------- 说明 ---------------- */
details { margin-top: 12px; border-top: 1px solid #bde3a52e; padding-top: 10px; }
summary { cursor: pointer; font-size: 12.5px; color: #a9d875; }
details ul { margin: 8px 0 0; padding-left: 18px; color: #cfe3c8; font-size: 12.5px; line-height: 1.75; }
details li { margin: 4px 0; }
details b { color: #ffeaa0; }

/* ---------------- 结算 ---------------- */
.bigscore { text-align: center; margin-bottom: 6px; }
.bigscore b { font-size: 62px; line-height: 1; color: #fff6d8; }
.bigscore span { font-size: 13px; color: #a9d875; margin-left: 5px; }
.badge {
  text-align: center; padding: 7px 12px; border-radius: 99px; background: #173b27;
  color: #dff0d6; font-size: 13px; font-weight: 700; margin: 0 auto 10px; width: fit-content;
}
.badge.gold { background: linear-gradient(180deg, #ffe9a8, #f2c94c); color: #4a3607; }
.badge.hot { background: #7c2f2f; color: #ffd9d9; }
.rankline { text-align: center; font-size: 14px; color: #eaf6df; margin-bottom: 4px; }
.diff { text-align: center; font-size: 12.5px; color: #ffeaa0; margin-bottom: 14px; min-height: 18px; }
.diff.ok { color: #a9d875; }
.diff.bad { color: #ff9c9c; }
.diff.warn { color: #ffb27a; line-height: 1.5; }
.diff.warn a { color: #f3d48a; text-decoration: underline; text-underline-offset: 2px; }
.verify {
  margin-top: 12px; padding: 8px 10px; border-radius: 9px; background: #0b1f14;
  font-size: 11.5px; color: #9db7a1; word-break: break-all;
}
.verify.ok { color: #a9d875; }
.verify.bad { color: #ff9c9c; }
.warn { margin: 6px 0 0; font-size: 11.5px; color: #e8c07d; }
.overlay .panel .primary { margin-top: 14px; }

/* ---------------- 排行榜 ---------------- */
.board { list-style: none; margin: 10px 0 12px; padding: 0; }
/* 完整榜单（最多 100 名）自己滚，别把"返回"顶到屏幕外 */
#boardList { max-height: min(56vh, 520px); overflow-y: auto; padding-right: 2px; }
.board li { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto auto auto auto; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 9px; background: #0b1f14; margin-bottom: 5px; font-size: 13px; }
.board li.mine { background: #1b3a26; border: 1px solid #a9d87555; }
.board .rk { color: #a9d875; font-weight: 700; }
.board .nm { color: #dff0d6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .sc { color: #ffeaa0; font-weight: 700; }
.board .tm { color: #7d9782; font-size: 11.5px; min-width: 46px; text-align: right; }
.board .rt { font-style: normal; font-size: 10px; padding: 1px 5px; border-radius: 4px; background: #2c4a33; color: #9db7a1; white-space: nowrap; }
.board .rt.pending { background: rgba(246,213,143,.14); color: #f6d58f; }
.board .rt.verified { background: rgba(169,216,117,.14); color: #a9d875; }
.board .rt.cheater { background: rgba(255,156,156,.16); color: #ff9c9c; }
.board .rp { text-align: right; }
.board .rp a { color: #a9d875; font-size: 11.5px; text-decoration: underline; text-underline-offset: 2px; white-space: nowrap; }
.board .rp i { font-style: normal; }
.top3 li .rt { font-style: normal; font-size: 10px; padding: 1px 5px; border-radius: 4px; margin-left: 5px; background: rgba(246,213,143,.14); color: #f6d58f; }
.top3 li .rt.cheater { background: rgba(255,156,156,.16); color: #ff9c9c; }
.tag { font-style: normal; font-size: 10px; padding: 1px 5px; border-radius: 4px; background: #2c4a33; color: #9db7a1; }
.tag.warn { background: #5c2a2a; color: #ffb4a8; }
.note { margin: 0 0 6px; font-size: 11px; color: #7d9782; line-height: 1.6; }

/* ---------------- 结算里的回放入口 ---------------- */
.over-replay { text-align: center; font-size: 11.5px; color: #9db7a1; margin: 0 0 12px; min-height: 16px; }
.over-replay a { color: #f3d48a; text-decoration: underline; text-underline-offset: 2px; }

/* ---------------- 回放 ---------------- */
.replay {
  position: absolute; inset: 0; z-index: 22; pointer-events: none;
  display: flex; flex-direction: column; justify-content: space-between;
  padding: 14px 16px 18px;
}
.replay.hidden { display: none; }
.replay > * { pointer-events: auto; }
.replay-top { display: flex; justify-content: center; }
.replay-head {
  width: min(560px, 100%); padding: 11px 14px; border: 1px solid #bde3a544; border-radius: 12px;
  background: rgba(8, 22, 15, .82); backdrop-filter: blur(6px); box-shadow: 0 12px 30px rgba(0,0,0,.4);
}
.replay-title { font-size: 14px; color: #f3e3a8; }
.replay-title b { color: #fff6d8; }
.replay-sub { display: flex; align-items: center; gap: 8px; margin-top: 5px; font-size: 11.5px; color: #9db7a1; }
.replay-sub code { font-size: 12.5px; color: #ffeaa0; letter-spacing: .5px; }
.replay-stats { margin-top: 5px; font-size: 11.5px; color: #cfe3c8; line-height: 1.5; }
.replay-bottom { display: flex; flex-direction: column; align-items: center; gap: 9px; }
.replay-hud {
  display: flex; gap: 12px; padding: 8px 14px; border-radius: 12px;
  background: rgba(8, 22, 15, .72); border: 1px solid #bde3a52e;
}
.replay-hud div { display: flex; flex-direction: column; align-items: center; gap: 1px; min-width: 52px; }
.replay-hud label { font-size: 10.5px; color: #8fae8b; }
.replay-hud b { font-size: 15px; color: #ffeaa0; font-variant-numeric: tabular-nums; }
.replay-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.review-tag {
  font-style: normal; font-size: 10.5px; padding: 2px 7px; border-radius: 99px;
  border: 1px solid #bde3a544; color: #9db7a1;
}
.review-tag.pending { color: #f6d58f; border-color: rgba(246,213,143,.4); background: rgba(246,213,143,.1); }
.review-tag.verified { color: #a9d875; border-color: rgba(169,216,117,.4); background: rgba(169,216,117,.1); }
.review-tag.cheater { color: #ff9c9c; border-color: rgba(255,156,156,.45); background: rgba(255,156,156,.12); }

/* ---------------- Toast ---------------- */
.toast {
  position: absolute; left: 50%; bottom: 40px; transform: translate(-50%, 12px);
  z-index: 40; padding: 10px 16px; border-radius: 10px;
  background: rgba(14, 38, 26, .96); border: 1px solid #bde3a544; color: #eaf6df;
  font-size: 13px; opacity: 0; pointer-events: none; transition: .22s;
  max-width: calc(100vw - 40px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 420px) {
  .panel { padding: 16px; }
  .bigscore b { font-size: 52px; }
  .hud-score b { font-size: 36px; }
  .rows { grid-template-columns: repeat(3, 1fr); }
  /* 窄屏榜单：省掉用时列，给昵称和状态角标让位 */
  .board li { grid-template-columns: 22px minmax(0, 1fr) auto auto auto; gap: 6px; padding: 8px; }
  .board .tm { display: none; }
  .replay { padding: 10px 10px 14px; }
  .replay-head { padding: 9px 11px; }
  .replay-hud { gap: 9px; padding: 7px 10px; }
  .replay-hud div { min-width: 46px; }
}

/* ---------------- 横屏（手机横持）紧凑布局 ---------------- */
@media (orientation: landscape) and (max-height: 520px) {
  .hud { padding: 8px 14px 0; }
  .hud-score b { font-size: 30px; }
  .hud-score span { font-size: 11px; }
  .hud-meta span { font-size: 10px; }
  .hud-meta b { font-size: 11px; }
  .hud-side { gap: 1px 10px; }
  .hud-side label { font-size: 10px; }
  .hud-side b { font-size: 12px; }
  .hud-biome { margin-top: 5px; }
  .hud-hint { margin: 4px 0 0; font-size: 10px; }
  .overlay { padding: 10px; }
  .panel { width: min(520px, 94vw); max-height: calc(100vh - 20px); padding: 14px 18px; }
  .panel h1 { font-size: 20px; }
  .panel .sub { margin: 4px 0 10px; }
  .rows { margin-bottom: 10px; }
  .bigscore b { font-size: 44px; }
  .btnrow { margin-top: 6px; }
}
