/* Reset and base styles */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Arial', sans-serif;
  background: #faf8ef;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
}

/* Title */
h1 {
  font-size: 3rem;
  color: #776e65;
  margin-bottom: 10px;
}

/* Info bar: score + restart */
.info-bar {
  width: 100%;
  max-width: 400px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

#score {
  font-size: 1.4rem;
  color: #776e65;
}

#restart-btn {
  background-color: #8f7a66;
  color: #f9f6f2;
  border: none;
  padding: 10px 16px;
  font-size: 1rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

#restart-btn:hover {
  background-color: #9c8b75;
}

/* Game container */
.game-container {
  position: relative;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 1 / 1;
}

/* Grid layout */
#grid-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-gap: 10px;
  background: #bbada0;
  padding: 10px;
  width: 100%;
  height: 100%;
  border-radius: 6px;
}

/* Tile styles */
.tile {
  background-color: #cdc1b4;
  border-radius: 3px;
  position: relative;
  font-size: 2rem;
  font-weight: bold;
  color: #776e65;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 1 / 1;
}

/* Number-specific colors */
.tile-2    { background-color: #eee4da; }
.tile-4    { background-color: #ede0c8; }
.tile-8    { background-color: #f2b179; color: #f9f6f2; }
.tile-16   { background-color: #f59563; color: #f9f6f2; }
.tile-32   { background-color: #f67c5f; color: #f9f6f2; }
.tile-64   { background-color: #f65e3b; color: #f9f6f2; }
.tile-128  { background-color: #edcf72; color: #f9f6f2; }
.tile-256  { background-color: #edcc61; color: #f9f6f2; }
.tile-512  { background-color: #edc850; color: #f9f6f2; }
.tile-1024 { background-color: #edc53f; color: #f9f6f2; }
.tile-2048 { background-color: #edc22e; color: #f9f6f2; }

/* Merge animation */
.tile.merge {
  animation: merge 0.2s ease;
}

@keyframes merge {
  0% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

/* Game over overlay */
#game-over {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(238, 228, 218, 0.8);
  display: none;
  justify-content: center;
  align-items: center;
  font-size: 3rem;
  color: #776e65;
  z-index: 10;
  border-radius: 6px;
}

/* Responsive: smaller screens */
@media (max-width: 450px) {
  h1 {
    font-size: 2.2rem;
  }

  #score {
    font-size: 1.2rem;
  }

  #restart-btn {
    padding: 8px 14px;
    font-size: 0.9rem;
  }

  .tile {
    font-size: 1.5rem;
  }

  #game-over {
    font-size: 2.5rem;
  }
}
