/* Memoria de las tablas - overrides only; the layout is shell.css's grid.
   The cards are the input, so they fill .pad-area; landscape widens that
   column (it is sized for a keypad by default). */
#screen-game { --pad-width: min(560px, 58vw); }

.mm-start-hint {
  max-width: 26rem;
  margin: 0 auto;
  font: 600 1rem/1.4 var(--am-readable-font);
  color: var(--purple-dark);
}
.mm-left { font-size: .85em; }

/* the pair just found, big, in the stage (where a typed answer would go) */
.mm-equation {
  min-height: 1.3em;
  margin: 0;
  color: var(--purple-dark);
  font-size: clamp(30px, 8vw, 64px);
  text-shadow: 3px 3px 0 #fff;
  white-space: nowrap;
}
.mm-equation.mm-pop { animation: resultsPopIn .35s cubic-bezier(.34, 1.56, .64, 1) both; }

.pad-area { align-items: stretch; }
.mm-board {
  display: grid;
  grid-template-columns: repeat(var(--cols, 5), minmax(0, 1fr));
  gap: clamp(6px, 1.6vw, 12px);
  width: 100%;
  max-width: 560px;
  margin: 0 auto;
}
.mm-card {
  min-width: 0;
  aspect-ratio: 4 / 5;
  padding: 0;
  border: 0;
  border-radius: .7rem;
  background: none;
  color: #233f51;
  font-family: inherit;
  font-size: clamp(.85rem, 3.6vw, 1.6rem);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  perspective: 440px;
}
.mm-sides {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform .3s cubic-bezier(.35, .05, .2, 1);
}
.mm-card:not([data-state="closed"]) .mm-sides { transform: rotateY(180deg); }
.mm-face {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  isolation: isolate;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.mm-face::before {
  position: absolute;
  inset: 0;
  z-index: -1;
  content: "";
  background: url("assets/card.webp") center / 100% 100% no-repeat;
  filter: drop-shadow(0 3px 2px #33313f52);
}
.mm-front { transform: rotateY(180deg); }
.mm-front::before { filter: saturate(.15) brightness(1.12) drop-shadow(0 3px 2px #33313f52); }
.mm-card[data-kind="result"] .mm-front::before {
  filter: hue-rotate(125deg) saturate(.75) brightness(1.08) drop-shadow(0 3px 2px #33313f52);
}
.mm-card[data-state="matched"] { cursor: default; }
.mm-card[data-state="matched"] .mm-front::before { opacity: .6; }
.mm-card.mm-found .mm-sides { animation: mmFound .4s ease-out; }
@keyframes mmFound { 50% { transform: rotateY(180deg) scale(1.1); } }
.mm-card:focus-visible { outline: 3px solid var(--ink); outline-offset: 2px; }
@media (hover: hover) {
  .mm-card[data-state="closed"]:hover { transform: translateY(-3px); }
}

/* Phone portrait: the board is the tallest thing; keep the stage compact. */
@media (max-width: 639px), (orientation: portrait) {
  #screen-game .stage-area { gap: 4px; }
  .mm-card { aspect-ratio: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .mm-sides { transition: none; }
  .mm-card.mm-found .mm-sides, .mm-equation.mm-pop { animation: none; }
}
