.memory-page {
    gap: 16px;
    width: 100%;
}

.stats-bar {
    display: flex;
    gap: 12px 24px;
    flex-wrap: wrap;
    justify-content: center;
    font-size: clamp(0.9rem, 3.5vw, 1.05rem);
    color: #999;
}

.stats-bar span {
    white-space: nowrap;
}

.stats-bar span span {
    color: #667eea;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    perspective: 1000px;
    /* Fluid width keeps left/right padding on mobile instead of sticking out */
    width: min(100%, 400px);
}

.card {
    width: 100%;
    aspect-ratio: 1 / 1;
    position: relative;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.5s;
    border-radius: 12px;
}

.card.flipped {
    transform: rotateY(180deg);
}

.card-front,
.card-back {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    font-size: clamp(1.4rem, 7vw, 2rem);
}

.card-front {
    background: #1a1a2e;
    border: 2px solid #2a2a4a;
    color: #667eea;
    font-size: 1.8rem;
    font-weight: 700;
    transition: border-color 0.2s;
}

.card:hover .card-front {
    border-color: #667eea;
}

.card-back {
    background: #252545;
    border: 2px solid #667eea;
    transform: rotateY(180deg);
}

.win-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    align-items: center;
    justify-content: center;
    z-index: 200;
}

.win-content {
    background: #1a1a2e;
    border: 1px solid #2a2a4a;
    border-radius: 16px;
    padding: 40px;
    text-align: center;
    gap: 12px;
    display: flex;
    flex-direction: column;
}

.win-content h2 {
    font-size: 1.8rem;
    color: #fff;
}

.win-content p {
    color: #999;
    font-size: 1.1rem;
}

@media (max-width: 380px) {
    .card-grid {
        gap: 8px;
    }

    .game-title {
        font-size: 1.5rem;
    }
}
