/* ============ The Playroom — Match My Finds ============ */
.mm { --mm-gap: clamp(10px, 1.6vw, 16px); --mm-flip: .6s; }

/* ---------- top bar: level picker + stats ---------- */
.mm-bar { align-items: flex-end; margin-bottom: 6px; }
.mm-levels { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; border: 0; min-width: 0; }
.mm-legend { width: 100%; margin-bottom: 6px; padding: 0; font-size: 11px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; color: var(--rose-ink); }
.mm-level { position: relative; cursor: pointer; }
.mm-level input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.mm-level span {
  display: grid; justify-items: center; gap: 1px; min-width: 88px; min-height: 44px; padding: 6px 14px 7px;
  border: 1px solid rgba(94, 22, 36, .35); background: var(--ivory);
  font-family: var(--f-display); font-style: italic; font-size: 20px; line-height: 1; color: var(--burgundy);
  transition: background .25s, color .25s, border-color .25s;
}
.mm-level small { font-family: var(--f-body); font-style: normal; font-size: 9.5px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; color: var(--rose-ink); }
.mm-level:hover span { background: var(--blush-2); }
.mm-level input:checked + span {
  border-color: var(--velvet); color: var(--ivory);
  background: linear-gradient(180deg, rgba(255, 190, 205, .12), transparent 50%, rgba(0, 0, 0, .25)), linear-gradient(rgba(140, 26, 52, .2), rgba(140, 26, 52, .2)), url("/assets/velvet.jpg") 40% 30% / 900px auto, var(--velvet);
  box-shadow: inset 0 0 0 3px var(--velvet), inset 0 0 0 4px rgba(228, 208, 160, .7);
}
.mm-level input:checked + span small { color: var(--gold-lt); }
.mm-level input:focus-visible + span { outline: 1.5px solid var(--burgundy); outline-offset: 3px; }
.mm .game-stat b { font-weight: 600; }

.mm-msg { margin: 10px 0 14px; }

/* ---------- the board ---------- */
.mm-board {
  --cols: 4; --card-max: 168px;
  display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); gap: var(--mm-gap);
  max-width: calc(var(--cols) * var(--card-max) + (var(--cols) - 1) * var(--mm-gap));
  margin: 0 auto; padding: 8px 0 4px;
}
.mm-board[data-count="16"] { --card-max: 150px; }
.mm-board[data-count="20"] { --cols: 5; --card-max: 146px; }

.mm-cell { position: relative; }
.mm-card {
  display: block; width: 100%; aspect-ratio: 4 / 5; padding: 0; border: 0; background: none;
  cursor: pointer; perspective: 900px; -webkit-tap-highlight-color: transparent; border-radius: 6px;
}
.mm-card:focus-visible { outline: 2px solid var(--burgundy); outline-offset: 4px; }
.mm-inner {
  position: relative; display: block; width: 100%; height: 100%;
  transform-style: preserve-3d; transition: transform var(--mm-flip) var(--ease);
}
.mm-cell:not(.is-up) .mm-card:hover .mm-inner { transform: translateY(-4px) rotateZ(-1.2deg); }
.mm-cell.is-up .mm-inner { transform: rotateY(180deg); }
.mm-back, .mm-face {
  position: absolute; inset: 0; overflow: hidden; border-radius: 6px;
  -webkit-backface-visibility: hidden; backface-visibility: hidden;
}

/* card back: burgundy velvet, gold inner border, BF monogram */
.mm-back {
  display: grid; place-items: center;
  background:
    radial-gradient(120% 90% at 28% 12%, rgba(255, 190, 210, .2), transparent 55%),
    linear-gradient(rgba(140, 26, 52, .16), rgba(40, 4, 14, .18)),
    url("/assets/velvet.jpg") var(--vx, 30%) var(--vy, 20%) / 1100px auto,
    var(--velvet);
  box-shadow: 0 1px 1px rgba(59, 37, 27, .25), 0 12px 18px -10px rgba(59, 10, 20, .7);
}
.mm-back::before { content: ""; position: absolute; inset: 6px; border: 1px solid rgba(228, 208, 160, .75); border-radius: 3px; pointer-events: none; }
.mm-back::after { content: ""; position: absolute; inset: 9px; border: .5px solid rgba(228, 208, 160, .3); border-radius: 2px; pointer-events: none; }
.mm-mono {
  position: relative; display: flex; align-items: center; justify-content: center; width: 50%; aspect-ratio: 3 / 4;
  border: 1px solid rgba(228, 208, 160, .75); border-radius: 50%;
  background: radial-gradient(closest-side, rgba(40, 4, 14, .45), transparent);
  font-family: var(--f-display); font-style: italic; font-weight: 400; font-size: clamp(24px, 3.2vw, 34px); line-height: 1; color: var(--gold-lt);
  text-shadow: 0 1px 1px rgba(0, 0, 0, .45);
}
.mm-mono i { font-style: italic; }
.mm-mono i + i { margin-left: .02em; }
.mm-mono::before, .mm-mono::after { content: ""; position: absolute; left: 50%; width: 5px; height: 5px; background: var(--gold-lt); transform: translateX(-50%) rotate(45deg); }
.mm-mono::before { top: -3px; }
.mm-mono::after { bottom: -3px; }

/* card face */
.mm-face {
  transform: rotateY(180deg);
  background: #fff;
  box-shadow: 0 1px 1px rgba(59, 37, 27, .2), 0 12px 18px -10px rgba(59, 37, 27, .5);
  transition: box-shadow .5s var(--ease);
}
/* a thin print frame that sits over the photo */
.mm-face::after { content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(176, 141, 87, .6), inset 0 0 0 3px rgba(255, 251, 243, .85); transition: box-shadow .5s var(--ease); }
.mm-face img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: 50% 22%; user-select: none; -webkit-user-drag: none; }
.mm-face--product img { inset: 8% 8% 22%; width: 84%; height: 70%; object-fit: contain; object-position: center; }
.mm-cap {
  position: absolute; left: 0; right: 0; bottom: 0;
  padding: 16px 6px 6px;
  font-family: var(--f-display); font-style: italic; font-weight: 500; font-size: 13.5px; line-height: 1.05; text-align: center; color: var(--burgundy);
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow: hidden;
  opacity: 0; transition: opacity .4s .3s;
}
.mm-face--photo .mm-cap { color: var(--ivory); background: linear-gradient(180deg, transparent, rgba(59, 10, 20, .78)); text-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.mm-face--product .mm-cap { opacity: 1; padding-top: 0; }
.mm-glint { position: absolute; z-index: 1; top: 7px; left: 7px; width: 16px; height: 16px; fill: var(--gold); opacity: 0; transform: scale(.2) rotate(-40deg); transition: opacity .3s, transform .6s var(--ease); }
.mm-glint svg { display: block; width: 100%; height: 100%; }

/* matched: gold glow, caption, sparkle */
.mm-cell.is-matched .mm-face {
  box-shadow: 0 0 0 1px rgba(176, 141, 87, .6), 0 0 22px 4px rgba(228, 208, 160, .95), 0 12px 18px -10px rgba(59, 37, 27, .5);
}
.mm-cell.is-matched .mm-face::after { box-shadow: inset 0 0 0 2px var(--gold-lt), inset 0 0 0 3px var(--gold); }
.mm-cell.is-matched .mm-inner { animation: mm-pop .7s var(--ease) .35s both; }
.mm-cell.is-matched .mm-cap { opacity: 1; }
.mm-cell.is-matched .mm-glint { opacity: 1; transform: scale(1) rotate(0); transition-delay: .5s; }
.mm-cell.is-matched .mm-card { cursor: default; }
@keyframes mm-pop { 0% { transform: rotateY(180deg) scale(1); } 45% { transform: rotateY(180deg) scale(1.07); } 100% { transform: rotateY(180deg) scale(1); } }
.mm-cell.is-miss .mm-inner { animation: mm-nope .38s ease-in-out both; }
@keyframes mm-nope { 0%, 100% { transform: rotateY(180deg) translateX(0); } 25% { transform: rotateY(180deg) translateX(-4px); } 75% { transform: rotateY(180deg) translateX(4px); } }

/* "Shop it →" hang tag — the link itself is a roomy invisible tap target, the tag is inside */
.mm-tag {
  position: absolute; z-index: 3; top: -19px; right: -15px;
  display: block; padding: 10px 8px; color: var(--ivory); text-decoration: none;
  filter: drop-shadow(0 4px 5px rgba(59, 10, 20, .4));
  animation: mm-swing .9s var(--ease) both; transform-origin: 20px 50%;
}
.mm-tag-body {
  position: relative; display: inline-flex; align-items: center; gap: 4px; min-height: 26px; padding: 5px 9px 5px 19px;
  background: linear-gradient(180deg, #74203A, var(--velvet));
  font: 500 10px/1 var(--f-body); letter-spacing: .14em; text-transform: uppercase; white-space: nowrap;
  clip-path: polygon(9px 0, 100% 0, 100% 100%, 9px 100%, 0 50%);
  transform: rotate(7deg);
}
.mm-tag-hole { position: absolute; left: 9px; top: 50%; width: 5px; height: 5px; margin-top: -2.5px; border-radius: 50%; background: var(--ivory); box-shadow: 0 0 0 1px var(--gold-lt); }
.mm-tag:hover .mm-tag-body { background: var(--burgundy); color: var(--gold-lt); }
.mm-tag:focus-visible { outline: none; }
.mm-tag:focus-visible .mm-tag-body { outline: 2px solid var(--gold-lt); outline-offset: -4px; }
@keyframes mm-swing { 0% { opacity: 0; transform: rotate(-26deg) translateY(-6px); } 60% { opacity: 1; transform: rotate(6deg); } 100% { transform: rotate(0); } }

.mm-foot { display: flex; justify-content: center; margin-top: 22px; }

/* ---------- win screen ---------- */
.mm-win .game-win { padding-bottom: 8px; }
.mm-win-eyebrow { margin: 0; }
.mm-win h2 { max-width: 14ch; }
.mm-win h2:focus { outline: none; }
.mm-win h2 em { display: block; margin-top: .12em; font-size: .62em; color: var(--rose-ink); }
.mm-win-score { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px; font-size: 13px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; color: var(--burgundy) !important; }
.mm-win-score > span:not(.mm-dot) { display: inline-flex; align-items: baseline; gap: 7px; }
.mm-win-score b { font-family: var(--f-display); font-style: italic; font-weight: 500; font-size: 30px; line-height: 1; letter-spacing: 0; }
.mm-dot { width: 5px; height: 5px; background: var(--gold); transform: rotate(45deg); }

.mm-haul { max-width: 760px; margin: 18px auto 0; padding-top: 22px; border-top: 1px solid rgba(176, 141, 87, .45); }
.mm-haul-title { margin: 0 0 16px; text-align: center; font-family: var(--f-display); font-weight: 400; font-size: 28px; color: var(--burgundy); }
.mm-haul-title em { color: var(--rose-ink); }
.mm-haul-title span { display: block; margin-top: 4px; font-family: var(--f-body); font-size: 11px; font-weight: 500; letter-spacing: .18em; text-transform: uppercase; color: var(--brown); }
.mm-haul-list { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin: 0; padding: 0; list-style: none; }
.mm-haul-list li { flex: 0 1 236px; }
.mm-find {
  display: flex; align-items: center; gap: 12px; min-height: 76px; padding: 8px 12px 8px 8px;
  background: #fff; border: 1px solid rgba(176, 141, 87, .45); color: inherit; text-decoration: none;
  box-shadow: 0 10px 16px -12px rgba(59, 37, 27, .5); transition: transform .3s var(--ease), box-shadow .3s var(--ease);
}
.mm-find:hover { transform: translateY(-2px) rotate(-.5deg); box-shadow: 0 16px 20px -12px rgba(59, 37, 27, .55); }
.mm-find-img { flex: none; display: grid; place-items: center; width: 60px; height: 60px; background: #fff; }
.mm-find-img img { display: block; width: 60px; height: 60px; object-fit: contain; }
.mm-find-text { display: grid; gap: 3px; min-width: 0; }
.mm-find-name { font-family: var(--f-display); font-size: 19px; line-height: 1.05; color: var(--burgundy); }
.mm-find-store { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--brown); }
.mm-find-go { font-size: 11px; font-weight: 500; letter-spacing: .16em; text-transform: uppercase; color: var(--rose-ink); }
.mm-find:hover .mm-find-go { color: var(--burgundy); }
.mm-haul-none { margin: 10px auto 0; max-width: 40ch; text-align: center; font-family: var(--f-display); font-style: italic; font-size: 20px; color: var(--brown); }
.mm-win-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 26px; }
.mm-win-actions .game-btn { min-height: 46px; }

/* ---------- phones ---------- */
@media (max-width: 640px) {
  .mm { --mm-gap: 9px; }
  .mm-bar { display: grid; justify-items: center; justify-content: stretch; gap: 12px; }
  .mm-levels { justify-content: center; }
  .mm-legend { text-align: center; }
  .mm-level span { min-width: 0; padding: 6px 12px 7px; font-size: 18px; }
  .mm .game-stats { justify-content: center; gap: 6px; }
  .mm .game-stat { padding: 7px 10px; font-size: 11px; letter-spacing: .1em; }
  .mm-board { --cols: 3; --card-max: 999px; }
  .mm-board[data-count="16"], .mm-board[data-count="20"] { --cols: 4; }
  .mm-cap { font-size: 12px; padding-left: 4px; padding-right: 4px; }
  .mm-board[data-count="16"] .mm-cap, .mm-board[data-count="20"] .mm-cap { font-size: 10.5px; }
  .mm-board[data-count="16"] .mm-mono, .mm-board[data-count="20"] .mm-mono { font-size: 19px; }
  .mm-tag { top: -18px; right: -13px; }
  .mm-tag-body { padding: 5px 7px 5px 17px; font-size: 9px; letter-spacing: .1em; }
  .mm-board[data-count="16"] .mm-tag-body, .mm-board[data-count="20"] .mm-tag-body { font-size: 8.5px; padding-right: 5px; }
  .mm-haul-list li { flex-basis: 100%; }
  .mm-find { min-height: 68px; }
  .mm-win-score b { font-size: 26px; }
}

/* ---------- reduced motion: instant flips, no wiggles ---------- */
@media (prefers-reduced-motion: reduce) {
  .mm { --mm-flip: 0s; }
  .mm-inner, .mm-face, .mm-cap, .mm-glint, .mm-find { transition: none !important; }
  .mm-cell.is-matched .mm-inner, .mm-cell.is-miss .mm-inner, .mm-tag { animation: none !important; }
  .mm-cell:not(.is-up) .mm-card:hover .mm-inner { transform: none; }
}
