* {
  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;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  max-width: 600px;
  width: 100%;
  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;
}

.info {
  font-size: 1.1rem;
  font-weight: 600;
  color: #555;
  background: #f0f0f0;
  padding: 8px 16px;
  border-radius: 10px;
}

button {
  background: #667eea;
  color: white;
  border: none;
  padding: 10px 24px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.3s, transform 0.1s;
}

button:hover {
  background: #5a6fd6;
  transform: scale(1.03);
}

button:active {
  transform: scale(0.97);
}

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

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

.card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 25px rgba(0,0,0,0.2);
}

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

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

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

.win-message {
  margin-top: 20px;
  padding: 20px;
  background: linear-gradient(135deg, #43e97b, #38f9d7);
  border-radius: 15px;
  font-size: 1.3rem;
  font-weight: 700;
  color: #fff;
  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) {
  .grid {
    gap: 8px;
  }
  .card {
    font-size: 1.8rem;
  }
  h1 {
    font-size: 1.5rem;
  }
}