/* 记忆矩阵 · 样式（.g-memorygrid 前缀） */

.g-memorygrid {
  justify-content: center;
}

.g-memorygrid .g-head { min-height: 44px; align-items: center; }
.g-memorygrid .mg-level { font-size: 15px; font-weight: 800; letter-spacing: 0.01em; }
.g-memorygrid .mg-phase { min-height: 17px; }

.g-memorygrid .stat-v.mg-danger { color: var(--err); }

/* ---------------- 棋盘 ---------------- */

.g-memorygrid .mg-board-wrap {
  flex: 0 0 auto;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.g-memorygrid .mg-board {
  position: relative;
  width: min(100%, calc(100dvh - 330px));
  max-width: 100%;
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  padding: 8px;
  border-radius: 20px;
  background:
    radial-gradient(110% 90% at 50% 0%, rgba(183, 140, 255, 0.1), transparent 62%),
    linear-gradient(160deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--line-2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 22px 54px -32px rgba(0, 0, 0, 0.95);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  font-size: 50px;
}

.g-memorygrid .mg-cells {
  position: absolute;
  inset: 8px;
  display: grid;
  gap: 8px;
}

.g-memorygrid .mg-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.022));
  color: #fff;
  font-size: calc(var(--mg-cell, 50px) * 0.46);
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  touch-action: manipulation;
  transition:
    background 0.18s ease,
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.12s ease;
}

.g-memorygrid .mg-cell::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle at 30% 18%, rgba(255, 255, 255, 0.1), transparent 62%);
  pointer-events: none;
}

/* 点亮 */
.g-memorygrid .mg-cell.on {
  background: linear-gradient(160deg, rgba(183, 140, 255, 0.96), rgba(124, 77, 219, 0.94));
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 0 20px rgba(183, 140, 255, 0.65), inset 0 1px 0 rgba(255, 255, 255, 0.55);
  animation: mgPulse 0.9s ease-in-out infinite alternate;
}

@keyframes mgPulse {
  from { box-shadow: 0 0 12px rgba(183, 140, 255, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.5); }
  to { box-shadow: 0 0 26px rgba(183, 140, 255, 0.85), inset 0 1px 0 rgba(255, 255, 255, 0.6); }
}

/* 点对 / 点错 */
.g-memorygrid .mg-cell.hit {
  background: linear-gradient(160deg, rgba(126, 231, 135, 0.94), rgba(47, 158, 68, 0.92));
  border-color: rgba(255, 255, 255, 0.42);
  box-shadow: 0 0 18px rgba(126, 231, 135, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  animation: mgHit 0.22s ease-out;
}

@keyframes mgHit {
  0% { transform: scale(0.88); }
  60% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.g-memorygrid .mg-cell.wrong {
  background: rgba(255, 92, 108, 0.22);
  border-color: rgba(255, 92, 108, 0.6);
  box-shadow: 0 0 18px rgba(255, 92, 108, 0.28);
  color: #ff8b96;
}

.g-memorygrid .mg-cell:active:not(.hit):not(.wrong):not(.on) { transform: scale(0.95); }

/* ---------------- 准备 / 结算遮罩 ---------------- */

.g-memorygrid .mg-over {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  border-radius: inherit;
  background: rgba(8, 11, 18, 0.74);
  -webkit-backdrop-filter: blur(7px);
  backdrop-filter: blur(7px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.18s ease, visibility 0.18s;
  pointer-events: none;
}

.g-memorygrid .mg-over.show { opacity: 1; visibility: visible; }

.g-memorygrid .mg-over-card {
  pointer-events: auto;
  width: 100%;
  max-width: 268px;
  padding: 18px 16px 16px;
  text-align: center;
  border-radius: 18px;
  border: 1px solid var(--line-2);
  background: linear-gradient(180deg, rgba(22, 28, 43, 0.94), rgba(17, 22, 35, 0.96));
  box-shadow: 0 24px 60px -22px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.g-memorygrid .mg-over-badge {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--dim);
  margin-bottom: 7px;
}

.g-memorygrid .mg-over-title {
  font-size: 20px;
  font-weight: 800;
  line-height: 1.3;
  letter-spacing: 0.01em;
}

.g-memorygrid .mg-over-sub {
  margin-top: 7px;
  font-size: 11.5px;
  line-height: 1.6;
  color: var(--dim);
}

.g-memorygrid .mg-over-stats {
  display: flex;
  gap: 8px;
  margin: 14px 0 4px;
}

.g-memorygrid .mg-over-btn {
  width: 100%;
  min-height: 46px;
  margin-top: 14px;
}

/* ---------------- 难度 / 提示 ---------------- */

.g-memorygrid .mg-seg .seg { width: 100%; }
.g-memorygrid .mg-seg .seg-item { min-height: 40px; font-size: 12.5px; }

.g-memorygrid .mg-hint {
  font-size: 11px;
  line-height: 1.55;
  text-align: center;
  min-height: 17px;
}

/* ---------------- 窄屏 ---------------- */

@media (max-width: 359px) {
  .g-memorygrid .mg-level { font-size: 14px; }
  .g-memorygrid .mg-hint { font-size: 10.5px; }
  .g-memorygrid .mg-board { width: min(100%, calc(100dvh - 320px)); }
}
