/* ============================================================
   apps/minesweeper.html 样式（美化重写 · v2）
   ------------------------------------------------------------
   设计要点：
   - 蓝紫品牌渐变，立体浮雕棋盘，等宽 LCD 数字
   - 圆角统一 4/8/12/20；阴影三档
   - 难度切换器分段控件；格子 3D 凸起/凹陷
   - 棋盘图标全 SVG（旗/雷/问号）；胜负弹窗动效 + 彩带
   - 状态卡根据对局状态切换整卡背景
   ============================================================ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
/* body 用 min-height（而非 height:100%）：让 body 高度随内容增长，保证 sticky 顶栏全程有效 */
html { height: 100%; }
body { min-height: 100%; }

/* ===== 设计 Token ===== */
:root {
  /* 品牌色 */
  --brand-1: #2563eb;       /* 蓝 */
  --brand-2: #7c3aed;       /* 紫 */
  --brand-grad: linear-gradient(135deg, #2563eb 0%, #4f46e5 45%, #7c3aed 100%);
  --brand-grad-soft: linear-gradient(135deg, rgba(37,99,235,0.10) 0%, rgba(124,58,237,0.10) 100%);

  /* 底色 */
  --bg-page: #f5f7fb;
  --bg-card: #ffffff;
  --bg-soft: #eef2ff;
  --bg-header: rgba(255, 255, 255, 0.72);
  --bg-board-inner: #c7d2fe;        /* 棋盘凹陷深底 */
  --bg-board-frame: #1e293b;        /* 棋盘外框金属 */

  /* 文字 */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-hint: #94a3b8;
  --text-on-accent: #ffffff;

  /* 边线 */
  --border: #e2e8f0;
  --border-soft: #f1f5f9;
  --border-strong: #cbd5e1;

  /* 状态 */
  --success: #10b981;
  --success-soft: #d1fae5;
  --warning: #f59e0b;
  --warning-soft: #fef3c7;
  --danger: #ef4444;
  --danger-soft: #fee2e2;

  /* 扫雷数字经典配色（保持识别度） */
  --n1: #2563eb; --n2: #10b981; --n3: #ef4444; --n4: #7c3aed;
  --n5: #92400e; --n6: #0891b2; --n7: #1f2937; --n8: #6b7280;

  /* 圆角 */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 8px 24px rgba(37, 99, 235, 0.10);
  --shadow-lg: 0 24px 60px rgba(15, 23, 42, 0.25);
  --shadow-inset: inset 0 1px 2px rgba(15, 23, 42, 0.06);

  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: 'SF Mono', 'Consolas', 'JetBrains Mono', ui-monospace, monospace;
}

/* ===== 基础 ===== */
body {
  background:
    radial-gradient(ellipse 70% 50% at 50% 0%, rgba(124, 58, 237, 0.10) 0%, transparent 55%),
    radial-gradient(ellipse 60% 50% at 100% 100%, rgba(37, 99, 235, 0.08) 0%, transparent 55%),
    radial-gradient(ellipse 50% 40% at 0% 100%, rgba(99, 102, 241, 0.06) 0%, transparent 55%),
    var(--bg-page);
  color: var(--text-primary);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  user-select: none;
  -webkit-user-select: none;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }

/* ===== 顶栏 / 返回链接 ===== */
.back-link-wrapper {
  padding: 0 40px 12px;
  background: var(--bg-header);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border-bottom: 1px solid var(--border-soft);
}
.back-link {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
  position: relative;
  transition: color 0.18s ease;
}
.back-link:hover { color: var(--brand-1); }

/* ===== 主体 ===== */
main {
  flex: 1;
  padding: 32px 40px 60px;
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* ===== 头部 Head ===== */
.head { text-align: center; margin-bottom: 28px; }

.head-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px; height: 64px;
  border-radius: var(--r-lg);
  background: var(--brand-grad);
  color: #fff;
  margin-bottom: 14px;
  box-shadow:
    0 12px 28px rgba(37, 99, 235, 0.30),
    inset 0 1px 0 rgba(255, 255, 255, 0.25);
  position: relative;
}
.head-icon::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: calc(var(--r-lg) + 4px);
  background: var(--brand-grad);
  opacity: 0.15;
  z-index: -1;
  filter: blur(8px);
}
.head-icon svg { width: 36px; height: 36px; }

.head .eyebrow {
  display: inline-block;
  padding: 4px 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.32em;
  color: var(--brand-1);
  background: var(--brand-grad-soft);
  border: 1px solid rgba(124, 58, 237, 0.18);
  border-radius: 999px;
  margin-bottom: 14px;
}

.head h1 {
  font-size: 36px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
  margin-bottom: 12px;
}

.head .sub {
  margin-top: 0;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.7;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}
.head .sub .chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
.head .sub .chip svg { width: 12px; height: 12px; opacity: 0.85; }
.head .sub .chip b { color: var(--text-primary); font-weight: 600; }

/* ===== 难度切换器（分段控件） ===== */
.diff-row {
  display: inline-flex;
  padding: 5px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  gap: 0;
  position: relative;
}
.diff-row::before {
  /* 滑动指示器由 .diff-btn.active 控制位置，通过 transform 切换 */
  content: '';
  position: absolute;
  top: 5px; bottom: 5px;
  left: 5px;
  width: var(--seg-w, 110px);
  transform: translateX(var(--seg-x, 0px));
  background: var(--brand-grad);
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.30);
  transition: transform 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2), width 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  z-index: 0;
}
.diff-btn {
  position: relative;
  z-index: 1;
  padding: 9px 22px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-secondary);
  background: transparent;
  border: none;
  cursor: pointer;
  transition: color 0.22s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
}
.diff-btn svg { width: 13px; height: 13px; opacity: 0.85; }
.diff-btn:hover { color: var(--brand-1); }
.diff-btn.active { color: #fff; }
.diff-btn.active svg { opacity: 1; }

/* ===== 主区网格 ===== */
.game-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 24px;
  align-items: start;
}

/* ===== 棋盘卡片 ===== */
.board-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 22px;
  box-shadow:
    var(--shadow-md),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  position: relative;
  overflow: hidden;
}
.board-card::before {
  /* 顶部高光线 */
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.9), transparent);
  pointer-events: none;
}

.board-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
}
.board-head .l {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.28em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.board-head .info {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.board-head .info b {
  color: var(--text-primary);
  font-weight: 700;
  margin: 0 2px;
}

/* ===== 棋盘 ===== */
.board {
  display: grid;
  gap: 3px;
  background: var(--bg-board-inner);
  padding: 10px;
  border-radius: var(--r-md);
  margin: 0 auto;
  width: max-content;
  max-width: 100%;
  overflow-x: auto;
  /* 凹陷内阴影 */
  box-shadow:
    inset 0 2px 6px rgba(15, 23, 42, 0.12),
    inset 0 -1px 0 rgba(255, 255, 255, 0.4);
}

/* ===== 单元格 ===== */
.cell {
  width: var(--cell-size, 28px);
  height: var(--cell-size, 28px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--cell-font, 14px);
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  line-height: 1;
  border-radius: 4px;
  position: relative;
  /* 3D 凸起：上左亮 + 下右暗 */
  background: linear-gradient(180deg, #eef2ff 0%, #c7d2fe 100%);
  border: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.85),
    inset -1px -1px 0 rgba(99, 102, 241, 0.35),
    0 1px 0 rgba(15, 23, 42, 0.04);
  transition:
    transform 0.08s ease,
    box-shadow 0.12s ease,
    background 0.18s ease;
}
.cell:hover {
  background: linear-gradient(180deg, #e0e7ff 0%, #a5b4fc 100%);
  transform: translateY(-1px);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.9),
    inset -1px -1px 0 rgba(99, 102, 241, 0.45),
    0 4px 8px rgba(37, 99, 235, 0.18);
}
.cell:active {
  /* 按下内陷 */
  transform: translateY(0);
  box-shadow:
    inset 1px 1px 2px rgba(99, 102, 241, 0.4),
    inset -1px -1px 0 rgba(255, 255, 255, 0.5);
}

/* 已翻开：凹陷 */
.cell.revealed {
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  border-color: rgba(203, 213, 225, 0.6);
  cursor: default;
  box-shadow:
    inset 1px 1px 2px rgba(15, 23, 42, 0.08),
    inset -1px -1px 0 rgba(255, 255, 255, 0.8);
  animation: ms-pop 0.16s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}
.cell.revealed:hover {
  background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
  transform: none;
  box-shadow:
    inset 1px 1px 2px rgba(15, 23, 42, 0.08),
    inset -1px -1px 0 rgba(255, 255, 255, 0.8);
}
@keyframes ms-pop {
  0%   { transform: scale(0.6); opacity: 0.4; }
  60%  { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

/* 数字 */
.cell.n1 { color: var(--n1); text-shadow: 0 1px 2px rgba(37,99,235,0.18); }
.cell.n2 { color: var(--n2); text-shadow: 0 1px 2px rgba(16,185,129,0.18); }
.cell.n3 { color: var(--n3); text-shadow: 0 1px 2px rgba(239,68,68,0.18); }
.cell.n4 { color: var(--n4); text-shadow: 0 1px 2px rgba(124,58,237,0.18); }
.cell.n5 { color: var(--n5); text-shadow: 0 1px 2px rgba(146,64,14,0.18); }
.cell.n6 { color: var(--n6); text-shadow: 0 1px 2px rgba(8,145,178,0.18); }
.cell.n7 { color: var(--n7); text-shadow: 0 1px 2px rgba(31,41,55,0.18); }
.cell.n8 { color: var(--n8); text-shadow: 0 1px 2px rgba(107,114,128,0.18); }

/* 地雷 */
.cell.mine {
  background: linear-gradient(180deg, #ef4444 0%, #b91c1c 100%);
  border-color: rgba(255, 255, 255, 0.4);
  box-shadow:
    inset 1px 1px 0 rgba(255, 255, 255, 0.35),
    inset -1px -1px 0 rgba(127, 29, 29, 0.5);
  color: #fff;
  cursor: default;
  animation: ms-shake 0.32s ease-out;
}
.cell.mine::before {
  content: '';
  width: 65%;
  height: 65%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><g fill='%23fff'><circle cx='16' cy='18' r='8'/><path d='M14 9 L14 4 L18 4 L18 9 Z'/><path d='M22 11 L26 8 L24.5 5.5 L20.5 8.5 Z' fill='%23fbbf24'/><circle cx='22' cy='9' r='1.5' fill='%23f59e0b'/></g></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
}
@keyframes ms-shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-2px, 1px); }
  40% { transform: translate(2px, -1px); }
  60% { transform: translate(-1px, 2px); }
  80% { transform: translate(1px, -2px); }
}

/* 触发的雷 */
.cell.mine-triggered {
  background: linear-gradient(180deg, #dc2626 0%, #7f1d1d 100%);
  box-shadow:
    inset 0 0 0 2px #fbbf24,
    inset 1px 1px 0 rgba(255, 255, 255, 0.4),
    0 0 16px rgba(239, 68, 68, 0.7);
  animation: ms-pulse-red 1.2s ease-in-out infinite;
}
@keyframes ms-pulse-red {
  0%, 100% { box-shadow: inset 0 0 0 2px #fbbf24, inset 1px 1px 0 rgba(255,255,255,0.4), 0 0 12px rgba(239,68,68,0.55); }
  50%      { box-shadow: inset 0 0 0 2px #fbbf24, inset 1px 1px 0 rgba(255,255,255,0.4), 0 0 28px rgba(239,68,68,0.85); }
}

/* 错标 */
.cell.mine-wrong {
  background: linear-gradient(180deg, #fee2e2 0%, #fecaca 100%);
  border-color: #f87171;
  color: #b91c1c;
  cursor: default;
  box-shadow:
    inset 1px 1px 0 rgba(255,255,255,0.6),
    inset -1px -1px 0 rgba(248,113,113,0.4);
  animation: ms-shake 0.4s ease-out;
}
.cell.mine-wrong::before {
  content: '✕';
  color: #b91c1c;
  font-weight: 800;
  font-size: var(--cell-font, 14px);
}

/* 红旗 */
.cell.flag {
  background: linear-gradient(180deg, #fef3c7 0%, #fde68a 100%);
  border-color: rgba(245, 158, 11, 0.5);
}
.cell.flag::before {
  content: '';
  width: 70%;
  height: 70%;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'><g><line x1='9' y1='4' x2='9' y2='28' stroke='%2392400e' stroke-width='2.2' stroke-linecap='round'/><path d='M10 5 L24 5 L20 11 L24 16 L10 16 Z' fill='%23ef4444' stroke='%2392400e' stroke-width='1' stroke-linejoin='round'/></g></svg>");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  animation: ms-flag-drop 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
@keyframes ms-flag-drop {
  0%   { transform: translateY(-30%) scale(0.4); opacity: 0; }
  60%  { transform: translateY(2%) scale(1.1); opacity: 1; }
  100% { transform: translateY(0) scale(1); opacity: 1; }
}

/* 问号 */
.cell.question {
  background: linear-gradient(180deg, #ede9fe 0%, #ddd6fe 100%);
  border-color: rgba(124, 58, 237, 0.4);
}
.cell.question::before {
  content: '?';
  color: var(--brand-2);
  font-weight: 800;
  font-size: calc(var(--cell-font, 14px) * 0.95);
}

/* 震屏容器 */
.board-card.shake {
  animation: ms-cards-shake 0.32s ease-out;
}
@keyframes ms-cards-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

/* ===== 右侧栏 ===== */
.right-col { display: flex; flex-direction: column; gap: 14px; }

/* 主指标卡：用时 + 剩余地雷合并 */
.ms-main-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.ms-main-stats .stat-cell {
  padding: 16px 18px;
  position: relative;
}
.ms-main-stats .stat-cell + .stat-cell {
  border-left: 1px dashed var(--border);
}
.ms-main-stats .stat-cell .ico {
  display: inline-flex;
  width: 24px; height: 24px;
  align-items: center; justify-content: center;
  border-radius: 6px;
  margin-bottom: 8px;
  color: var(--brand-1);
  background: var(--brand-grad-soft);
}
.ms-main-stats .stat-cell .ico svg { width: 14px; height: 14px; }
.ms-main-stats .stat-cell .l {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.ms-main-stats .stat-cell .v {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.ms-main-stats .stat-cell .v.alert { color: var(--warning); }
.ms-main-stats .stat-cell .v.danger { color: var(--danger); }
.ms-main-stats .stat-cell .v.success { color: var(--success); }

/* 状态卡 */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
  transition: all 0.3s ease;
}
.stat-card .l {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.stat-card .v {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}
.stat-card .v small {
  font-size: 12px;
  color: var(--text-muted);
  margin-left: 4px;
  font-family: var(--font-sans);
  font-weight: 400;
}

/* 状态卡：动态背景 */
.stat-card.status-card {
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}
.stat-card.status-card .l { color: var(--text-muted); }
.stat-card.status-card .v { font-size: 14px; font-weight: 600; font-family: var(--font-sans); }

.stat-card.status-card.playing {
  background: linear-gradient(135deg, rgba(37, 99, 235, 0.05) 0%, rgba(124, 58, 237, 0.05) 100%);
  border-color: rgba(124, 58, 237, 0.22);
}
.stat-card.status-card.playing .v {
  color: var(--brand-1);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.stat-card.status-card.playing .v::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand-1);
  box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5);
  animation: ms-blink 1.4s ease-in-out infinite;
}
@keyframes ms-blink {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5); opacity: 1; }
  50%      { box-shadow: 0 0 0 8px rgba(37, 99, 235, 0); opacity: 0.5; }
}

.stat-card.status-card.won {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.08) 0%, rgba(52, 211, 153, 0.06) 100%);
  border-color: rgba(16, 185, 129, 0.35);
}
.stat-card.status-card.won .v { color: var(--success); }

.stat-card.status-card.lost {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.08) 0%, rgba(248, 113, 113, 0.06) 100%);
  border-color: rgba(239, 68, 68, 0.35);
}
.stat-card.status-card.lost .v { color: var(--danger); }

/* 最佳记录卡 */
.stat-card.best {
  background: linear-gradient(135deg, #fffbeb 0%, #fef3c7 100%);
  border-color: rgba(245, 158, 11, 0.4);
  position: relative;
}
.stat-card.best::after {
  content: '🏆';
  position: absolute;
  top: 12px; right: 14px;
  font-size: 16px;
  opacity: 0.7;
}
.stat-card.best .l { color: var(--warning); }
.stat-card.best .v {
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
}

/* ===== 操作按钮区 ===== */
.actions { display: flex; flex-direction: column; gap: 10px; }

.btn {
  padding: 12px 16px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all 0.22s ease;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.btn svg { width: 13px; height: 13px; }
.btn:focus-visible {
  outline: 2px solid var(--brand-1);
  outline-offset: 2px;
}
.btn:hover {
  border-color: var(--brand-1);
  color: var(--brand-1);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
  transform: translateY(-1px);
}
.btn:active { transform: scale(0.97); box-shadow: var(--shadow-inset); }

.btn.primary {
  background: var(--brand-grad);
  color: var(--text-on-accent);
  border-color: transparent;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.32);
}
.btn.primary:hover {
  background: var(--brand-grad);
  color: var(--text-on-accent);
  filter: brightness(1.08);
  border-color: transparent;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.45);
}
.btn.primary:active { transform: scale(0.97); }

/* ===== 状态提示 ===== */
.status-info {
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.7;
  color: var(--text-secondary);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand-1);
  border-radius: var(--r-md);
}
.status-info b { color: var(--text-primary); font-weight: 600; }
.status-info .guest { color: var(--warning); font-weight: 600; }

/* ===== 弹窗 ===== */
.modal-mask {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.modal-mask.show {
  display: flex;
  animation: ms-fade 0.22s ease;
}
@keyframes ms-fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  max-width: 460px;
  width: calc(100% - 40px);
  padding: 36px 32px 28px;
  text-align: center;
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: ms-popup 0.32s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  overflow: hidden;
}
.modal::before {
  /* 顶部装饰条 */
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--brand-grad);
}
.modal.win::before {
  background: linear-gradient(90deg, #fbbf24 0%, #f59e0b 50%, #fbbf24 100%);
}
.modal.lose::before {
  background: linear-gradient(90deg, #f87171 0%, #dc2626 100%);
}
@keyframes ms-popup {
  from { transform: scale(0.88) translateY(16px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal h2 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.modal h2 .emoji {
  font-size: 32px;
  display: inline-block;
  animation: ms-bounce 0.6s ease-out;
}
@keyframes ms-bounce {
  0%   { transform: scale(0) rotate(-30deg); opacity: 0; }
  60%  { transform: scale(1.25) rotate(8deg); opacity: 1; }
  100% { transform: scale(1) rotate(0); opacity: 1; }
}
.modal h2.win { color: var(--success); }
.modal h2.lose { color: var(--danger); }

.modal .sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.7;
}

.modal .result {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 22px;
}
.modal .result .r {
  padding: 14px 6px;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.modal .result .r .l {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.modal .result .r .v {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.modal .badge {
  display: inline-block;
  padding: 5px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  background: var(--brand-grad-soft);
  color: var(--brand-1);
  border: 1px solid rgba(124, 58, 237, 0.3);
  border-radius: 999px;
  margin-bottom: 18px;
}
.modal .badge.guest {
  background: rgba(245, 158, 11, 0.10);
  color: var(--warning);
  border-color: rgba(245, 158, 11, 0.35);
}
.modal .badge.lost {
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger);
  border-color: rgba(239, 68, 68, 0.3);
}
.modal .badge.best {
  background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
  color: #92400e;
  border-color: #f59e0b;
  animation: ms-shimmer 1.6s ease-in-out infinite;
}
@keyframes ms-shimmer {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
  50%      { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
}

.modal .actions {
  display: flex;
  gap: 10px;
  flex-direction: row;
}
.modal .actions .btn { flex: 1; }

/* ===== 自定义弹窗表单 ===== */
.modal .form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 22px;
  text-align: left;
}
.modal .field label {
  display: block;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 6px;
}
.modal .field input {
  width: 100%;
  padding: 11px 14px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: var(--bg-page);
  border: 1.5px solid var(--border);
  outline: none;
  transition: all 0.18s ease;
  border-radius: var(--r-md);
  font-variant-numeric: tabular-nums;
}
.modal .field input:hover { border-color: var(--border-strong); }
.modal .field input:focus {
  border-color: var(--brand-1);
  background: var(--bg-card);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.12);
}
.modal .field .err {
  min-height: 16px;
  font-size: 11px;
  line-height: 16px;
  color: var(--danger);
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.modal .field .err:not(:empty)::before {
  content: '⚠';
  font-size: 12px;
}

/* ===== Toast ===== */
.toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 11px 20px;
  background: var(--text-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  opacity: 0;
  transition: all 0.28s cubic-bezier(0.2, 0.9, 0.3, 1.2);
  pointer-events: none;
  z-index: 200;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error {
  background: var(--danger);
}
.toast.success {
  background: var(--success);
}
.toast::before {
  font-size: 14px;
}
.toast.error::before { content: '✕'; }
.toast.success::before { content: '✓'; }
.toast:not(.error):not(.success)::before { content: 'ℹ'; }

/* ===== 胜利彩带 ===== */
.ms-confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 99;
  overflow: hidden;
}
.ms-confetti span {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 14px;
  background: var(--brand-1);
  opacity: 0;
  animation: ms-fall linear forwards;
}
.ms-confetti span:nth-child(2n) { background: var(--brand-2); width: 6px; height: 12px; }
.ms-confetti span:nth-child(3n) { background: var(--success); width: 10px; height: 6px; border-radius: 50%; }
.ms-confetti span:nth-child(4n) { background: var(--warning); width: 7px; height: 7px; border-radius: 50%; }
.ms-confetti span:nth-child(5n) { background: #ec4899; }
@keyframes ms-fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* ===== 响应式 ===== */
@media (max-width: 900px) {
  .back-link-wrapper { padding: 0 16px 12px; }
  main { padding: 24px 16px 40px; }
  .game-area { grid-template-columns: 1fr; }
  .right-col { order: 2; }
  .head h1 { font-size: 28px; }
  .head-icon { width: 56px; height: 56px; }
  .head-icon svg { width: 30px; height: 30px; }
  .diff-row { flex-wrap: wrap; border-radius: var(--r-lg); }
  .diff-row::before { display: none; }
  .diff-btn {
    background: var(--bg-card);
    border: 1px solid var(--border);
    flex: 1;
    min-width: 80px;
  }
  .diff-btn.active {
    background: var(--brand-grad);
    border-color: transparent;
    color: #fff;
  }
}
@media (max-width: 480px) {
  .head .sub .chip { font-size: 10px; }
  .head h1 { font-size: 24px; }
  .board-card { padding: 14px; }
  .modal { padding: 28px 20px 22px; }
  .modal .actions { flex-direction: column; }
}