:root { --bg1: #1c7ed6; --bg2: #22b8cf; --accent: #0B4DA2; --accent-ink: #fff; --panel-ink: #062A5F; --muted: #3D5B8C; --card: 100px; --cols: 4; --g: 10px; }
.grid {
  display: grid; grid-template-columns: repeat(var(--cols), var(--card)); gap: var(--g);
  perspective: 900px;
}
.mcard {
  width: var(--card); height: calc(var(--card) * 1.18);
  border: 0; padding: 0; background: none; cursor: pointer; position: relative;
  transform-style: preserve-3d; transition: transform .35s cubic-bezier(.3,1.3,.5,1);
  -webkit-tap-highlight-color: transparent;
}
.mcard.up, .mcard.matched { transform: rotateY(180deg); }
.mcard:focus-visible { outline: 4px solid var(--accent); outline-offset: 3px; border-radius: 16px; }
.mcard .side {
  position: absolute; inset: 0; border-radius: 16px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  display: grid; place-items: center; box-shadow: 0 5px 0 rgba(0,0,0,.18), 0 8px 18px rgba(0,0,0,.15);
}
.mcard .back {
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,.35) 0 10%, transparent 11%),
    radial-gradient(circle at 70% 70%, rgba(255,255,255,.25) 0 14%, transparent 15%),
    linear-gradient(135deg, #7048e8, #4c6ef5);
  border: 4px solid #fff;
}
.mcard .back::after {
  content: "?"; font-size: calc(var(--card) * .42); font-weight: 900; color: rgba(255,255,255,.9);
  text-shadow: 0 3px 0 rgba(0,0,0,.2);
}
.mcard .front { transform: rotateY(180deg); border: 4px solid #fff; }
.mcard .front svg { width: 78%; height: 78%; }
.mcard.matched .front { animation: matchPop .5s ease; box-shadow: 0 0 0 4px #51cf66, 0 8px 18px rgba(0,0,0,.15); }
.mcard.matched { cursor: default; }
.mcard.wrong .front { animation: shake .35s ease; box-shadow: 0 0 0 4px #ff6b6b, 0 8px 18px rgba(0,0,0,.15); }
.mcard:not(.up):not(.matched):hover { transform: translateY(-3px); }

.toolbar { display: flex; gap: 12px; justify-content: center; align-items: center; flex: 0 0 auto; min-height: 52px; }
.level-chip { background: rgba(255,255,255,.22); padding: 8px 16px; border-radius: 999px; font-weight: 900; }
.spaced { margin-top: 16px; }

@keyframes matchPop { 40% { transform: rotateY(180deg) scale(1.12); } }
@media (max-width: 560px) { .stat { min-width: 0; padding: 4px 6px; } }
