/* ===== 游戏模块样式 ===== */

.game-wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 8px 0 24px;
  text-align: center;
}

.game-tabs {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.game-tab {
  padding: 6px 20px;
  font-size: 14px;
  line-height: 1.6;
  border: 1px solid var(--theme-color, #49b1f5);
  border-radius: 20px;
  background: transparent;
  color: var(--theme-color, #49b1f5);
  cursor: pointer;
  transition: all 0.25s;
}

.game-tab:hover {
  background: rgba(73, 177, 245, 0.12);
}

.game-tab.active {
  background: var(--theme-color, #49b1f5);
  color: #fff;
}

.game-panel[hidden] {
  display: none;
}

.game-score {
  margin-bottom: 12px;
  font-size: 15px;
  color: var(--font-color, #4c4948);
}

.game-score b {
  color: var(--theme-color, #49b1f5);
  font-size: 18px;
}

.game-btn {
  display: inline-block;
  margin-left: 10px;
  padding: 4px 14px;
  font-size: 13px;
  line-height: 1.6;
  border: 1px solid var(--theme-color, #49b1f5);
  border-radius: 16px;
  background: transparent;
  color: var(--theme-color, #49b1f5);
  cursor: pointer;
  transition: all 0.25s;
  vertical-align: middle;
}

.game-btn:hover {
  background: var(--theme-color, #49b1f5);
  color: #fff;
}

.game-tip {
  margin-top: 12px;
  font-size: 13px;
  color: var(--secondtext, #858585);
}

/* -------- 贪吃蛇 -------- */
#snake-canvas {
  display: block;
  margin: 0 auto;
  max-width: 100%;
  height: auto;
  border: 2px solid var(--card-bg, #fff);
  border-radius: 8px;
  box-shadow: var(--card-box-shadow, 0 8px 16px -4px rgba(0, 0, 0, 0.1));
  background: #1b1b1b;
}

.game-dpad {
  margin-top: 16px;
  display: none;
}

.dpad-btn {
  width: 46px;
  height: 46px;
  margin: 3px;
  font-size: 18px;
  border: 1px solid var(--tab-border-color, #f0f0f0);
  border-radius: 10px;
  background: var(--card-bg, #fff);
  color: var(--font-color, #4c4948);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active {
  background: var(--theme-color, #49b1f5);
  color: #fff;
}

/* 触屏设备显示方向键 */
@media (hover: none), (pointer: coarse) {
  .game-dpad {
    display: block;
  }
}

/* -------- 2048 -------- */
.board2048 {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-gap: 8px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  padding: 8px;
  background: #bbada0;
  border-radius: 8px;
  touch-action: none;
  user-select: none;
}

.cell2048 {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  border-radius: 4px;
  background: #cdc1b4;
  color: #776e65;
  transition: background 0.1s, transform 0.1s;
}

.cell2048.t2    { background: #eee4da; color: #776e65; }
.cell2048.t4    { background: #ede0c8; color: #776e65; }
.cell2048.t8    { background: #f2b179; color: #f9f6f2; }
.cell2048.t16   { background: #f59563; color: #f9f6f2; }
.cell2048.t32   { background: #f67c5f; color: #f9f6f2; }
.cell2048.t64   { background: #f65e3b; color: #f9f6f2; }
.cell2048.t128  { background: #edcf72; color: #f9f6f2; font-size: 22px; }
.cell2048.t256  { background: #edcc61; color: #f9f6f2; font-size: 22px; }
.cell2048.t512  { background: #edc850; color: #f9f6f2; font-size: 22px; }
.cell2048.t1024 { background: #edc53f; color: #f9f6f2; font-size: 18px; }
.cell2048.t2048 { background: #edc22e; color: #f9f6f2; font-size: 18px; }
.cell2048.tsuper { background: #3c3a32; color: #f9f6f2; font-size: 18px; }

.board2048.over::after {
  content: "游戏结束";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #776e65;
  background: rgba(238, 228, 218, 0.75);
  border-radius: 8px;
}

/* -------- 扫雷 -------- */
.ms-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-gap: 2px;
  width: 100%;
  max-width: 324px;
  margin: 0 auto;
  padding: 8px;
  background: #bdbdbd;
  border-radius: 8px;
  touch-action: manipulation;
  user-select: none;
}

.ms-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  border-radius: 3px;
  background: #cfcfcf;
  cursor: pointer;
  border: none;
  padding: 0;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6), inset 0 0 0 1px rgba(0, 0, 0, 0.15);
}

.ms-cell.revealed {
  background: #ececec;
  cursor: default;
  box-shadow: none;
}

.ms-cell.mine-boom {
  background: #e74c3c;
}

.ms-cell.flagged {
  background: #cfcfcf;
}

.ms-cell.n1 { color: #1976d2; }
.ms-cell.n2 { color: #388e3c; }
.ms-cell.n3 { color: #d32f2f; }
.ms-cell.n4 { color: #7b1fa2; }
.ms-cell.n5 { color: #e65100; }
.ms-cell.n6 { color: #0097a7; }
.ms-cell.n7 { color: #212121; }
.ms-cell.n8 { color: #757575; }
