/* ==========================================================================
   2048 · 经典配色（原版米色/橙红/金黄色带）+ 全屏布局
   皮肤层，不改游戏逻辑。app.js 依赖的契约：
     id: #board #score #best #new-game #overlay #overlay-kicker #overlay-title
         #overlay-message #overlay-primary #overlay-secondary #board-status
     class: .cell（JS 创建 16 个）/ .tile-super（JS 切换）/ [hidden] 属性
   顶栏与返回按钮由 game-shell.css 提供，本文件只负责游戏本体。
   ========================================================================== */

body.g2048page {
  background: #faf8ef;
}

.g2048page .gbar {
  background: rgba(250, 248, 239, 0.92);
  border-bottom-color: rgba(119, 110, 101, 0.12);
}
.g2048page .back {
  color: #776e65;
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(119, 110, 101, 0.18);
}
.g2048page .back:hover { color: #8f7a66; border-color: #8f7a66; }
.g2048page .gbar-title b { color: #776e65; }
.g2048page .gbar-title i { color: #b3a79c; }
.g2048page .gbar-home { color: #b3a79c; border-color: rgba(119, 110, 101, 0.16); }
.g2048page .gbar-home:hover { color: #8f7a66; border-color: #8f7a66; }
.g2048page .gicp { color: #b3a79c; }
.g2048page .gicp a:hover { color: #8f7a66; border-color: #8f7a66; }
.g2048page .gicp kbd {
  color: #776e65;
  background: rgba(255, 255, 255, 0.75);
  border-color: rgba(119, 110, 101, 0.18);
}
.g2048page .gicp .dot { color: rgba(119, 110, 101, 0.3); }

.g2048 {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 2.2vw, 16px);
  width: min(100%, 520px);
  margin: 0 auto;
}

/* ---- 标题与分数 ---- */
.g2048 .g2048-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.g2048 .g2048-huge {
  margin: 0;
  font-size: clamp(42px, 12vw, 60px);
  font-weight: 800;
  line-height: 0.95;
  letter-spacing: -0.05em;
  color: #776e65;
}
.g2048 .g2048-scores { display: flex; gap: 8px; flex: 0 0 auto; }
.g2048 .g2048-score {
  min-width: clamp(72px, 20vw, 92px);
  padding: 7px 11px 8px;
  text-align: center;
  background: #bbada0;
  border-radius: 10px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.06);
}
.g2048 .g2048-score span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #f9f6f2;
  opacity: 0.82;
}
.g2048 .g2048-score strong {
  display: block;
  font-size: clamp(19px, 4.4vw, 24px);
  font-weight: 700;
  line-height: 1.25;
  color: #f9f6f2;
  font-variant-numeric: tabular-nums;
}

/* ---- 提示与新游戏 ---- */
.g2048 .g2048-tools {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.g2048 .g2048-hint { margin: 0; font-size: 13px; color: #9a8c7f; }
.g2048 .g2048-new {
  min-height: 44px;
  padding: 0 20px;
  font-size: 14.5px;
  font-weight: 700;
  color: #f9f6f2;
  background: #8f7a66;
  border: none;
  border-radius: 9px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  cursor: pointer;
  touch-action: manipulation;
  transition: background 0.16s, transform 0.1s;
}
.g2048 .g2048-new:hover { background: #7f6a56; }
.g2048 .g2048-new:active { transform: translateY(1px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.12); }

/* ---- 棋盘 ---- */
.g2048 .g2048-wrap {
  position: relative;
  width: min(100%, 480px, calc(100dvh - 300px));
  min-width: 0;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}
.g2048 .board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: clamp(6px, 2vw, 10px);
  width: 100%;
  height: 100%;
  padding: clamp(7px, 2.4vw, 12px);
  background: #bbada0;
  border-radius: 16px;
  box-shadow: 0 18px 40px rgba(119, 110, 101, 0.18);
  outline: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.g2048 .board:focus-visible {
  box-shadow: 0 0 0 4px rgba(242, 177, 121, 0.6), 0 18px 40px rgba(119, 110, 101, 0.18);
}

.g2048 .cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  border-radius: clamp(6px, 1.6vw, 9px);
  background: rgba(238, 228, 218, 0.35);
  color: transparent;
  font-size: clamp(19px, 6.2vmin, 34px);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: background-color 90ms ease, color 90ms ease;
}

/* 经典色带 */
.g2048 .cell[data-value="2"]    { background: #eee4da; color: #776e65; }
.g2048 .cell[data-value="4"]    { background: #ede0c8; color: #776e65; }
.g2048 .cell[data-value="8"]    { background: #f2b179; color: #f9f6f2; }
.g2048 .cell[data-value="16"]   { background: #f59563; color: #f9f6f2; }
.g2048 .cell[data-value="32"]   { background: #f67c5f; color: #f9f6f2; }
.g2048 .cell[data-value="64"]   { background: #f65e3b; color: #f9f6f2; }
.g2048 .cell[data-value="128"]  { background: #edcf72; color: #f9f6f2; font-size: clamp(17px, 5.4vmin, 30px); }
.g2048 .cell[data-value="256"]  { background: #edcc61; color: #f9f6f2; font-size: clamp(17px, 5.4vmin, 30px); }
.g2048 .cell[data-value="512"]  { background: #edc850; color: #f9f6f2; font-size: clamp(17px, 5.4vmin, 30px); }
.g2048 .cell[data-value="1024"] { background: #edc53f; color: #f9f6f2; font-size: clamp(15px, 4.8vmin, 26px); }
.g2048 .cell[data-value="2048"] {
  background: #edc22e;
  color: #f9f6f2;
  font-size: clamp(15px, 4.8vmin, 26px);
  box-shadow: 0 0 24px rgba(237, 194, 46, 0.45);
}
.g2048 .cell.tile-super {
  background: #3c3a32;
  color: #f9f6f2;
  font-size: clamp(13px, 4.2vmin, 22px);
}

/* ---- 遮罩 ---- */
.g2048 .g2048-ov {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(250, 248, 239, 0.84);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  border-radius: 16px;
}
.g2048 .g2048-ov[hidden] { display: none; }

.g2048 .g2048-card {
  width: 100%;
  max-width: 320px;
  padding: clamp(18px, 5vw, 26px);
  text-align: center;
  background: #fffaf0;
  border-radius: 14px;
  box-shadow: 0 18px 50px rgba(90, 70, 50, 0.2);
}
.g2048 .g2048-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #b08968;
}
.g2048 .g2048-card h2 { margin: 0 0 8px; font-size: clamp(25px, 6.6vw, 33px); color: #776e65; }
.g2048 .g2048-card p { margin: 0 0 16px; font-size: 14px; line-height: 1.6; color: #9a8c7f; }
.g2048 .g2048-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.g2048 .g2048-actions button {
  min-height: 46px;
  padding: 0 20px;
  font-size: 15px;
  font-weight: 700;
  color: #f9f6f2;
  background: #8f7a66;
  border: none;
  border-radius: 9px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
  cursor: pointer;
  transition: background 0.16s, transform 0.1s;
}
.g2048 .g2048-actions button:hover { background: #7f6a56; }
.g2048 .g2048-actions button:active { transform: translateY(1px); }
.g2048 .g2048-actions button[hidden] { display: none; }
.g2048 .g2048-actions .g2048-ghost {
  color: #776e65;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.08);
}
.g2048 .g2048-actions .g2048-ghost:hover { background: #fff; }

/* 视觉隐藏，仅供读屏播报 */
.g2048 .g2048-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---- 手机端虚拟方向键 ---- */
.g2048 .g2048-dpad { display: none; }

@media (max-width: 859px) {
  .g2048 .g2048-wrap { width: min(100%, 480px, calc(100dvh - 320px)); }
}

@media (max-width: 680px) {
  .g2048 { gap: 9px; }
  .g2048 .g2048-top { align-items: flex-start; }
  .g2048 .g2048-huge { font-size: 44px; }
  .g2048 .g2048-wrap { width: min(100%, 480px, calc(100dvh - 330px)); }
  .g2048 .g2048-dpad {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 7px;
    max-width: 228px;
    margin: 1px auto 0;
  }
  .g2048 .g2048-dpad button {
    min-width: 0;
    min-height: 44px;
    font-size: 16px;
    font-weight: 700;
    color: #f9f6f2;
    background: #bbada0;
    border: none;
    border-radius: 9px;
    box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
    cursor: pointer;
    touch-action: manipulation;
    -webkit-user-select: none;
    user-select: none;
  }
  .g2048 .g2048-dpad button:active {
    transform: translateY(2px);
    background: #a89a8c;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
  }
  .g2048 .g2048-dpad .dpad-up { grid-column: 2; }
  .g2048 .g2048-dpad .dpad-l { grid-column: 1; grid-row: 2; }
  .g2048 .g2048-dpad .dpad-d { grid-column: 2; grid-row: 2; }
  .g2048 .g2048-dpad .dpad-r { grid-column: 3; grid-row: 2; }
}

@media (max-height: 760px) {
  .g2048 { gap: 7px; }
  .g2048 .g2048-huge { font-size: 38px; }
  .g2048 .g2048-wrap { width: min(100%, 480px, calc(100dvh - 348px)); }
  .g2048 .g2048-dpad { max-width: 200px; }
  .g2048 .g2048-dpad button { min-height: 38px; }
}
