/*
 * 厚描边平涂（BRAND.md）。
 *
 * 三条硬规则，别破：无渐变、无模糊阴影、描边一律 Ink 色不用纯黑。
 * 中低端安卓上渐变和模糊阴影是帧率杀手，而这个品类的一屏全是重叠图形。
 */
:root {
  --ink: #2e2119;
  --bg: #fbf3e7;
  --tray: #f0e2cf;
  --kraft: #e3b584;
  --kraft-dark: #c9925f;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  /* 泰文有上下叠加声调，行高不能按拉丁文给 */
  font: 500 16px/1.6 system-ui, "Noto Sans Thai", sans-serif;
  overscroll-behavior: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

#hud {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px 14px 4px;
}

.grow {
  flex: 1;
}

/**
 * HUD 上的胶囊按钮。
 *
 * **44×44 是触摸目标的下限**（iOS HIG 44pt / Material 48dp），
 * 原来是 46×38 —— 高度差 6px。在 375 宽的手机上实测就是这个尺寸，
 * 桌面浏览器上用鼠标完全感觉不到，只有手机尺寸才量得出来。
 *
 * 视觉大小仍然由 padding 和字号控制；`min-height` 只保证手指够得着。
 */
.pill {
  min-width: 46px;
  min-height: 44px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid var(--ink);
  border-radius: 22px;
  background: var(--kraft);
  font-weight: 500;
  font-size: 15px;
  color: var(--ink);
}

.btn {
  cursor: pointer;
  background: var(--tray);
  transition: transform 0.08s;
}
.btn:active {
  transform: scale(0.94);
}
.btn[disabled] {
  opacity: 0.4;
  cursor: default;
}

#board {
  flex: 1;
  width: 100%;
  display: block;
  touch-action: manipulation;
}

#status {
  padding: 6px 14px 12px;
  font-size: 12px;
  line-height: 1.4;
  color: #8a7663;
  min-height: 34px;
  word-break: break-all;
}

#toast {
  position: absolute;
  left: 50%;
  top: 92px;
  /* 要盖得过排行榜整页（.boardpage z9）：会员中心打不开时的提示就发生在那页上 */
  z-index: 15;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 18px;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s;
  max-width: 86vw;
  text-align: center;
}
#toast.show {
  opacity: 1;
}

#panel {
  position: absolute;
  inset: 0;
  background: rgba(46, 33, 25, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
#panel.hidden {
  display: none;
}

.card {
  background: var(--bg);
  border: 4px solid var(--ink);
  border-radius: 20px;
  padding: 22px;
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.card h1 {
  margin: 0 0 6px;
  font-size: 22px;
}

.card p {
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-all;
}

#panel-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#panel-actions button {
  height: 46px;
  border: 3px solid var(--ink);
  border-radius: 23px;
  background: var(--kraft);
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  cursor: pointer;
}
#panel-actions button.ghost {
  background: var(--tray);
}
#panel-actions button:active {
  transform: scale(0.97);
}


/* ---- PDPA 同意书 / 隐私设置 ----
   刻意做成 HTML 而不是画进 canvas：泰文有上下叠加声调，
   游戏用的位图字体渲染出来是一排空方块。 */
.sheet {
  position: absolute;
  inset: 0;
  background: rgba(46, 33, 25, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 10;
  overflow-y: auto;
}

.sheet-card {
  background: var(--bg);
  border: 4px solid var(--ink);
  border-radius: 20px;
  padding: 20px;
  width: 100%;
  max-width: 380px;
  max-height: 88vh;
  overflow-y: auto;
  /* 泰文行高要给够，否则上下声调会被裁掉 */
  line-height: 1.75;
}

.sheet-card h1 {
  margin: 0 0 10px;
  font-size: 19px;
}

.sheet-card .muted {
  color: #8a7663;
  font-size: 13px;
  margin: 2px 0;
}

.sheet-card .warn {
  background: #ffe9c9;
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 13px;
  margin: 8px 0;
}

.sheet-card .purpose {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-top: 2px solid rgba(46, 33, 25, 0.12);
}

.sheet-card .purpose input[type='checkbox'] {
  width: 22px;
  height: 22px;
  margin-top: 4px;
  flex: none;
  accent-color: #f2544b;
}

.sheet-card .purpose input[type='number'] {
  flex: 1;
  height: 40px;
  /* 16px 以上，否则 iOS 聚焦时会自动放大整页 */
  font-size: 16px;
  padding: 0 10px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff;
}

.sheet-card .purpose strong {
  display: block;
  font-weight: 500;
}

.sheet-card details.third {
  margin: 10px 0;
  font-size: 13px;
}

.sheet-card button {
  width: 100%;
  min-height: 46px;
  margin-top: 10px;
  border: 3px solid var(--ink);
  border-radius: 23px;
  background: var(--tray);
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
}

.sheet-card button.primary { background: var(--kraft); }
.sheet-card button.danger { background: #f7c1c1; }
.sheet-card button.ghost { background: transparent; }
.sheet-card button[disabled] { opacity: 0.45; cursor: default; }

.hidden { display: none !important; }


/* ---- 选关 ---- */
.sheet-card .level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin: 10px 0;
}

/* 选择器要压得过上面的 `.sheet-card button`，否则圆角、外边距、最小高度
   会被那条通用规则接管 —— 之前就是靠 !important 硬顶的，那是个将来会咬人的补丁 */
.sheet-card .level-grid .level-cell {
  aspect-ratio: 1;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 3px solid var(--ink);
  border-radius: 12px;
  background: var(--tray);
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  cursor: pointer;
}
.sheet-card .level-grid .level-cell.done { background: var(--kraft); }
/* 下一关高亮 —— 玩家打开选关十有八九就是想接着打 */
.sheet-card .level-grid .level-cell.next { background: #f2544b; color: var(--bg); }
.sheet-card .level-grid .level-cell[disabled] { opacity: 0.3; cursor: default; }

.sheet-card select {
  flex: 1;
  height: 40px;
  font-size: 16px;
  padding: 0 8px;
  border: 3px solid var(--ink);
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

/* ---- 区域积分榜（平台积分闭环，2026-08-14）----
   面板走 sheet-card 的既有语言：3px 墨描边、牛皮纸底、圆角胶囊按钮。 */
.sheet-card .board-tabs {
  display: flex;
  gap: 8px;
}

/* 要压得过 `.sheet-card button` 的通用规则（同 level-cell 那条注释） */
.sheet-card .board-tabs button {
  flex: 1;
  margin-top: 0;
  background: transparent;
}

.sheet-card .board-tabs button.on {
  background: var(--kraft);
}

.sheet-card .board-rows {
  margin: 6px 0 2px;
}

.sheet-card .board-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 7px 4px;
  border-top: 2px solid rgba(46, 33, 25, 0.12);
  font-size: 14px;
}

.sheet-card .board-row .rk {
  flex: none;
  width: 36px;
  color: #8a7663;
  font-variant-numeric: tabular-nums;
}

.sheet-card .board-row .nm {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-card .board-row .sc {
  flex: none;
  font-variant-numeric: tabular-nums;
}

/* 「我」那一行 / 我的城市：和胜利面板的强调色同一块牛皮纸黄 */
.sheet-card .board-row.me {
  background: #ffe9c9;
  border-top-color: transparent;
  border-radius: 10px;
}

/* ---- 排行榜整页（v9 定稿，2026-08-14）----
   视觉规格：line-platform/docs/design/board-ui-mockup.html（v9），四端统一配色：
   晴空蓝底、白卡片、金橙点缀。类名照规格（gr/rb/chip/mebar/…），全部圈在
   .boardpage 作用域里，不外溢。

   ⚠️ 这一段是文件头三条硬规则（无渐变/无模糊阴影）的**例外**，理由：
   那三条管的是常驻 60fps 的游戏画面（canvas + HUD）；排行榜是按需打开的
   整页静态视图，不在渲染循环里，渐变和一层 feDropShadow 花得起。
   规格是平台四端统一的 v9 原版，这里不做本端化改色。 */
.boardpage {
  position: absolute;
  inset: 0;
  z-index: 9; /* 游戏之上、.sheet(10) 之下 —— 设置/同意书仍能盖住它 */
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  background: linear-gradient(180deg, #cdebff 0%, #e4f4ff 40%, #f4faff 100%);
  color: #1a2330;
}

/* 双城对峙插图：96px，SVG 铺满，标题压在左下 */
.boardpage .bd-hero {
  position: relative;
  height: 96px;
  flex: none;
}
.boardpage .bd-hero > svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.boardpage .bd-title {
  position: absolute;
  left: 52px; /* 规格是 14px，让位给返回键 —— 游戏里这页需要一条回去的路 */
  bottom: 8px;
  color: #fff;
  font-weight: 900;
  font-size: 19px;
  letter-spacing: 3px;
  text-shadow: 0 2px 5px rgba(20, 70, 140, 0.65);
}
.boardpage .bd-back {
  position: absolute;
  left: 10px;
  bottom: 6px;
  width: 34px;
  height: 32px;
  border: 2px solid #b7d4f2;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  color: #41628c;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  padding: 0 0 3px;
}

/* 76×30 迷你分段：🏆 天梯 / 🗺️ 地图，只在城市对抗 tab 出现 */
.boardpage .bd-mini {
  position: absolute;
  right: 12px;
  top: 12px;
  display: flex;
  background: rgba(255, 255, 255, 0.88);
  border: 2px solid #b7d4f2;
  border-radius: 12px;
  overflow: hidden;
}
.boardpage .bd-mini i {
  width: 38px;
  height: 30px;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 15px;
  color: #7fa6ce;
  cursor: pointer;
}
.boardpage .bd-mini i.on {
  background: linear-gradient(180deg, #ffe066, #ffa41b);
  color: #7a3b00;
}

/* 页内 tab：城市对抗 / 我的城市。选中态与迷你分段同一块金 */
.boardpage .bd-tabs {
  display: flex;
  gap: 8px;
  padding: 10px 14px 0;
}
.boardpage .bd-tabs button {
  flex: 1;
  min-height: 34px;
  border: 2px solid #b7d4f2;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.88);
  color: #41628c;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}
.boardpage .bd-tabs button.on {
  background: linear-gradient(180deg, #ffe066, #ffa41b);
  border-color: #d98e1b;
  color: #7a3b00;
}

.boardpage .bd-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px 4px;
  color: #5b7290;
  font-size: 11.5px;
  min-height: 26px;
}
.boardpage .bd-link {
  border: none;
  background: none;
  color: #2f6fbe;
  font: inherit;
  font-size: 11.5px;
  text-decoration: underline;
  cursor: pointer;
  padding: 4px 0;
}

.boardpage .bd-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.boardpage .bd-note {
  color: #5b7290;
  font-size: 13px;
  text-align: center;
  margin: 12px 16px;
}
.boardpage .bd-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 14px 2px;
}

/* v9 天梯行：章完全在卡内、不对称圆角（20/12/20/12）打破方框感 */
.boardpage .gr {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 12px;
  margin-bottom: 7px;
  border-radius: 20px 12px 20px 12px;
  background: linear-gradient(180deg, #ffffff, #f2f8ff);
  border: 2px solid #d5e3f5;
  box-shadow: 0 3px 0 rgba(120, 160, 210, 0.2);
}
/* 32px 圆角方章。前三名金/银/铜圆章配色 */
.boardpage .rb {
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 14px;
  color: #6b84a8;
  background: linear-gradient(180deg, #f4f8fe, #e3ecf8);
  border: 2px solid #c9d9ee;
}
.boardpage .rb.r1 {
  background: radial-gradient(circle at 35% 28%, #fff3b0, #ffd23f 60%, #f0a400);
  border-color: #d98e1b;
  color: #7a3b00;
}
.boardpage .rb.r2 {
  background: radial-gradient(circle at 35% 28%, #fff, #e4ecfa 60%, #9fb2d4);
  border-color: #8fa6c6;
  color: #3c4c66;
}
.boardpage .rb.r3 {
  background: radial-gradient(circle at 35% 28%, #ffd9b8, #ff9c5b 60%, #d96627);
  border-color: #c1702e;
  color: #6b2e00;
}
.boardpage .mid {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.boardpage .nm {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.boardpage .nm b {
  color: #27436b;
  font-size: 14.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.boardpage .nm span {
  color: #8aa3c4;
  font-size: 10.5px;
  flex: none;
}
/* 能量条：宽度 ∝ 积分/榜首 */
.boardpage .bar {
  height: 8px;
  border-radius: 5px;
  background: #e4edf9;
  overflow: hidden;
}
.boardpage .bar i {
  display: block;
  height: 100%;
  border-radius: 5px;
  background: linear-gradient(90deg, #ffd23f, #ff7a3d);
}
/* 前三名整卡金/银/铜渐变，文字与能量条同步换色 */
.boardpage .gr.t1 {
  background: linear-gradient(135deg, #ffe99a, #ffc93c);
  border-color: #e8a20e;
}
.boardpage .gr.t2 {
  background: linear-gradient(135deg, #edf3fc, #c9d6ea);
  border-color: #a9bcd8;
}
.boardpage .gr.t3 {
  background: linear-gradient(135deg, #ffdcbb, #ff9c5b);
  border-color: #e07e36;
}
.boardpage .gr.t1 .nm b,
.boardpage .gr.t3 .nm b {
  color: #5c3a08;
}
.boardpage .gr.t1 .nm span,
.boardpage .gr.t3 .nm span {
  color: #8a6425;
}
.boardpage .gr.t2 .nm b {
  color: #33445f;
}
.boardpage .gr.t2 .nm span {
  color: #6c7f9d;
}
.boardpage .gr.t1 .bar,
.boardpage .gr.t3 .bar {
  background: rgba(255, 255, 255, 0.5);
}
.boardpage .gr.t1 .bar i {
  background: linear-gradient(90deg, #fffdf4, #ffab1f);
}
.boardpage .gr.t2 .bar {
  background: rgba(255, 255, 255, 0.6);
}
.boardpage .gr.t2 .bar i {
  background: linear-gradient(90deg, #fff, #93a9cc);
}
.boardpage .gr.t3 .bar i {
  background: linear-gradient(90deg, #fff3e6, #f07018);
}
/* 金币胶囊分数 */
.boardpage .chip {
  flex: none;
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 13.5px;
  color: #b35a00;
  background: linear-gradient(180deg, #fff7df, #ffe9ad);
  border: 2px solid #edc35c;
}
.boardpage .cc {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  display: inline-block;
  font-style: normal;
  background: radial-gradient(circle at 35% 30%, #fff3b0, #ffc93c 60%, #e4700c);
  border: 2px solid #d98e1b;
}
/* 我的城市/我那一行：青绿描边圈出来 */
.boardpage .myrow {
  outline: 3px solid #0fbe8f;
  outline-offset: -3px;
}

/* 底部绿色固定条：我的城市（天梯版面）。没设城市时它就是引导按钮 */
.boardpage .mebar {
  margin: 8px 14px 14px;
  padding: 11px 16px;
  border-radius: 15px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(180deg, #3ce08a, #12a85e);
  border: 3px solid #0a9052;
  box-shadow: 0 4px 0 #0a7a46, inset 0 2px 0 rgba(255, 255, 255, 0.45);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  text-align: left;
}
.boardpage .mebar:disabled {
  cursor: default;
  opacity: 1; /* disabled 只表示「纯展示」，不是灰掉 */
}

/* 地图：无框，靠 feDropShadow 浮在浅蓝底上 */
.boardpage .mapfree {
  flex: 1;
  min-height: 0;
  margin: 0 8px;
  display: flex;
}
.boardpage .mapfree svg {
  flex: 1;
  width: 100%;
  max-height: 100%;
}
.boardpage .mapfree [data-code] {
  cursor: pointer;
}

/* 图例：低→高连续渐变条 + 斜纹样例 */
.boardpage .legend {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  font-size: 10.5px;
  color: #41628c;
  padding: 2px 14px 6px;
}
.boardpage .legend .grad {
  flex: 1;
  max-width: 150px;
  height: 9px;
  border-radius: 5px;
  border: 1.5px solid rgba(60, 90, 140, 0.25);
  background: linear-gradient(90deg, #cdd8f4, #b28af5, #ff7a3d, #ffc93c);
}
.boardpage .legend .hatch {
  width: 14px;
  height: 11px;
  border-radius: 3px;
  display: inline-block;
  background: repeating-linear-gradient(45deg, #edf2fa 0 3px, #d8e1f0 3px 6px);
  border: 1.5px solid rgba(60, 90, 140, 0.25);
  vertical-align: -2px;
}

/* 底部铭牌：点府就地更新 */
.boardpage .selplaque {
  margin: 0 14px 14px;
  padding: 10px 14px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: #27436b;
  background: linear-gradient(180deg, #ffffff, #f4f9ff);
  border: 2.5px solid #c9dbf2;
  box-shadow: 0 3px 0 rgba(120, 160, 210, 0.25);
}
.boardpage .selplaque .p {
  margin-left: auto;
  font-weight: 900;
  color: #e4700c;
  font-size: 16px;
  flex: none;
}

/* no-province 引导：不是错误态，给一条能走通的路（去会员中心设城市） */
.boardpage .bd-guide {
  margin: 26px 22px;
  padding: 18px 16px;
  border-radius: 20px 12px 20px 12px;
  background: linear-gradient(180deg, #ffffff, #f2f8ff);
  border: 2px solid #d5e3f5;
  box-shadow: 0 3px 0 rgba(120, 160, 210, 0.2);
  text-align: center;
}
.boardpage .bd-guide-title {
  margin: 0 0 4px;
  font-weight: 900;
  font-size: 16px;
  color: #27436b;
}
.boardpage .bd-cta {
  display: block;
  margin: 10px auto 2px;
  padding: 10px 24px;
  border-radius: 15px;
  border: 3px solid #0a9052;
  background: linear-gradient(180deg, #3ce08a, #12a85e);
  box-shadow: 0 4px 0 #0a7a46, inset 0 2px 0 rgba(255, 255, 255, 0.45);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 900;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  cursor: pointer;
}
.boardpage .bd-cta:active,
.boardpage .mebar:not(:disabled):active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #0a7a46, inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

/* ---- 首屏 ----
   不放进度条，放一颗慢慢拧出的螺丝：首屏是唯一保证被 100% 看到的一屏，
   用来演示玩法比用来显示百分比划算（BRAND.md）。 */
.loading {
  position: absolute;
  inset: 0;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 20;
}
.loading p { color: #8a7663; font-size: 14px; margin: 0; }
.loading .screw {
  transform-origin: 60px 67px;
  animation: unscrew 1.6s ease-in-out infinite;
}
@keyframes unscrew {
  0%   { transform: rotate(0deg) translateY(0); }
  70%  { transform: rotate(-540deg) translateY(-26px); }
  100% { transform: rotate(-540deg) translateY(-26px); opacity: 0; }
}
