/* memory.css — Memory / Pairs. Immersive: site chrome hidden; only the HUD,
   the card grid and the start/solved overlay show. */

.wg-main.wg-main-game { max-width: none; width: 100%; margin: 0; padding: 0; }

.wg-mem {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center;
  gap: 8px; padding: 8px 10px 12px; background: #0b1016;
}

/* ── HUD ── */
.wg-mem-hud { width: 100%; max-width: 520px; display: flex; align-items: center; gap: 10px; color: #eaf0f5; }
.wg-mem-exit {
  flex: 0 0 auto; width: 38px; height: 38px; display: grid; place-items: center;
  font-size: 1.5rem; line-height: 1; color: #cdd6de; text-decoration: none;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); border-radius: 10px;
}
.wg-mem-exit:hover { background: rgba(255,255,255,0.12); color: #fff; }
.wg-mem-score { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.05; }
.wg-mem-num { font-size: 1.6rem; font-weight: 800; letter-spacing: -0.01em; }
.wg-mem-mini { font-size: 0.7rem; color: #8a99a8; font-weight: 600; }
.wg-mem-hud-btns { flex: 0 0 auto; display: flex; gap: 6px; }
.wg-mem-hbtn {
  font: inherit; font-size: 0.82rem; font-weight: 700; padding: 8px 12px; min-width: 40px;
  color: #eaf0f5; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.14); border-radius: 10px; cursor: pointer;
}
.wg-mem-hbtn:hover { background: rgba(255,255,255,0.16); }
.wg-mem-hbtn:disabled { opacity: 0.4; cursor: default; }

/* ── Phase label + countdown bar ── */
.wg-mem-timerbar { width: 100%; max-width: 520px; display: flex; align-items: center; gap: 10px; }
.wg-mem-phase { flex: 0 0 auto; min-width: 92px; font-size: 0.78rem; font-weight: 800; color: #7ee0a2; }
.wg-mem-phase.is-peek { color: #ffd54a; }
.wg-mem-phase:empty { min-width: 0; }
.wg-mem-bar { flex: 1 1 auto; height: 8px; background: rgba(255,255,255,0.10); border-radius: 999px; overflow: hidden; }
.wg-mem-bar-fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #17c257, #ffd54a); }
/* Amber while memorising; the green→red drain only reads during the match. */
.wg-mem-phase.is-peek ~ .wg-mem-bar .wg-mem-bar-fill { background: #ffd54a; }

/* ── Card grid ── */
.wg-mem-boardwrap { position: relative; flex: 1 1 auto; display: flex; align-items: center; justify-content: center; width: 100%; }
.wg-mem-board {
  display: grid; grid-template-columns: repeat(var(--cols, 4), 1fr); gap: 8px;
  width: 100%; max-width: min(94vw, 520px);
  padding: 4px;
}
.wg-mem-card {
  aspect-ratio: 3 / 4; padding: 0; border: none; background: none;
  cursor: pointer; perspective: 600px; -webkit-tap-highlight-color: transparent;
}
.wg-mem-inner {
  position: relative; display: block; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform 0.32s cubic-bezier(.2,.7,.3,1);
}
.wg-mem-card.is-flipped .wg-mem-inner { transform: rotateY(180deg); }
.wg-mem-back, .wg-mem-front {
  position: absolute; inset: 0; display: grid; place-items: center;
  border-radius: 11px; backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.wg-mem-back {
  color: rgba(255,255,255,0.85); font-weight: 800; font-size: clamp(1rem, 5vw, 1.6rem);
  background: linear-gradient(160deg, #17c257 0%, #0eaf4c 100%);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.18), 0 2px 6px rgba(0,0,0,0.3);
}
.wg-mem-front {
  transform: rotateY(180deg);
  font-size: clamp(1.3rem, 8vw, 2.4rem); line-height: 1;
  background: #1c2230; border: 1px solid rgba(255,255,255,0.10);
}
.wg-mem-card.is-matched .wg-mem-front { background: #0f3a22; border-color: rgba(126,224,162,0.5); }
.wg-mem-card.is-matched { animation: wg-mem-pop 0.3s ease; }
@keyframes wg-mem-pop { 50% { transform: scale(1.06); } }
@media (prefers-reduced-motion: reduce) {
  .wg-mem-inner { transition: none; } .wg-mem-card.is-matched { animation: none; }
}

/* ── Overlay ── */
.wg-mem-overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(9,14,20,0.92); border-radius: 14px; padding: 14px; }
.wg-mem-overlay[hidden] { display: none; }
.wg-mem-overlay-card {
  color: #fff; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 9px;
  width: 100%; max-width: 320px; max-height: 100%; overflow: hidden;
}
.wg-mem-overlay-card h2 { margin: 0; font-size: 1.45rem; }
.wg-mem-overlay-card p { margin: 0; display: flex; flex-direction: column; gap: 5px; font-size: 0.9rem; }
.wg-mem-overlay-card .wg-btn { min-width: 160px; }
.wg-mem-final { font-size: 1.2rem; font-weight: 800; }
.wg-mem-time { color: #7ee0a2; font-weight: 700; font-size: 0.86rem; }
.wg-mem-best-tag { color: #ffd54a; font-weight: 700; }
.wg-mem-hint { font-size: 0.82rem; opacity: 0.82; }
.wg-mem-controls { flex: 0 0 auto; margin: 0; font-size: 0.72rem; line-height: 1.45; color: #9fb0be; max-width: 300px; }
.wg-mem-overlay-exit { color: #9fb0be; font-size: 0.85rem; text-decoration: underline; }
.wg-mem-overlay-exit:hover { color: #fff; }

/* ── Leaderboard (its list is the only scroll region) ── */
.wg-mem-lb { flex: 1 1 auto; min-height: 0; width: 100%; display: flex; flex-direction: column; text-align: left; margin-top: 2px; }
.wg-mem-lb-head { display: flex; align-items: baseline; gap: 8px; justify-content: center; margin-bottom: 6px; }
.wg-mem-lb-head h3 { margin: 0; font-size: 1rem; color: #eaf0f5; }
.wg-mem-lb-total { font-size: 0.78rem; color: #8a99a8; }
.wg-mem-lb-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 3px; flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.wg-mem-lb-row { display: flex; align-items: center; gap: 10px; padding: 7px 10px; font-size: 0.88rem; background: rgba(255,255,255,0.05); border: 1px solid rgba(255,255,255,0.08); border-radius: 8px; }
.wg-mem-lb-row.is-me { border-color: var(--wg-color); background: rgba(14,175,76,0.18); }
.wg-mem-lb-rank { flex: 0 0 auto; width: 22px; font-weight: 800; color: #8a99a8; text-align: center; }
.wg-mem-lb-row:nth-child(1) .wg-mem-lb-rank { color: #f5b301; }
.wg-mem-lb-row:nth-child(2) .wg-mem-lb-rank { color: #c4ced6; }
.wg-mem-lb-row:nth-child(3) .wg-mem-lb-rank { color: #cd7f32; }
.wg-mem-lb-name { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wg-mem-lb-name em { color: #7ee0a2; font-style: normal; font-weight: 700; font-size: 0.85em; }
.wg-mem-lb-score { flex: 0 0 auto; font-weight: 800; }
.wg-mem-lb-empty { color: #8a99a8; font-size: 0.86rem; text-align: center; padding: 6px 2px; }
.wg-mem-lb-me { margin: 6px 0 0; font-size: 0.84rem; color: #7ee0a2; font-weight: 600; text-align: center; }
