.memory-scoreboard{max-width:620px;margin:38px auto 24px;padding:18px 28px;display:grid;grid-template-columns:repeat(3,1fr);gap:0;background:#fffdf8;border:2px solid #193452;border-radius:18px;box-shadow:0 8px 0 #d6b858,0 18px 35px #203a5a20;text-align:center}.memory-score{display:flex;flex-direction:column;gap:5px;padding:3px 18px}.memory-score+.memory-score{border-left:1px solid #d6b858}.memory-score b{font:500 25px 'DM Mono',monospace;color:#193452}.memory-score small{font:9px 'DM Mono',monospace;letter-spacing:.08em;color:#718096}.memory-controls{max-width:980px;margin:0 auto 20px}.memory-front{padding:0!important;background:#f8f5ec!important;border:4px solid #193452!important;display:block!important;box-shadow:0 12px 24px #203a5a2c}.memory-front:before{content:'';position:absolute;inset:7px;border:1px solid #d6b858;border-radius:9px;pointer-events:none;z-index:4}.memory-front:after{content:'';position:absolute;inset:12px;border:1px solid #193452;border-radius:6px;pointer-events:none;z-index:4}.memory-corner{position:absolute;z-index:5;color:#193452;font:700 clamp(20px,3vw,34px)/1 Georgia,serif}.memory-corner-top-left{top:16px;left:17px}.memory-corner-top-right{top:16px;right:17px}.memory-corner-bottom-left{bottom:16px;left:17px;transform:rotate(180deg)}.memory-corner-bottom-right{bottom:16px;right:17px;transform:rotate(180deg)}.memory-king-art{position:absolute;inset:18% 14%;height:64%;margin:0;overflow:hidden;border:1px solid #193452;background:#e9dfc8;z-index:1}.memory-king-art:before{content:'';position:absolute;inset:7px;border:1px solid #d6b858;z-index:3;pointer-events:none}.memory-king-art:after{top:50%;height:2px;background:#d6b858;z-index:4}.memory-person{left:12%;width:76%;height:88%;background-position:center 20%;filter:saturate(.78) contrast(1.05);border:2px solid #193452;box-shadow:0 0 0 2px #d6b858}.memory-person-top{top:-31%}.memory-person-bottom{bottom:-31%}.memory-ornament{position:absolute;z-index:5;left:50%;top:50%;transform:translate(-50%,-50%);display:grid;place-items:center;width:30px;height:30px;background:#193452;border:2px solid #d6b858;border-radius:50%;color:#f8f5ec;font-size:14px}.memory-back{background-color:#f8f5ec!important;background-image:radial-gradient(#193452 1px,transparent 1px),radial-gradient(#193452 1px,transparent 1px)!important;background-position:0 0,8px 8px!important;background-size:16px 16px!important;border:6px solid #193452!important;box-shadow:inset 0 0 0 3px #d6b858,inset 0 0 0 7px #f8f5ec,0 12px 24px #203a5a2c!important}.memory-back:before{inset:12px!important;border:2px solid #d6b858!important;border-radius:8px!important;background:transparent!important;z-index:2}.memory-back:after{content:'';position:absolute;inset:20px;border:1px solid #193452;border-radius:5px;background:repeating-linear-gradient(45deg,transparent 0 7px,#19345218 8px 9px);z-index:0}.back-pattern{position:absolute;inset:25px;z-index:1;border:1px solid #d6b858;border-radius:4px;background:linear-gradient(135deg,transparent 48%,#d6b858 49%,#d6b858 51%,transparent 52%),linear-gradient(45deg,transparent 48%,#d6b858 49%,#d6b858 51%,transparent 52%);background-size:24px 24px}.memory-card-inner{transform-style:preserve-3d;will-change:transform}.memory-face{backface-visibility:hidden;-webkit-backface-visibility:hidden}.win-overlay{position:fixed;z-index:20;inset:0;display:grid;place-items:center;padding:24px;background:#10233c99;animation:memory-fade-in .25s ease-out}.win-overlay[hidden]{display:none}.win-panel{width:min(650px,100%);margin:0;padding:48px 25px;background:#fffdf8;border:2px solid var(--mint);border-radius:22px;box-shadow:0 0 0 7px #c8fbed,0 22px 60px #10233c55;animation:memory-win-pop .45s cubic-bezier(.2,.8,.2,1)}.win-panel h2{font-size:42px}.memory-card.matched .memory-front{border-color:var(--mint)!important}.memory-card:disabled{cursor:default}@keyframes memory-fade-in{from{opacity:0}to{opacity:1}}@keyframes memory-win-pop{from{opacity:0;transform:translateY(18px) scale(.82)}to{opacity:1;transform:translateY(0) scale(1)}}
@media(max-width:680px){.memory-scoreboard{margin-top:25px;padding:15px 8px}.memory-score{padding:3px 7px}.memory-score b{font-size:19px}.memory-score small{font-size:8px}.memory-controls{display:flex;align-items:center}.memory-controls .game-button{margin-top:0}.memory-corner{font-size:24px}.memory-corner-top-left{top:12px;left:12px}.memory-corner-top-right{top:12px;right:12px}.memory-corner-bottom-left{bottom:12px;left:12px}.memory-corner-bottom-right{bottom:12px;right:12px}.memory-king-art{inset:18% 12%;height:64%}.win-panel h2{font-size:32px}}
@media(prefers-reduced-motion:reduce){.win-overlay,.win-panel{animation:none}.memory-card-inner{will-change:auto}}

/* Explicit face visibility prevents the textured back from showing through the revealed face. */
.memory-back{transform:rotateY(0deg);opacity:1;visibility:visible}.memory-front{transform:rotateY(180deg);opacity:0;visibility:hidden}.memory-card.flipped .memory-back,.memory-card.matched .memory-back{opacity:0;visibility:hidden}.memory-card.flipped .memory-front,.memory-card.matched .memory-front{opacity:1;visibility:visible}

/* Keep each portrait rectangular, show its top half, and tuck the lower source image under its mirror. */
.memory-person{left:0;width:100%;height:50%;border-radius:0!important;background-position:center top!important;background-size:100% 200%!important}.memory-person-top{top:0}.memory-person-bottom{bottom:0;transform:rotate(180deg)}

/* Responsive game feedback: reveal, mismatch, match, and ambient motion. */
.memory-card{transition:transform .2s ease,filter .2s ease}.memory-card:not(.flipped):not(.matched):hover{transform:translateY(-5px) rotate(-1deg);filter:drop-shadow(0 10px 12px #19345222)}.memory-card:not(.flipped):not(.matched):active{transform:translateY(-1px) scale(.98)}.memory-card.flipped .memory-card-inner,.memory-card.matched .memory-card-inner{transition:transform .62s cubic-bezier(.22,.8,.2,1)}.memory-card--wrong{animation:memory-wrong-shake .55s ease-in-out}.memory-card--match{animation:memory-right-celebrate .8s cubic-bezier(.2,.8,.2,1)}.memory-card--match .memory-front{box-shadow:0 0 0 4px #bafbea,0 0 28px #20d8a088,0 12px 24px #203a5a2c}.memory-board{animation:memory-board-enter .55s ease-out both}.memory-scoreboard{animation:memory-score-enter .5s .1s ease-out both}.memory-score b{transition:color .25s,transform .25s}.memory-scoreboard:has([data-moves]) .memory-score:first-child b{color:#078c68}@keyframes memory-wrong-shake{0%,100%{transform:translateX(0)}18%{transform:translateX(-7px) rotate(-1deg)}36%{transform:translateX(6px) rotate(1deg)}54%{transform:translateX(-4px)}72%{transform:translateX(3px)}}@keyframes memory-right-celebrate{0%{transform:scale(1)}35%{transform:scale(1.06) rotate(1.5deg)}65%{transform:scale(.98) rotate(-1deg)}100%{transform:scale(1)}}@keyframes memory-board-enter{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:translateY(0)}}@keyframes memory-score-enter{from{opacity:0;transform:translateY(-10px) scale(.98)}to{opacity:1;transform:translateY(0) scale(1)}}
@media(prefers-reduced-motion:reduce){.memory-card,.memory-board,.memory-scoreboard,.memory-card--wrong,.memory-card--match{animation:none;transition:none}.memory-card:not(.flipped):not(.matched):hover{transform:none;filter:none}}

.memory-board--shuffling .memory-card{animation:memory-shuffle-card .78s cubic-bezier(.2,.8,.2,1) both}.memory-board--shuffling .memory-card:nth-child(2n){animation-delay:.06s}.memory-board--shuffling .memory-card:nth-child(3n){animation-delay:.12s}.memory-board--shuffling .memory-card:nth-child(4n){animation-delay:.18s}@keyframes memory-shuffle-card{0%{opacity:0;transform:translateY(-18px) rotate(-8deg) scale(.88)}45%{opacity:1;transform:translateY(5px) rotate(5deg) scale(1.03)}75%{transform:translateY(-2px) rotate(-1deg) scale(.99)}100%{opacity:1;transform:translateY(0) rotate(0) scale(1)}}
@media(prefers-reduced-motion:reduce){.memory-board--shuffling .memory-card{animation:none}}
