/* General body styling */
body {
    font-family: 'Inter', sans-serif;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #f0f8ff, #e0f2f7); /* Light blue gradient background */
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    color: #333;
}

/* Hidden utility class for main containers (menu/game) */
.hidden {
    display: none !important;
}

/* Main Menu styling */
.main-menu {
    background-color: #ffffff;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 30px;
    text-align: center;
    max-width: 90%;
    width: 600px;
    transition: all 0.3s ease-in-out;
}

.main-menu p {
    font-size: 1.2em;
    color: #555;
    margin-bottom: 25px;
}

/* Game container styling */
.game-container {
    background-color: #ffffff;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    padding: 30px;
    text-align: center;
    max-width: 90%;
    width: 600px;
    transition: all 0.3s ease-in-out;
}

/* Title styling */
h1 {
    color: #007bff;
    margin-bottom: 20px;
    font-size: 2.5em;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.05);
}

/* Definition tooltip styling */
#definitionTooltip {
    position: relative;
    top: -10px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 8px;
    font-size: 0.9em;
    z-index: 10;
    max-width: 80%;
    margin: 0 auto 10px;
    text-align: left;
    line-height: 1.4;
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none; /* Allows clicks to pass through to the element below */
}

#definitionTooltip.visible {
    opacity: 1;
}

/* Input section styling */
.input-section {
    margin-bottom: 25px;
}

label {
    display: block;
    margin-bottom: 10px;
    font-size: 1.1em;
    color: #555;
}

input[type="text"] {
    padding: 12px 15px;
    border: 2px solid #a7d9ff;
    border-radius: 8px;
    font-size: 1.1em;
    width: calc(100% - 30px); /* Adjust for padding */
    max-width: 300px;
    box-sizing: border-box;
    outline: none;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus {
    border-color: #007bff;
    box-shadow: 0 0 8px rgba(0, 123, 255, 0.2);
}

/* Button styling */
button {
    background: linear-gradient(180deg, #007bff, #0056b3);
    color: white;
    padding: 12px 25px;
    border: none;
    border-radius: 8px;
    font-size: 1.1em;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 123, 255, 0.3);
    margin-top: 15px;
    outline: none;
    position: relative;
    overflow: hidden;
    z-index: 1;
}

button:hover {
    background: linear-gradient(180deg, #0056b3, #007bff);
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 123, 255, 0.4);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 123, 255, 0.3);
}

button::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
    z-index: -1;
}

button:hover::before {
    width: 200%;
    height: 200%;
}

button:disabled {
    background: #cccccc;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Small button styling for "Back to Main Menu" */
.small-button {
    padding: 8px 15px;
    font-size: 0.9em;
    margin-top: 30px;
    background: linear-gradient(180deg, #6c757d, #5a6268); /* Grey gradient */
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.2);
}

.small-button:hover {
    background: linear-gradient(180deg, #5a6268, #6c757d);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.small-button:active {
    transform: translateY(0);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}


/* Message area styling */
#message {
    margin-top: 20px;
    font-size: 1.1em;
    color: #333;
    min-height: 25px; /* To prevent layout shift */
}

/* Highlight for the target word in messages */
.highlight-word {
    font-weight: bold;
    color: #004085; /* A darker blue */
    text-decoration: underline; /* Add an underline */
    cursor: pointer; /* Add this line to make the word clickable */
}

/* Game board styling */
#game-board {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(60px, 1fr)); /* Responsive grid */
    gap: 10px;
    margin: 30px auto;
    max-width: 500px;
    padding: 15px;
    background-color: #e9f5ff;
    border-radius: 10px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.05);
    opacity: 0; /* Hidden initially */
    transform: scale(0.9);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

#game-board.visible {
    opacity: 1;
    transform: scale(1);
}

/* Cell styling */
.cell {
    width: 100%;
    padding-top: 100%; /* Makes cells square */
    position: relative;
    background-color: #a7d9ff; /* Default visible color */
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2em;
    font-weight: bold;
    color: white;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    overflow: hidden; /* Ensure content stays within rounded corners */
}

/* Letter visibility within the cell */
.cell span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    opacity: 1; /* Always present, control visibility with opacity */
    transition: opacity 0.3s ease;
}

/* New class to visually hide the letter and change cell background */
.cell.hide-content {
    background-color: #007bff; /* Color when content is hidden */
}

.cell.hide-content span {
    opacity: 0; /* Hide the letter */
}

.cell.correct {
    background-color: #28a745; /* Green for correct */
    color: white;
}

.cell.incorrect {
    background-color: #dc3545; /* Red for incorrect */
    color: white;
    animation: shake 0.3s ease-in-out;
}

/* Shake animation for incorrect clicks */
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    50% { transform: translateX(5px); }
    75% { transform: translateX(-5px); }
    100% { transform: translateX(0); }
}

/* Score/Timer display */
.game-info {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    font-size: 1.2em;
    font-weight: bold;
    color: #007bff;
}

.game-info div {
    padding: 10px 15px;
    background-color: #e9f5ff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

/* Single game info display for high score */
.game-info-single {
    margin-top: 20px;
    font-size: 1.2em;
    font-weight: bold;
    color: #007bff;
    padding: 10px 15px;
    background-color: #e9f5ff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    display: inline-block; /* To make it wrap content */
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .game-container, .main-menu {
        padding: 20px;
        width: 95%;
    }
    h1 {
        font-size: 2em;
    }
    input[type="text"], button {
        font-size: 1em;
        padding: 10px 20px;
    }
    .cell {
        font-size: 1.5em;
    }
    #game-board {
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
        gap: 8px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 1.8em;
    }
    .cell {
        font-size: 1.2em;
    }
    #game-board {
        grid-template-columns: repeat(auto-fit, minmax(45px, 1fr));
        gap: 5px;
    }
    .game-info {
        font-size: 1em;
    }
}
