/*!
 * game.css — 棋盘、牌、堆叠、动画、HUD、工具栏、菜单
 */

/* ==========================================================
 * 顶部信息栏
 * ========================================================== */
.hud {
  flex: none;
  padding: 8px 0 6px;
}
.hud[hidden] { display: none; }

.hud-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 56px;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, .72);
  border: 1px solid var(--border);
}
.hud-stat.grow { flex: 1; }
.hud-stat .label { font-size: 10px; color: var(--text-faint); letter-spacing: .5px; }
.hud-stat .value {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}
.hud-stat .value.combo { color: var(--accent-dark); }
.hud-stat .value.combo.hot { color: #e8630a; transform: scale(1.12); }

.hud-time {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
}
.time-bar {
  flex: 1;
  height: 10px;
  border-radius: 99px;
  background: #e2edfa;
  box-shadow: inset 0 1px 2px rgba(31, 43, 58, .08);
  overflow: hidden;
}
.time-fill {
  height: 100%;
  width: 100%;
  border-radius: 99px;
  background: linear-gradient(90deg, #5fd8b0, var(--accent));
  transition: width 120ms linear, background 240ms;
}
.time-fill.low { background: linear-gradient(90deg, var(--warn), var(--danger)); }
.time-fill.low + .time-text, .time-bar.low { animation: warnPulse 640ms ease-in-out infinite; }

/* 闯关正计时：填充颜色代表与"标准时间"的关系 */
.time-fill.ahead  { background: linear-gradient(90deg, #5fd8b0, var(--accent)); }
.time-fill.close  { background: linear-gradient(90deg, #ffd34d, var(--warn)); }
.time-fill.behind { background: linear-gradient(90deg, var(--danger), #ff7a6b); }

/* 挑战模式：每完成一张地图的补时，结算弹窗里最抢眼的一块 */
.reward.bonus-time {
  background: linear-gradient(120deg, #e6f6ff, #d8eeff);
  border-color: #9fd4ff;
}
.reward.bonus-time .tx b { color: var(--accent-dark); }

/* 时间条囤到超过开局时间：保持满格，加一点光晕表示"还有富余" */
.time-fill.over {
  background: linear-gradient(90deg, var(--mint), var(--accent));
  box-shadow: 0 0 10px rgba(74, 163, 255, .5);
}

/* 结算弹窗里的奖牌 */
.reward.medal-gold   { background: linear-gradient(120deg, #fff6da, #ffefc2); border-color: #ffd968; }
.reward.medal-silver { background: linear-gradient(120deg, #eef3f8, #e2eaf2); border-color: #c2d0de; }
.reward.medal-bronze { background: linear-gradient(120deg, #f8ece2, #f3e2d4); border-color: #e0b894; }
.reward.medal-gold .tx b   { color: #9a6b00; }
.reward.medal-silver .tx b { color: #4a5d70; }
.reward.medal-bronze .tx b { color: #8a5a2a; }
.time-text {
  min-width: 48px;
  text-align: right;
  font-size: 14px;
  font-weight: 800;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.time-text.low { color: var(--danger); }
@keyframes warnPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

/* 关卡限制条 */
.hud-mod {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.hud-mod[hidden] { display: none; }
.hud-mod .chip { background: #fff1e6; border-color: #ffd3b0; color: #a3500a; }

/* ==========================================================
 * 棋盘
 * ========================================================== */
.board-wrap {
  position: relative;
  flex: 1;
  min-height: 0;                    /* 关键：flex 子项默认不收缩，会撑破屏幕 */
  display: grid;
  place-items: center;
  padding: 10px 0;
}

.board {
  position: relative;
  display: grid;
  gap: 0;                           /* 缝做成格子内部的 padding，SVG 坐标才精确 */
  border-radius: var(--radius);
  /* 让顶层牌的视觉偏移不被裁掉 */
  overflow: visible;
}

/* 覆盖层：连线。必须 pointer-events:none，否则会盖住所有格子、点击全部失效 */
.lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 50;
}
#linePath {
  fill: none;
  stroke: var(--accent);
  stroke-width: .085;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  opacity: 0;
  filter: drop-shadow(0 0 .16px rgba(43, 127, 224, .95));
}
#linePath.draw {
  opacity: 1;
  animation: lineFlow var(--line-ms, 260ms) ease-out forwards;
}
@keyframes lineFlow {
  0%   { stroke-dashoffset: 1; opacity: 1; }
  70%  { stroke-dashoffset: 0; opacity: 1; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}

/* 格子 */
.cell {
  position: relative;
  width: var(--cell);
  height: var(--cell);
  transition: transform 120ms;
}

/* 触摸屏：棋盘区域的"防选中 / 防拖动 / 去掉双击缩放与 300ms 延迟"交给 CSS。
   以前是在 touchstart 里 preventDefault()，但那会连带取消浏览器合成的 click
   （Touch Events 规范），手机端整块棋盘会完全点不动 —— 已有实测。 */
.board-wrap, .board, .cell {
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* 空地（高度 0 = 可以当通路走）：用地面纹理明确标出来。
   玩家必须一眼分清"这里能走过去"和"这里被牌堵住" */
.cell.empty::after {
  content: '';
  position: absolute;
  left: 20%; right: 20%; top: 20%; bottom: 20%;
  border-radius: 30%;
  background: rgba(74, 163, 255, .07);
  box-shadow: inset 0 0 0 1px rgba(74, 163, 255, .12);
}

/* 叠了 2 张以上的格子：右下角挂一个层数徽标。
   光靠向上错位 + 压暗，玩家在小屏上根本看不出"这里叠了两张"。
   尺寸跟着 --cell 走，360px 屏上格子只有 28px 时也不会盖住整格 */
.cell[data-cnt]::before {
  content: attr(data-cnt);
  position: absolute;
  right: 1%;
  bottom: 2%;
  z-index: 30;
  min-width: calc(var(--cell) * .28);
  height: calc(var(--cell) * .28);
  padding: 0 calc(var(--cell) * .06);
  border-radius: 99px;
  /* 高关满盘都是 2 层时徽标会铺满全屏 —— 降低对比度，保留信息但不抢视线 */
  background: rgba(31, 43, 58, .55);
  color: #fff;
  font-family: var(--font-ui);
  font-size: calc(var(--cell) * .18);
  font-weight: 800;
  line-height: calc(var(--cell) * .28);
  text-align: center;
  pointer-events: none;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}

/* 牌 */
.tile {
  --k: 0;
  position: absolute;
  left: 5%; right: 5%; top: 5%; bottom: 5%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 26%;
  background: #fff;
  font-family: var(--font-emoji);
  font-size: calc(var(--cell) * .5);
  line-height: 1;                   /* 彩色 emoji 字体行高偏大，会顶破格子 */
  box-shadow:
    0 1px 2px rgba(31, 43, 58, .16),
    inset 0 -2px 0 rgba(31, 43, 58, .07),
    inset 0 1px 0 rgba(255, 255, 255, .95);
  transform-origin: 50% 96%;
  transform:
    translateY(calc(var(--k) * -0.17 * var(--cell)))
    scale(calc(1 - var(--k) * 0.1));
  z-index: calc(var(--k) + 1);
  transition:
    transform 180ms cubic-bezier(.2, .85, .3, 1.15),
    filter 180ms ease,
    box-shadow 140ms ease,
    opacity 160ms ease;
}
.tile.hidden { visibility: hidden; opacity: 0; }

/* 被压住的牌：压暗 + 一圈内描边，一眼看出"还不能点" */
.tile.buried {
  filter: brightness(.62) saturate(.45);
  box-shadow:
    0 0 0 1px rgba(31, 43, 58, .22),
    inset 0 -3px 0 rgba(0, 0, 0, .16),
    inset 0 1px 0 rgba(255, 255, 255, .6);
}

/* 顶上那张牌：只有确实叠了东西时才加重投影，体现"压在上面"。
   单层的牌用同样的重投影会被误读成"这里叠了两张" */
.cell[data-cnt] .tile.top {
  box-shadow:
    0 3px 7px rgba(31, 43, 58, .24),
    inset 0 -2px 0 rgba(31, 43, 58, .07),
    inset 0 1px 0 rgba(255, 255, 255, .95);
}

/* 选中 */
.tile.sel {
  box-shadow:
    0 0 0 3px var(--accent),
    0 6px 16px rgba(74, 163, 255, .45),
    inset 0 -2px 0 rgba(31, 43, 58, .07);
  transform:
    translateY(calc(var(--k) * -0.17 * var(--cell)))
    scale(calc((1 - var(--k) * 0.1) * 1.06));
}

/* 消除 */
.tile.removing {
  animation: tilePop 320ms cubic-bezier(.3, .9, .3, 1) forwards;
  will-change: transform, opacity;
}
@keyframes tilePop {
  0%   { transform: translateY(calc(var(--k) * -0.17 * var(--cell))) scale(calc(1 - var(--k) * 0.1)); opacity: 1; }
  38%  { transform: translateY(calc(var(--k) * -0.17 * var(--cell))) scale(calc((1 - var(--k) * 0.1) * 1.18)); opacity: 1; }
  100% { transform: translateY(calc(var(--k) * -0.17 * var(--cell))) scale(calc((1 - var(--k) * 0.1) * .3)) rotate(16deg); opacity: 0; }
}

/* 非法配对 */
.tile.bad { animation: tileBad 340ms ease; }
@keyframes tileBad {
  0%, 100% { transform: translateY(calc(var(--k) * -0.17 * var(--cell))) scale(calc(1 - var(--k) * 0.1)); }
  20% { transform: translateX(-9%) translateY(calc(var(--k) * -0.17 * var(--cell))) scale(calc(1 - var(--k) * 0.1)); }
  45% { transform: translateX(9%)  translateY(calc(var(--k) * -0.17 * var(--cell))) scale(calc(1 - var(--k) * 0.1)); }
  70% { transform: translateX(-5%) translateY(calc(var(--k) * -0.17 * var(--cell))) scale(calc(1 - var(--k) * 0.1)); }
}
.tile.bad::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255, 92, 92, .34);
}

/* 提示高亮 */
.tile.hint { animation: tileHint 620ms ease-in-out 2; }
@keyframes tileHint {
  0%, 100% { box-shadow: 0 1px 2px rgba(31, 43, 58, .16), inset 0 -2px 0 rgba(31, 43, 58, .07); }
  50% { box-shadow: 0 0 0 4px var(--mint), 0 0 20px rgba(53, 201, 163, .8); }
}

/* 新牌淡入（补牌 / 洗牌后） */
.tile.appear { animation: tileAppear 300ms cubic-bezier(.2, .9, .3, 1.1) backwards; }
@keyframes tileAppear {
  from { opacity: 0; transform: translateY(calc(var(--k) * -0.17 * var(--cell))) scale(.4); }
}

/* 整盘抖动（时间告急 / 失败） */
.board.shake { animation: boardShake 320ms ease; }
@keyframes boardShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* ==========================================================
 * 浮动文字（分数 / 连击）
 * ========================================================== */
.floaters {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  overflow: hidden;
}
.floater {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 16px;
  font-weight: 900;
  color: var(--accent-dark);
  text-shadow: 0 1px 0 #fff, 0 0 8px rgba(255, 255, 255, .9);
  animation: floatUp 820ms cubic-bezier(.2, .8, .3, 1) forwards;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.floater.combo { font-size: 20px; color: #e8630a; }
.floater.item { font-size: 20px; color: #17866a; }
.floater.warn { font-size: 18px; color: var(--danger); }
@keyframes floatUp {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  18%  { opacity: 1; transform: translate(-50%, -64%) scale(1.1); }
  35%  { transform: translate(-50%, -72%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -150%) scale(.92); }
}

/* ==========================================================
 * 教学提示条（不打断操作，几秒后自己消失）
 * ========================================================== */
.tip-bar {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  z-index: 70;
  max-width: min(92%, 470px);
  padding: 9px 16px;
  border-radius: 99px;
  background: rgba(31, 43, 58, .9);
  color: #eaf4ff;
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
  box-shadow: var(--shadow-2);
  pointer-events: none;
  animation: tipIn 260ms cubic-bezier(.2, .9, .3, 1.1);
}
.tip-bar[hidden] { display: none; }
@keyframes tipIn {
  from { opacity: 0; transform: translate(-50%, 10px); }
}

/* ==========================================================
 * 死局重排遮罩
 * 作用有两个：一是明确告诉玩家"要变天了"，二是**挡住这段等待里的点击**
 * （以前这 700ms 里点击仍会被处理，玩家会白点好几下）
 * ========================================================== */
.veil {
  position: absolute;
  inset: 0;
  z-index: 80;                     /* 盖在牌上面，pointer-events 默认开启 → 天然挡住点击 */
  display: grid;
  place-items: center;
  border-radius: var(--radius);
  background: rgba(232, 242, 255, .72);
  -webkit-backdrop-filter: blur(2px);
  backdrop-filter: blur(2px);
  animation: veilIn 180ms ease-out;
}
.veil[hidden] { display: none; }
.veil span {
  padding: 10px 20px;
  border-radius: 99px;
  background: rgba(31, 43, 58, .9);
  color: #eaf4ff;
  font-size: 13.5px;
  font-weight: 700;
  box-shadow: var(--shadow-2);
  text-align: center;
  max-width: 88%;
}
@keyframes veilIn { from { opacity: 0; } to { opacity: 1; } }

/* 提示时把拐角格标出来 —— 顺带把"最多拐两个弯"这条规则教给玩家 */
.cell.corner::after {
  content: '';
  position: absolute;
  left: 12%; right: 12%; top: 12%; bottom: 12%;
  border-radius: 30%;
  border: 2px dashed var(--mint);
  background: rgba(53, 201, 163, .14);
  pointer-events: none;
  animation: cornerPulse 620ms ease-in-out 2;
}
@keyframes cornerPulse {
  0%, 100% { opacity: .45; }
  50% { opacity: 1; }
}

/* ==========================================================
 * 时间冻结特效
 * ========================================================== */
.freeze-layer {
  position: absolute;
  inset: 0;
  z-index: 55;
  display: none;
  pointer-events: none;
  place-items: center;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 28% 22%, rgba(180, 235, 255, .5), transparent 42%),
    radial-gradient(circle at 76% 78%, rgba(200, 240, 255, .45), transparent 45%),
    rgba(150, 220, 255, .16);
  box-shadow: inset 0 0 0 3px rgba(120, 200, 255, .55), inset 0 0 60px rgba(150, 220, 255, .5);
  animation: freezeIn 260ms ease-out;
}
.freeze-layer.on { display: grid; }
.freeze-layer span {
  font-size: 15px;
  font-weight: 800;
  color: #10688f;
  background: rgba(255, 255, 255, .82);
  padding: 6px 14px;
  border-radius: 99px;
  box-shadow: var(--shadow-1);
}
@keyframes freezeIn { from { opacity: 0; } to { opacity: 1; } }

/* ==========================================================
 * 底部工具栏
 * ========================================================== */
.toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 10px;
}
.toolbar[hidden] { display: none; }

.tool-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 9px 13px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  transition: transform 120ms, opacity 120ms;
}
.tool-btn .ti { font-size: 15px; font-style: normal; font-family: var(--font-emoji); }
.tool-btn b {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--text-dim);
  font-weight: 700;
}
.tool-btn:active:not(:disabled) { transform: scale(.95); }
.tool-btn:disabled { opacity: .42; }
.tool-btn.disabled-by-mod { opacity: .42; }
.tool-btn.used-up { opacity: .5; }

.item-bar {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}
.item-btn {
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 20px;
  font-family: var(--font-emoji);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-1);
  transition: transform 120ms, opacity 120ms;
}
.item-btn:active:not(:disabled) { transform: scale(.92); }
.item-btn:disabled { opacity: .34; filter: grayscale(.7); }
.item-btn .cnt {
  position: absolute;
  right: -3px;
  bottom: -3px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--accent-dark);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
  font-family: var(--font-ui);
  box-shadow: 0 1px 3px rgba(0, 0, 0, .2);
}
.item-btn.empty .cnt { background: var(--text-faint); }
.item-btn.armed { box-shadow: 0 0 0 3px var(--mint), 0 4px 12px rgba(53, 201, 163, .4); }

@media (hover: hover) and (pointer: fine) {
  .tool-btn:hover:not(:disabled) { background: var(--surface-2); }
  .item-btn:hover:not(:disabled) { background: var(--surface-2); }
}

/* ==========================================================
 * 主菜单
 * ========================================================== */
.menu-panel { text-align: center; }

.logo {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 1px;
  color: var(--accent-dark);
}
.logo em {
  display: block;
  font-size: 17px;
  font-style: normal;
  font-weight: 700;
  color: var(--mint);
  letter-spacing: 6px;
  margin-top: 2px;
}
.tagline {
  margin: 10px 0 20px;
  font-size: 12.5px;
  color: var(--text-faint);
  letter-spacing: .5px;
}

.mode-list { display: flex; flex-direction: column; gap: 10px; }

.mode-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  text-align: left;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: transform 130ms, border-color 130ms, background 130ms;
}
.mode-btn:active { transform: scale(.985); }
.mode-icon { font-size: 26px; font-family: var(--font-emoji); flex: none; }
.mode-text { flex: 1; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.mode-text b { font-size: 15.5px; font-weight: 800; }
.mode-text i { font-size: 11.5px; font-style: normal; color: var(--text-faint); line-height: 1.4; }
.mode-best { flex: none; text-align: right; }
.mode-best em {
  display: inline-block;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
  color: var(--accent-dark);
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 99px;
  padding: 3px 9px;
  white-space: nowrap;
}
@media (hover: hover) and (pointer: fine) {
  .mode-btn:hover { border-color: var(--border-strong); background: #eaf4ff; }
}

.menu-foot {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}
.save-line {
  margin-top: 14px;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-faint);
  min-height: 1em;
}

/* ==========================================================
 * 玩家名入口 + 档案
 * ========================================================== */
.gate-panel { text-align: center; }

.gate-form {
  display: flex;
  gap: 8px;
  margin: 18px 0 8px;
}
.gate-input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
}
.gate-input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(74, 163, 255, .18);
}
.gate-input.bad {
  border-color: var(--danger);
  background: #fff6f6;
  box-shadow: 0 0 0 3px rgba(255, 92, 92, .15);
}

.gate-err {
  margin: 4px 0 0;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--danger);
  text-align: left;
  min-height: 1.2em;
}
.gate-err[hidden] { display: none; }
/* 柔和提示（退出登录后告诉玩家"进度还在"），不是报错，别用红色吓人 */
.gate-err.soft {
  color: var(--text-dim);
  background: #f4f7fb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 10px;
  margin-top: 8px;
}

.gate-note {
  margin-top: 14px;
  font-size: 11.5px;
  line-height: 1.75;
  color: var(--text-faint);
  text-align: left;
}
.gate-note b { color: #b56a00; }

.gate-legacy {
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  background: #fff8e8;
  border: 1px solid #ffe0a8;
  font-size: 12.5px;
  color: #8a5a00;
}
.gate-legacy[hidden] { display: none; }
.gate-legacy-acts {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* 菜单顶部的当前玩家名 */
.profile-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: -4px 0 14px;
  padding: 6px 8px 6px 6px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.pf-avatar {
  flex: none;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #5cb0ff, var(--accent-dark));
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}
.pf-name {
  flex: 1;
  min-width: 0;
  text-align: left;
  font-size: 13.5px;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ghost-btn.sm {
  padding: 5px 12px;
  font-size: 12px;
  border-radius: 99px;
}

/* 档案列表（切换档案弹窗里） */
.profile-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  margin-bottom: 8px;
  border-radius: 12px;
  text-align: left;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: transform 120ms, border-color 120ms;
}
.profile-item:active { transform: scale(.985); }
.profile-item.cur { border-color: var(--accent); background: #eaf4ff; }
.profile-item .nm { flex: 1; font-weight: 800; font-size: 14px; }
.profile-item .tag { font-size: 11px; color: var(--text-faint); }
@media (hover: hover) and (pointer: fine) {
  .profile-item:hover { border-color: var(--border-strong); }
}

/* ==========================================================
 * 排行榜
 * ========================================================== */
.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.tab {
  flex: 1;
  padding: 8px 6px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-dim);
  transition: background 120ms, color 120ms;
}
.tab.on {
  background: #fff;
  color: var(--accent-dark);
  box-shadow: var(--shadow-1);
}
.board-body { max-height: 46vh; overflow: auto; }

.kv.me {
  margin: 0 -8px;
  padding-left: 8px;
  padding-right: 8px;
  border-radius: 8px;
  background: #eaf4ff;
}
.kv .tiny {
  font-size: 10.5px;
  font-style: normal;
  color: var(--text-faint);
  font-weight: 400;
}

/* 云储存按钮：账号与当前玩家不一致时高亮，让人一眼看到 */
.ghost-btn.warn {
  background: #fff5e1;
  border-color: #f0c36d;
  color: #8a5b12;
  font-weight: 600;
}

/* 数据来源徽标：全网 / 本机 必须一眼能分清 */
.board-head {
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.src {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 99px;
  font-size: 11px;
  font-weight: 700;
  margin-right: 4px;
}
.src.net   { background: #e6f6ff; color: var(--accent-dark); border: 1px solid #9fd4ff; }
.src.local { background: #f2f5fa; color: var(--text-dim); border: 1px solid var(--border); }

.link-btn {
  padding: 0 2px;
  color: var(--accent-dark);
  font-size: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  background: none;
  border: 0;
  cursor: pointer;
}

/* 排查信息：默认折叠，用户看不懂就整段转给开发者 */
.diag {
  margin-top: 10px;
  font-size: 11.5px;
  color: var(--text-faint);
}
.diag summary { cursor: pointer; }
.diag pre {
  margin: 6px 0 0;
  padding: 8px 10px;
  background: #f4f7fb;
  border: 1px solid var(--border);
  border-radius: 8px;
  white-space: pre-wrap;
  word-break: break-all;
  font-size: 11px;
  line-height: 1.6;
  color: var(--text-dim);
}

/* ==========================================================
 * 弹窗内容
 * ========================================================== */
.modal-panel h2 {
  font-size: 19px;
  font-weight: 900;
  margin-bottom: 14px;
  text-align: center;
}
.modal-body { font-size: 14px; line-height: 1.7; }
.modal-body .lead {
  text-align: center;
  color: var(--text-dim);
  margin-bottom: 12px;
}
.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}
.modal-actions > * { flex: 1 1 auto; min-width: 110px; }

/* 设置项 */
.set-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px dashed var(--border);
}
.set-row:last-of-type { border-bottom: 0; }
.set-row .nm { font-weight: 700; }
.set-row .ds { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }

.switch {
  flex: none;
  width: 50px;
  height: 29px;
  border-radius: 99px;
  background: #d8e4f2;
  position: relative;
  transition: background 160ms;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 23px; height: 23px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(31, 43, 58, .25);
  transition: transform 160ms cubic-bezier(.3, .9, .3, 1.2);
}
.switch.on { background: var(--mint); }
.switch.on::after { transform: translateX(21px); }

/* 玩法说明表格 */
.rule-list { display: flex; flex-direction: column; gap: 10px; }
.rule {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.rule .ic { flex: none; font-size: 18px; font-family: var(--font-emoji); line-height: 1.3; }
.rule .tx { font-size: 13px; line-height: 1.65; }
.rule .tx b { color: var(--accent-dark); }

/* 奖励卡片 */
.reward {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  margin-top: 10px;
  border-radius: var(--radius);
  background: linear-gradient(120deg, #eaf7ff, #f2fff9);
  border: 1px solid #cfeaff;
}
.reward .ic { font-size: 26px; font-family: var(--font-emoji); }
.reward .tx b { display: block; font-size: 14px; }
.reward .tx i { font-size: 11.5px; font-style: normal; color: var(--text-dim); }

/* ==========================================================
 * 调试面板
 * ========================================================== */
.dev-bar {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 500;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  border-radius: 10px;
  background: rgba(28, 40, 56, .9);
  color: #cfe6ff;
  font-size: 11px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  max-width: calc(100vw - 16px);
  overflow: auto;
}
.dev-bar[hidden] { display: none; }
.dev-bar span { white-space: pre; }
.dev-bar button {
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, .14);
  color: #eaf4ff;
  font-size: 11px;
}

/* ==========================================================
 * 竖屏 / 小屏适配
 * ========================================================== */
@media (max-width: 420px) {
  .app { padding: 0 6px; }
  .logo { font-size: 25px; }
  .mode-text i { display: none; }
  .hud-stat { min-width: 48px; padding: 2px 6px; }
  .hud-stat .value { font-size: 15px; }
  .tool-btn { padding: 8px 10px; font-size: 12px; }
  .tool-btn .ti { font-size: 14px; }
  .item-btn { width: 42px; height: 42px; font-size: 18px; }
  .floaters .floater { font-size: 14px; }
}

/* 矮屏（横屏手机）：把 HUD 压扁，把高度全留给棋盘 */
@media (max-height: 520px) {
  .hud-top { gap: 6px; }
  .hud-stat { flex-direction: row; gap: 5px; padding: 2px 7px; }
  .hud-stat .label { font-size: 10px; }
  .logo { font-size: 22px; }
  .mode-text i { display: none; }
  .menu-foot { margin-top: 12px; }
}

/* ==========================================================
 * 横屏手机：改成「棋盘 + 右侧竖栏」的两栏布局。
 * 原来的上下排布在横屏下会被高度卡死，棋盘在 740px 宽里只占 380px，
 * 右边一大片全浪费掉。
 * ========================================================== */
@media (orientation: landscape) and (max-height: 560px) {
  .app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 208px;
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "board hud"
      "board tools";
    gap: 8px;
    max-width: none;
    height: 100%;
    padding: 0 8px;
  }

  .hud {
    grid-area: hud;
    padding: 4px 0 0;
  }
  .hud-top {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
  /* 竖栏里的图标按钮拉满宽度，别缩成 38px 的小方块飘在右边 */
  .hud-top .icon-btn { width: 100%; height: 32px; font-size: 13px; }
  .hud-stat {
    flex-direction: row;
    justify-content: space-between;
    align-items: baseline;
    min-width: 0;
    padding: 2px 8px;
  }
  .hud-stat .label { font-size: 10px; }
  .hud-stat .value { font-size: 14px; }
  .hud-time { margin-top: 5px; gap: 6px; }
  .time-text { min-width: 42px; font-size: 12px; }
  .hud-mod { margin-top: 5px; }
  .hud-mod .chip { font-size: 11px; padding: 2px 7px; }

  .board-wrap {
    grid-area: board;
    padding: 4px;
  }

  .toolbar {
    grid-area: tools;
    flex-direction: column;
    align-items: stretch;
    gap: 5px;
    padding: 0 0 6px;
  }
  .tool-btn { justify-content: center; padding: 8px 10px; }
  .item-bar {
    flex: none;
    flex-wrap: wrap;
    justify-content: flex-start;
    gap: 5px;
  }
  .item-btn { width: 42px; height: 42px; font-size: 18px; }
}
