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

body {
  font-family: 'Clear Sans', 'Helvetica Neue', Arial, 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: 400px;
  width: 100%;
}

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

.title {
  font-size: 80px;
  font-weight: bold;
  color: #f9f6f2;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.header-right {
  display: flex;
  gap: 10px;
}

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

.score-label {
  font-size: 12px;
  text-transform: uppercase;
  font-weight: bold;
  color: rgba(255,255,255,0.8);
}

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

.game-info {
  color: #f9f6f2;
  margin-bottom: 15px;
  font-size: 14px;
  line-height: 1.6;
}

.game-info strong {
  color: #f2b179;
}

.game-container {
  background: #bbada0;
  border-radius: 6px;
  padding: 15px;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  background: #cdc1b4;
  padding: 10px;
  border-radius: 3px;
}

.tile {
  aspect-ratio: 1;
  background: #eee4da;
  border-radius: 3px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 36px;
  font-weight: bold;
  color: #776e65;
  transition: all 0.15s ease;
}

.tile-new {
  animation: appear 0.2s ease;
}

.tile-merged {
  animation: pop 0.2s ease;
}

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

@keyframes pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  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; }
.tile-256 { background: #edcc61; color: #f9f6f2; }
.tile-512 { background: #edc850; color: #f9f6f2; }
.tile-1024 { background: #edc53f; color: #f9f6f2; font-size: 28px; }
.tile-2048 { background: #edc22e; color: #f9f6f2; font-size: 28px; }
.tile-super { background: #3c3a32; color: #f9f6f2; font-size: 24px; }

.controls {
  margin-top: 20px;
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.new-game-btn, .save-score-btn {
  padding: 12px 30px;
  font-size: 16px;
  font-weight: bold;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.new-game-btn {
  background: #8f7a66;
  color: white;
}

.new-game-btn:hover {
  background: #9f8b77;
  transform: translateY(-2px);
}

.save-score-btn {
  background: #00b894;
  color: white;
}

.save-score-btn:hover {
  background: #00a884;
  transform: translateY(-2px);
}

.home-btn {
  display: inline-block;
  padding: 12px 30px;
  background: linear-gradient(135deg, #3498db 0%, #2980b9 100%);
  color: white;
  border-radius: 6px;
  text-decoration: none;
  font-weight: bold;
  font-size: 16px;
  transition: transform 0.15s, box-shadow 0.15s;
}

.home-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

footer {
  margin-top: 30px;
  text-align: center;
  color: rgba(255,255,255,0.8);
  font-size: 14px;
}

footer a {
  color: #f2b179;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* 游戏结束遮罩 */
.game-over-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(238, 228, 218, 0.73);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 6px;
  z-index: 10;
}

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

.game-over-score {
  font-size: 24px;
  color: #776e65;
  margin-bottom: 20px;
}

.game-over-btn {
  padding: 12px 30px;
  font-size: 16px;
  font-weight: bold;
  background: #8f7a66;
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.game-over-btn:hover {
  background: #9f8b77;
}

@media (max-width: 400px) {
  .title {
    font-size: 60px;
  }
  
  .tile {
    font-size: 28px;
  }
  
  .tile-1024 {
    font-size: 22px;
  }
  
  .tile-2048 {
    font-size: 22px;
  }
}