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

html,
body {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: rgba(199, 143, 245, 0.815);
}

.container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 1rem;
  align-items: center;
  width: 100%;
  max-width: 600px;
  min-height: 100vh;
  padding: 1rem;
  box-sizing: border-box;
}

.game-title {
  text-align: center;
  color: rgb(63, 63, 63);
  font-family: Helvetica, sans-serif;
  font-weight: 700;
  font-size: 2em;
  margin: 0;
}

h3 {
  font-family: "Orbitron", sans-serif;
  font-size: 1.2rem;
  line-height: 1.4;
  font-weight: 500;
  color: rgb(63, 63, 63);
  text-align: center;
  text-shadow: rgb(104, 104, 104) 0px 5px 19px 0px;
  margin: 0;
}

.features {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  background-color: rgba(162, 87, 222, 0.815);
  box-shadow: rgb(104, 104, 104) 0px 5px 19px 0px;
  border-radius: 8px 8px 0 0;
  width: 100%;
  margin: 0;
}

.left {
  display: flex;
  flex-direction: row;
  gap: 1rem;
}

.flip-counter,
.timer {
  font-family: "Orbitron", sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: rgb(189, 189, 189);
  background-color: rgb(63, 63, 63);
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
}

.button-wrapper {
  margin-left: auto;
}

button {
  width: 8rem;
  height: 2rem;
  font-size: 0.75rem;
  letter-spacing: 0.08rem;
  font-weight: 700;
  color: rgb(63, 63, 63);
  background-color: white;
  padding: 0.5rem;
  border-radius: 20px;
  border: 0;
  cursor: pointer;
  text-transform: uppercase;
  transition: all 0.5s ease;
}

button:hover {
  background-color: rgb(63, 63, 63);
  color: hsl(0, 0%, 100%);
  box-shadow: rgb(63, 63, 63) 0px 7px 29px 0px;
}

#cards-container {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  gap: 1rem;
  justify-content: center;
  justify-items: center;
  align-items: center;
  margin: 1rem auto;
  border-radius: 0 0 10px 10px;
  max-width: 100%;
  width: 100%;
  padding: 1rem;
  background-color: rgba(162, 87, 222, 0.815);
  box-sizing: border-box;
  box-shadow: rgb(104, 104, 104) 0px 0px 19px 0px;
  margin: 0;
}

.card {
  aspect-ratio: 3 / 4;
  width: 100%;
  max-width: 120px;
  height: auto;
  position: relative;
  cursor: pointer;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
  border-radius: 8px;
  box-shadow: rgb(104, 104, 104) 0px 0px 19px 0px;
}

.card img {
  width: 100%;
  height: 100%;
  position: absolute;
  backface-visibility: hidden;
  border-radius: 8px;
}

.card .front {
  transform: rotateY(0deg);
  z-index: 2;
}

.card .back {
  transform: rotateY(180deg);
}

.flipped {
  transform: rotateY(180deg);
}

@keyframes shake {
  0% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  50% {
    transform: translateX(5px);
  }
  75% {
    transform: translateX(-5px);
  }
  100% {
    transform: translateX(0);
  }
}

.matched {
  animation: shake 0.5s ease-in-out;
}

@media only screen and (max-width: 768px) {
  .container {
    gap: 0.8rem;
  }

  .game-title {
    font-size: 1.8em;
  }

  h3 {
    font-size: 1rem;
  }

  .features {
    padding: 0.8vh 1.5vw;
  }

  .flip-counter,
  .timer {
    font-size: 0.9rem;
  }

  button {
    width: 7rem;
    height: 1.8rem;
    font-size: 0.7rem;
  }

  #cards-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.8rem;
    padding: 1rem;
  }

  .card {
    max-width: 100px;
  }
}

@media only screen and (max-width: 480px) {
  .container {
    gap: 0.6rem;
  }

  .game-title {
    font-size: 1.5em;
  }

  h3 {
    font-size: 0.9rem;
  }

  .features {
    padding: 0.5vh 1vw;
  }

  .flip-counter,
  .timer {
    font-size: 0.8rem;
  }

  button {
    width: 5rem;
    height: 1.6rem;
    font-size: 0.65rem;
  }

  #cards-container {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    padding: 0.8rem;
  }

  .card {
    max-width: 80px;
  }
}
