/* 记忆配对 · 样式（.g-memory 前缀） */

.g-memory {
  padding-left: 12px;
  padding-right: 12px;
  gap: 10px;
}

.g-memory .mem-board-wrap { padding: 2px 0; }

.g-memory .mem-board {
  position: relative;
  width: 100%;
  margin: 0 auto;
  display: grid;
  gap: 6px;
  touch-action: manipulation;
}
.g-memory .mem-board[data-size="4x4"] {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  max-width: min(100%, calc((100dvh - 336px) * 1));
}
.g-memory .mem-board[data-size="4x5"] {
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(5, 1fr);
  max-width: min(100%, calc((100dvh - 336px) * 0.8));
}
.g-memory .mem-board[data-size="5x6"] {
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(6, 1fr);
  max-width: min(100%, calc((100dvh - 336px) * 0.8333));
  gap: 5px;
}

/* ---------------- 卡牌 ---------------- */
.g-memory .mem-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 40px;
  min-height: 40px;
  border-radius: 12px;
  perspective: 620px;
  background: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  transition: transform 0.12s ease;
}
.g-memory .mem-card:active { transform: scale(0.96); }

.g-memory .mem-inner {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.22s cubic-bezier(0.3, 0.7, 0.3, 1);
  will-change: transform;
}
.g-memory .mem-card.flip .mem-inner { transform: rotateY(180deg); }

.g-memory .mem-face {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}

.g-memory .mem-back {
  background:
    radial-gradient(90% 90% at 30% 20%, rgba(255, 255, 255, 0.16), transparent 60%),
    linear-gradient(155deg, rgba(255, 122, 184, 0.3), rgba(201, 61, 130, 0.14));
  border: 1px solid rgba(255, 122, 184, 0.32);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14), 0 5px 12px -8px rgba(0, 0, 0, 0.8);
}
.g-memory .mem-back::before {
  content: "";
  position: absolute;
  inset: 5px;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
}
.g-memory .mem-back-mark {
  font-size: clamp(15px, 5.5vw, 22px);
  font-weight: 800;
  color: rgba(255, 255, 255, 0.42);
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.g-memory .mem-front {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.045));
  border: 1px solid var(--line-2);
  font-size: clamp(22px, 7.6vw, 34px);
  line-height: 1;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.16);
}
.g-memory .mem-front span {
  transform: translateZ(0.1px);
}

.g-memory .mem-card.matched {
  pointer-events: none;
}
.g-memory .mem-card.matched .mem-front {
  background: linear-gradient(160deg, rgba(62, 207, 142, 0.2), rgba(62, 207, 142, 0.07));
  border-color: rgba(62, 207, 142, 0.4);
  box-shadow: 0 0 0 1px rgba(62, 207, 142, 0.20), 0 6px 16px -10px rgba(62, 207, 142, 0.7);
}

.g-memory .mem-card.wrong .mem-front {
  border-color: rgba(255, 92, 108, 0.65);
  background: linear-gradient(160deg, rgba(255, 92, 108, 0.18), rgba(255, 92, 108, 0.06));
}
.g-memory .mem-card.wrong { animation: memShake 0.3s ease; }
@keyframes memShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
}

.g-memory .mem-seg { flex: none; }
.g-memory .mem-seg .seg { width: 100%; }
.g-memory .mem-hint { text-align: center; font-size: 10.5px; }

/* ---------------- 弹层 ---------------- */
.m-layer {
  position: fixed;
  inset: 0;
  z-index: 94;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
  background: rgba(4, 6, 11, 0.6);
  animation: fadeIn 0.18s ease both;
}
.m-sheet {
  width: min(100%, 352px);
  max-height: min(84vh, 640px);
  overflow-y: auto;
  background: linear-gradient(180deg, #161c2b, #111623);
  border: 1px solid var(--line-2);
  border-radius: 22px;
  padding: 19px;
  box-shadow: 0 34px 80px -18px rgba(0, 0, 0, 0.78), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  animation: popIn 0.22s cubic-bezier(0.22, 1.1, 0.36, 1) both;
}
.m-sheet-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--accent) 34%, transparent);
  border-radius: 999px;
  padding: 3px 10px;
  margin-bottom: 10px;
}
.m-sheet-title { font-size: 18px; font-weight: 800; line-height: 1.3; }
.m-sheet-sub { font-size: 11.5px; color: var(--faint); margin-top: 4px; }
.m-sheet-actions { display: flex; gap: 8px; margin-top: 16px; }
.m-sheet-actions .btn { flex: 1; }

.m-guide { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.m-guide-row { font-size: 12.5px; line-height: 1.65; color: var(--dim); }
.m-guide-row b { display: inline-block; min-width: 34px; margin-right: 6px; color: var(--accent); font-weight: 700; }

.m-win { margin-top: 14px; }
.m-win-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.m-win-stats .stat { background: rgba(255, 255, 255, 0.045); }
.m-win-tip { margin-top: 12px; font-size: 12px; line-height: 1.6; color: var(--dim); text-align: center; }

@media (max-height: 720px) {
  .g-memory .mem-hint { display: none; }
}
