* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    background: linear-gradient(135deg, #DCBFFF 0%, #E8F1FF 100%);
    font-family: 'Quicksand', sans-serif;
    color: #2C3A4B;
    min-height: 100vh;
    padding: 20px;
}

h1, .home-btn, .btn-restart, .score-badge, .card-front, .card-back { font-family: 'Fredoka One', cursive; }
.container { max-width: 850px; margin: 0 auto; }

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 20px;
}

.home-btn {
    background: #FFF;
    color: #3C2A21;
    border: 3px solid #3C2A21;
    border-radius: 12px;
    padding: 8px 16px;
    text-decoration: none;
    box-shadow: 0 4px 0 #3C2A21;
}

.header-info { text-align: center; flex-grow: 1; }
.header-info h1 { font-size: 2.2rem; color: #9D4EDD; text-shadow: 2px 2px 0 #FFF; }
.header-info p { font-weight: 700; color: #435B66; }

.score-badge {
    background: #FFE569;
    border: 3px solid #3C2A21;
    border-radius: 12px;
    padding: 8px 14px;
    font-size: 1.1rem;
    box-shadow: 0 4px 0 #3C2A21;
}

.top-controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.btn-restart {
    background: #54B435;
    color: white;
    border: 2px solid #3C2A21;
    border-radius: 12px;
    padding: 10px 20px;
    font-size: 1.1rem;
    cursor: pointer;
    box-shadow: 0 4px 0 #3C2A21;
}

.win-banner {
    background: #FFD93D;
    border: 3px solid #3C2A21;
    border-radius: 12px;
    padding: 8px 20px;
    font-family: 'Fredoka One', cursive;
    font-size: 1.2rem;
    color: #FF597B;
    animation: bounce 0.8s infinite alternate;
}

/* 3D Card Grid */
.memory-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    perspective: 1000px;
}

.card-item {
    height: 140px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.4s;
    cursor: pointer;
}

.card-item.flipped, .card-item.matched {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border: 3.5px solid #3C2A21;
    border-radius: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 5px 0 #3C2A21;
}

.card-front {
    background: #FF9B9B;
    color: #FFF;
    font-size: 3rem;
}

.card-back {
    background: #FFFDF0;
    transform: rotateY(180deg);
    padding: 10px;
    text-align: center;
}

.card-emoji { font-size: 2.6rem; display: block; margin-bottom: 2px; }
.card-val { font-size: 1.8rem; color: #4D96FF; }

@keyframes bounce {
    0% { transform: scale(1); }
    100% { transform: scale(1.08); }
}