/* ==========================================================================
   2048 · 页面样式（沿用站点暖色深色主题）
   ========================================================================== */

.game-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  align-items: start;
}

.board-zone { min-width: 0; }

.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 18px;
  margin-bottom: 14px;
  font-size: 14.5px;
  min-height: 50px;
}

.status-text { color: var(--text); font-weight: 600; }

/* 分数条 */
.score-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
}

.score-box {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px 12px;
}

.score-label { font-size: 12px; color: var(--text-faint); letter-spacing: 0.08em; }

.score-value {
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  background: linear-gradient(120deg, #ffd98a, #f0713d);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.score-add {
  position: absolute;
  right: 12px;
  top: 8px;
  font-size: 15px;
  font-weight: 800;
  color: var(--accent);
  opacity: 0;
  pointer-events: none;
}

.score-add.pop { animation: scoreUp 0.7s ease-out; }

@keyframes scoreUp {
  0% { opacity: 0; transform: translateY(6px); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-18px); }
}

/* ---------- 棋盘 ---------- */
.board-wrap {
  display: flex;
  justify-content: center;
}

.g2048-board {
  --pad: 10px;
  --gap: 10px;
  position: relative;
  width: min(460px, 100%);
  aspect-ratio: 1 / 1;
  background: linear-gradient(160deg, #2b3040, #1d2230);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--pad);
  box-shadow: var(--shadow-card);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
}

.g2048-bg {
  position: absolute;
  inset: var(--pad);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: var(--gap);
}

.g2048-bg i {
  background: rgba(255, 255, 255, 0.055);
  border-radius: 10px;
}

.g2048-tiles { position: absolute; inset: var(--pad); }

.tile {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: transform 0.13s ease-in-out;
  will-change: transform;
}

.tile span { pointer-events: none; }

.tile.spawn { animation: tileIn 0.18s ease-out 0.08s backwards; }

@keyframes tileIn {
  from { transform: var(--tf) scale(0.3); opacity: 0; }
  to { transform: var(--tf) scale(1); opacity: 1; }
}

.obcell {
  position: absolute;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(160deg, #3c4254, #2a3040);
  border: 1px dashed rgba(248, 113, 113, 0.5);
  z-index: 3;
}

.tile.merged { animation: tilePop 0.2s ease-out 0.12s backwards; z-index: 2; }

@keyframes tilePop {
  0% { transform: var(--tf) scale(0.7); }
  60% { transform: var(--tf) scale(1.12); }
  100% { transform: var(--tf) scale(1); }
}

/* 值配色（暖色阶梯） */
.tile-2 { background: #ece5d8; color: #5a5148; }
.tile-4 { background: #ecd8b0; color: #5a5148; }
.tile-8 { background: #f2b179; color: #fff; }
.tile-16 { background: #f59563; color: #fff; }
.tile-32 { background: #f57c5f; color: #fff; }
.tile-64 { background: #f65e3b; color: #fff; }
.tile-128 { background: #edcf72; color: #fff; box-shadow: 0 0 18px rgba(237, 207, 114, 0.35); }
.tile-256 { background: #edcc61; color: #fff; box-shadow: 0 0 22px rgba(237, 204, 97, 0.45); }
.tile-512 { background: #e8c850; color: #fff; box-shadow: 0 0 26px rgba(232, 200, 80, 0.55); }
.tile-1024, .tile-2048 {
  background: linear-gradient(140deg, #f5b04a, #f0713d);
  color: #fff;
  box-shadow: 0 0 30px rgba(240, 113, 61, 0.65);
}
.tile-super { background: linear-gradient(140deg, #8b5cf6, #6d28d9); color: #fff; box-shadow: 0 0 30px rgba(139, 92, 246, 0.6); }

/* 终局遮罩 */
.g2048-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 6px;
  background: rgba(10, 12, 17, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border-radius: var(--radius);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  text-align: center;
}

.g2048-overlay.show { opacity: 1; pointer-events: auto; }

.g2048-overlay h2 { font-size: 30px; font-weight: 800; letter-spacing: -0.01em; }

.g2048-overlay p { color: var(--text-dim); font-size: 15px; }

.g2048-overlay .dialog-btns { display: flex; gap: 12px; margin-top: 14px; }

/* ---------- 键位图 ---------- */
.keys-grid {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  gap: 6px;
  justify-content: center;
  margin: 4px 0 12px;
}

.keys-grid kbd {
  display: grid;
  place-items: center;
  height: 36px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 9px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-dim);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.4);
}

/* ---------- 侧栏 ---------- */
.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 84px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.card.grow { flex: 1; }

.card-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-dim);
  margin-bottom: 16px;
}

.field-note {
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 8px;
  line-height: 1.6;
}

.btn-row { display: flex; gap: 10px; }

.btn-row .btn { flex: 1; }

/* ---------- 规则弹窗 / Toast ---------- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(6, 8, 12, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.overlay.show { opacity: 1; pointer-events: auto; }

.dialog {
  width: min(420px, calc(100vw - 40px));
  background: linear-gradient(165deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 36px 32px 30px;
  text-align: center;
  box-shadow: 0 40px 90px -20px rgba(0, 0, 0, 0.8);
  transform: translateY(14px) scale(0.96);
  transition: transform 0.3s cubic-bezier(0.2, 0.7, 0.3, 1.2);
}

.overlay.show .dialog { transform: translateY(0) scale(1); }

.dialog-icon { font-size: 52px; line-height: 1; margin-bottom: 14px; }

.dialog h2 { font-size: 24px; font-weight: 800; }

.rules-body { text-align: left; margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }

.rules-body p { font-size: 13.5px; color: var(--text-dim); line-height: 1.7; }

.rules-body b { color: var(--text); }

.dialog-btns { display: flex; gap: 12px; margin-top: 26px; justify-content: center; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translate(-50%, 20px);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 11px 22px;
  border-radius: 999px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 400;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .game-layout { grid-template-columns: 1fr; }
  .panel { position: static; }
  .game-shell { padding: 20px 14px 48px; }
}
