/* The wrap reserves the board height. */
.mm-wrap { min-height: clamp(300px, 100vh - 310px, 610px); align-items: center; overflow: visible; }
.is-immersive .mm-wrap { min-height: 0; }
.mm-game:not(.is-ready) :is(.mm-stats, .mm-rules) { visibility: hidden; }
.mm-board { position: relative; border-radius: 16px; background: #0003; touch-action: manipulation; user-select: none; }
.mm-tile { position: absolute; left: 0; top: 0; width: var(--mm-w); height: var(--mm-h); padding: 0; border: 0; border-radius: 8px; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
/* A flat flip: no 3D, so no mirrored faces. */
.mm-tile > * { --ring: inset 0 0 0 1px #7d623359; position: absolute; inset: 0; border-radius: 8px; transition: transform .1s .1s, opacity .2s .4s; box-shadow: var(--ring), 2px 3px 0 var(--tile-side), 3px 4px 5px #00000059; }
.mm-tile > .mm-back { --ring: inset 0 0 0 3px #f3e3b4, inset 0 0 0 4px #6a1220; --lace: #f6dc8a42 0 1px, transparent 1px 8px; background: repeating-linear-gradient(45deg, var(--lace)), repeating-linear-gradient(-45deg, var(--lace)), radial-gradient(#b5394a, #7d1727); }
.mm-back::after { content: ""; position: absolute; inset: 0 31%; margin: auto; aspect-ratio: 1; transform: rotate(45deg); border: 2px solid var(--gold-soft); border-radius: 22%; background: radial-gradient(circle, var(--gold) 22%, #6a1220 25%); }
.mm-face { background: linear-gradient(150deg, var(--ivory), var(--ivory-2)); }
.mm-face img { display: block; width: 100%; height: 100%; padding: 6%; pointer-events: none; }
.mm-face[data-kind="flower"] { background: linear-gradient(#fff6f8, #ffdfe8); }
.mm-face[data-kind="season"] { background: linear-gradient(#f6fbff, #d8ecff); }
.mm-game [data-kind]::after { content: "\273F"; display: inline-grid; place-items: center; width: 1.5em; height: 1.5em; border-radius: 50%; background: #c2305f; color: #fff; font: 700 min(12px, calc(var(--mm-w, 60px) * .22))/1 sans-serif; }
.mm-game [data-kind="season"]::after { content: "\21C5"; background: #1d5fa8; }
.mm-face[data-kind]::after { position: absolute; right: 3px; top: 3px; }
.mm-tile:not(.is-up) > .mm-face, .is-up > .mm-back { transform: scaleX(0); transition: transform .1s; }
.is-open .mm-face { --ring: inset 0 0 0 3px var(--gold); }
.is-peek .mm-face { --ring: inset 0 0 0 3px #ff9d2e, 0 0 14px 2px #ffbe5acc; }
.is-hint .mm-face { --ring: inset 0 0 0 3px var(--focus); }
.is-miss .mm-face { --ring: inset 0 0 0 3px var(--danger); }
.is-miss { animation: shake .25s; }
.is-matched .mm-face { box-shadow: var(--ring); opacity: .42; }
.is-swap { transition: transform .25s .35s; }
.is-swap::before { content: ""; position: absolute; inset: -3px; border: 2px dashed #bfe0ff; border-radius: 10px; }
.mm-toast { position: absolute; left: 50%; z-index: 3; padding: 6px 14px; border-radius: 99px; background: #04170feb; color: #fff; font-weight: 700; white-space: nowrap; pointer-events: none; opacity: 0; transform: translate(-50%, -50%); }
.mm-toast.is-on { opacity: 1; }
.mm-rules { display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 14px; margin: 2px 0 0; color: #cfe9db; font-size: .82rem; }
.mm-result { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 0 0 18px; }
.mm-result div { padding: 8px 4px; border-radius: 10px; background: #f4f1e8; }
.mm-result dt { color: var(--muted); font-size: .78rem; }
.mm-result dd { margin: 0; font-weight: 700; }
@media (max-width: 760px) {
  .mm-wrap { min-height: clamp(300px, 100vh - 345px, 126vw); }
  .mm-status { min-height: 3.2em; }
  .game-stats.mm-stats { display: grid; grid-template-columns: repeat(3, auto); }
  .game-actions.mm-actions { grid-template-columns: 1fr 1.35fr 1fr 1.2fr; }
  .mm-actions .btn { font-size: .82rem; line-height: 1.15; }
}
@media (max-width: 760px) and (min-height: 520px) and (max-height: 700px) {
  .mm-wrap { min-height: min(100svh - 184px, 140vw); }
}
@media (min-width: 761px) and (max-width: 869px) and (min-height: 520px) {
  .mm-stats { width: 100%; }
}
@media (min-width: 761px) and (orientation: portrait) {
  .mm-wrap { min-height: clamp(300px, 100vh - 384px, 812px); }
}
@media (max-height: 519px) and (min-width: 800px) {
  .mm-game :is(.game-bar, .mm-stats, .mm-actions) { flex-wrap: nowrap; gap: 6px; font-size: .8rem; white-space: nowrap; }
}
@media (prefers-reduced-motion: reduce) {
  .mm-tile, .mm-tile > * { transition: none !important; }
  .is-miss { animation: none; }
}
