* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #0e1020;
  color: #e8eaf2;
  display: flex;
  justify-content: center;
  padding: 24px 12px;
}

.game-wrap { width: 100%; max-width: 360px; }

.top-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.back { color: #aab0d0; text-decoration: none; font-size: 13px; }
.top-bar h1 {
  font-size: 30px;
  font-weight: 800;
  background: linear-gradient(90deg, #edc22e, #f2b179);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.scores { display: flex; gap: 8px; }
.score-box { background: #171a33; border-radius: 10px; padding: 6px 12px; text-align: center; min-width: 60px; }
.score-box span { display: block; font-size: 11px; color: #9aa0c0; }
.score-box b { font-size: 18px; }

.hint { color: #aab0d0; font-size: 13px; margin-bottom: 14px; }

.board {
  position: relative;
  background: #171a33;
  padding: 10px;
  border-radius: 12px;
  aspect-ratio: 1 / 1;
}

.cells {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  height: 100%;
}

.cell {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(18px, 7vw, 30px);
  font-weight: 800;
  color: #fff;
}

.cell[data-v="2"]    { background: #eee4da; color: #3a2c00; }
.cell[data-v="4"]    { background: #ede0c8; color: #3a2c00; }
.cell[data-v="8"]    { background: #f2b179; }
.cell[data-v="16"]   { background: #f59563; }
.cell[data-v="32"]   { background: #f67c5f; }
.cell[data-v="64"]   { background: #f65e3b; }
.cell[data-v="128"]  { background: #edcf72; font-size: clamp(16px, 6vw, 26px); }
.cell[data-v="256"]  { background: #edcc61; }
.cell[data-v="512"]  { background: #edc850; }
.cell[data-v="1024"] { background: #edc53f; font-size: clamp(14px, 5vw, 22px); }
.cell[data-v="2048"] { background: #edc22e; font-size: clamp(14px, 5vw, 22px); }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(14, 16, 32, 0.85);
  border-radius: 12px;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.overlay.show { display: flex; }
.overlay-msg { font-size: 26px; font-weight: 800; }

.restart {
  margin-top: 16px;
  background: linear-gradient(90deg, #7c5cff, #23d5ab);
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 10px;
  font-size: 15px;
  cursor: pointer;
  font-weight: 700;
}
.restart:hover { opacity: .9; }
