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

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

.game-container {
    text-align: center;
    padding: 20px;
    width: 100%;
    max-width: 600px;
}

.game-info {
    display: flex;
    justify-content: space-around;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    padding: 15px;
    margin-bottom: 20px;
    color: white;
    font-size: 18px;
    font-weight: bold;
}

.game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    margin-bottom: 20px;
}

.card {
    aspect-ratio: 1;
    background: linear-gradient(145deg, #4a5568, #2d3748);
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 40px;
    transition: transform 0.3s ease, background 0.3s ease;
    position: relative;
    transform-style: preserve-3d;
}

.card:hover:not(.flipped):not(.matched) {
    transform: scale(1.05);
    background: linear-gradient(145deg, #5a6878, #3d4758);
}

.card.flipped {
    transform: rotateY(180deg);
    background: linear-gradient(145deg, #f7fafc, #edf2f7);
}

.card.matched {
    background: linear-gradient(145deg, #48bb78, #38a169);
    transform: rotateY(180deg);
    cursor: default;
}

.card .card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    backface-visibility: hidden;
    font-size: 30px;
    color: #a0aec0;
}

.card .card-front {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    backface-visibility: hidden;
    transform: rotateY(180deg);
}

.start-screen,
.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    z-index: 100;
}

.start-screen h2,
.game-over h2 {
    font-size: 42px;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.start-screen p,
.game-over p {
    font-size: 18px;
    margin-bottom: 10px;
    opacity: 0.9;
}

.start-screen button,
.game-over button,
.controls button {
    margin-top: 20px;
    padding: 15px 40px;
    font-size: 20px;
    background: linear-gradient(145deg, #667eea, #764ba2);
    color: white;
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    font-weight: bold;
}

.start-screen button:hover,
.game-over button:hover,
.controls button:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.5);
}

.controls {
    margin-top: 10px;
}

.controls button {
    padding: 10px 25px;
    font-size: 16px;
}

.hidden {
    display: none !important;
}

/* Card flip animation */
@keyframes flipIn {
    0% {
        transform: rotateY(0deg);
    }
    100% {
        transform: rotateY(180deg);
    }
}

@keyframes flipOut {
    0% {
        transform: rotateY(180deg);
    }
    100% {
        transform: rotateY(0deg);
    }
}

/* Match celebration animation */
@keyframes celebrate {
    0%, 100% {
        transform: rotateY(180deg) scale(1);
    }
    50% {
        transform: rotateY(180deg) scale(1.1);
    }
}

.card.matched {
    animation: celebrate 0.5s ease;
}

/* Responsive design */
@media (max-width: 500px) {
    .game-board {
        gap: 8px;
        padding: 15px;
    }
    
    .card {
        font-size: 30px;
    }
    
    .game-info {
        font-size: 14px;
        padding: 10px;
    }
}
