/* ═══════════════════════════════════════════════════════════
   小游戏页面 — 2048
   ═══════════════════════════════════════════════════════════ */

/* ── 页面布局 ──────────────────────────────────────────── */
.games-page {
  display: flex;
  gap: 0;
  min-height: 550px;
  position: relative;
}

/* ── 游戏主显示区（全宽） ───────────────────────────────── */
.games-main-full {
  flex: 1;
  background: linear-gradient(135deg, #0f0c29 0%, #1a1a2e 40%, #16213e 100%);
  border-radius: 12px;
  padding: 24px;
  min-height: 520px;
  position: relative;
}

/* ═══════════════════════════════════════════════════════════
   2048 游戏
   ═══════════════════════════════════════════════════════════ */

/* 主容器 — 适应页面宽度 */
.game-2048-container {
  max-width: 560px;
  margin: 0 auto;
  min-height: 500px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.g2048-wrap {
  width: 100%;
  position: relative;
  user-select: none;
  -webkit-user-select: none;
}

/* ── 头部 ──────────────────────────────────────────── */
.g2048-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  gap: 12px;
}

.g2048-title {
  font-size: 2.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, #ff6b6b, #ffd93d);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1;
  letter-spacing: 2px;
}

.g2048-scores {
  display: flex;
  gap: 8px;
}

.g2048-score-box {
  background: rgba(0,0,0,0.35);
  border-radius: 6px;
  padding: 4px 14px;
  text-align: center;
  min-width: 70px;
}

.g2048-score-label {
  display: block;
  font-size: 0.6rem;
  text-transform: uppercase;
  color: #888;
  letter-spacing: 1px;
}

.g2048-score-val {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  color: #fff;
  font-family: 'Courier New', monospace;
}

/* ── 网格 ──────────────────────────────────────────── */
.g2048-grid-container {
  position: relative;
  background: rgba(0,0,0,0.35);
  border-radius: 10px;
  padding: 8px;
  aspect-ratio: 1 / 1;
  width: 100%;
  touch-action: none;
}

.g2048-grid-bg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  width: 100%;
  height: 100%;
}

.g2048-cell-bg {
  background: rgba(255,255,255,0.06);
  border-radius: 6px;
  aspect-ratio: 1 / 1;
}

/* ── 方块容器 ────────────────────────────────────────── */
.g2048-tiles {
  position: absolute;
  inset: 8px;
  z-index: 2;
}

/* ── 单个方块 ────────────────────────────────────────── */
.g2048-tile {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  border-radius: 6px;
  z-index: 3;

  /* 方块尺寸 + 间距 */
  width: calc((100% - 18px) / 4);
  height: calc((100% - 18px) / 4);

  /* 移动动画 — 核心！ */
  transition: top 0.12s ease, left 0.12s ease;
}

/* 新方块出现 */
.tile-new {
  animation: tile-pop 0.2s ease-out;
}
@keyframes tile-pop {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

/* 合并脉冲 */
.tile-merged {
  animation: tile-merge-pulse 0.2s ease-out;
}
@keyframes tile-merge-pulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* 移除 */
.tile-removed {
  animation: tile-fade 0.15s ease-out forwards;
}
@keyframes tile-fade {
  to { transform: scale(0); opacity: 0; }
}

/* ── 底部 ──────────────────────────────────────────── */
.g2048-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  gap: 8px;
  flex-wrap: wrap;
}

.g2048-hint {
  font-size: 0.75rem;
  color: #555;
}

/* ── 覆盖层 ────────────────────────────────────────── */
.g2048-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(4px);
  animation: overlay-in 0.3s ease-out;
}
@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.g2048-overlay-box {
  text-align: center;
  padding: 20px;
}
.g2048-overlay-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 10px;
  color: #fff;
}
.g2048-overlay-score {
  font-size: 1.1rem;
  color: #ffd93d;
  margin-bottom: 14px;
}
.g2048-overlay-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ── 通用按钮 ─────────────────────────────────────── */
.hrc-btn {
  padding: 8px 20px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px;
  background: rgba(255,255,255,0.06);
  color: #ccc;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
  transition: all 0.2s ease;
}
.hrc-btn:hover {
  background: rgba(255,255,255,0.12);
  color: #fff;
}
.hrc-btn-primary {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: #fff;
  border: none;
}
.hrc-btn-primary:hover {
  box-shadow: 0 4px 15px rgba(255,107,107,0.3);
}

/* ── 响应式 ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .games-main-full { padding: 12px; }
  .game-2048-container { max-width: 100%; }
  .g2048-title { font-size: 1.8rem; }
  .g2048-score-box { min-width: 54px; padding: 3px 8px; }
  .g2048-score-val { font-size: 1rem; }
}
@media (max-width: 380px) {
  .g2048-header { flex-wrap: wrap; justify-content: center; }
  .g2048-title { font-size: 1.5rem; }
}

/* ── 排行榜面板 ────────────────────────────────── */
.g2048-lb-panel {
  margin-top: 16px;
  background: rgba(0,0,0,0.3);
  border-radius: 10px;
  padding: 16px;
  animation: overlay-in 0.3s ease-out;
}
.g2048-lb-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffd93d;
  text-align: center;
  margin-bottom: 12px;
}
.g2048-lb-subtitle {
  font-size: 0.75rem;
  color: #888;
  font-weight: 400;
}
.g2048-lb-table {
  width: 100%;
  border-collapse: collapse;
  color: #ccc;
  font-size: 0.85rem;
}
.g2048-lb-table th {
  color: #888;
  font-weight: 400;
  padding: 5px 8px;
  text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.g2048-lb-table td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.g2048-lb-rank {
  width: 32px;
  text-align: center;
  font-weight: 700;
  font-size: 0.95rem;
}
.g2048-lb-rank-1 { color: #ffd700; }
.g2048-lb-rank-2 { color: #c0c0c0; }
.g2048-lb-rank-3 { color: #cd7f32; }
.g2048-lb-name { color: #fff; }
.g2048-lb-score { text-align: right; font-weight: 700; color: #ff6b6b; font-family: 'Courier New', monospace; white-space: nowrap; }
.g2048-lb-date { text-align: right; color: #555; font-size: 0.7rem; white-space: nowrap; }
.g2048-lb-empty {
  text-align: center;
  color: #666;
  padding: 20px;
  font-size: 0.9rem;
}
.g2048-lb-hide-btn {
  display: block;
  margin: 12px auto 0;
}

/* ── 名字输入 ──────────────────────────────────── */
.g2048-name-input-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-bottom: 14px;
}
.g2048-name-input {
  padding: 7px 12px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px;
  background: rgba(255,255,255,0.08);
  color: #fff;
  font-size: 0.9rem;
  width: 140px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.g2048-name-input::placeholder { color: #666; }
.g2048-name-input:focus { border-color: #ff6b6b; }
.g2048-save-btn { font-size: 0.85rem; }
.g2048-save-msg {
  font-size: 0.85rem;
  color: #2ecc71;
  margin-bottom: 12px;
  text-align: center;
}

/* ── 排行榜按钮响应式 ─────────────────────────── */
@media (max-width: 500px) {
  .g2048-footer { justify-content: center; }
}

/* ═══════════════════════════════════════════════════════════
   游戏切换标签
   ═══════════════════════════════════════════════════════════ */
.game-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.game-tab {
  padding: 8px 18px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  background: rgba(255,255,255,0.04);
  color: #888;
  cursor: pointer;
  font-size: 0.9rem;
  font-family: inherit;
  transition: all 0.25s ease;
}
.game-tab:hover {
  background: rgba(255,255,255,0.1);
  color: #ddd;
  border-color: rgba(255,255,255,0.2);
}
.game-tab.active {
  background: linear-gradient(135deg, #ff6b6b, #ee5a24);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 4px 15px rgba(255,107,107,0.25);
}
.game-container {
  max-width: 600px;
  margin: 0 auto;
  min-height: 500px;
}

/* ═══════════════════════════════════════════════════════════
   贪吃蛇
   ═══════════════════════════════════════════════════════════ */
.snake-wrap {
  max-width: 560px;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
}
.snake-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.snake-title {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.snake-score-box {
  background: rgba(0,0,0,0.35);
  border-radius: 6px;
  padding: 4px 14px;
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}
.snake-canvas-wrap {
  background: rgba(0,0,0,0.35);
  border-radius: 10px;
  padding: 10px;
  display: flex;
  justify-content: center;
}
#snake-canvas {
  border-radius: 6px;
  display: block;
  width: 500px;
  height: 500px;
  max-width: 100%;
  aspect-ratio: 1 / 1;
}
.snake-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════════════════════════
   扫雷
   ═══════════════════════════════════════════════════════════ */
.ms-wrap {
  max-width: 560px;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
}
.ms-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.ms-title {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.ms-controls select {
  padding: 5px 10px;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  background: rgba(0,0,0,0.3);
  color: #ccc;
  font-size: 0.8rem;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
.ms-controls select:focus {
  border-color: #e74c3c;
}
.ms-info {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 10px;
  background: rgba(0,0,0,0.25);
  border-radius: 8px;
  padding: 8px 16px;
}
.ms-counter, .ms-timer {
  font-size: 1rem;
  color: #fff;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  min-width: 70px;
  text-align: center;
}
#ms-reset {
  font-size: 1.3rem;
  padding: 2px 12px;
  line-height: 1.4;
}
.ms-grid {
  display: inline-grid;
  gap: 2px;
  justify-content: center;
  background: rgba(0,0,0,0.35);
  border-radius: 8px;
  padding: 8px;
  width: 100%;
  box-sizing: border-box;
}
.ms-cell {
  width: 100%;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.1s;
  box-sizing: border-box;
  min-width: 24px;
  min-height: 24px;
}
.ms-cell-hidden {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.05);
}
.ms-cell-hidden:hover {
  background: rgba(255,255,255,0.18);
}
.ms-cell-revealed {
  background: rgba(255,255,255,0.05);
}
.ms-cell-flagged {
  background: rgba(231, 76, 60, 0.15);
}
.ms-cell-mine {
  background: rgba(231, 76, 60, 0.35);
}
.ms-cell-n1 { color: #3498db; }
.ms-cell-n2 { color: #27ae60; }
.ms-cell-n3 { color: #e74c3c; }
.ms-cell-n4 { color: #2c3e50; }
.ms-cell-n5 { color: #8e44ad; }
.ms-cell-n6 { color: #1abc9c; }
.ms-cell-n7 { color: #fff; }
.ms-cell-n8 { color: #95a5a6; }
.ms-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
}
.ms-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(4px);
  animation: overlay-in 0.3s ease-out;
}

/* ═══════════════════════════════════════════════════════════
   俄罗斯方块
   ═══════════════════════════════════════════════════════════ */
.tetris-wrap {
  max-width: 600px;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
}
.tetris-header {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 12px;
}
.tetris-title {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tetris-body {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: center;
}
.tetris-left, .tetris-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 90px;
}
.tetris-info-box {
  background: rgba(0,0,0,0.3);
  border-radius: 8px;
  padding: 10px;
  text-align: center;
}
.tetris-info-label {
  font-size: 0.7rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.tetris-info-val {
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  font-family: 'Courier New', monospace;
}
.tetris-center {
  background: rgba(0,0,0,0.35);
  border-radius: 10px;
  padding: 8px;
  display: flex;
  justify-content: center;
}
#tetris-board {
  border-radius: 4px;
  display: block;
  max-width: 100%;
}
#tetris-next {
  border-radius: 4px;
  display: block;
  margin: 6px auto 0;
  max-width: 100%;
}
.tetris-controls-hint {
  font-size: 0.7rem;
  color: #666;
  line-height: 1.6;
  text-align: left;
}
.tetris-footer {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.tetris-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.6);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(4px);
  animation: overlay-in 0.3s ease-out;
}

/* ── 响应式 ──────────────────────────────────────────── */
@media (max-width: 600px) {
  .tetris-body { flex-direction: column; align-items: center; }
  .tetris-left, .tetris-right { flex-direction: row; flex-wrap: wrap; justify-content: center; min-width: 0; }
  .tetris-info-box { min-width: 80px; }
  #tetris-board { width: 100%; height: auto; }
  .ms-grid { gap: 1px; padding: 4px; }
  .ms-cell { min-width: 18px; min-height: 18px; font-size: 0.65rem; }
}
