/* ============================================================================
 * public/css/style.css —— 军训内务整理模拟器 · 全部样式
 * ----------------------------------------------------------------------------
 * 结构：
 *   0. 变量与基础
 *   1. 通用组件（按钮 / 卡片 / 标签）
 *   2. 开始菜单
 *   3. 游戏主界面（顶部 HUD / 中部棋盘 / 底部工具 / 右侧图鉴）
 *   4. 棋盘与物品方块（含重叠层、选中、消除动画）
 *   5. 查寝摆放界面
 *   6. 结算界面
 *   7. 排行榜 / 提示气泡 / 敲门特效
 *   8. 响应式（手机竖屏 / 平板 / 大屏）
 * ========================================================================== */

/* ============================ 0. 变量与基础 ============================ */
:root {
  --bg-0: #0b1410;
  --bg-1: #101d16;
  --bg-2: #16271d;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: rgba(255, 255, 255, 0.075);
  --line: rgba(168, 224, 99, 0.18);
  --line-strong: rgba(168, 224, 99, 0.42);
  --army: #4c8c2b;
  --army-light: #a8e063;
  --army-dark: #2c5720;
  --gold: #f2cf6b;
  --cream: #f3ead6;
  --text: #e8f2e9;
  --text-dim: #9fb4a6;
  --danger: #ff6b6b;
  --danger-soft: #ffb3b3;
  --ok: #7ee07a;
  --shadow-lg: 0 22px 60px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.38);
  --radius: 16px;
  --radius-sm: 10px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 700px at 15% -10%, rgba(76, 140, 43, 0.28), transparent 62%),
    radial-gradient(900px 600px at 105% 8%, rgba(242, 207, 107, 0.12), transparent 60%),
    linear-gradient(180deg, var(--bg-0), var(--bg-1) 42%, #0a120e 100%);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
}

/* 背景扫描线纹理：营造军旅作战地图的质感 */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image:
    linear-gradient(rgba(168, 224, 99, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 224, 99, 0.035) 1px, transparent 1px);
  background-size: 34px 34px, 34px 34px;
  mask-image: radial-gradient(120% 90% at 50% 0%, #000 30%, transparent 100%);
}

#app {
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.view { display: none; }
.view.active { display: block; animation: viewIn 0.36s ease both; }

@keyframes viewIn {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ============================ 1. 通用组件 ============================ */

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease, border-color 0.16s ease;
  white-space: nowrap;
}
.btn:hover { transform: translateY(-2px); border-color: var(--army-light); box-shadow: 0 10px 22px rgba(76, 140, 43, 0.28); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn[disabled], .btn.disabled { opacity: 0.42; cursor: not-allowed; transform: none; box-shadow: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--army), var(--army-light));
  border-color: transparent;
  color: #10200f;
  box-shadow: 0 12px 26px rgba(76, 140, 43, 0.36);
}
.btn-primary:hover { box-shadow: 0 16px 34px rgba(76, 140, 43, 0.46); }

.btn-gold {
  background: linear-gradient(135deg, #d8a33c, var(--gold));
  color: #2a1e05;
  border-color: transparent;
}

.btn-ghost { background: rgba(255, 255, 255, 0.03); }

.btn-sm { font-size: 13px; padding: 8px 14px; }
.btn-block { width: 100%; }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(6px);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(168, 224, 99, 0.12);
  border: 1px solid var(--line);
  color: var(--army-light);
}
.tag-gold { background: rgba(242, 207, 107, 0.14); color: var(--gold); border-color: rgba(242, 207, 107, 0.32); }
.tag-danger { background: rgba(255, 107, 107, 0.14); color: var(--danger-soft); border-color: rgba(255, 107, 107, 0.34); }

.muted { color: var(--text-dim); }
.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ============================ 2. 开始菜单 ============================ */

.menu-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 34px 20px 60px;
}

.hero {
  text-align: center;
  padding: 18px 10px 6px;
}
.hero .kicker {
  letter-spacing: 4px;
  font-size: 12px;
  color: var(--army-light);
  text-transform: uppercase;
}
.hero h1 {
  margin: 10px 0 6px;
  font-size: clamp(30px, 6vw, 52px);
  line-height: 1.1;
  letter-spacing: 2px;
  background: linear-gradient(120deg, #fff 8%, var(--army-light) 46%, var(--gold) 96%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: 0 12px 40px rgba(76, 140, 43, 0.28);
}
.hero p { max-width: 720px; margin: 8px auto; color: var(--text-dim); line-height: 1.75; font-size: 14.5px; }

.hero-badges { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 16px 0 6px; }

.diff-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 26px 0 18px;
}

.diff-card {
  position: relative;
  overflow: hidden;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.02));
  padding: 20px 18px 18px;
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}
.diff-card:hover { transform: translateY(-5px); border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.diff-card.selected { border-color: var(--army-light); box-shadow: 0 0 0 2px rgba(168, 224, 99, 0.28), var(--shadow-md); }
.diff-card.selected::after {
  content: "已选择";
  position: absolute;
  top: 14px; right: -34px;
  transform: rotate(38deg);
  background: linear-gradient(135deg, var(--army), var(--army-light));
  color: #10200f;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 38px;
  letter-spacing: 2px;
}
.diff-card h3 { margin: 8px 0 2px; font-size: 22px; }
.diff-card .sub { font-size: 12px; color: var(--gold); letter-spacing: 2px; }
.diff-card .emoji { font-size: 30px; }
.diff-card ul { margin: 12px 0 0; padding: 0; list-style: none; }
.diff-card li { display: flex; justify-content: space-between; font-size: 13px; color: var(--text-dim); padding: 4px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.07); }
.diff-card li b { color: var(--text); font-weight: 600; }
.diff-card .desc { margin-top: 10px; font-size: 12.5px; color: var(--text-dim); line-height: 1.6; }

.menu-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin: 10px 0 26px; }

.rules-grid { display: grid; grid-template-columns: 1.15fr 0.85fr; gap: 16px; }
.rules-grid h3 { margin: 0 0 10px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.rules-list { margin: 0; padding-left: 20px; color: var(--text-dim); font-size: 13.6px; line-height: 1.9; }
.rules-list b { color: var(--army-light); }

.item-legend { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: 8px; }
.legend-cell {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 9px 6px; border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 11px; color: var(--text-dim); text-align: center;
}
.legend-cell .ico { font-size: 20px; }
.legend-cell .w { color: var(--gold); font-weight: 700; }

/* ============================ 3. 游戏主界面 ============================ */

.game-top {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: linear-gradient(180deg, rgba(11, 20, 16, 0.96), rgba(11, 20, 16, 0.72));
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.game-top .brand { font-weight: 800; letter-spacing: 1px; display: flex; align-items: center; gap: 8px; }
.game-top .brand small { color: var(--text-dim); font-weight: 500; letter-spacing: 0; }
.game-top .spacer { flex: 1 1 auto; }

.hud { display: flex; flex-wrap: wrap; gap: 8px; }
.hud-chip {
  display: flex; align-items: center; gap: 7px;
  padding: 7px 13px; border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 13px;
  min-width: 92px;
}
.hud-chip .k { color: var(--text-dim); font-size: 11.5px; }
.hud-chip .v { font-weight: 800; font-size: 16px; font-variant-numeric: tabular-nums; }
.hud-chip.timer .v { color: var(--army-light); }
.hud-chip.timer.warn { border-color: rgba(255, 107, 107, 0.55); background: rgba(255, 107, 107, 0.1); animation: pulseWarn 1s ease-in-out infinite; }
.hud-chip.timer.warn .v { color: var(--danger-soft); }
@keyframes pulseWarn { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px) scale(1.03); } }
.hud-chip.supply .v { color: var(--gold); }

.game-main {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr) 236px;
  gap: 16px;
  align-items: start;
  padding: 16px;
  max-width: 1520px;
  margin: 0 auto;
}

.side { display: flex; flex-direction: column; gap: 12px; position: sticky; top: 76px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.panel h4 { margin: 0 0 10px; font-size: 13.5px; letter-spacing: 1px; color: var(--army-light); display: flex; align-items: center; gap: 6px; }
.panel h4 .count { margin-left: auto; color: var(--text-dim); font-weight: 500; letter-spacing: 0; }

/* 收纳袋（已消除物品统计） */
.bag-list { display: flex; flex-direction: column; gap: 6px; max-height: 340px; overflow-y: auto; padding-right: 2px; }
.bag-list::-webkit-scrollbar { width: 6px; }
.bag-list::-webkit-scrollbar-thumb { background: rgba(168, 224, 99, 0.28); border-radius: 3px; }
.bag-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px;
  padding: 5px 7px; border-radius: 9px;
  background: rgba(255, 255, 255, 0.035);
}
.bag-row .ico { font-size: 15px; }
.bag-row .nm { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-dim); }
.bag-row .num { font-weight: 800; font-variant-numeric: tabular-nums; }
.bag-row.flash { animation: bagFlash 0.6s ease; }
@keyframes bagFlash {
  0% { background: rgba(168, 224, 99, 0.5); transform: translateX(6px); }
  100% { background: rgba(255, 255, 255, 0.035); transform: none; }
}
.bag-row .w { color: var(--gold); font-size: 11px; }

/* 棋盘中区 */
.board-area { display: flex; flex-direction: column; align-items: center; gap: 12px; min-width: 0; }
.board-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center; }

.board-shell {
  position: relative;
  width: 100%;
  max-width: min(76vh, 720px);
  padding: 14px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(0, 0, 0, 0.18)),
    repeating-linear-gradient(45deg, rgba(168, 224, 99, 0.03) 0 8px, transparent 8px 16px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg), inset 0 0 60px rgba(0, 0, 0, 0.4);
}
/* 宿舍四个角落的"床/桌"提示 */
.board-shell::before,
.board-shell::after {
  content: "";
  position: absolute;
  width: 58px; height: 58px;
  border: 2px solid rgba(168, 224, 99, 0.28);
  pointer-events: none;
}
.board-shell::before { top: 8px; left: 8px; border-right: none; border-bottom: none; border-radius: 14px 0 0 0; }
.board-shell::after { bottom: 8px; right: 8px; border-left: none; border-top: none; border-radius: 0 0 14px 0; }

.board {
  display: grid;
  position: relative;
  grid-template-columns: repeat(var(--cols, 8), minmax(0, 1fr));
  gap: 4px;
  width: 100%;
}

.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid rgba(255, 255, 255, 0.045);
  transition: background 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.cell.empty::after {
  content: "";
  position: absolute; inset: 26%;
  border-radius: 50%;
  border: 1px dashed rgba(255, 255, 255, 0.12);
}
.cell.clickable:hover { background: rgba(168, 224, 99, 0.09); border-color: var(--line); }
.cell.selected { box-shadow: inset 0 0 0 2px var(--army-light), 0 0 16px rgba(168, 224, 99, 0.35); background: rgba(168, 224, 99, 0.14); }
.cell.selected-anchor { box-shadow: inset 0 0 0 3px var(--gold), 0 0 20px rgba(242, 207, 107, 0.45); }
.cell.shake { animation: shake 0.34s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px) rotate(-2deg); }
  45% { transform: translateX(4px) rotate(2deg); }
  70% { transform: translateX(-3px); }
}
.cell.hint::before {
  content: "";
  position: absolute; inset: -3px;
  border-radius: 12px;
  border: 2px dashed var(--gold);
  animation: hintPulse 1.1s ease-in-out infinite;
}
@keyframes hintPulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }

/* ------- 补给待放置状态：棋盘整体呼吸提示 + 每个方块可替换 ------- */
.board.supply-mode .cell.clickable {
  cursor: crosshair;
  box-shadow: inset 0 0 0 1px rgba(242, 207, 107, 0.45);
  animation: supplyBreathe 1.4s ease-in-out infinite;
}
.board.supply-mode .cell.clickable:hover { background: rgba(242, 207, 107, 0.16); }
.board.supply-mode .cell.clickable:hover .token.top { transform: scale(1.12) rotate(-4deg); }
@keyframes supplyBreathe {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(242, 207, 107, 0.35); }
  50% { box-shadow: inset 0 0 0 2px rgba(242, 207, 107, 0.75), 0 0 14px rgba(242, 207, 107, 0.35); }
}
/* 被替换下来的旧方块：向上飞走后淡出 */
.cell.replacing .token.top { animation: replaceOut 0.4s ease forwards; }
@keyframes replaceOut {
  0% { transform: none; }
  100% { transform: translateY(-130%) rotate(-24deg) scale(0.4); opacity: 0; }
}
/* 补给按钮进入待放置状态 */
.btn.armed {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(242, 207, 107, 0.35), 0 0 22px rgba(242, 207, 107, 0.35);
  animation: supplyBreathe 1.4s ease-in-out infinite;
}

/* ------- 物品方块（一格一件，互不重叠） ------- */
.token {
  position: absolute;
  left: 0; top: 0;
  width: 100%; height: 100%;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: clamp(15px, 3.1vh, 26px);
  line-height: 1;
  user-select: none;
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: transform 0.18s ease, filter 0.18s ease, opacity 0.18s ease;
  will-change: transform;
}
.token.top { z-index: 5; }

.cell.clickable .token.top { cursor: pointer; }
.cell.clickable:hover .token.top { transform: translateY(-3px) scale(1.06); }

/* 交换 / 下落 / 补位时，正在移动的方块要盖住旁边的格子 */
.cell.animating { z-index: 20; }
.cell.animating .token.top { z-index: 20; }

/* 消除动画：向上飞起 + 缩小 + 淡出（消除成功后） */
.cell.clearing .token.top {
  animation: clearPop 0.42s cubic-bezier(0.22, 1.2, 0.36, 1) forwards;
  z-index: 9;
}
@keyframes clearPop {
  0% { transform: translateY(0) scale(1); }
  35% { transform: translateY(-16%) scale(1.16) rotate(6deg); filter: brightness(1.7); }
  100% { transform: translateY(-120%) scale(0.3) rotate(18deg); opacity: 0; }
}

/* 交换失败：两块弹回原位并抖一下 */
.cell.swap-back .token.top { animation: swapBack 0.42s cubic-bezier(0.36, 0.07, 0.19, 0.97) both; }
@keyframes swapBack {
  0% { transform: translate(var(--swap-x, 0), var(--swap-y, 0)); }
  55% { transform: translate(calc(var(--swap-x, 0px) * -0.18), calc(var(--swap-y, 0px) * -0.18)); }
  100% { transform: translate(0, 0); }
}

/* 顶部随机补位：新方块从上方向下掉入 */
.cell.dropping .token.top { animation: dropIn 0.42s cubic-bezier(0.2, 1.25, 0.4, 1) both; }
@keyframes dropIn {
  0% { transform: translateY(-260%) scale(0.72); opacity: 0; }
  65% { transform: translateY(5%) scale(1.05); opacity: 1; }
  100% { transform: none; }
}

/* 被选中的方块：轻微上浮 + 呼吸，提示"点它旁边的格子来交换" */
.cell.selected .token.top { animation: selectedPulse 1.2s ease-in-out infinite; }
@keyframes selectedPulse {
  0%, 100% { transform: translateY(-2px) scale(1.04); }
  50% { transform: translateY(-4px) scale(1.08); }
}
/* 连击 / 加分浮字 */
.floater {
  position: absolute;
  left: 50%; top: 20%;
  transform: translateX(-50%);
  font-weight: 900;
  font-size: 15px;
  color: var(--gold);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.75);
  pointer-events: none;
  z-index: 40;
  animation: floatUp 0.95s ease-out forwards;
  white-space: nowrap;
}
@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.8); }
  25% { opacity: 1; transform: translate(-50%, -4px) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -46px) scale(1); }
}

/* 底部工具栏 */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.supply-btn { position: relative; }
.supply-btn .dots { display: inline-flex; gap: 4px; margin-left: 8px; }
.supply-btn .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 8px rgba(242, 207, 107, 0.6); }
.supply-btn .dot.used { background: rgba(255, 255, 255, 0.18); box-shadow: none; }

/* 右侧：内务细则 / 图鉴 */
.rule-item { font-size: 12.4px; color: var(--text-dim); line-height: 1.6; padding: 6px 0; border-bottom: 1px dashed rgba(255, 255, 255, 0.07); }
.rule-item b { color: var(--cream); }
.zone-mini { display: flex; flex-direction: column; gap: 7px; }
.zone-mini .row { display: flex; gap: 8px; font-size: 12px; align-items: flex-start; }
.zone-mini .row .e { font-size: 15px; }
.zone-mini .row .t { color: var(--text-dim); line-height: 1.5; }
.zone-mini .row .t b { color: var(--army-light); display: block; font-size: 12.4px; }

.final-minute-banner {
  position: fixed;
  left: 50%; top: 84px;
  transform: translateX(-50%);
  z-index: 60;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(180, 40, 40, 0.92), rgba(120, 18, 18, 0.92));
  border: 1px solid rgba(255, 200, 200, 0.42);
  box-shadow: 0 14px 40px rgba(160, 20, 20, 0.45);
  font-weight: 800; letter-spacing: 1px;
  animation: bannerIn 0.5s ease both, bannerPulse 1.6s ease-in-out infinite 0.5s;
}
@keyframes bannerIn { from { opacity: 0; transform: translate(-50%, -18px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes bannerPulse { 0%, 100% { box-shadow: 0 14px 40px rgba(160, 20, 20, 0.42); } 50% { box-shadow: 0 14px 54px rgba(255, 60, 60, 0.65); } }

/* 敲门时的画面震动 */
body.knock-shake #app { animation: knockShake 0.5s ease; }
@keyframes knockShake {
  0%, 100% { transform: translate(0, 0); }
  15% { transform: translate(-5px, 2px) rotate(-0.35deg); }
  35% { transform: translate(5px, -2px) rotate(0.35deg); }
  55% { transform: translate(-3px, 1px); }
  75% { transform: translate(3px, -1px); }
}

/* 查寝员喊话气泡 */
.shout {
  position: fixed;
  right: 18px; bottom: 18px;
  z-index: 70;
  max-width: min(76vw, 330px);
  padding: 12px 16px;
  border-radius: 16px 16px 4px 16px;
  background: linear-gradient(135deg, #f3ead6, #e6d7b4);
  color: #3a2f14;
  font-size: 13.6px;
  font-weight: 600;
  line-height: 1.55;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  animation: shoutIn 0.4s cubic-bezier(0.2, 1.2, 0.35, 1) both;
}
.shout::after {
  content: "";
  position: absolute; right: 16px; bottom: -9px;
  width: 16px; height: 16px;
  background: #e6d7b4;
  transform: rotate(45deg);
}
.shout .who { display: block; font-size: 11px; color: #8a6a1f; letter-spacing: 2px; margin-bottom: 3px; }
.shout.out { animation: shoutOut 0.3s ease forwards; }
@keyframes shoutIn { from { opacity: 0; transform: translateY(16px) scale(0.92); } to { opacity: 1; transform: none; } }
@keyframes shoutOut { to { opacity: 0; transform: translateY(10px) scale(0.94); } }

/* 弹出提示（toast） */
.toast-wrap { position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  padding: 9px 18px;
  border-radius: 999px;
  font-size: 13.5px;
  font-weight: 600;
  background: rgba(12, 22, 16, 0.94);
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-md);
  animation: toastIn 0.28s ease both;
}
.toast.bad { border-color: rgba(255, 107, 107, 0.5); color: var(--danger-soft); }
.toast.good { border-color: var(--line-strong); color: var(--army-light); }
.toast.gold { border-color: rgba(242, 207, 107, 0.5); color: var(--gold); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============================ 5. 查寝摆放界面 ============================ */

.place-head {
  text-align: center;
  padding: 14px 16px 4px;
}
.place-head h2 { margin: 6px 0; font-size: clamp(20px, 3.4vw, 28px); letter-spacing: 1px; }
.place-head p { margin: 4px 0; color: var(--text-dim); font-size: 13.5px; }
.place-timer { font-family: var(--mono); font-size: 26px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; }

.place-wrap { max-width: 1180px; margin: 0 auto; padding: 10px 16px 48px; }

.place-current {
  display: flex; align-items: center; gap: 14px; justify-content: center;
  margin: 12px auto 18px;
  padding: 14px 22px;
  border-radius: 20px;
  background: linear-gradient(135deg, rgba(168, 224, 99, 0.12), rgba(242, 207, 107, 0.08));
  border: 1px solid var(--line-strong);
  max-width: 620px;
  animation: currentIn 0.3s ease both;
}
@keyframes currentIn { from { opacity: 0; transform: scale(0.94); } to { opacity: 1; transform: none; } }
.place-current .big { font-size: 42px; line-height: 1; filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.4)); }
.place-current .meta { text-align: left; }
.place-current .meta .nm { font-size: 19px; font-weight: 800; }
.place-current .meta .tip { font-size: 12.5px; color: var(--text-dim); margin-top: 3px; }
.place-current .meta .w { color: var(--gold); font-weight: 700; }

.zone-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.zone-card {
  position: relative;
  border-radius: 18px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015));
  padding: 16px 14px;
  cursor: pointer;
  text-align: center;
  transition: transform 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}
.zone-card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: var(--shadow-md); }
.zone-card .e { font-size: 32px; }
.zone-card .n { font-size: 15.5px; font-weight: 700; margin-top: 6px; }
.zone-card .h { font-size: 11.8px; color: var(--text-dim); margin-top: 5px; line-height: 1.5; }
.zone-card .stat { margin-top: 8px; font-size: 12px; color: var(--gold); font-variant-numeric: tabular-nums; }
.zone-card.ok { animation: zoneOk 0.5s ease; border-color: var(--ok); }
@keyframes zoneOk {
  0% { background: rgba(126, 224, 122, 0.45); transform: scale(1.03); }
  100% { background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015)); }
}
.zone-card.bad { animation: shake 0.34s ease; border-color: var(--danger); }
.zone-card.hintable::after {
  content: "放这里 ✓";
  position: absolute; top: -10px; right: 12px;
  background: var(--ok); color: #10200f;
  font-size: 11px; font-weight: 800;
  padding: 3px 9px; border-radius: 999px;
  box-shadow: 0 6px 16px rgba(126, 224, 122, 0.4);
}

.place-stats { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 18px 0 4px; }

/* ============================ 6. 结算界面 ============================ */

.result-wrap { max-width: 1080px; margin: 0 auto; padding: 26px 18px 60px; }
.result-hero {
  text-align: center;
  padding: 26px 20px;
  border-radius: 24px;
  background: radial-gradient(600px 260px at 50% 0%, rgba(168, 224, 99, 0.16), transparent 70%), var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-lg);
}
.result-hero .rank { font-size: 54px; line-height: 1; animation: rankIn 0.7s cubic-bezier(0.2, 1.3, 0.4, 1) both; }
@keyframes rankIn { 0% { transform: scale(0.3) rotate(-18deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.result-hero h2 { margin: 10px 0 4px; font-size: 27px; letter-spacing: 2px; }
.result-hero .stars { font-size: 26px; letter-spacing: 6px; color: var(--gold); }
.result-hero .comment { color: var(--text-dim); font-size: 13.6px; margin-top: 8px; }
.score-big {
  font-size: clamp(46px, 11vw, 82px);
  font-weight: 900;
  line-height: 1;
  margin: 12px 0 2px;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(120deg, #fff, var(--army-light) 52%, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.score-big + .label { color: var(--text-dim); font-size: 12.5px; letter-spacing: 4px; }

.result-grid { display: grid; grid-template-columns: 1.05fr 0.95fr; gap: 16px; margin-top: 18px; }
.formula { display: flex; flex-direction: column; gap: 8px; }
.formula .line { display: flex; justify-content: space-between; align-items: baseline; font-size: 13.6px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.035); }
.formula .line b { font-variant-numeric: tabular-nums; }
.formula .line.total { background: rgba(168, 224, 99, 0.14); border: 1px solid var(--line-strong); font-size: 15.5px; font-weight: 800; }
.formula .line.total b { color: var(--army-light); font-size: 19px; }
.formula .small { font-size: 11.8px; color: var(--text-dim); line-height: 1.7; }

.detail-table { width: 100%; border-collapse: collapse; font-size: 12.8px; }
.detail-table th, .detail-table td { padding: 7px 8px; text-align: left; border-bottom: 1px dashed rgba(255, 255, 255, 0.08); }
.detail-table th { color: var(--text-dim); font-weight: 600; font-size: 11.6px; letter-spacing: 1px; }
.detail-table td.num, .detail-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.detail-table tr:hover td { background: rgba(168, 224, 99, 0.06); }
.detail-scroll { max-height: 320px; overflow-y: auto; }

.save-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.input {
  flex: 1 1 180px;
  min-width: 0;
  padding: 11px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s ease;
}
.input:focus { border-color: var(--army-light); }
.input::placeholder { color: rgba(255, 255, 255, 0.32); }

.result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 22px; }

/* ============================ 7. 排行榜 ============================ */

.board-list { display: flex; flex-direction: column; gap: 6px; }
.board-row {
  display: grid;
  grid-template-columns: 34px 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 9px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 13.4px;
}
.board-row .rk { font-weight: 900; color: var(--text-dim); font-variant-numeric: tabular-nums; text-align: center; }
.board-row.gold .rk { color: var(--gold); }
.board-row.silver .rk { color: #d7dde3; }
.board-row.bronze .rk { color: #d9a06a; }
.board-row .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .meta { color: var(--text-dim); font-size: 11.6px; }
.board-row .sc { font-weight: 800; color: var(--army-light); font-variant-numeric: tabular-nums; }

.loading { text-align: center; color: var(--text-dim); font-size: 13px; padding: 18px; }
.spinner {
  display: inline-block; width: 16px; height: 16px; margin-right: 8px;
  border: 2px solid rgba(168, 224, 99, 0.25); border-top-color: var(--army-light);
  border-radius: 50%; animation: spin 0.8s linear infinite; vertical-align: -3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 帮助/图鉴弹层 */
.modal-mask {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(4, 8, 6, 0.72);
  backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 18px;
  animation: viewIn 0.24s ease both;
}
.modal {
  width: min(760px, 100%);
  max-height: 86vh;
  overflow-y: auto;
  background: linear-gradient(180deg, #16271d, #101d16);
  border: 1px solid var(--line-strong);
  border-radius: 22px;
  padding: 22px;
  box-shadow: var(--shadow-lg);
}
.modal h3 { margin: 0 0 6px; font-size: 20px; }
.modal .close { float: right; }

/* ============================ 8. 响应式 ============================ */

@media (max-width: 1180px) {
  .game-main { grid-template-columns: 148px minmax(0, 1fr) 210px; gap: 12px; padding: 12px; }
  .side { position: static; }
}

@media (max-width: 980px) {
  .game-main { grid-template-columns: minmax(0, 1fr); }
  .side-left { order: 3; }
  .side-right { order: 4; }
  .board-area { order: 1; }
  .bag-list { max-height: none; flex-direction: row; flex-wrap: wrap; }
  .bag-row { flex: 0 0 auto; }
  .board-shell { max-width: min(92vw, 620px); }
  .rules-grid { grid-template-columns: 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  .diff-grid { grid-template-columns: 1fr; }
  .diff-card.selected::after { right: -28px; }
}

@media (max-width: 620px) {
  .menu-wrap { padding: 20px 12px 40px; }
  .hero h1 { letter-spacing: 1px; }
  .game-top { padding: 8px 10px; gap: 8px; }
  .game-top .brand small { display: none; }
  .hud { width: 100%; gap: 6px; }
  .hud-chip { flex: 1 1 44%; min-width: 0; padding: 6px 10px; }
  .hud-chip .v { font-size: 14.5px; }
  .board { gap: 3px; }
  .cell { border-radius: 7px; }
  .token { border-radius: 7px; font-size: 15px; }
  .zone-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .place-current { padding: 12px 14px; gap: 10px; }
  .place-current .big { font-size: 32px; }
  .place-current .meta .nm { font-size: 16px; }
  .board-row { grid-template-columns: 28px 1fr auto; }
  .board-row .meta { display: none; }
  .toast-wrap { bottom: 14px; }
  .shout { right: 10px; bottom: 10px; max-width: 80vw; }
}

/* 降低动画（尊重系统"减少动态效果"设置） */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.05ms !important; }
}
