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

body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    font-family: 'Roboto', sans-serif;
    background: linear-gradient(135deg, #fbc2eb 0%, #a6c1ee 100%);
    color: #333;
    overflow: hidden;
}

.navbar {
    width: 100%;
    height: 100px;
    background: linear-gradient(to right, #ff6fd8, #69c0ff);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.1);
    border-radius: 0 0 20px 20px;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
}

.navbar h1 {
    font-size: 2.5em;
    font-family: 'Fredoka', sans-serif;
    color: #fff;
    text-shadow: 2px 4px 6px rgba(0, 0, 0, 0.3);
}

#timer {
    font-family: 'Baloo 2', sans-serif;
    font-size: 2em;
    color: #fff;
    font-weight: bold;
    background: rgba(255, 255, 255, 0.2);
    padding: 10px 20px;
    border-radius: 20px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
}

#game {
    display: flex;
    font-family: 'Press Start 2P', cursive;
    align-items: center;

    width: 90%;
    margin-top: 150px;
    background: rgba(255, 255, 255, 0.7);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.2);
}

#game p {    
    font-size: 1.6em;
    font-weight: bold;
    margin-bottom: 20px;
    text-align: center;
    color: #333;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-gap: 10px;
    width: 120%;
    max-width: 700px;
    border: 1px solid #ddd;
    padding: 10px;
    background-color: #f7f7f7;
    border-radius: 15px;
    transition: transform 0.5s ease, box-shadow 0.3s ease;
}


.grid img {
    width: 100%;
    height: auto;
    cursor: pointer;
    transition: transform 0.6s ease, box-shadow 0.3s ease;
    transform: rotateY(180deg);
    border-radius: 15px;
    background: #ddd;
    padding: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    will-change: transform;
}

.grid img.show {
    transform: rotateY(0deg);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

.grid img.placeholder {
    content: url('question-mark.png');
    opacity: 0.7;
    background: rgba(0, 0, 0, 0.1);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Zoom effect on hover ONLY for hidden cards */
.grid img.placeholder:hover {
    transform: scale(1.05) rotateY(180deg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    z-index: 2;
}

#score {
    font-size: 2.5em;
    margin-top: 20px;
    color: #333;
    background: rgba(255, 255, 255, 0.5);
    padding: 20px 30px;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
    text-shadow: 2px 4px 6px rgba(0, 0, 0, 0.2);
}

#gameOver {
    display: none;
    text-align: center;
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 20px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
    margin-top: 30px;
}

#gameOver h2 {
    font-size: 3em;
    color: #d75757;
    margin-bottom: 20px;
    text-shadow: 2px 4px 6px rgba(0, 0, 0, 0.2);
}


@media (max-width: 768px) {
    .grid {
        max-width: 100%;
    }

    #game {
        width: 95%;
    }
}

.hidden {
    display: none !important;
}

.grid-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 70px;
}

.score-container {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 1.2em;
    margin-bottom: auto;
    margin-top: auto;
    background: rgba(255, 255, 255, 0.5);
    padding: 5px 20px;
    border-radius: 15px;
    box-shadow: 0 5px 12px rgba(0, 0, 0, 0.1);
    font-family: 'Press Start 2P', cursive;
    color: #222;
}

.score-label {
    font-weight: bold;
    text-transform: uppercase;
    color: #444;
    font-size: 1.3em;
    margin-bottom: auto;
    margin-top: auto;
}

#score {
    font-size: 1.2em;
    font-weight: bold;
    color: #185a9d;
    margin-bottom: 20px;
}


/* --- Popup Overlay for Game Completion --- */
#popupOverlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-content {
    background: #fff;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
    max-width: 500px;
    width: 90%;
    font-family: 'Fredoka', sans-serif;
    animation: scaleIn 0.4s ease;
}

.popup-content h2 {
    font-size: 2em;
    margin-bottom: 20px;
    color: #5b2c6f;
}

.popup-content p {
    font-size: 1.2em;
    margin-bottom: 10px;
    color: #333;
}

.popup-content .motivational {
    font-style: italic;
    font-weight: bold;
    color: #007bff;
    margin-top: 15px;
}

#restartBtn {
    margin-top: 20px;
    padding: 12px 25px;
    font-size: 1em;
    font-weight: bold;
    color: white;
    background: linear-gradient(to right, #ff6fd8, #69c0ff);
    border: none;
    border-radius: 30px;
    cursor: pointer;
    transition: background 0.3s ease;
}

#restartBtn:hover {
    background: linear-gradient(to right, #69c0ff, #ff6fd8);
}

@keyframes scaleIn {
    from {
        transform: scale(0.7);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

#creditsBtn {
    position: fixed;
    bottom: 20px;
    left: 20px;
    background: #ffffffcc;
    color: #333;
    font-family: 'Press Start 2P', cursive;
    padding: 10px 20px;
    border: none;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
    z-index: 999;
}

#creditsBtn:hover {
    background: #eee;
    transform: scale(1.05);
}

#homeBtn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #ffffffcc;
    color: #333;
    font-family: 'Press Start 2P', cursive;
    padding: 10px 40px;
    border: none;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    cursor: pointer;
    transition: background 0.3s, transform 0.2s;
    z-index: 999;
}

#homeBtn:hover {
    background: #eee;
    transform: scale(1.05);
}
