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

body {
  font-family: "Helvetica Neue", Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: linear-gradient(135deg, #faf8ef 0%, #eee4da 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  user-select: none;
}

.container {
  max-width: 500px;
  width: 100%;
  padding: 20px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.title {
  font-size: 56px;
  font-weight: 800;
  color: #776e65;
}

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

.score-box {
  background: #bbada0;
  color: #fff;
  border-radius: 6px;
  padding: 6px 16px;
  text-align: center;
  min-width: 76px;
}

.score-box .label {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #eee4da;
}

.score-box span:last-child {
  font-size: 22px;
  font-weight: 700;
}

.instructions {
  color: #8f7a66;
  font-size: 14px;
  margin-bottom: 16px;
  text-align: center;
}

#game-container {
  position: relative;
  background: #bbada0;
  border-radius: 12px;
  padding: 12px;
}

#grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 12px;
  aspect-ratio: 1;
}

.cell {
  background: rgba(238, 228, 218, 0.35);
  border-radius: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 40px;
  font-weight: 800;
  color: #776e65;
  transition: transform 0.15s ease;
}

.cell.pop {
  animation: pop 0.2s ease;
}

@keyframes pop {
  0% { transform: scale(0.6); }
  100% { transform: scale(1); }
}

.tile-2    { background: #eee4da; color: #776e65; }
.tile-4    { background: #ede0c8; color: #776e65; }
.tile-8    { background: #f2b179; color: #f9f6f2; }
.tile-16   { background: #f59563; color: #f9f6f2; }
.tile-32   { background: #f67c5f; color: #f9f6f2; }
.tile-64   { background: #f65e3b; color: #f9f6f2; }
.tile-128  { background: #edcf72; color: #f9f6f2; font-size: 34px; }
.tile-256  { background: #edcc61; color: #f9f6f2; font-size: 34px; }
.tile-512  { background: #edc850; color: #f9f6f2; font-size: 34px; }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 28px; }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 28px; }
.tile-4096 { background: #3c3a32; color: #f9f6f2; font-size: 26px; }
.tile-8192 { background: #3c3a32; color: #f9f6f2; font-size: 26px; }

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(238, 228, 218, 0.73);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
  z-index: 10;
}

.hidden {
  display: none;
}

.overlay-text {
  font-size: 48px;
  font-weight: 800;
  color: #776e65;
}

.btn {
  background: #8f7a66;
  color: #f9f6f2;
  border: none;
  border-radius: 6px;
  padding: 12px 28px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s;
}

.btn:hover {
  background: #7f6a56;
}

.restart {
  display: block;
  margin: 16px auto 0;
}

@media (max-width: 480px) {
  .title { font-size: 44px; }
  #grid { gap: 8px; }
  #game-container { padding: 8px; }
  .cell { font-size: 28px; }
  .tile-128, .tile-256, .tile-512 { font-size: 24px; }
  .tile-1024, .tile-2048 { font-size: 20px; }
  .tile-4096, .tile-8192 { font-size: 18px; }
}
