/* Visual Memory */
.g-visual-memory [hidden] { display: none !important; }

.g-visual-memory .vm-levelbar { margin: 0 0 10px; gap: 10px; flex-wrap: nowrap; }
.g-visual-memory .vm-levelbar .pz-btn { flex: none; min-width: 44px; min-height: 44px; padding: 4px 10px; font-size: 1.3rem; line-height: 1; }
.g-visual-memory .vm-leveltitle { display: flex; flex-direction: column; align-items: center; flex: 1 1 auto; min-width: 0; line-height: 1.25; text-align: center; }
.g-visual-memory .vm-leveltitle strong { font-size: 1.1rem; font-weight: 900; }
.g-visual-memory .vm-leveltitle span { font-size: .8rem; font-weight: 700; color: var(--muted); }

.g-visual-memory .vm-status { margin: 0 0 10px; font-weight: 800; color: var(--text); }
.g-visual-memory .vm-help { font-size: .85rem; margin: 12px 0 0; }

/* the board keeps one outer size per grid so tiles shrink as the grid grows */
.g-visual-memory .vm-stage { position: relative; width: 100%; max-width: 420px; margin: 0 auto; --vm-gap: 8px; }
.g-visual-memory .vm-stage.vm-g3 { max-width: 340px; }
.g-visual-memory .vm-stage.vm-g4 { max-width: 390px; }
.g-visual-memory .vm-stage.vm-g5 { --vm-gap: 6px; }
.g-visual-memory .vm-stage.vm-g6 { max-width: 440px; --vm-gap: 5px; }
.g-visual-memory .vm-stage.vm-g7 { max-width: 460px; --vm-gap: 4px; }
.g-visual-memory .vm-board { display: grid; grid-template-columns: repeat(var(--vm-n, 3), minmax(0, 1fr)); gap: var(--vm-gap); }

.g-visual-memory .vm-tile {
  appearance: none; -webkit-appearance: none; aspect-ratio: 1; min-width: 0; padding: 0; margin: 0;
  border: 2px solid var(--border); border-radius: 12px; background: var(--surface-2); color: var(--text);
  font: inherit; font-weight: 900; line-height: 1; display: grid; place-items: center; cursor: pointer; position: relative;
  transition: background-color .08s, border-color .08s;
}
.g-visual-memory .vm-g6 .vm-tile,
.g-visual-memory .vm-g7 .vm-tile { border-radius: 8px; border-width: 1.5px; }
.g-visual-memory .vm-board.locked .vm-tile { cursor: default; }
.g-visual-memory .vm-tile::after { content: ''; font-size: 1.25rem; line-height: 1; pointer-events: none; }
.g-visual-memory .vm-g5 .vm-tile::after { font-size: 1.1rem; }
.g-visual-memory .vm-g6 .vm-tile::after,
.g-visual-memory .vm-g7 .vm-tile::after { font-size: .9rem; }

/* every state has its own symbol as well as its own colour */
.g-visual-memory .vm-tile.show { background: var(--accent); border-color: var(--accent); }
.g-visual-memory .vm-tile.show::after { content: '◆'; color: var(--accent-ink); }
.g-visual-memory .vm-tile.hit { background: color-mix(in srgb, var(--good) 22%, var(--surface)); border-color: var(--good); }
.g-visual-memory .vm-tile.hit::after { content: '✓'; color: var(--good); }
.g-visual-memory .vm-tile.miss { background: color-mix(in srgb, var(--bad) 18%, var(--surface)); border-color: var(--bad); }
.g-visual-memory .vm-tile.miss::after { content: '✕'; color: var(--bad); }
.g-visual-memory .vm-tile.reveal { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); border-style: dashed; border-color: var(--accent); }
.g-visual-memory .vm-tile.reveal::after { content: '◇'; color: var(--accent); }

/* start panel / countdown sits over the board */
.g-visual-memory .vm-overlay {
  position: absolute; top: -4px; right: -4px; bottom: -4px; left: -4px; z-index: 2;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; text-align: center; border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
}
.g-visual-memory .vm-ov-title { font-weight: 900; font-size: 1.35rem; line-height: 1.15; }
.g-visual-memory .vm-ov-sub { color: var(--muted); font-weight: 700; font-size: .9rem; line-height: 1.35; max-width: 30ch; }
.g-visual-memory .vm-start { margin-top: 6px; min-width: 140px; min-height: 52px; font-size: 1.1rem; }
.g-visual-memory .vm-count { font-size: 4.5rem; font-weight: 900; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }

@media (max-width: 380px) {
  .g-visual-memory .vm-stage.vm-g5 { --vm-gap: 5px; }
  .g-visual-memory .vm-stage.vm-g6,
  .g-visual-memory .vm-stage.vm-g7 { --vm-gap: 3px; }
  .g-visual-memory .vm-tile { border-radius: 10px; }
  .g-visual-memory .vm-g6 .vm-tile,
  .g-visual-memory .vm-g7 .vm-tile { border-radius: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  .g-visual-memory .vm-tile { transition: none; }
}
