.memory-body {
    background-color: #F8C8DC;
    min-height: 100vh;
}

.memory-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px 40px;
}

.memory-title {
    text-align: center;
    color: white;
    font-family: 'Playfair Display', serif;
    font-size: 40px;
    font-weight: 700;
    margin: 8px 0 4px;
}

.memory-instructions {
    text-align: center;
    color: white;
    font-family: 'Playfair Display', serif;
    font-size: 20px;
    margin: 0 0 20px;
}

.memory-scoreboard {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.memory-btn {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 11px 26px;
    border: none;
    border-radius: 999px;
    background: linear-gradient(135deg, #ffffff 0%, #fce7ef 100%);
    color: #2b1a22;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(43, 26, 34, 0.18), inset 0 0 0 2px #2b1a22;
    transition: transform 0.15s, box-shadow 0.2s, background 0.2s, color 0.2s;
}

.memory-btn:hover {
    background: linear-gradient(135deg, #2b1a22 0%, #5a3b4a 100%);
    color: #fce7ef;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(43, 26, 34, 0.28), inset 0 0 0 2px #2b1a22;
}

.memory-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(43, 26, 34, 0.2), inset 0 0 0 2px #2b1a22;
}

.memory-btn.primary {
    background: linear-gradient(135deg, #2b1a22 0%, #5a3b4a 100%);
    color: #fce7ef;
    font-size: 20px;
    padding: 13px 34px;
    box-shadow: 0 4px 14px rgba(43, 26, 34, 0.32), inset 0 0 0 2px #2b1a22;
}

.memory-btn.primary:hover {
    background: linear-gradient(135deg, #5a3b4a 0%, #7a5465 100%);
    color: white;
}

.memory-board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    perspective: 1200px;
}

.card {
    position: relative;
    aspect-ratio: 3 / 4;
    cursor: pointer;
    transform-style: preserve-3d;
    transition: transform 0.45s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.card.flipped,
.card.matched {
    transform: rotateY(180deg);
    cursor: default;
}

.card-face {
    position: absolute;
    inset: 0;
    backface-visibility: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

.card-back {
    background-color: #2b1a22;
    border: 2px solid #5a3b4a;
    color: #f5d3de;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Playfair Display', serif;
    font-size: 48px;
    font-weight: 700;
    letter-spacing: 2px;
}

.card-back::after {
    content: "JA";
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.card-front {
    background-color: white;
    transform: rotateY(180deg);
    display: flex;
    flex-direction: column;
    border: 2px solid #2b1a22;
}

.card-image {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background-color: #f5e4ea;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.card-name {
    background-color: #2b1a22;
    color: white;
    font-family: 'Playfair Display', serif;
    text-align: center;
    padding: 6px 4px;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.15;
}

.card.matched .card-front {
    border-color: #5a8c55;
    animation: match-glow 0.6s ease-out;
}

.card.matched .card-name {
    background-color: #5a8c55;
}

@keyframes match-glow {
    0% { box-shadow: 0 0 0 0 rgba(90, 140, 85, 0.6); }
    100% { box-shadow: 0 0 0 14px rgba(90, 140, 85, 0); }
}

.card.wrong .card-front {
    animation: wrong-shake 0.4s;
    border-color: #a44;
}

@keyframes wrong-shake {
    0%, 100% { transform: rotateY(180deg) translateX(0); }
    25% { transform: rotateY(180deg) translateX(-6px); }
    75% { transform: rotateY(180deg) translateX(6px); }
}

.win-banner {
    margin-top: 28px;
    text-align: center;
    background-color: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.win-text {
    font-family: 'Playfair Display', serif;
    font-size: 30px;
    font-weight: 700;
    color: #2b1a22;
    margin: 0 0 8px;
}

.win-detail {
    font-family: 'Playfair Display', serif;
    font-size: 22px;
    color: #5a3b4a;
    margin: 0 0 8px;
}

.win-record {
    font-family: 'Playfair Display', serif;
    font-size: 18px;
    font-style: italic;
    color: #5a8c55;
    margin: 0 0 18px;
}

.win-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

@media (max-width: 800px) {
    .memory-board { grid-template-columns: repeat(5, 1fr); }
    .card-name { font-size: 12px; }
}

@media (max-width: 600px) {
    .memory-title { font-size: 30px; }
    .memory-instructions { font-size: 16px; }
    .memory-board { grid-template-columns: repeat(4, 1fr); gap: 8px; }
    .card-name { font-size: 11px; padding: 4px 2px; }
    .card-back { font-size: 32px; }
}

@media (max-width: 420px) {
    .memory-board { grid-template-columns: repeat(3, 1fr); }
}
