body {
  font-family: Arial, sans-serif;
  text-align: center;
  background: #faf8ef;
  margin: 0;
  padding: 20px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-sizing: border-box;
}

h1 {
  font-size: 48px;
  color: #776e65;
  margin-bottom: 10px;
}

.score-board {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 15px;
  width: 100%;
  max-width: 500px;
}

.score-box {
  background: #bbada0;
  color: #fff;
  padding: 10px 20px;
  font-size: 20px;
  border-radius: 6px;
  flex: 1;
  text-align: center;
}

.controls {
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  justify-content: center;
  width: 100%;
  max-width: 500px;
}

button {
  margin: 5px;
  padding: 12px 20px;
  font-size: 16px;
  border: none;
  border-radius: 6px;
  background: #8f7a66;
  color: #fff;
  cursor: pointer;
  min-width: 120px;
  flex: 1;
  max-width: 200px;
  text-align: center;
  transition: background 0.3s;
}

button:hover {
  background: #9f8b77;
}

.game-container {
  width: 90vmin;
  height: 90vmin;
  max-width: 500px;
  max-height: 500px;
  background: #bbada0;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
  padding: 10px;
  border-radius: 10px;
  box-sizing: border-box;
}

.tile {
  background: #cdc1b4;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 6vmin;
  font-weight: bold;
  transition: transform 0.15s ease-in-out;
}

.tile.new {
  animation: pop 0.2s;
}

.tile.merged {
  animation: merge 0.2s;
}

@keyframes pop {
  from { transform: scale(0); }
  to { transform: scale(1); }
}

@keyframes merge {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(238, 228, 218, 0.7);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10;
}

.message {
  background: #f9f6f2;
  padding: 20px 40px;
  border-radius: 10px;
  font-size: 24px;
  color: #776e65;
  text-align: center;
}

/* 移动端适配 */
@media (max-width: 768px) {
  body {
    padding: 10px;
  }
  
  h1 {
    font-size: 36px;
    margin-bottom: 5px;
  }
  
  .score-board {
    gap: 10px;
    margin-bottom: 10px;
    max-width: 90vmin;
  }
  
  .score-box {
    padding: 8px 15px;
    font-size: 16px;
  }
  
  .controls {
    margin-bottom: 15px;
    max-width: 90vmin;
    gap: 8px;
  }
  
  button {
    padding: 10px 16px;
    font-size: 14px;
    min-width: 100px;
    max-width: 150px;
  }
  
  .game-container {
    gap: 8px;
    padding: 8px;
  }
  
  .message {
    padding: 15px 30px;
    font-size: 20px;
    margin: 0 20px;
  }
}

@media (max-width: 480px) {
  h1 {
    font-size: 28px;
  }
  
  .score-box {
    padding: 6px 12px;
    font-size: 14px;
  }
  
  button {
    padding: 8px 12px;
    font-size: 12px;
    min-width: 80px;
    max-width: 120px;
  }
  
  .game-container {
    gap: 6px;
    padding: 6px;
  }
  
  .tile {
    font-size: 5vmin;
  }
}

/* 超小屏幕适配 */
@media (max-width: 320px) {
  h1 {
    font-size: 24px;
  }
  
  .score-box {
    padding: 5px 10px;
    font-size: 12px;
  }
  
  button {
    padding: 6px 10px;
    font-size: 11px;
    min-width: 70px;
    max-width: 100px;
  }
}

/* 添加滑动动画样式 */
.slide-animation {
  /* 启用硬件加速，提高动画性能 */
  will-change: transform;
  /* 定义过渡效果：transform 属性变化时，持续 0.15 秒，使用 ease-out 缓动函数 */
  transition: transform 0.15s ease-out;
}