/* 小游戏 */

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 5px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-xs);
  margin-bottom: 24px;
  flex-wrap: wrap;
}

.tab {
  border: 0;
  background: transparent;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-3);
  cursor: pointer;
  transition: all 0.25s var(--ease);
  white-space: nowrap;
}

.tab:hover { color: var(--ink); }
.tab.active { background: var(--ink); color: #fff; }

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}

.board-card {
  border-radius: 30px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  display: grid;
  place-items: center;
  min-height: 480px;
}

.side-card {
  border-radius: 26px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
  padding: 22px;
  position: sticky;
  top: 96px;
}

.side-card h3 { margin: 0 0 4px; font-size: 15px; letter-spacing: -0.01em; }
.side-card p { margin: 0 0 16px; font-size: 12.5px; line-height: 1.75; color: var(--ink-3); }

.score-row { display: flex; gap: 10px; margin-bottom: 16px; }

.score-box {
  flex: 1;
  padding: 10px 12px;
  border-radius: 14px;
  background: #f8f6f1;
  border: 1px solid var(--line);
}

.score-box span {
  display: block;
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.14em;
  color: var(--ink-4);
  text-transform: uppercase;
}

.score-box b { font-size: 20px; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

.side-actions { display: grid; gap: 8px; }

.btn-block {
  height: 44px;
  border-radius: 14px;
  border: 1px solid var(--line-2);
  background: #fff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.22s var(--ease);
}

.btn-block:hover { background: #fffdf8; box-shadow: var(--shadow-sm); }
.btn-block--ink { background: var(--ink); color: #fff; border-color: var(--ink); }
.btn-block--ink:hover { background: #2b2935; }

.hint {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--ink-4);
  line-height: 1.8;
  font-family: var(--mono);
  letter-spacing: 0.02em;
}

/* ---------------- 2048 ---------------- */

.g2048 {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: min(420px, 100%);
  padding: 10px;
  border-radius: 22px;
  background: #f0ece2;
  touch-action: none;
}

.cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.55);
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: clamp(18px, 4.4vw, 26px);
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
  transition: transform 0.12s var(--ease), background 0.15s;
}

.cell[data-v="0"] { color: transparent; }

.cell[data-v="2"] { background: #fffdf8; color: #6b6257; }
.cell[data-v="4"] { background: #fff6e2; color: #7a6440; }
.cell[data-v="8"] { background: #ffe3c4; color: #8a5827; }
.cell[data-v="16"] { background: #ffd2ab; color: #8f4f18; }
.cell[data-v="32"] { background: #ffbb8c; color: #fff; }
.cell[data-v="64"] { background: #ff9a66; color: #fff; }
.cell[data-v="128"] { background: #ffd166; color: #7a5310; font-size: clamp(15px, 3.8vw, 22px); }
.cell[data-v="256"] { background: #ffc233; color: #7a5310; font-size: clamp(15px, 3.8vw, 22px); }
.cell[data-v="512"] { background: #ffb42e; color: #fff; font-size: clamp(15px, 3.8vw, 22px); }
.cell[data-v="1024"] { background: #8fb0ff; color: #fff; font-size: clamp(13px, 3.2vw, 19px); }
.cell[data-v="2048"] { background: linear-gradient(135deg, #6b87ff, #b0a0ff); color: #fff; font-size: clamp(13px, 3.2vw, 19px); }
.cell[data-v="4096"], .cell[data-v="8192"] { background: #17161b; color: #fff; font-size: clamp(13px, 3.2vw, 19px); }

.cell.pop { animation: cellPop 0.22s var(--ease); }

@keyframes cellPop {
  0% { transform: scale(0.72); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.g2048-over {
  position: absolute;
  inset: 0;
  border-radius: 22px;
  background: rgba(251, 250, 247, 0.9);
  display: grid;
  place-items: center;
  backdrop-filter: blur(3px);
  text-align: center;
  padding: 20px;
}

.g2048-wrap { position: relative; width: min(420px, 100%); }

/* ---------------- 记忆翻牌 ---------------- */

.mem-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: min(420px, 100%);
}

.mem-card {
  aspect-ratio: 1;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, #fff, #f3f6ff);
  display: grid;
  place-items: center;
  font-size: clamp(22px, 5vw, 30px);
  cursor: pointer;
  position: relative;
  transition: transform 0.3s var(--ease), background 0.3s;
  user-select: none;
}

.mem-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 50% 35%, rgba(107, 135, 255, 0.18), transparent 70%);
}

.mem-card span { opacity: 0; transform: scale(0.6); transition: all 0.28s var(--ease); position: relative; z-index: 1; }

.mem-card.flip { background: #fff; transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.mem-card.flip span { opacity: 1; transform: scale(1); }
.mem-card.done { background: #eefbf5; border-color: rgba(79, 195, 161, 0.4); }
.mem-card.done span { opacity: 1; transform: scale(1); }
.mem-card.done::after { display: none; }
.mem-card.wrong { animation: shake 0.34s; }

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

/* ---------------- 反应测试 ---------------- */

.react-wrap { width: 100%; display: grid; place-items: center; }

.react-pad {
  width: min(460px, 100%);
  aspect-ratio: 16 / 10;
  border-radius: 24px;
  border: 1px solid var(--line);
  background: #f2efe7;
  display: grid;
  place-items: center;
  text-align: center;
  cursor: pointer;
  padding: 24px;
  transition: background 0.12s;
  user-select: none;
}

.react-pad.wait { background: #ffe3d9; }
.react-pad.go { background: #d9f5e8; }
.react-pad.early { background: #ffe0e0; }

.react-pad h4 { margin: 0 0 6px; font-size: 20px; letter-spacing: -0.02em; }
.react-pad p { margin: 0; font-size: 12.5px; color: var(--ink-3); font-family: var(--mono); }

@media (max-width: 980px) {
  .game-layout { grid-template-columns: 1fr; }
  .side-card { position: static; }
  .board-card { min-height: 380px; padding: 14px; }
}
