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

body {
  font-family: 'Arial', 'Helvetica', sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  max-width: 500px;
  width: 100%;
  background: white;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

.title {
  font-size: 48px;
  font-weight: bold;
  color: #776e65;
}

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

.score-container {
  background: #bbada0;
  color: white;
  padding: 10px 15px;
  border-radius: 5px;
  text-align: center;
  min-width: 80px;
}

.score-label {
  font-size: 12px;
  text-transform: uppercase;
  margin-bottom: 5px;
}

.score-value {
  font-size: 20px;
  font-weight: bold;
}

.game-info {
  background: #eee4da;
  padding: 15px;
  border-radius: 5px;
  margin-bottom: 20px;
}

.game-info p {
  margin-bottom: 10px;
  color: #776e65;
  font-size: 14px;
}

.button {
  background: #8f7a66;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 5px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.3s;
}

.button:hover {
  background: #9f8a76;
}

.game-container {
  position: relative;
  background: #bbada0;
  border-radius: 5px;
  padding: 10px;
  margin-bottom: 20px;
}

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

.grid-cell {
  background: rgba(238, 228, 218, 0.35);
  border-radius: 5px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 32px;
  font-weight: bold;
  color: #776e65;
  transition: transform 0.1s ease-in-out, background 0.15s ease-in-out, color 0.15s ease-in-out;
}

.grid-cell.tile-new {
  animation: appear 0.2s ease-in-out;
}

.grid-cell.tile-merged {
  animation: pop 0.2s ease-in-out;
}

@keyframes appear {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.1);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

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

@keyframes slide {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(0);
  }
}

/* 方块颜色 */
.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: 28px;
}

.tile-256 {
  background: #edcc61;
  color: #f9f6f2;
  font-size: 28px;
}

.tile-512 {
  background: #edc850;
  color: #f9f6f2;
  font-size: 28px;
}

.tile-1024 {
  background: #edc53f;
  color: #f9f6f2;
  font-size: 24px;
}

.tile-2048 {
  background: #edc22e;
  color: #f9f6f2;
  font-size: 24px;
}

.tile-4096 {
  background: #3c3a32;
  color: #f9f6f2;
  font-size: 20px;
}

.game-message {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(238, 228, 218, 0.95);
  border-radius: 5px;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
}

.game-message p {
  font-size: 48px;
  font-weight: bold;
  color: #776e65;
  margin-bottom: 20px;
}

#continue-button {
  display: none;
}

.instructions {
  background: #eee4da;
  padding: 15px;
  border-radius: 5px;
  color: #776e65;
}

.instructions p {
  font-weight: bold;
  margin-bottom: 10px;
}

.instructions ul {
  list-style: none;
  padding-left: 0;
}

.instructions li {
  margin-bottom: 5px;
  font-size: 14px;
}

.instructions li:before {
  content: "• ";
  color: #8f7a66;
  font-weight: bold;
  margin-right: 5px;
}

/* 响应式设计 */
@media (max-width: 480px) {
  .title {
    font-size: 36px;
  }

  .grid-cell {
    font-size: 24px;
  }

  .tile-128,
  .tile-256,
  .tile-512 {
    font-size: 20px;
  }

  .tile-1024,
  .tile-2048 {
    font-size: 18px;
  }

  .tile-4096 {
    font-size: 16px;
  }

  .game-message p {
    font-size: 36px;
  }
}
