/* ============================================================
   小游戏页 · 样式
   复用 styles.css 的配色变量，保持与待办页一致的观感
   ============================================================ */

.games-body { overflow-x: hidden; }

.games-shell {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 16px) 14px
           calc(24px + env(safe-area-inset-bottom));
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- 头部 ---------- */
.games-header {
  display: flex;
  align-items: center;
  gap: 10px;
}

.back-link {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  text-decoration: none;
  transition: color .18s, border-color .18s;
}
.back-link:hover { color: var(--accent); border-color: #dfe4f7; }

.games-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .3px;
}

.games-spacer { flex: 1; }

/* ---------- 游戏切换 ---------- */
.game-tabs {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: #eaeef8;
  border-radius: 14px;
}

.game-tab {
  flex: 1;
  height: 38px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .18s, color .18s, box-shadow .18s;
  -webkit-tap-highlight-color: transparent;
}
.game-tab.is-active {
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(21, 27, 45, .08);
}

.game-root {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- 通用面板 ---------- */
.panel {
  background: var(--surface);
  border-radius: 18px;
  box-shadow: var(--shadow-sm);
  padding: 14px;
}

.status-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  flex-wrap: wrap;
}

.status-chip {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 12px;
  border-radius: 12px;
  background: #f4f6fc;
  min-width: 66px;
}
.status-chip .k { font-size: 11px; color: var(--muted); }
.status-chip .v {
  font-size: 16px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.status-grow {
  /* 按钮组单独占一行，避免在窄屏被挤成竖排 */
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.btn-sm {
  height: 38px;
  padding: 0 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: transform .12s var(--ease), background-color .18s, color .18s;
  -webkit-tap-highlight-color: transparent;
}
.btn-sm:active { transform: scale(.96); }
.btn-sm.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-sm.on { background: var(--accent-soft); border-color: #d6dcfa; color: var(--accent); }

.hint {
  margin: 8px 0 0;
  font-size: 11.5px;
  line-height: 1.55;
  color: var(--muted);
}

/* ---------- 扫雷 ---------- */
.ms-scroll {
  overflow: auto;
  max-width: 100%;
  padding: 4px 0 6px;
  -webkit-overflow-scrolling: touch;
}

/* 长按时禁止文本选择与系统气泡：选中要从格子间的缝隙就开始拦，
   否则长按会选中数字并弹出「拷贝/查询」那种选择框 */
.ms-scroll,
.ms-grid,
.ms-cell {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.ms-grid {
  display: grid;
  gap: 2px;
  justify-content: center;
  margin: 0 auto;
  touch-action: manipulation;
}

.ms-cell {
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: linear-gradient(180deg, #e5ebf8 0%, #d8e0f2 100%);
  color: #2a3350;
  font-weight: 700;
  font-size: calc(var(--cell) * .52);
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background-color .12s, transform .08s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.ms-cell:active { transform: scale(.94); }
.ms-cell.revealed {
  background: #f8fafd;
  box-shadow: inset 0 0 0 1px #e8edf7;
  cursor: default;
}
.ms-cell.flag { background: linear-gradient(180deg, #ffecec 0%, #ffdede 100%); color: var(--danger); }
.ms-cell.mine { background: #f6dada; color: #c0392b; }
.ms-cell.wrong { background: #fff3cd; color: #b07d00; }
.ms-cell.exploded { background: var(--danger); color: #fff; }

.ms-cell.n1 { color: #2f6fd0; }
.ms-cell.n2 { color: #0e9f6e; }
.ms-cell.n3 { color: #d9534f; }
.ms-cell.n4 { color: #6b46c1; }
.ms-cell.n5 { color: #b45309; }
.ms-cell.n6 { color: #0e7490; }
.ms-cell.n7 { color: #334155; }
.ms-cell.n8 { color: #64748b; }

/* ---------- 弹珠台 ---------- */
.pinball-stage {
  position: relative;
  display: flex;
  justify-content: center;
}

.pinball-canvas {
  display: block;
  width: 100%;
  max-width: 360px;
  height: auto;
  border-radius: 18px;
  background: #0d1526;
  box-shadow: 0 14px 34px rgba(13, 21, 38, .32);
  touch-action: none;
}

.pinball-controls {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.flip-btn {
  flex: 1;
  height: 62px;
  border: 0;
  border-radius: 16px;
  background: linear-gradient(180deg, #4d5fdb 0%, #35429f 100%);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 6px 14px rgba(53, 66, 159, .3);
  transition: transform .08s, filter .08s;
}
.flip-btn.is-down {
  transform: translateY(2px) scale(.985);
  filter: brightness(.88);
}
.flip-btn:disabled { opacity: .5; }

/* ---------- 接龙 ---------- */
.sol-table {
  --gap: 5px;
  user-select: none;
  -webkit-user-select: none;
}

.sol-top {
  display: flex;
  gap: var(--gap);
  justify-content: center;
}

.sol-slot {
  position: relative;
  width: var(--cw);
  height: var(--ch);
  border-radius: 7px;
  border: 1.5px dashed #cfd7ea;
  background: #f7f9fd;
  display: grid;
  place-items: center;
  color: #b9c2d6;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  flex: 0 0 auto;
}
.sol-slot.can-drop { border-color: var(--accent); background: var(--accent-soft); }

.sol-tableau {
  display: flex;
  gap: var(--gap);
  justify-content: center;
  align-items: flex-start;
  margin-top: 14px;
}

.sol-col {
  position: relative;
  width: var(--cw);
  min-height: var(--ch);
  flex: 0 0 auto;
}

.card {
  position: absolute;
  left: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: 6px;
  background: #fff;
  border: 1px solid #e3e9f6;
  box-shadow: 0 1px 3px rgba(21, 27, 45, .16);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  padding: 2px 3px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: box-shadow .14s, transform .12s;
  -webkit-tap-highlight-color: transparent;
}
.card.red { color: #d94a4a; }
.card.black { color: #25304d; }

.card .r { font-size: calc(var(--cw) * .30); letter-spacing: -.5px; }
.card .s { font-size: calc(var(--cw) * .38); align-self: center; margin-bottom: 2px; }

.card.down {
  background: linear-gradient(135deg, #4a5bdc 0%, #36429f 100%);
  border-color: #2f3b8f;
  cursor: default;
}
.card.down .r, .card.down .s { visibility: hidden; }
.card.down::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, .28);
  background-image: repeating-linear-gradient(45deg, rgba(255,255,255,.10) 0 2px, transparent 2px 5px);
}

.card.is-sel {
  box-shadow: 0 0 0 2px var(--accent), 0 8px 18px rgba(69, 87, 214, .32);
  transform: translateY(-2px);
}

.card.can-target { box-shadow: 0 0 0 2px #0e9f6e; }

/* ---------- 结算浮层 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px;
  border-radius: 18px;
  background: rgba(13, 21, 38, .72);
  color: #fff;
  text-align: center;
  backdrop-filter: blur(3px);
  z-index: 10;
}
.overlay[hidden] { display: none; }
.overlay .o-title { font-size: 20px; font-weight: 700; }
.overlay .o-sub { font-size: 14px; color: rgba(255, 255, 255, .78); }
.overlay .o-actions { display: flex; gap: 10px; margin-top: 12px; }
.overlay .btn-sm { background: rgba(255,255,255,.14); border-color: rgba(255,255,255,.28); color: #fff; }
.overlay .btn-sm.primary { background: var(--accent); border-color: var(--accent); }

@media (max-width: 360px) {
  .status-chip { min-width: 56px; padding: 6px 9px; }
  .flip-btn { height: 56px; font-size: 14px; }
}
