* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

body {
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
}

.screen {
    min-height: 100vh;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
}

.screen.hidden {
    display: none;
}

.screen-content {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 40px;
    max-width: 600px;
    width: 100%;
    text-align: center;
}

.start-btn {
    font-size: 1.5rem;
    padding: 15px 40px;
    margin: 25px 0;
    background: #4a6ee0;
    color: white;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.start-btn:hover {
    background: #3a5bc7;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.instructions {
    margin-top: 30px;
    text-align: left;
    background: #f8f9fa;
    padding: 20px;
    border-radius: 10px;
}

.instructions h3 {
    margin-top: 0;
    color: #4a6ee0;
}

.instructions ul {
    padding-left: 20px;
}

.instructions li {
    margin-bottom: 8px;
    color: #555;
}

/* Game container styles */

.game-container {
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 800px;
    padding: 20px;
    position: relative;
    overflow: hidden;
}

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

.stats {
    display: flex;
    gap: 15px;
    font-size: 1.1rem;
    flex-wrap: wrap;
}

.btn {
    background: #4a6ee0;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn:hover {
    background: #3a5bc7;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.game-board {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin: 0 auto;
    max-width: 800px;
    padding: 10px;
    perspective: 1000px;
    width: 100%;
}

.card {
    aspect-ratio: 1;
    background: #f0f2f5;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    cursor: pointer;
    transition: transform 0.5s ease, background-color 0.3s ease;
    transform-style: preserve-3d;
    position: relative;
    transform: rotateY(0deg);
    transform-origin: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card.flipped {
    transform: rotateY(180deg);
    background: white;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    pointer-events: none;
}

.card.matched {
    background: #e8f5e9;
    transform: rotateY(180deg);
    cursor: default;
}

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

.card-front {
    background: #4a6ee0;
    color: white;
    font-size: 1.8rem;
}

.card-back {
    background: white;
    transform: rotateY(180deg);
}

.message-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}

.message-content {
    background: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
}

.message-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

.win-message h2,
.lose-message h2 {
    color: #4a6ee0;
    margin-bottom: 15px;
    font-size: 2rem;
}

.win-message p,
.lose-message p {
    margin-bottom: 25px;
    font-size: 1.2rem;
    color: #555;
}

/* Responsive Design */
@media (max-width: 768px) {
    .game-board {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        padding: 10px 5px;
    }
    
    .card {
        font-size: 1.6rem;
        aspect-ratio: 0.8;
    }
    
    .stats {
        font-size: 0.85rem;
        gap: 10px;
    }
    
    .btn {
        padding: 8px 16px;
        font-size: 0.85rem;
    }
    
    .game-header {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }
    
    .stats {
        justify-content: space-between;
    }
}

/* Extra small devices */
@media (max-width: 768px) {
    .screen-content {
        padding: 25px 15px;
    }
    
    .start-btn {
        font-size: 1.2rem;
        padding: 12px 30px;
    }
    
    .instructions {
        padding: 15px;
        font-size: 0.95rem;
    }
}

@media (max-width: 480px) {
    .game-board {
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
    }
    
    .card {
        font-size: 1.4rem;
        border-radius: 8px;
    }
    
    .game-header {
        margin-bottom: 10px;
    }
    
    .stats {
        font-size: 0.8rem;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
        margin-top: 5px;
    }
}

/* Tiny devices */
@media (max-width: 320px) {
    .game-board {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .card {
        font-size: 1.6rem;
    }
}

/* Animation */
@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

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

/* Add some fun hover effects */
.card:not(.flipped):not(.matched):hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}
