.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 45px);
  background: linear-gradient(135deg, #faf8ef 0%, #f2eee4 100%);
  font-family: Arial, sans-serif;
  padding: 20px;
  padding-top: 65px;
  box-sizing: border-box;
}

.game-board {
  width: 500px;
  height: 500px;
  background: #bbada0;
  border-radius: 10px;
  position: relative;
  padding: 15px;
  box-sizing: border-box;
  margin-bottom: 20px;
  box-shadow: 0 8px 20px #0000001a;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 10px;
}

.tile {
  width: 100%;
  height: 100%;
  background: #eee4da59;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: bold;
  color: #776e65;
  position: relative;
  transition: all .15s ease-in-out;
  user-select: none;
}

.tile.filled {
  background: #eee4da;
  color: #776e65;
}

.tile.tile-2 {
  background: #eee4da;
  color: #776e65;
}

.tile.tile-4 {
  background: #ede0c8;
  color: #776e65;
}

.tile.tile-8 {
  background: #f2b179;
  color: #f9f6f2;
}

.tile.tile-16 {
  background: #f59563;
  color: #f9f6f2;
}

.tile.tile-32 {
  background: #f67c5f;
  color: #f9f6f2;
}

.tile.tile-64 {
  background: #f65e3b;
  color: #f9f6f2;
}

.tile.tile-128 {
  background: #edcf72;
  color: #f9f6f2;
  font-size: 28px;
  box-shadow: 0 0 30px 10px #f3d77433;
}

.tile.tile-256 {
  background: #edcc61;
  color: #f9f6f2;
  font-size: 28px;
  box-shadow: 0 0 30px 10px #f3d7744d;
}

.tile.tile-512 {
  background: #edc850;
  color: #f9f6f2;
  font-size: 28px;
  box-shadow: 0 0 30px 10px #f3d77466;
}

.tile.tile-1024 {
  background: #edc53f;
  color: #f9f6f2;
  font-size: 24px;
  box-shadow: 0 0 30px 10px #f3d77480;
}

.tile.tile-2048 {
  background: #edc22e;
  color: #f9f6f2;
  font-size: 24px;
  box-shadow: 0 0 30px 10px #f3d77499;
  animation: 1s infinite pulse;
}

.tile.new-tile {
  animation: .2s ease-in-out appear;
}

.tile.merged-tile {
  animation: .3s ease-in-out merge;
}

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

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

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

  50% {
    transform: scale(1.2);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.05);
  }
}

.game-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  max-width: 500px;
  width: 100%;
}

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

.score-box {
  background: #bbada0;
  padding: 15px 25px;
  border-radius: 8px;
  color: #fff;
  text-align: center;
  min-width: 80px;
}

.score-label {
  font-size: 14px;
  font-weight: bold;
  text-transform: uppercase;
  margin-bottom: 5px;
}

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

.controls-info {
  background: #fffc;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 2px 10px #0000001a;
}

.controls-info h3 {
  margin: 0 0 15px;
  color: #776e65;
  font-size: 18px;
}

.key-info {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 8px 0;
  color: #776e65;
  font-size: 14px;
}

.key {
  background: #8f7a66;
  color: #fff;
  padding: 5px 10px;
  border-radius: 5px;
  font-weight: bold;
  margin-right: 10px;
  min-width: 25px;
  text-align: center;
  font-size: 16px;
}

.keyboard-test {
  background: #ffffffe6;
  padding: 20px;
  border-radius: 10px;
  text-align: center;
  box-shadow: 0 2px 10px #0000001a;
  min-width: 300px;
}

.keyboard-test h4 {
  margin: 0 0 15px;
  color: #776e65;
  font-size: 16px;
}

.test-display {
  background: #f4f4f4;
  padding: 15px;
  border-radius: 8px;
  font-family: monospace;
  font-size: 16px;
  color: #333;
  margin-bottom: 15px;
  border: 2px solid #ddd;
  min-height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.test-display.active {
  border-color: #8f7a66;
  background: #fff;
  box-shadow: 0 0 10px #8f7a664d;
}

.last-keys {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  min-height: 40px;
  align-items: center;
}

.key-press {
  background: #eee4da;
  color: #776e65;
  padding: 5px 10px;
  border-radius: 5px;
  font-size: 12px;
  font-weight: bold;
  animation: .3s ease-out keyPress;
}

@keyframes keyPress {
  0% {
    transform: scale(.8);
    opacity: 0;
  }

  50% {
    transform: scale(1.1);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.restart-btn {
  background: #8f7a66;
  color: #fff;
  border: none;
  padding: 15px 30px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  transition: all .2s;
  text-transform: uppercase;
}

.restart-btn:hover {
  background: #9f8a76;
  transform: translateY(-2px);
  box-shadow: 0 4px 15px #0003;
}

.restart-btn:active {
  transform: translateY(0);
}

.game-over {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #eee4dae6;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.game-over-content {
  background: #fff;
  padding: 40px;
  border-radius: 15px;
  text-align: center;
  box-shadow: 0 10px 30px #0000004d;
  animation: .3s ease-out appear;
}

.game-over-content h2 {
  color: #776e65;
  margin: 0 0 15px;
  font-size: 32px;
}

.game-over-content p {
  color: #8f7a66;
  margin: 0 0 25px;
  font-size: 18px;
}

@media (width <= 600px) {
  .game-board {
    width: 320px;
    height: 320px;
    padding: 10px;
    gap: 8px;
  }

  .tile {
    font-size: 24px;
  }

  .tile.tile-128, .tile.tile-256, .tile.tile-512 {
    font-size: 20px;
  }

  .tile.tile-1024, .tile.tile-2048 {
    font-size: 18px;
  }

  .game-container {
    padding: 10px;
    padding-top: 50px;
    min-height: calc(100vh - 40px);
  }

  .controls-info, .keyboard-test {
    padding: 15px;
    font-size: 14px;
  }

  .key {
    font-size: 14px;
    padding: 4px 8px;
  }
}

.restart-btn:focus, .tile:focus {
  outline: 3px solid #8f7a66;
  outline-offset: 2px;
}
