/* Общие стили */
body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', sans-serif;
  background-color: #faf8ef;
  color: #776e65;
}

.game-container {
  max-width: 600px;
  margin: 40px auto;
  padding: 0 20px;
  position: relative;
}

/* Стили для рекламных зон */
.ad {
  width: 100%;
  min-height: 60px;
  background-color: #f2f2eb;
  border: 2px dashed #d0c8b8;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #8f7a66;
  font-size: 14px;
  margin-bottom: 20px;
}

.ad-top {
  margin-top: 0;
}

.ad-bottom {
  margin-top: 20px;
  margin-bottom: 0;
}

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

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

.scoreboard {
  background-color: #bbada0;
  padding: 10px 20px;
  border-radius: 6px;
  color: #f9f6f2;
  text-align: center;
  transition: transform 0.2s ease;
}

.scoreboard.bounce {
  animation: bounce 0.5s ease;
}

.score-label {
  font-size: 12px;
  text-transform: uppercase;
  opacity: 0.8;
}

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

@keyframes bounce {
  0% {
    transform: scale(1);
  }
  20% {
    transform: scale(1.15);
  }
  40% {
    transform: scale(0.9);
  }
  60% {
    transform: scale(1.05);
  }
  80% {
    transform: scale(0.97);
  }
  100% {
    transform: scale(1);
  }
}

.restart-button {
  background-color: #8f7a66;
  color: #f9f6f2;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 16px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.restart-button:hover {
  background-color: #786b61;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-gap: 10px;
  background-color: #bbada0;
  padding: 10px;
  border-radius: 6px;
  position: relative;
  /* Отключаем стандартные жесты браузера (например, навигация свайпами в Safari) внутри поля */
  touch-action: none;
}

.cell {
  width: 100%;
  padding-bottom: 100%; /* For responsive square cells */
  position: relative;
  border-radius: 3px;
  background-color: #cdc1b4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-weight: 700;
  color: #776e65;
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Центрируем текст внутри плитки с помощью flex */
/* Центрируем текст внутри плитки с абсолютным позиционированием */
.cell span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Плитки цветов в зависимости от значения */
.tile-2 {
  background-color: #eee4da;
  color: #776e65;
}
.tile-4 {
  background-color: #ede0c8;
  color: #776e65;
}
.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;
  font-size: 20px;
}
.tile-256 {
  background-color: #edcc61;
  color: #f9f6f2;
  font-size: 20px;
}
.tile-512 {
  background-color: #edc850;
  color: #f9f6f2;
  font-size: 20px;
}
.tile-1024 {
  background-color: #edc53f;
  color: #f9f6f2;
  font-size: 18px;
}
.tile-2048 {
  background-color: #edc22e;
  color: #f9f6f2;
  font-size: 18px;
}

/* Overlay when game is over */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(238, 228, 218, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

.overlay-content {
  background-color: #faf8ef;
  padding: 30px;
  border-radius: 6px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  text-align: center;
}

.overlay-content h2 {
  margin-top: 0;
}

.overlay-content button {
  margin-top: 10px;
  padding: 10px 20px;
  background-color: #8f7a66;
  color: #f9f6f2;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.overlay-content button:hover {
  background-color: #786b61;
}