:root {
  --primary: #5b4fb5;
  --secondary: #8b7fd4;
  --accent: #ff6b6b;
  --background: #f8f9fa;
  --text: #333;
  --border: #e0e0e0;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.container {
  background: white;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.15);
  padding: 40px;
  max-width: 600px;
  width: 100%;
}

h1 {
  text-align: center;
  color: var(--primary);
  margin-bottom: 10px;
  font-size: 2.5rem;
}

.subtitle {
  text-align: center;
  color: #666;
  margin-bottom: 30px;
  font-size: 0.95rem;
}

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

.stats {
  display: flex;
  gap: 20px;
  background: var(--background);
  padding: 15px;
  border-radius: 8px;
}

.stat-item {
  flex: 1;
  text-align: center;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--primary);
}

.stat-label {
  font-size: 0.85rem;
  color: #666;
  margin-top: 5px;
}

select {
  padding: 10px 15px;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  background: white;
  color: var(--text);
}

button {
  background: var(--primary);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

button:hover {
  background: var(--secondary);
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(91, 79, 181, 0.4);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.game-board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
  gap: 12px;
  margin: 30px 0;
  min-height: 300px;
}

.card {
  aspect-ratio: 1 / 1;
  background: var(--primary);
  border: none;
  border-radius: 12px;
  color: white;
  font-size: 2rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card:hover {
  transform: scale(1.05);
  box-shadow: 0 5px 15px rgba(91, 79, 181, 0.4);
}

.card.flipped {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  transform: rotateY(180deg);
}

.card.matched {
  background: #4caf50;
  cursor: default;
}

.card.matched:hover {
  transform: none;
}

.best-scores {
  background: var(--background);
  padding: 20px;
  border-radius: 8px;
  margin-top: 20px;
}

.best-scores h3 {
  color: var(--primary);
  margin-bottom: 15px;
}

.scores-list {
  list-style: none;
}

.scores-list li {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

.scores-list li:last-child {
  border-bottom: none;
}

.score-badge {
  background: var(--accent);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
}

@media (max-width: 600px) {
  .container {
    padding: 20px;
  }

  h1 {
    font-size: 2rem;
  }

  .game-board {
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
    gap: 8px;
  }

  .card {
    font-size: 1.5rem;
  }

  .controls {
    flex-direction: column;
  }

  select {
    width: 100%;
  }
}
