@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap');

html, body {
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden; 
}

/* Basic styling for functionality */
body {
    font-family: 'Nunito', sans-serif; 
    background-color: #f0f2f5;
    perspective: 1000px;
}

body.in-game {
    background-color: #000; /* A solid black background */
}

body.in-game::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7); /* The transparent black overlay */
    z-index: -1; /* Places the overlay behind the game content */
}

.centered-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center; 
    min-height: 100vh;
    box-sizing: border-box;
    position: relative;
    z-index: 10;
}

h1 {
    color: #333;
    text-align: center;
}

h2, p {
    text-align: center;
}

h3 {
    text-align: center;
}

/* --- NEW, RELIABLE HEADER STYLES --- */
.home-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 30px 40px; /* Adjust padding as needed */
    box-sizing: border-box;

    display: flex;
    justify-content: space-between; /* This is the key */
    align-items: center;
    z-index: 50;
}

.home-header .home-logo {
    width: 10vw; /* Adjust size of logo */
}

.home-header .home-tagline {
    width: 15vw; /* Adjust size of tagline */
}

.home-header img {
    width: 100%;
    height: auto;
}

/* --- Initial Welcome Text Styles --- */
.initial-text {
    display: none;
    text-align: center;
    width: 100%;
    z-index: 11;
    position: absolute;
    top: 50px;
}

#level-selector .initial-text {
    display: block;
    position: static; 
    margin-bottom: 20px;
    color: white;
}

#level-selector .initial-text h1, 
#level-selector .initial-text h2, 
#level-selector .initial-text p,
#level-selector .initial-text h3 {
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

/* --- SPECIAL STYLES FOR LEVEL 1 --- */

/* 1. Make the grid tiles larger for Level 1 */
#game-board.level-1-grid {
    grid-template-columns: repeat(var(--cols, 3), 130px); /* Use a larger size, e.g., 130px */
    grid-template-rows: repeat(var(--rows, 2), 130px);
}

/* 2. Make the cards themselves larger to fill the new tile size */
#game-board.level-1-grid .card {
    width: 130px;
    height: 130px;
}

/* 3. "Zoom in" on the images for Level 1 only */
#game-board.level-1-grid .card-face-front img {
    object-fit: cover; /* Change back to 'cover' to zoom in */
}

#game-board.level-3-grid .card-face-front img {
    object-fit: cover; /* "Zoom in" only on level 3 images */
}

.initial-text h1 { font-size: 2rem; margin: 0; }
.initial-text h2 { font-size: 2.5rem; margin: 0; }
.initial-text p { font-size: 1rem; margin-top: 5px; }


/* --- Logo Styles --- */
.logo-container {
    position: absolute;
    top: 20px;
    right: -10px;
    width: 300px;
    z-index: 52; /* Increased to be on top of the menu */
    pointer-events: none; /* This makes the container's empty space click-through */
}

#game-container.large-grid .logo-container {
    width: 200px; /* Default is 300px, adjust as needed */
}

/* Add the pointer-events property to this existing rule */
.logo-container img {
    width: 100%;
    height: auto;
    pointer-events: auto; /* Makes the image block clicks, but not the container */
}

/* --- Splash Screen Styles --- */
#splash-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 1s ease-out;
}

#intro-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* --- Animated Background Keyframes --- */
@keyframes gradient-animation {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* --- Level Selector Styling --- */
#level-selector {
    position: relative;
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 50px; /* This is the space between the leaderboard and the menu */
    position: relative;

    /* These are your existing background styles */
    width: 100%;
    min-height: 100vh;
    padding: 20px;
    box-sizing: border-box;
}

#level-selector::before {
    content: ''; /* Required for pseudo-elements */
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    
    /* The background properties are now here */
    background-image: url('Asset/Images/Background/Home.png'); /* <-- Make sure this path is correct */
    background-size: cover;
    background-position: center;
    
    /* This is the line that creates the blur */
    filter: blur(7px);
    
    /* Places the blurred background behind your content */
    z-index: -1;
}

#main-menu-content .initial-text {
        /* --- Add these lines to control the size --- */
    width: fit-content;       /* Makes the box only as wide as its content */
    margin: 0 auto 20px auto; /* Centers the box and adds space below it */

    /* --- You can also reduce the padding --- */
    padding: 0.5rem 1rem;       /* Reduced from 1.5rem 2.5rem */

    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

#main-menu-content .initial-text h1, 
#main-menu-content .initial-text h2, 
#main-menu-content .initial-text h3,
#main-menu-content .initial-text p {
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    margin: 3px 0;
}

#main-menu-content .initial-text h1 {
    margin-bottom: 0; 
}

#main-menu-content .initial-text h2 {
    margin-top: 0; 
}

#level-selector .menu-card {
    text-align: center;
    background: rgba(255, 255, 255, 0.1);
    padding: 2rem 3rem;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37);
}

#level-selector .menu-card h1 {
    font-size: 3rem;
    font-weight: 700;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
}

.level-button {
    background-image: linear-gradient(to right, #00d2ff 0%, #3a7bd5  51%, #00d2ff  100%);
    color: white;
    border: none;
    border-radius: 10px;
    padding: 15px 30px;
    font-size: 1.2rem;
    font-weight: 600;
    margin: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px 0 rgba(49, 196, 190, 0.75);
    background-size: 200% auto;
}
.level-button:hover {
    transform: scale(1.1);
    background-position: right center;
    box-shadow: 0 6px 20px 0 rgba(49, 196, 190, 0.9);
}

.level-buttons-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 15px; 
    max-width: 700px; 
}

/* Main Game Container */
#game-container {
    display: none; /* Hidden by default */
    width: 100%; /* Ensure it takes full width */
    padding: 20px;
    height: 100%;
    background-size: cover;
    background-position: center;
}

#game-container h1, #game-container #game-info p {
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

#level-subtitle {
    font-size: 1.5rem;
    font-weight: 400;  
    margin-top: -15px; 
    margin-bottom: 20px;
    color: white;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

/* --- Back Button Style --- */
#back-button {
    position: absolute;
    top: 25px;
    left: 25px;
    z-index: 50;
    background-color: #fff;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.2s ease-in-out;
}
#back-button:hover {
    background-color: #f8f8f8;
    transform: scale(1.1);
}

#game-board {
    display: grid;
    grid-template-columns: repeat(var(--cols, 4), 100px); 
    grid-template-rows: repeat(var(--rows, 4), 100px);   
    gap: 10px;
    margin-top: 20px;
}

/* The card container */
.card {
    width: 100px;
    height: 100px;
    cursor: pointer;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s;
}

.card.is-flipped {
    transform: rotateY(180deg);
}

.card-face {
    position: absolute;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.card-face-front {
    background-color: #fff;
    color: #000;
    transform: rotateY(180deg);
    border: 2px solid #999;
    overflow: hidden;
}

.card-face-front img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.card-face-back {
    background-color: #4a90e2;
    color: white;
    border: 2px solid #357abd;
    font-size: 50px;
}

.card.is-matched .card-face-front {
    border-color: #52b788;
}

#main-content-wrapper {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 40px; /* Space between the panel and the grid */  
    margin-top: 20px;
}

#left-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#game-info {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 20px;
    border-radius: 10px;
    margin-top: 0;
    font-size: 1.2rem;
    text-align: left;
}

.game-controls {
    margin-top: 20px;
}

.game-button {
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: bold;
    border-radius: 8px;
    border: none;
    color: white;
    cursor: pointer;
    margin: 0 5px;
    background-color: #28a745; 
    transition: background-color 0.2s ease;
}

.game-button:hover {
    background-color: #218838;
}

#next-level-button {
    display: none; 
    background-color: #007bff; 
}
#next-level-button:hover {
    background-color: #0056b3;
}

#end-level-message {
    margin-top: 10px;
    font-weight: bold;
}

/* --- LEADERBOARD STYLES --- */
#leaderboard-container {
    margin-top: 40px;
    padding: 20px;
    width: 300px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

#leaderboard-container h2 {
    color: white;
    text-align: center;
    margin-top: 0;
    border-bottom: 1px solid rgba(255,255,255,0.3);
    padding-bottom: 10px;
}

#leaderboard-list {
    list-style-type: decimal;
    padding-left: 30px;
    color: white;
    font-size: 1.1rem;
}

#leaderboard-list li {
    margin-bottom: 8px;
    text-shadow: 1px 1px 3px rgba(0, 0, 0, 0.7); 
}

/* --- SAVE SCORE MODAL STYLES --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal-content {
    background-color: #fff;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    color: #333;
}

#save-score-form input {
    display: block;
    width: 80%;
    margin: 20px auto;
    padding: 10px;
    font-size: 1rem;
    border: 1px solid #ccc;
    border-radius: 5px;
}

#clear-leaderboard-button {
    display: block;
    width: 80%;
    margin: -10px auto 20px auto; /* Position it nicely below the title */
    padding: 8px;
    background-color: #dc3545; /* A 'danger' red color */
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#clear-leaderboard-button:hover {
    background-color: #c82333; /* A darker red for hover */
}

/* Pushes the title down on larger levels (3, 4, 5) for better visibility */
#game-container.large-grid #title-game {
    margin-top: 90px;
}

/* ==========================================================================
   Responsive Styles for Mobile Devices
   ========================================================================== */
   
/* --- Styles for Tablets and Medium Screens --- */
@media (max-width: 1024px) {

    .logo-container { /* CORRECTED from .home-mascot */
        width: 20vw;   /* A medium size for tablets */
        right: 4vw;
    }

}

@media (max-width: 768px) {

    /* --- General Adjustments --- */
    body {
        overflow-y: auto; /* Always allow scrolling on mobile */
    }

    /* Inside the @media (max-width: 768px) block */
    .logo-container {
        width: 150px;  /* A smaller size for mobile */
        right: 3vw;    /* Position from the right edge */
        top: 55%;
        left: auto;    /* This overrides the old 'left: 10px' */
    }

    h1 { font-size: 1.8rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.1rem; }
    p { font-size: 0.9rem; }


    /* --- Home Screen / Level Selector --- */
    #level-selector {
        flex-direction: column; /* Stack leaderboard and menu vertically */
        justify-content: flex-start; /* Align to top */
        padding-top: 80px; /* Add space for the top logo */
        gap: 30px;
    }

    #leaderboard-container, 
    #main-menu-content {
        width: 90%; /* Make containers take up most of the screen width */
        margin: 0;
    }

    #level-selector .menu-card h1 {
        font-size: 2rem;
    }

    .level-buttons-container {
        max-width: 100%; /* Allow buttons to wrap freely */
    }
    

    /* --- Game Screen --- */
    #game-container {
        justify-content: flex-start; /* Aligns content to the top */
        padding-top: 80px;          /* Adds space at the top, below the back button */
    }

    #game-container.large-grid #title-game,
    #game-container h1#title-game {
        font-size: 1.4rem;
    }
    
    #level-subtitle {
        font-size: 1rem;
    }

    #main-content-wrapper {
        flex-direction: column; /* Stack info panel and game board vertically */
        gap: 20px;
    }

    #left-panel {
        order: 2; /* Move the info panel below the game board */
        width: 90%;
    }

    #game-board {
        order: 1; /* Move the game board above the info panel */
        /* Make the grid smaller for phones */
        grid-template-columns: repeat(var(--cols, 4), 65px);
        grid-template-rows: repeat(var(--rows, 4), 65px);
        gap: 8px;
    }

    .card {
        /* Make cards smaller */
        width: 65px;
        height: 65px;
    }
    
    .card-face-back {
        font-size: 35px; /* Make the '?' smaller */
    }
    
    /* Also resize the special Level 1 grid */
    #game-board.level-1-grid {
        grid-template-columns: repeat(var(--cols, 3), 85px);
        grid-template-rows: repeat(var(--rows, 2), 85px);
    }
    
    #game-board.level-1-grid .card {
        width: 85px;
        height: 85px;
    }


    /* --- Modal Adjustments --- */
    .modal-content {
        width: 85%; /* Make the save score modal fit better */
    }
}