/* Memory Match — Soft Editorial Light */

.controls {
  justify-content: space-between;
}

.difficulty {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.label {
  color: var(--muted);
  font-size: 0.85rem;
}

.btn-group {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.diff-btn {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--ink);
  font-weight: 500;
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  min-height: 36px;
  box-shadow: none;
}

.diff-btn:hover {
  border-color: rgba(15, 118, 110, 0.35);
  background: var(--bg-soft);
}

.diff-btn.active {
  background: #ccfbf1;
  border-color: var(--accent);
  color: var(--accent-press);
  font-weight: 700;
  box-shadow: none;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0 16px;
}

.stat {
  text-align: center;
  padding: 10px 8px;
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.03);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 2px;
}

.stat-value {
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--ink);
}

.board {
  display: grid;
  gap: 10px;
  margin: 0 auto;
  width: 100%;
  touch-action: manipulation;
}

.board.cols-4 {
  grid-template-columns: repeat(4, 1fr);
}

.board.cols-6 {
  grid-template-columns: repeat(6, 1fr);
}

.card {
  aspect-ratio: 1;
  perspective: 800px;
  cursor: pointer;
  border: none;
  padding: 0;
  background: transparent;
  font: inherit;
  color: inherit;
  -webkit-user-select: none;
  user-select: none;
}

.card:disabled {
  cursor: default;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.35s ease;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--line);
}

.face-back {
  background: linear-gradient(145deg, #fff7ed, #ccfbf1);
}

.face-back::after {
  content: "?";
  font-size: clamp(1.2rem, 5vw, 1.8rem);
  font-weight: 700;
  color: var(--muted);
}

.face-front {
  transform: rotateY(180deg);
  font-size: clamp(1.4rem, 6vw, 2.2rem);
  background: var(--panel);
}

.card.matched .face-front {
  box-shadow: inset 0 0 0 2px var(--success), 0 0 0 1px rgba(21, 128, 61, 0.12);
  background: #f0fdf4;
}

.card:not(.flipped):not(.matched):not(:disabled):hover .face-back {
  border-color: rgba(15, 118, 110, 0.35);
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(120, 113, 108, 0.28);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  padding: 20px;
  z-index: 50;
  animation: fade-in 0.25s ease;
}

.overlay.hidden {
  display: none;
}

.win-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-align: center;
  max-width: 340px;
  width: 100%;
  box-shadow: var(--shadow);
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.win-emoji {
  font-size: 2.5rem;
  animation: bounce 0.8s ease infinite alternate;
}

.win-card h2 {
  margin: 8px 0;
  font-size: 1.6rem;
  color: var(--ink);
  letter-spacing: 0.03em;
}

.win-card p {
  color: var(--muted);
  margin: 0 0 18px;
  line-height: 1.5;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes pop-in {
  from { transform: scale(0.85); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes bounce {
  from { transform: translateY(0); }
  to { transform: translateY(-6px); }
}

@media (max-width: 420px) {
  .board {
    gap: 6px;
  }

  .board.cols-6 {
    gap: 5px;
  }

  .controls {
    flex-direction: column;
    align-items: stretch;
  }

  .controls .btn-primary {
    width: 100%;
  }

  .face,
  .card-inner {
    border-radius: 10px;
  }
}

@media (min-width: 640px) {
  .board.cols-4 {
    max-width: 480px;
  }

  .board.cols-6 {
    max-width: 640px;
  }
}
