/* ==========================================================================
   Memory Match — Direction B: Playful Neo-Pop / Bento
   包含：糖果色三栏计分板、波普斜纹星标立体卡牌、街机风胜利弹窗
   ========================================================================== */

/* 三栏糖果色计分板 */
.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0 0 18px;
}

.stat-card {
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  border: 2.5px solid var(--border);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.stat-card--moves { background: var(--indigo-soft); }
.stat-card--time { background: var(--amber-soft); }
.stat-card--pairs { background: var(--mint-soft); }

.stat-label {
  font-size: 0.76rem;
  font-weight: 900;
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 2px;
}

.stat-value {
  font-size: clamp(1.2rem, 4vw, 1.45rem);
  font-weight: 900;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

/* 卡牌矩阵容器 */
.board {
  display: grid;
  gap: 12px;
  margin: 0 auto;
  width: 100%;
  touch-action: manipulation;
}

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

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

/* 单张 3D 翻牌 */
.card {
  aspect-ratio: 1;
  perspective: 900px;
  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.42s var(--ease-spring);
}

.card:not(.flipped):not(.matched):not(:disabled):hover .card-inner {
  transform: translateY(-3px);
}

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

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

/* 牌背：白色外衬 + 斜纹波普底 + 星形徽章 */
.face-back {
  background: #ffffff;
  padding: 5px;
}

.face-back-pattern {
  width: 100%;
  height: 100%;
  border-radius: 10px;
  border: 2px solid var(--border);
  background: repeating-linear-gradient(
    -45deg,
    #4f46e5,
    #4f46e5 9px,
    #6366f1 9px,
    #6366f1 18px
  );
  display: grid;
  place-items: center;
}

.face-back-star {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid var(--border);
  box-shadow: 0 2px 0 var(--border);
  display: grid;
  place-items: center;
  color: var(--ink);
  font-size: 1rem;
  font-weight: 900;
  transition: transform 0.2s var(--ease-spring), background 0.15s ease, color 0.15s ease;
}

.card:not(.flipped):not(.matched):not(:disabled):hover .face-back-star {
  transform: rotate(24deg) scale(1.1);
  background: var(--coral);
  color: #ffffff;
}

/* 牌面：柔色果盘圆环 + 大号 Emoji */
.face-front {
  transform: rotateY(180deg);
  background: var(--surface);
}

.fruit-halo {
  width: 74%;
  height: 74%;
  border-radius: 50%;
  background: #f8fafc;
  border: 2px dashed #cbd5e1;
  display: grid;
  place-items: center;
  font-size: clamp(1.5rem, 5.5vw, 2.25rem);
}

/* 配对成功状态 */
.card.matched .face-front {
  background: var(--mint-soft);
  box-shadow: 0 4px 0 #059669;
}

.card.matched .fruit-halo {
  background: #ffffff;
  border: 2px solid var(--mint);
}

.match-check {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--mint);
  color: #ffffff;
  border: 1.5px solid var(--border);
  font-size: 0.7rem;
  font-weight: 900;
  display: none;
  place-items: center;
}

.card.matched .match-check {
  display: grid;
}

/* ==========================================================================
   街机风胜利结算弹窗 (.overlay & .win-card)
   ========================================================================== */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fade-in 0.22s ease;
}

.overlay.hidden {
  display: none;
}

.win-card {
  width: 100%;
  max-width: 370px;
  background: var(--surface);
  border: 3px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: 0 10px 0 var(--border), 0 24px 48px rgba(15, 23, 42, 0.35);
  overflow: hidden;
  text-align: center;
  animation: pop-in 0.4s var(--ease-spring);
}

.win-banner {
  background: linear-gradient(135deg, var(--amber) 0%, #f59e0b 100%);
  border-bottom: 3px solid var(--border);
  padding: 22px 20px 18px;
}

.win-trophy {
  width: 68px;
  height: 68px;
  margin: 0 auto 8px;
  border-radius: 20px;
  background: var(--surface);
  border: 2.5px solid var(--border);
  box-shadow: var(--shadow-md);
  display: grid;
  place-items: center;
  font-size: 2.3rem;
  animation: bounce 0.8s ease infinite alternate;
}

.win-card h2 {
  margin: 0;
  font-size: 1.65rem;
  font-weight: 900;
  color: var(--ink);
}

.win-body {
  padding: 20px 22px 24px;
}

.win-msg-text {
  margin: 0 0 14px;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink-secondary);
}

.win-stats-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.win-stat-pill {
  padding: 10px;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--surface-soft);
  box-shadow: var(--shadow-xs);
}

.win-stat-pill span {
  display: block;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--muted);
}

.win-stat-pill strong {
  font-size: 1.2rem;
  font-weight: 900;
  color: var(--ink);
}

.win-again-btn {
  width: 100%;
  padding: 12px;
}

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

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

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

@media (max-width: 460px) {
  .board {
    gap: 8px;
  }

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

  .face-back {
    padding: 3px;
  }

  .face-back-star {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
  }
}
