* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
  background-color: #f5f5f5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 15px;
  color: #333;
}

h1 {
  font-size: 2.5rem;
  margin-bottom: 10px;
  text-align: center;
}
h2 {
  font-size: 2rem;
  margin-bottom: 20px;
  text-align: center;
  color: red;
}

#container {
  background-color: white;
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 500px;
}

#game-info {
  display: flex;
  justify-content: space-between;
  margin-bottom: 15px;
  font-size: 1rem;
  background-color: #f0f8ff;
  padding: 10px;
  border-radius: 8px;
}

#grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 15px;
}

.card {
  aspect-ratio: 3/4;
  perspective: 1000px;
  cursor: pointer;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.5s;
  transform-style: preserve-3d;
  border-radius: 6px;
}

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

.card.matched .card-inner {
  transform: rotateY(180deg);
  box-shadow: 0 0 8px 2px rgba(175, 76, 76, 0.6);
}

.card-front,
.card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 6px;
}

.card-front {
  background-color: #f8f8f8;
  color: #2c3e50;
  font-size: 1.5rem;
  transform: rotateY(180deg);
}

.card-back {
  background: linear-gradient(135deg, #db3434, #cc2e2e);
  color: white;
  font-size: 1.2rem;
}

.card-back::after {
  content: '?';
}

#countdown {
  text-align: center;
  font-size: 1.2rem;
  margin-bottom: 10px;
  font-weight: bold;
  color: #8b0000;
}

#restart {
  background-color: #af4c4c;
  color: white;
  border: none;
  padding: 10px 15px;
  font-size: 1rem;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  transition: background-color 0.3s;
}

#restart:hover {
  background-color: #a04545;
}

@media (max-width: 480px) {
  h1 {
    font-size: 1.5rem;
  }

  #grid {
    grid-template-columns: repeat(3, 1fr);
  }
}
