/* ================================================================
   MEMORY
================================================================ */
#page-memory .container { max-width: 860px; }
@media (max-width: 600px) {
  #page-memory { overflow-x: clip; }
  #page-memory .container { overflow-x: clip; padding-left: 10px; padding-right: 10px; }
  #page-memory .title-top { font-size: clamp(22px, 6.5vw, 76px); white-space: nowrap; letter-spacing: 2px; }
  .grid.size-12 { grid-template-columns: repeat(4, 1fr); max-width: 100%; }
  .grid.size-20 { grid-template-columns: repeat(5, 1fr); max-width: 100%; }
  .grid.size-28 { grid-template-columns: repeat(6, 1fr); max-width: 100%; }
  .grid.size-30 { grid-template-columns: repeat(6, 1fr); max-width: 100%; }
}

/* MEMORY tło — siatka kart odwróconych */
#page-memory::before {
  content: '';
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(ellipse 50% 40% at 20% 80%, rgba(26,122,58,0.1) 0%, transparent 70%),
    radial-gradient(ellipse 40% 30% at 80% 20%, rgba(245,200,66,0.06) 0%, transparent 60%);
}
.grid { display: grid; gap: 10px; justify-content: center; width: 100%; }
.grid.size-12 { grid-template-columns: repeat(4, 1fr); max-width: 520px; }
.grid.size-20 { grid-template-columns: repeat(5, 1fr); max-width: 640px; }
.grid.size-28 { grid-template-columns: repeat(6, 1fr); max-width: 860px; }
.grid.size-30 { grid-template-columns: repeat(6, 1fr); max-width: 860px; }

.card { aspect-ratio: 1; cursor: pointer; perspective: 800px; position: relative; }
.card-inner { width: 100%; height: 100%; transform-style: preserve-3d; transition: transform 0.45s cubic-bezier(0.4,0,0.2,1); position: relative; border-radius: 10px; border: 1px solid #58d68d; box-shadow: 0 4px 16px rgba(0,0,0,0.5); }
.card.flipped .card-inner, .card.matched .card-inner { transform: rotateY(180deg); }
.card-face { position: absolute; inset: 0; border-radius: 10px; backface-visibility: hidden; display: flex; align-items: center; justify-content: center; user-select: none; }
.card-back { background: linear-gradient(145deg, #2a2a2e 0%, #1a1a1f 50%, #222228 100%); }
.card-back::after { content: ''; position: absolute; inset: 6px; border: 2px solid rgba(255,255,255,0.1); border-radius: 6px; }
.card-front { background: linear-gradient(145deg, #1e3a2e 0%, #0d2218 100%); border: 3px solid var(--gold); box-shadow: 0 0 18px rgba(245,200,66,0.35); transform: rotateY(180deg); flex-direction: column; gap: 6px; }
.card-front .m-emoji { font-size: clamp(24px, 5vw, 44px); line-height: 1; filter: drop-shadow(0 2px 6px rgba(0,0,0,0.5)); }
.card-front .m-label { font-family: 'Barlow Condensed', sans-serif; font-size: clamp(8px, 1.5vw, 12px); font-weight: 700; color: var(--gold); text-align: center; letter-spacing: 1px; text-transform: uppercase; padding: 0 4px; }
.card.matched .card-front { background: linear-gradient(145deg, #0d3d1e 0%, #165c2e 100%); border-color: #4ade80; box-shadow: 0 0 22px rgba(74,222,128,0.5); animation: matchPulse 0.5s ease; }
.card.matched .card-front .m-label { color: #4ade80; }
@keyframes matchPulse { 0% { transform: rotateY(180deg) scale(1); } 40% { transform: rotateY(180deg) scale(1.08); } 100% { transform: rotateY(180deg) scale(1); } }
.card:not(.flipped):not(.matched):hover .card-inner { transform: rotateY(8deg) scale(1.04); }

@keyframes mSpin { from { display:inline-block; transform:rotate(0deg); } to { transform:rotate(-360deg); } }
@keyframes mShake { 0%{transform:translateX(0)} 15%{transform:translateX(-4px)} 30%{transform:translateX(4px)} 45%{transform:translateX(-4px)} 60%{transform:translateX(4px)} 75%{transform:translateX(-2px)} 90%{transform:translateX(2px)} 100%{transform:translateX(0)} }
.m-shake-icon { display:inline-block; }
.m-shake-icon.shaking { animation: mShake 0.45s ease; }
.m-spin-arrow { display:inline-block; }
.m-spin-arrow.spinning { animation: mSpin 0.5s ease-out; }
.m-msg { font-size: 13px; letter-spacing: 2px; text-transform: uppercase; text-align: center; min-height: 20px; opacity: 0; transition: opacity 0.6s ease; }
.m-msg.show-match { color: #4ade80; opacity: 1; }
.m-msg.show-nomatch { color: #e74c3c; opacity: 1; }
.m-msg.show-match.fade-out { color: #4ade80; opacity: 0; transition: opacity 0.8s ease; }
.m-msg.show-nomatch.fade-out { color: #e74c3c; opacity: 0; transition: opacity 0.8s ease; }

/* memory overlay extras */