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

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

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

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

h1 {
  font-size: 60px;
  font-weight: 700;
  color: white;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.score-container {
  display: flex;
  gap: 10px;
}

.score-box {
  background: rgba(255, 255, 255, 0.9);
  padding: 10px 20px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.score-label {
  display: block;
  font-size: 12px;
  color: #666;
  text-transform: uppercase;
  font-weight: 600;
}

.score {
  display: block;
  font-size: 24px;
  font-weight: 700;
  color: #333;
}

.game-info {
  background: rgba(255, 255, 255, 0.9);
  padding: 15px;
  border-radius: 10px;
  margin-bottom: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
}

.game-info p {
  flex: 1;
  font-size: 14px;
  color: #666;
}

.new-game-btn {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.new-game-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.game-container {
  position: relative;
  background: #bbada0;
  border-radius: 10px;
  padding: 10px;
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
}

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

.cell {
  background: #cdc1b4;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  position: relative;
  transition: all 0.15s ease;
}

.tile {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  position: absolute;
  top: 0;
  left: 0;
  transition: all 0.15s ease;
  animation: tileAppear 0.2s ease;
}

@keyframes tileAppear {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 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: 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-merged {
  animation: tileMerge 0.2s ease;
}

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

.game-over-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.9);
  display: none;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  backdrop-filter: blur(5px);
}

.game-over-overlay.show {
  display: flex;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.game-over-message {
  text-align: center;
  padding: 30px;
}

.game-over-message h2 {
  font-size: 48px;
  color: #333;
  margin-bottom: 10px;
}

.game-over-message p {
  font-size: 24px;
  color: #666;
  margin-bottom: 20px;
}

.instructions {
  background: rgba(255, 255, 255, 0.9);
  padding: 20px;
  border-radius: 10px;
  margin-top: 20px;
}

.instructions h3 {
  font-size: 18px;
  margin-bottom: 10px;
  color: #333;
}

.instructions p {
  font-size: 14px;
  color: #666;
  line-height: 1.6;
}

@media (max-width: 600px) {
  .container {
    padding: 15px;
  }
  
  h1 {
    font-size: 48px;
  }
  
  .score-box {
    padding: 8px 15px;
  }
  
  .score {
    font-size: 20px;
  }
  
  .cell {
    font-size: 28px;
  }
  
  .tile-128, .tile-256, .tile-512 {
    font-size: 24px;
  }
  
  .tile-1024, .tile-2048 {
    font-size: 20px;
  }
}
