/* ECDS Memory Game v2.0 — Image + Emoji Cards */

.ecds-memory-board {
    display: grid;
    grid-template-columns: repeat(var(--ecds-mem-cols, 4), 1fr);
    gap: 12px;
    max-width: 600px;
    margin: 0 auto 16px;
}

/* Card container */
.ecds-mem-card {
    aspect-ratio: 1;
    cursor: pointer;
    perspective: 700px;
}

/* Inner — rotates on flip */
.ecds-mem-inner {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform .5s cubic-bezier(.4, 0, .2, 1);
    border-radius: 12px;
}

/* Face-up states */
.ecds-mem-card.ecds-mem-flipped .ecds-mem-inner,
.ecds-mem-card.ecds-mem-matched .ecds-mem-inner {
    transform: rotateY(180deg);
}

/* Shared face base */
.ecds-mem-front,
.ecds-mem-back {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    user-select: none;
    overflow: hidden;
    border: 2px solid transparent;
    transition: background .2s, border-color .2s;
}

/* Front face — face-down, shows ? */
.ecds-mem-front {
    background: linear-gradient(135deg, var(--ecds-primary) 0%, #6366f1 100%);
    box-shadow: 0 3px 10px rgba(79, 70, 229, .25);
}

.ecds-card-icon {
    color: rgba(255, 255, 255, .65);
    font-size: clamp(22px, 5vw, 36px);
    font-weight: 900;
}

/* Back face — shown when flipped */
.ecds-mem-back {
    background: #fff;
    transform: rotateY(180deg);
    border-color: var(--ecds-border-dark);
}

/* IMAGE card back */
.ecds-mem-back-img {
    padding: 0;
}

.ecds-mem-back-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    border-radius: 10px;
}

/* EMOJI card back */
.ecds-mem-back-emoji {
    font-size: clamp(24px, 6vw, 48px);
}

/* Matched pair — green ring */
.ecds-mem-card.ecds-mem-matched .ecds-mem-back {
    border-color: #34d399;
    box-shadow: 0 0 0 3px #d1fae5;
}

.ecds-mem-card.ecds-mem-matched .ecds-mem-back-img img {
    border-radius: 10px;
}

/* Wrong match — red flash */
.ecds-mem-card.ecds-mem-wrong .ecds-mem-back {
    border-color: #f87171;
    background: #fee2e2;
}

.ecds-mem-card.ecds-mem-wrong .ecds-mem-back-img img {
    opacity: .55;
    filter: saturate(.3);
}

/* Hover on face-down cards only */
.ecds-mem-card:not(.ecds-mem-flipped):not(.ecds-mem-matched):hover .ecds-mem-inner {
    transform: rotateY(15deg) scale(1.05);
    box-shadow: 0 6px 20px rgba(99, 102, 241, .25);
}

/* Stats bar */
.ecds-memory-stats {
    text-align: center;
    font-size: 15px;
    font-weight: 700;
    color: var(--ecds-text-muted);
    margin-top: 4px;
}

@media (max-width: 500px) {
    .ecds-memory-board { gap: 8px; }
}
