/* ===== 记忆翻牌 ===== */
.board-wrap {
  width: 100%;
  max-width: 520px;
  margin-bottom: 22px;
}

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

.card {
  position: relative;
  aspect-ratio: 1 / 1;
  cursor: pointer;
  perspective: 800px;
}

.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform .45s cubic-bezier(.4, .2, .2, 1);
  transform-style: preserve-3d;
}

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

.card-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  user-select: none;
}

/* 背面（盖着的时候） */
.card-back {
  background: linear-gradient(135deg, #ffa751, #ff7043);
  font-size: 30px;
  color: rgba(255, 255, 255, .85);
  box-shadow: 0 6px 16px rgba(255, 130, 60, .3);
}

.card:not(.flipped):not(.matched):hover .card-back {
  background: linear-gradient(135deg, #ffb877, #ff8555);
  transform: scale(1.02);
}

/* 正面（翻开后） */
.card-front {
  background: #fff;
  transform: rotateY(180deg);
  font-size: clamp(30px, 7vw, 44px);
  box-shadow: 0 6px 16px rgba(120, 90, 150, .16);
  border: 3px solid #ffe0c2;
}

.card.matched .card-front {
  background: #e8fbf1;
  border-color: #7fe0b0;
  animation: matchPop .4s ease;
}

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

/* 翻错时抖一下 */
.card.wrong .card-front { animation: shake .4s; border-color: #ffb3b3; }

@keyframes shake {
  0%, 100% { transform: rotateY(180deg) translateX(0); }
  25% { transform: rotateY(180deg) translateX(-6px); }
  75% { transform: rotateY(180deg) translateX(6px); }
}

.board.locked .card { pointer-events: none; }

@media (max-width: 480px) {
  .board { gap: 8px; }
  .card-back { font-size: 22px; }
  .card-front { border-width: 2px; border-radius: 10px; }
  .card-face { border-radius: 10px; }
}
