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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.container {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 20px;
  padding: 30px;
  max-width: 600px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  text-align: center;
}

h1 {
  color: #333;
  margin-bottom: 20px;
  font-size: 2rem;
}

.controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 10px;
}

.stats {
  display: flex;
  gap: 20px;
  font-size: 1rem;
  color: #555;
}

.stats strong {
  color: #764ba2;
}

#resetBtn, #playAgainBtn {
  background: #764ba2;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 1rem;
  transition: background 0.3s;
}

#resetBtn:hover, #playAgainBtn:hover {
  background: #5a3d7a;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.card {
  aspect-ratio: 1;
  background: linear-gradient(145deg, #667eea, #764ba2);
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2.5rem;
  transition: transform 0.4s, box-shadow 0.3s;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
  user-select: none;
}

.card:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.card.flipped {
  background: white;
  transform: rotateY(180deg);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.card.matched {
  background: #4caf50;
  transform: scale(0.95);
  cursor: default;
  box-shadow: 0 0 20px rgba(76, 175, 80, 0.4);
}

.card.matched:hover {
  transform: scale(0.95);
}

.win-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  padding: 20px;
  background: linear-gradient(135deg, #667eea, #764ba2);
  border-radius: 15px;
  color: white;
  font-size: 1.8rem;
  font-weight: bold;
  animation: popIn 0.5s ease;
}

.win-message.hidden {
  display: none;
}

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

@media (max-width: 500px) {
  .board {
    gap: 8px;
  }
  .card {
    font-size: 1.8rem;
  }
  .stats {
    font-size: 0.85rem;
    gap: 10px;
  }
}