/* --- Base and Body Styles --- */
body {
    font-family: 'Arial', sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start; /* Align to start for scrollable content on small screens */
    min-height: 100vh;
    margin: 0;
    background-color: #f4f7f6; /* Slightly off-white background for the page */
    color: #333;
    padding: 5px; /* Minimal body padding */
    box-sizing: border-box;
    overflow-x: hidden; /* Prevent horizontal scrollbars */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

/* --- Title Screen Styles --- */
#title-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #d32f2f; /* A rich Muppet curtain red */
    color: white;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    z-index: 1000; /* Ensure it's on top of other content */
    padding: 20px;
    box-sizing: border-box;
    opacity: 1; /* Start visible for transition */
    transition: opacity 0.5s ease-out; /* For smooth hiding */
}

.title-content {
    background-color: rgba(0, 0, 0, 0.15);
    padding: 25px 30px;
    border-radius: 20px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.35);
    max-width: 90%; /* Ensure content doesn't stretch too wide */
}

.title-logo-placeholder { /* Style for your optional logo */
    max-width: 60%;
    height: auto;
    max-height: 100px; /* Adjusted */
    margin-bottom: 15px;
}

.title-text {
    font-family: 'Luckiest Guy', cursive; /* Playful font */
    font-size: 3em; /* Base size, will adjust in media query */
    margin: 0 0 10px 0;
    color: #FFD700; /* Bright gold */
    text-shadow: 3px 3px 0px #b71c1c; /* Darker red shadow for a pop effect */
    line-height: 1.1;
}

.title-subtitle {
    font-family: 'Bangers', cursive; /* Fun, comic-like font */
    font-size: 1.5em; /* Base size */
    margin: 0 0 25px 0;
    color: #fff59d; /* Light yellow, almost cream */
    letter-spacing: 1px;
}

#start-button {
    font-family: 'Bangers', cursive;
    font-size: 1.8em; /* Base size */
    padding: 12px 30px; /* Base padding */
    background-color: #009688; /* A friendly teal/green */
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: 0 5px 0 #00695C; /* Darker shade for 3D effect */
    transition: all 0.1s ease-out;
    letter-spacing: 1px;
}

#start-button:hover {
    background-color: #26A69A;
    transform: translateY(-2px);
    box-shadow: 0 7px 0 #00695C;
}

#start-button:active {
    transform: translateY(1px); /* Push button down effect */
    box-shadow: 0 2px 0 #00695C;
}

/* --- Utility Class --- */
.hidden {
    display: none !important;
}

/* --- Game Container and Content Styles --- */
#game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%; /* Allow game container to manage its width */
    margin-top: 10px; /* Reduced top margin for game when visible */
}

#game-container h1 {
    color: #e91e63; /* Game title color */
    margin-bottom: 10px; /* Adjusted */
    font-size: 2em; /* Base size */
    text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
}

.game-info {
    margin-bottom: 15px; /* Adjusted */
    font-size: 1.3em; /* Base size */
    color: #4A4A4A;
    background-color: #ffffff;
    padding: 10px 18px; /* Adjusted */
    border-radius: 8px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.12);
    font-weight: bold;
}

#game-board {
    display: grid;
    /* gap, padding, border-width are responsive in media queries */
    gap: 2px; /* Default small gap for more tile space */
    border: 2px solid #607d8b;
    background-color: #eceff1;
    padding: 3px; /* Minimal padding to maximize tile space */
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    max-width: 100%; /* Ensure board itself doesn't overflow */
    touch-action: none; /* Prevent default touch actions like scroll/zoom on the board for swipe */
    position: relative; /* For z-index context of child tiles if needed */
    /* width and height of grid cells determined by JS via grid-template-columns/rows */
}

.tile {
    width: 100%; /* Fill the grid cell defined by JS */
    height: 100%; /* Fill the grid cell defined by JS */
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #cfd8dc;
    box-sizing: border-box;
    /* cursor: grab; Removed for swipe interface */
    user-select: none;
    background-color: #ffffff;
    border-radius: 4px; /* Adjusted */
    overflow: hidden;
    transition: transform 0.25s ease-out, opacity 0.3s ease-out, box-shadow 0.2s ease-out; /* Adjusted transform duration */
    position: relative; /* For z-index during swap animation */
}

.tile img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    display: block;
    pointer-events: none; /* Important for pointer events on parent tile */
}

.tile.disappearing {
    transform: scale(0.1);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.68, -0.55, 0.27, 1.55), opacity 0.25s ease-in;
}

.tile.newly-added {
    transform: translateY(-110%); /* Relative to tile size for drop effect */
    opacity: 0;
}

.tile-empty {
    background-color: rgba(207, 216, 220, 0.5);
    cursor: default;
    border-color: rgba(176, 196, 222, 0.7);
}

/* Optional: Style for a tile actively being considered for a swipe */
.tile.swiping {
    box-shadow: 0 0 10px 3px rgba(255, 200, 0, 0.7); /* Example: yellow glow */
    /* transform: scale(1.05); /* Optional: Slightly larger when actively swiping */
}

/* Class for tiles during their swap animation */
.tile.swapping-animation {
    z-index: 10; /* Ensure swapping tiles are on top of others */
    /* The transition for 'transform' on .tile will handle the animation speed */
}


/* --- Media Queries for Responsiveness --- */
@media (max-width: 600px) {
    body {
        padding: 2px; /* Minimal body padding on small screens */
    }
    .title-text {
        font-size: 2.5em; /* Adjusted title for mobile */
        text-shadow: 2px 2px 0px #b71c1c;
    }
    .title-subtitle {
        font-size: 1.2em;
    }
    #start-button {
        font-size: 1.4em;
        padding: 10px 20px;
    }
    .title-content {
        padding: 15px; /* Less padding for title box */
        max-width: 95%;
    }
    #game-container {
        margin-top: 5px;
    }
    #game-container h1 {
        font-size: 1.6em;
        margin-bottom: 8px;
    }
    .game-info {
        font-size: 1.0em; /* Smaller score text */
        padding: 6px 12px;
        margin-bottom: 8px;
    }
    #game-board {
        /* gap, padding, border-width already small by default */
        border-radius: 6px;
    }
    .tile {
        border-radius: 3px;
    }
}

@media (max-width: 380px) { /* Extra small devices */
    .title-text {
        font-size: 2em;
    }
    .title-subtitle {
        font-size: 1em;
        margin-bottom: 20px;
    }
    #start-button {
        font-size: 1.2em;
        padding: 8px 15px;
    }
     #game-container h1 {
        font-size: 1.3em;
    }
    .game-info {
        font-size: 0.9em;
    }
}