/* css/classic-game.css - Styles specific to the Classic 2048 game variant */

/* ------------------------------------------------------------- */
/* Classic Game Container & Layout (Mimics multi-variant home page structure) */
/* ------------------------------------------------------------- */

/* Game Container (now acts as the main card) */
.game-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* gap: 20px; <-- Removed gap here, will use margin-bottom on children for more control */

    background: var(--text-color-light); /* White background for the game card (from _base.css) */
    padding: 25px; /* Consistent padding around the game content */
    border-radius: 15px;
    box-shadow: var(--box-shadow-light); /* Light shadow (from _base.css) */
    max-width: 550px; /* Limit overall game section width */
    width: 100%; /* Take full width of its parent */
    margin-bottom: 0; /* Managed by parent .game-main-area's gap */
    flex-shrink: 0; /* IMPORTANT: Prevent game card from shrinking when side ads are present */
    position: relative; /* Keep this for future potential absolute children, though not for cover-screen now */
}

/* Spacing for direct children of game-section */
.game-section > *:not(:last-child) {
    margin-bottom: 20px; /* Provides spacing between main blocks like title, header area, grid */
}
/* No margin-bottom for the last child within game-section */
.game-section > *:last-child {
    margin-bottom: 0;
}


/* Heading for the Classic 2048 game (e.g., "2048") */
.game-section .game-title-classic { /* New class for the game title specific to classic */
    color: #776e65; /* Specific text color for classic 2048 numbers */
    font-size: 5em; /* Large size for the 2048 title */
    margin: 0; /* Reset margins as it's part of a flex column now */
    font-family: 'Clear Sans', sans-serif; /* Specific font for classic 2048 look */
    font-weight: bold;
    text-align: center;
    line-height: 1; /* Adjust line height for large font */
}

/* Game Header Area (Contains score and controls) */
.game-header-area {
    display: flex;
    flex-direction: column; /* Stack score-board and game-controls vertically */
    width: 100%;
    gap: 15px; /* Space between score board and game controls */
}

/* Score Board */
.score-board {
    display: flex;
    justify-content: flex-end; /* Push scores to the right */
    gap: 10px; /* Space between score boxes */
    width: 100%; /* Take full width of parent */
}

/* Score Display (to look like multi-variant / classic 2048 compact style) */
.score-display {
    background-color: var(--game-score-bg); /* Use classic 2048 score bg from _base.css */
    color: var(--game-score-text); /* Use classic 2048 score text color from _base.css */
    padding: 8px 12px; /* Smaller padding */
    border-radius: 4px; /* Slightly less rounded for a tighter look */
    font-size: 0.8em; /* Smaller base font */
    font-weight: bold;
    text-align: center;
    flex: 0 0 auto; /* Don't grow, don't shrink, size based on content */
    display: flex;
    flex-direction: column; /* Stack label and value */
    align-items: center; /* Center horizontally */
    line-height: 1.2; /* Tighter line height */
    min-width: 70px; /* Ensure a minimum width for score boxes */
}

.score-display .label {
    font-size: 0.7em; /* Even smaller for "Score" / "Best" label */
    color: rgba(var(--game-score-text-rgb), 0.7); /* Slightly muted label color from _base.css */
    margin-bottom: 2px; /* Space between label and value */
    font-weight: 600;
    text-transform: uppercase;
}

.score-display .value {
    font-size: 1.5em; /* Larger for the actual score number */
    font-weight: 700;
    color: var(--game-score-text);
}

/* Game Controls (New Game, Undo buttons) */
.game-controls {
    display: flex;
    justify-content: center; /* Center buttons horizontally */
    gap: 15px; /* Space between New Game and Undo buttons */
    width: 100%;
    flex-wrap: wrap; /* Allow buttons to wrap on smaller screens */
}

.game-controls button {
    /* Inherits general button styles from _base.css */
    flex: 1; /* Allow buttons to share space */
    max-width: 150px; /* Max width for individual buttons */
    padding: 12px 25px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 8px; /* Consistent with other buttons */
    cursor: pointer;
    background-color: #8f7a66; /* Classic 2048 button color */
    color: white;
    transition: background-color 0.3s ease, transform 0.1s ease;
    outline: none;
    white-space: nowrap; /* Prevent button text from wrapping */
}

.game-controls button:hover {
    background-color: #9f8b77;
    transform: translateY(-2px);
}

#undo-btn:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.6;
}

/* The 2048 Grid */
.grid {
    /* Use min() for responsive sizing up to a max width, or fixed width */
    width: min(400px, 100% - 30px); /* 400px fixed, but max 100% of parent minus its padding */
    height: min(400px, 100% - 30px); /* Keep it square and responsive */
    aspect-ratio: 1; /* Ensure grid itself is square */

    background-color: #bbada0; /* Classic 2048 board background */
    border-radius: 10px;
    padding: 15px; /* Padding inside the grid */
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 15px; /* Gap between tiles */
    margin: 0 auto; /* Center the grid within its parent */
    user-select: none;
    -webkit-user-select: none;
    -ms-user-select: none;
    touch-action: manipulation;
    overflow: hidden; /* Important for tile animations */
}

/* Individual Tiles within the Grid */
.cell { /* Changed from .tile to .cell as per HTML/JS for classic */
    background-color: #cdc1b4;
    border-radius: 5px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 35px; /* Font size for tile numbers */
    font-weight: bold;
    color: #776e65;
    transition: all 0.15s ease-in-out; /* Adjusted transition for smoother movement */
    width: 100%; /* Fill grid cell width */
    height: 100%; /* Fill grid cell height */
    aspect-ratio: 1; /* IMPORTANT: Ensure tiles are square */
}

/* Classic 2048 Tile Colors (and text color adjustments for contrast) */
.cell.tile-2 { background-color: #eee4da; }
.cell.tile-4 { background-color: #ede0c8; }
.cell.tile-8 { background-color: #f2b179; color: #f9f6f2; }
.cell.tile-16 { background-color: #f59563; color: #f9f6f2; }
.cell.tile-32 { background-color: #f67c5f; color: #f9f6f2; }
.cell.tile-64 { background-color: #f65e3b; color: #f9f6f2; }
.cell.tile-128 { background-color: #edcf72; color: #f9f6f2; }
.cell.tile-256 { background-color: #edcc61; color: #f9f6f2; }
.cell.tile-512 { background-color: #edc850; color: #f9f6f2; }
.cell.tile-1024 { background-color: #edc53f; color: #f9f6f2; }
.cell.tile-2048 { background-color: #edc22e; color: #f9f6f2; }

/* Game Over/Win Screen */
.cover-screen {
    position: fixed; /* Covers the entire viewport */
    top: 0;
    left: 0;
    width: 100vw; /* Covers full viewport width */
    height: 100vh; /* Covers full viewport height */
    background: rgba(238, 228, 218, 0.9); /* Lighter, more opaque background, matching your screenshot */
    z-index: 9999; /* High z-index to ensure it's on top of everything */
    display: none; /* Hidden by default in CSS, shown by JS */
    flex-direction: column;
    justify-content: center; /* Center content vertically */
    align-items: center; /* Center content horizontally */
    
    /* Removed border-radius as it's now fixed to viewport */
    /* overflow: hidden; Removed as it's full viewport */

    /* Animation for appearance (optional, uncomment if desired) */
    /* animation: fade-in 0.5s ease forwards; */
}

.cover-screen h2 {
    font-size: 3.5em;
    font-weight: bold;
    color: #776e65; /* Classic game text color */
    margin-bottom: 30px; /* Spacing below title for "Play Again" button */
    font-family: 'Clear Sans', sans-serif;
    text-align: center;
    line-height: 1.2;
}

/* Styling for "Play Again" button inside cover screen */
#restart-btn {
    /* Inherits game-button, but some overrides for larger size/style on overlay */
    padding: 15px 30px;
    font-size: 1.2em;
    background-color: var(--primary-color); /* Green, consistent with new game button */
    color: var(--text-color-light);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border-radius: 25px; /* More rounded */
    
    /* NEW: Flexbox for perfect text centering */
    display: flex;
    justify-content: center;
    align-items: center;
}
#restart-btn:hover {
    background-color: #388E3C; /* Darker green on hover */
}


/* Animation for fade-in (if used) */
@keyframes fade-in {
    0% { opacity: 0; }
    100% { opacity: 1; }
}


/* ------------------------------------------------------------- */
/* Layout for Game Section and Vertical Side Ads (Copied from main.css) */
/* ------------------------------------------------------------- */
.game-main-area {
    display: flex;
    justify-content: center; /* Center the game content and ads */
    align-items: flex-start; /* Align items to the top (important for varying ad heights) */
    width: 100%;
    gap: 20px; /* Space between side ads and the game section */
    margin-bottom: 30px; /* Space below this whole game area */
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

/* AdSense Slot Styling (General) - Needed for placeholders */
.adsense-slot {
    background-color: #f0f0f0;
    border: 1px dashed #ccc;
    padding: 10px;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8em;
    color: #777;
    border-radius: 8px;
    overflow: hidden;
    box-sizing: border-box;
}

/* Styles for the inner placeholder content or actual ad container */
.adsense-placeholder-content {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: #777;
    font-size: 0.8em;
    padding: 5px;
}

/* Styles for Vertical Side Ad Banners (Copied from main.css) */
.adsense-slot.vertical-side-ad {
    margin: 0; /* Remove auto margins when in flex context */
    flex-shrink: 0; /* Prevent from shrinking */
    width: 100%; /* Take full width of its column */
    max-width: 160px; /* Standard vertical banner width (e.g., 160x600) */
    min-height: 400px; /* Minimum height for a noticeable vertical ad */
    align-self: flex-start; /* Align to the top of the flex container */
    display: none; /* Hidden by default and only shown on larger screens */
}


/* ------------------------------------------------------------- */
/* Responsive Adjustments (Game specific and Layout specific) */
/* ------------------------------------------------------------- */

/* Smaller Screens (up to 767px) - Mobile */
@media (max-width: 767px) {
    .game-section {
        padding: 15px; /* Reduce padding for game section */
    }
    .game-section .game-title-classic {
        font-size: 3em; /* Smaller game title on very small screens */
    }
    .score-display {
        padding: 6px 8px; /* Tighter score boxes */
        min-width: 60px;
    }
    .score-display .label {
        font-size: 0.6em; /* Smaller label */
    }
    .score-display .value {
        font-size: 1.2em; /* Smaller value */
    }
    .game-controls button {
        font-size: 0.9em;
        padding: 8px 15px;
        max-width: 120px;
    }
    .grid {
        width: min(280px, 100% - 16px); /* Even smaller grid */
        height: min(280px, 100% - 16px);
        padding: 8px;
        grid-gap: 8px;
    }
    .cell {
        font-size: 25px;
    }
    .cover-screen h2 {
        font-size: 2em;
    }

    /* Layout on small screens: Stack game and hide side ads */
    .game-main-area {
        flex-direction: column; /* Stack game section vertically */
        align-items: center;
        gap: 20px;
    }
    .adsense-slot.vertical-side-ad {
        display: none; /* Keep vertical side ads hidden on small screens */
    }
}

/* Tablet / Larger Mobile (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
    .game-section .game-title-classic {
        font-size: 4em; /* Mid-size game title */
    }
    /* Layout on tablets: Still stack game and hide side ads */
    .game-main-area {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }
    .adsense-slot.vertical-side-ad {
        display: none; /* Keep vertical side ads hidden */
    }
}

/* Desktop (992px and up) */
@media (min-width: 992px) {
    /* Layout on desktop: Game and side ads horizontally */
    .game-main-area {
        flex-direction: row; /* Layout game and ads horizontally */
        justify-content: center; /* Center the game content and ads as a group */
        align-items: flex-start; /* Align game and ads to the top */
        gap: 20px; /* Space between game and ads */
        flex-wrap: nowrap; /* Prevent wrapping */
        width: 100%; /* Take full width of its parent */
    }
    .adsense-slot.vertical-side-ad {
        display: flex; /* Show vertical side ads on desktop */
    }
}