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

body {
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(135deg, #1e3c72, #2a5298);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 32px 16px;
}

.container {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px;
  width: 100%;
  height: calc(100vh - 64px);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

h1 {
  text-align: center;
  color: #fff;
  margin-bottom: 20px;
  font-size: 28px;
}

.stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 16px;
  color: #fff;
}

.stat {
  text-align: center;
}

.stat .label {
  display: block;
  font-size: 13px;
  opacity: 0.8;
}

.stat span:last-child {
  font-size: 24px;
  font-weight: bold;
}

.controls {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

button {
  background: #ff9800;
  color: #fff;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.2s;
}

button:hover {
  background: #ffb74d;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-auto-rows: 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.card {
  background: #fff;
  border-radius: 10px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: clamp(28px, min(9vw, 9vh), 90px);
  cursor: pointer;
  user-select: none;
  transform-style: preserve-3d;
  transition: transform 0.3s;
  position: relative;
}

.card:hover {
  transform: scale(1.05);
}

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

.card .front,
.card .back {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 10px;
  backface-visibility: hidden;
}

.card .front {
  background: linear-gradient(145deg, #4caf50, #388e3c);
}

.card .back {
  background: #fff;
  transform: rotateY(180deg);
  box-shadow: inset 0 0 0 3px #2a5298;
}

.card.matched {
  animation: pop 0.4s ease;
  cursor: default;
}

.card.matched .back {
  background: #c8e6c9;
  box-shadow: inset 0 0 0 3px #388e3c;
}

.card.disabled {
  pointer-events: none;
}

@keyframes pop {
  0% { transform: rotateY(180deg) scale(1); }
  50% { transform: rotateY(180deg) scale(1.15); }
  100% { transform: rotateY(180deg) scale(1); }
}

.message {
  text-align: center;
  color: #fff;
  font-size: 22px;
  margin-top: 20px;
  background: rgba(0, 0, 0, 0.3);
  padding: 12px;
  border-radius: 10px;
}

.hidden {
  display: none;
}
