* {
  box-sizing: border-box;
}

body {
  background: rgb(26 26 26);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  font-family: "Clear Sans", "Helvetica Neue";
  margin: 0;
  padding: 10px;
  min-height: 100vh;
}

h1 {
  font-size: clamp(40px, 10vw, 80px);
  line-height: 0.7;
  color: #776e65;
  margin: 0px;
}

.container {
  width: 100%;
  max-width: 500px;
  margin-top: 10px;
}

.info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  position: absolute;
  top: 0;
  right: 0;
}

.grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
  aspect-ratio: 1;
  background-color: #bbada0;
  padding: 10px;
  border-radius: 6px;
  margin-top: 20px;
  touch-action: none;
}

.grid div {
  aspect-ratio: 1;
  border-radius: 3px;
  background-color: #eee4da;
  color: #afa192;
  font-weight: bold;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(30px, 8vw, 60px);
  transition: all 0.15s ease-in-out;
  animation: appear 0.2s ease-in-out;
}

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

.grid div[style*="background-color"] {
  animation: merge 0.2s ease-in-out;
}

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

.score-container {
  text-align: center;
  min-width: 70px;
  padding: 5px 10px;
  border-radius: 3px;
  background-color: #8f7a66;
  color: #ffffff;
}

#score {
  font-size: clamp(20px, 5vw, 30px);
  display: block;
  transition: transform 0.1s ease-in-out;
}

#score.score-update {
  animation: scoreUpdate 0.3s ease-in-out;
}

@keyframes scoreUpdate {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

.score-title {
  font-size: clamp(12px, 3vw, 16px);
  text-transform: uppercase;
}

#result {
  display: block;
  text-align: center;
  color: #776e65;
  font-size: clamp(14px, 3.5vw, 18px);
}

/* iPhone SE and small devices */
@media (max-width: 375px) {
  body {
    padding: 5px;
  }

  .container {
    margin-top: 5px;
  }

  .grid {
    gap: 5px;
    padding: 5px;
    margin-top: 10px;
  }

  .info {
    margin-bottom: 10px;
  }
}