* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #333;
}

.container {
    max-width: 900px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    text-align: center;
}

h1 {
    color: #4a5568;
    margin-bottom: 30px;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    padding: 15px;
    background: #f7fafc;
    border-radius: 15px;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
}

.game-info div {
    font-size: 1.2rem;
    font-weight: bold;
    color: #2d3748;
}

.game-info span {
    color: #4299e1;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
    padding: 20px;
}

.card {
    aspect-ratio: 1;
    min-height: 120px;
    perspective: 1000px;
    cursor: pointer;
}

.card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s;
    transform-style: preserve-3d;
    border-radius: 15px;
}

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

.card-front, .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: bold;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

.card-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: 3px solid #5a67d8;
}

.card-back {
    background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
    color: #2d3748;
    transform: rotateY(180deg);
    border: 3px solid #ed8936;
    padding: 10px;
    word-wrap: break-word;
}

.card:hover:not(.flipped):not(.matched) .card-inner {
    transform: scale(1.05);
}

.card.matched .card-inner {
    animation: matchAnimation 0.6s ease-in-out;
}

@keyframes matchAnimation {
    0% { transform: scale(1) rotateY(180deg); }
    50% { transform: scale(1.1) rotateY(180deg); }
    100% { transform: scale(1) rotateY(180deg); }
}

.card.matched .card-back {
    background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
    color: white;
    border-color: #38a169;
}

.card.wrong {
    animation: wrongAnimation 0.5s ease-in-out;
}

@keyframes wrongAnimation {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.controls {
    margin-bottom: 30px;
}

.btn {
    background: linear-gradient(135deg, #4299e1 0%, #3182ce 100%);
    color: white;
    border: none;
    padding: 12px 30px;
    margin: 0 10px;
    border-radius: 25px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.instructions {
    text-align: left;
    background: #edf2f7;
    padding: 20px;
    border-radius: 15px;
    margin-top: 20px;
}

.instructions h3 {
    color: #2d3748;
    margin-bottom: 15px;
    text-align: center;
}

.instructions p {
    margin-bottom: 8px;
    color: #4a5568;
    line-height: 1.5;
}

.game-complete {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.complete-modal {
    background: white;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    animation: modalAppear 0.5s ease-out;
}

@keyframes modalAppear {
    from {
        opacity: 0;
        transform: scale(0.5);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@media (max-width: 768px) {
    .game-board {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
        padding: 10px;
    }
    
    .card {
        min-height: 100px;
    }
    
    .card-front, .card-back {
        font-size: 0.9rem;
    }
    
    h1 {
        font-size: 2rem;
    }
    
    .game-info {
        flex-direction: column;
        gap: 10px;
    }
}