/* General Body and Container Styling */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f0f2f5;
    color: #333;
    /* Ensure body takes at least the full height, but can grow, allowing scrolling */
    min-height: 100vh;
    display: flex; /* Keep flex for centering the container */
    justify-content: center;
    align-items: flex-start; /* Align container to the top */
    box-sizing: border-box; /* Ensure padding is included in height/width */
}
.disabled-clicks {
    pointer-events: none; /* Prevents all mouse/touch events */
    opacity: 0.7; /* Optional: visually indicate that the grid is not yet interactive */
}
.container {
    width: 100%;
    max-width: 600px; /* Limit width for better readability on large screens */
    background-color: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    box-sizing: border-box; /* Include padding in width */
    display: flex;
    flex-direction: column;
    gap: 20px; /* Space between sections */
    /* Let the container determine its own height based on its content */
}

h1 {
    text-align: center;
    color: #2c3e50;
    margin-top: 0;
}

/* Puzzle Info Section */
#puzzle-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px; /* Increased gap for better spacing */
}

/* New styles for the right controls container */
#right-controls {
    display: flex;
    flex-direction: column;
    align-items: center; /* Center buttons and timer horizontally */
    gap: 4px; /* Small gap between buttons and timer */
    flex-shrink: 0; /* Prevent this container from shrinking */
}

/* Container for the buttons */
#control-buttons {
    display: flex;
    gap: 5px; /* Space between the two buttons */
}

/* The countdown timer itself */
#countdown-timer {
    font-size: 0.9em;
    font-weight: bold;
    color: #a72a45; /* A strong, cool-toned red */
    font-family: 'Courier New', Courier, monospace; /* Monospaced for stable width */
    width: 70px;
    text-align: left;
    padding-left: 2px;
}

#current-clue-display {
    font-size: 1.5em; /* Large and prominent */
    font-weight: bold;
    color: #007bff; /* Highlight color */
    min-height: 1.5em; /* Prevent layout shift if empty */
    margin-top: 0;
    margin-bottom: 0;
    text-align: left; /* Align to the left now that it's in a flexbox */
    flex-grow: 1; /* Allow it to take up available space */
}

/* Crossword Grid Styling */
#crossword-grid-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    /* REMOVE: overflow: auto; */
    /* REMOVE: max-height: 50vh; */
    /* REMOVE: transition: max-height 0.3s ease-out; (This transition will still apply if JS adds max-height) */
}

.crossword-grid {
    border-collapse: collapse;
    table-layout: fixed; /* Fixed cell width */
    border: 2px solid #333;
    touch-action: manipulation; /* Improve mobile touch responsiveness */
}

.crossword-grid td {
    width: 30px; /* Adjust cell size as needed */
    height: 30px;
    border: 1px solid #ccc;
    text-align: center;
    vertical-align: middle;
    position: relative;
    font-size: 1.2em;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none; /* Prevent text selection */
}

.black-cell {
    background-color: #333;
    border: 1px solid #333;
}

.black-cell.solved-black-cell {
    background-color: teal;
    border-color: teal;
    transition: background-color 0.5s ease-in-out, border-color 0.5s ease-in-out;
}

.white-cell {
    background-color: #f9f9f9;
}

.cell-number {
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 0.6em;
    color: #666;
    font-weight: normal;
}

.cell-letter {
    color: #000;
}

/* Cell Highlighting */
.white-cell.selected {
    background-color: #ffe082; /* Light yellow for selected cell */
    border-color: #ffc107;
}

.white-cell.active-word-cell {
    background-color: #c8e6c9; /* Light green for cells in the active word */
}

.white-cell.selected.active-word-cell {
    background-color: #a5d6a7; /* Slightly darker green for selected cell in active word */
}

.white-cell.incorrect-letter .cell-letter {
    color: #d32f2f; /* Red color for incorrect letters */
    font-weight: bold;
}

.white-cell.incorrect-letter {
    background-color: #ffcdd2; /* Light red background for incorrect cells */
}


/* Clues Section */
.clues-section {
    display: flex;
    justify-content: space-around;
    gap: 20px;
    flex-wrap: wrap; /* Allow columns to wrap on smaller screens */
}

.clues-section.solved-clues-section {
    display: block; /* Override flexbox */
    text-align: center;
    padding: 20px 0;
}

.clues-section.solved-clues-section h2 {
    color: teal;
}

.clues-column {
    flex: 1;
    min-width: 250px; /* Ensure columns don't get too narrow */
}

.clues-column h3 {
    color: #2c3e50;
    border-bottom: 2px solid #007bff;
    padding-bottom: 5px;
    margin-top: 0;
}

.clues-column ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.clues-column li {
    margin-bottom: 5px;
    font-size: 0.95em;
    line-height: 1.3;
}

/* Ad Container - Hidden by default on desktop */
.ad-container {
    display: none;
    padding: 10px 0;
    width: 100%;
}

/* Input Area */
.input-area {
    display: flex;
    gap: 10px;
    padding: 10px 0;
    justify-content: center;
    align-items: center;
}

#letter-input {
    width: 60px;
    height: 40px;
    font-size: 1.5em;
    text-align: center;
    border: 2px solid #ccc;
    border-radius: 5px;
    text-transform: uppercase;
}

button {
    padding: 10px 15px;
    font-size: 1em;
    background-color: #333;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

button:hover {
    background-color: #0056b3;
}

/* Specific styling for the share button in its new header location */
#share-btn {
    background-color: teal;
    padding: 4px;
    font-size: 0.8em;
    flex-shrink: 0; /* Prevent the button from shrinking */
}

/* Styling for the new reveal button */
#reveal-letter-btn {
    padding: 4px;
    font-size: 0.8em;
    flex-shrink: 0;
    background-color: #ffc107; /* A nice yellow/orange for hints */
    color: #333;
}

/* --- Shared Session UI Adjustments --- */
/* When in a shared session, swap the colors of the share button and the clue display */
.shared-session-active #share-btn {
    background-color: #007bff; /* Blue, from the original clue display */
}

.shared-session-active #current-clue-display {
    color: teal; /* Green, from the original share button */
}

/* Notification Area (from previous diff) */
#notification-area {
    transition: opacity 0.3s ease-in-out;
}
#notification-area.info {
    background-color: #4CAF50;
}
#notification-area.warning {
    background-color: #ff9800;
}
#notification-area.error {
    background-color: #f44336;
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    body {
        padding: 5px; /* Reduce overall padding */
    }

    .container {
        padding: 10px; /* Reduce container padding */
        gap: 10px; /* Reduce gap between sections */
    }
    
    /* Adjust clue display for mobile */
    #current-clue-display {
        font-size: 1.1em; /* Make it slightly smaller */
        min-height: 1.1em;
    }

    /* Adjust cell size for mobile to fit more on screen */
    .crossword-grid td {
        width: 25px; /* Smaller cells */
        height: 25px;
        font-size: 1em; /* Smaller font */
    }

    .cell-number {
        font-size: 0.5em; /* Smaller clue numbers */
    }

    /* On mobile, hide the clues section and show the ad container instead 
    .clues-section {
        display: none;
    }

    .ad-container {
        display: block;
    }*/
}

/* Party Emoji Animation */
.party-emoji {
    position: absolute;
    font-size: 2em;
    z-index: 2000;
    pointer-events: none;
    user-select: none;
    animation-name: dance-and-fade;
    animation-timing-function: ease-out;
    animation-fill-mode: forwards;
}

@keyframes dance-and-fade {
    0% {
        opacity: 1;
        transform: translateY(0) scale(1) rotate(0deg);
    }
    100% {
        opacity: 0;
        transform: translateY(-150px) scale(0.5) rotate(270deg);
    }
}

/* Label to clearly mark the ad */
.advertisement-label {
    font-size: 0.7em;
    color: #999;
    text-align: center;
    margin: 0 0 5px 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Wine Scanner AI Ad */
.wine-ad {
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 6px;
    background-color: #fafafa;
}

.wine-ad-top-bar {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 10px;
}

.wine-ad-logo {
    width: 40px;
    height: 40px;
    flex-shrink: 0;
}

.wine-ad-title {
    font-weight: bold;
    font-size: 1.1em;
    color: teal;
    flex-grow: 1; /* Pushes buttons to the right */
}

.wine-ad-buttons {
    display: flex;
    gap: 5px;
}

.wine-ad-download-btn img {
    /* Slightly smaller for better balance in the top bar */
    height: 28px;
    width: auto;
}

.wine-ad-content {
    text-align: center;
}

.wine-ad-claim {
    font-size: 1em;
    font-weight: bold;
    color: #333; /* A wine-like color */
    margin: 0 0 8px 0;
}

.wine-ad-content p {
    font-size: 0.85em;
    color: #555;
    line-height: 1.4;
    margin: 0;
}

.wine-ad-graphic {
    width: 100%;
    /* Adjusted for better padding within the container */
    max-width: 280px;
    height: auto;
    border-radius: 6px;
    margin: 12px auto 10px; /* Top, horizontal, bottom margin */
    display: block;
}
