:root {
    --primary: #FF6B6B;
    --secondary: #4ECDC4;
    --accent: #FFE66D;
    --dark: #2C3E50;
    --light: #F7F9FC;
}

body {
    font-family: 'Nunito', sans-serif;
    background: var(--light);
    text-align: center;
    margin: 0;
    padding: 20px;
    /* Prevent scroll inside iframe if possible */
    overflow: hidden; 
}

.game-wrapper {
    max-width: 600px;
    margin: 0 auto;
}

.title {
    font-family: 'Fredoka One', cursive;
    font-size: 32px;
    color: var(--primary);
    margin: 0;
    text-shadow: 2px 2px 0px rgba(0,0,0,0.1);
}

.subtitle {
    color: #7f8c8d;
    font-weight: 700;
    margin-top: 5px;
    margin-bottom: 20px;
}

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

.score-box {
    background: white;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    color: var(--dark);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.reset-btn {
    background: var(--secondary);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    color: white;
    font-weight: 700;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    transition: transform 0.1s;
    box-shadow: 0 4px 0 #3b9e96;
}

.reset-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    perspective: 800px;
}

/* Card Styling */
.card {
    background: white;
    border-radius: 12px;
    cursor: pointer;
    position: relative;
    aspect-ratio: 3/4; /* Consistent sizing */
    transform-style: preserve-3d;
    transition: transform 0.5s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.card:hover {
    transform: translateY(-5px);
}

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

.card-inner {
    position: absolute;
    width: 100%;
    height: 100%;
    transform-style: preserve-3d;
}

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-back {
    background: linear-gradient(135deg, var(--primary) 0%, #FF8E8E 100%);
    /* Pattern for back */
    background-image: 
        radial-gradient(circle at 10% 10%, rgba(255,255,255,0.2) 2px, transparent 2px),
        radial-gradient(circle at 90% 90%, rgba(255,255,255,0.2) 2px, transparent 2px);
    background-size: 20px 20px;
}

.card-back::after {
    content: '?';
    font-family: 'Fredoka One', cursive;
    color: white;
    font-size: 40px;
    opacity: 0.8;
}

.card-front {
    background: white;
    transform: rotateY(180deg);
    border: 3px solid var(--secondary);
}

.card-front img {
    width: 80%;
    height: auto;
    object-fit: contain;
}

/* Modal */
.modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-content h3 {
    font-family: 'Fredoka One', cursive;
    color: var(--secondary);
    font-size: 28px;
    margin-top: 0;
}

.play-again-btn {
    background: var(--accent);
    color: var(--dark);
    padding: 12px 24px;
    font-size: 18px;
    border: none;
    border-radius: 50px;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 4px 0 #e6c845;
    transition: transform 0.1s;
}

.play-again-btn:active {
    transform: translateY(4px);
    box-shadow: none;
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@media (max-width: 400px) {
    .game-board {
        grid-template-columns: repeat(4, 1fr); 
        gap: 8px;
    }
    .title { font-size: 24px; }
}
