:root {
    --background-color: #f0f0f0;
    --tile-background: #ffffff;
    --tile-border: #333333;
    --tile-text: #000000;
    --tile-points: #666666;
    --selected-tile: #4CAF50;
    --last-selected-shadow: #79ff0c;
    --selected-tile-text: #ffffff;
    --placeholder-border: #cccccc;
    --button-background: #4CAF50;
    --button-text: #ffffff;
    --button-active: #3e8e41;
    --disabled-button: #cccccc;
    --title-panel-background: #ffffff;
    --title-text-color: #000000;
    --title-panel-border: #000000;
}

body {
    background-color: var(--background-color);
    font-family: 'Merriweather', serif;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 50px; /* Add space for the title panel */
}

h1 {
    color: var(--title-text-color);
    text-align: center;
    font-size: 24px;
    font-weight: bold;
    margin: 0;
}

#game-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 2vw;
    width: 90vw;
    max-width: 600px;
    margin: 0px auto;
    justify-content: center;
    aspect-ratio: 1 / 1;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tile {
    width: 100%;
    aspect-ratio: 1 / 1;
    background-color: var(--tile-background);
    border: 0.5vw solid var(--tile-border);
    color: var(--tile-text);
    border-radius: 2vw;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    cursor: pointer;
    transition: opacity 0.3s ease-in-out;
    user-select: none;
    box-sizing: border-box;
    opacity: 0;
}

.tile-letter {
    font-size: 10vw;
    font-weight: bold;
}

.tile-points {
    position: absolute;
    top: 0.5vw;
    right: 1.4vw;
    font-size: 3.2vw;
    font-weight: bold;
    color: var(--tile-points);
}

.tile.selected {
    background-color: var(--selected-tile);
    color: var(--selected-tile-text);
}

.tile.visible {
    opacity: 1;
}

.tile.fade-in {
    animation: fadeIn 0.5s ease-in-out forwards;
}

.tile.last-selected {
    background-color: var(--selected-tile) !important; /* Slightly brighter green */
    box-shadow: 0 0 10px var(--last-selected-shadow); 
    border: 0.5vw solid var(--selected-tile); /* Add a subtle shadow */
}

.tile.placeholder {
    background-color: var(--background-color);
    border: 0.5vw dashed var(--placeholder-border);
    opacity: 1;
}

.button-container {
    display: flex;
    justify-content: space-between;
    width: 90vw;
    max-width: 600px;
    margin: 10px auto 0;
}

#shuffle-button,
#submit-button,
#clear-button {
    font-family: 'Merriweather', serif;
    font-size: 4vw;
    font-weight: bold;
    padding: 4vw 1vw;
    color: var(--button-text);
    border: none;
    border-radius: 2vw;
    cursor: pointer;
    width: 31%;
    transition: background-color 0.3s;
}

#submit-button {
    background-color: var(--button-background);
}

#shuffle-button,
#clear-button {
    background-color: #000000; /* Neutral gray color */
    color: #ffffff;
}

#submit-button:disabled {
    background-color: var(--disabled-button);
    cursor: not-allowed;
}

/* Add this new rule */
#submit-button:disabled:active {
    background-color: var(--disabled-button);
}

#shuffle-button:active,
#clear-button:active {
    background-color: #000000; /* Darker gray for active state */
}

#submit-button:active {
    background-color: var(--button-active);
}

@media (min-width: 667px) {
    #game-board {
        gap: 13.5px;
    }

    .tile {
        border-width: 3px;
        border-radius: 14px;
    }

    .tile-letter {
        font-size: 67px;
    }

    .tile-points {
        top: 3px;
        right: 9px;
        font-size: 21.5px;
    }

    .tile.placeholder {
        border: 0.5vw dashed var(--placeholder-border);
        border-width: 3px;
        border-radius: 14px;
    }

    #shuffle-button,
    #submit-button,
    #clear-button {
        font-size: 26px;
        padding: 26px 22px;
        border-radius: 13px;
    }
}

.game-info {
    display: flex;
    justify-content: space-between;
    width: 90vw;
    max-width: 600px;
    margin: 10px auto;
    font-size: 16px;
    font-weight: bold;
}

#tiles-remaining {
    text-align: left;
}

#score {
    text-align: right;
}

#fixed-height-container {
    width: 90vw;
    max-width: 600px;
    height: 100px;
    margin: 10px auto;
    display: block; /* Changed from flex to block */
}

#current-word {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    width: 100%; /* Ensure it takes full width of container */
}

#current-word div:first-child {
    font-size: 14px;
    color: var(--tile-points);
    margin-bottom: 5px; /* Add some space between points and word */
}

.title-panel {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--title-panel-background);
    padding: 10px 0;
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: default;
    border-bottom: 1px solid #000000; /* Add this line for the thin black line */
}

#helpButton {
    position: absolute;
    background-color: transparent;
    font-family: 'Merriweather', serif;
    border: none;
    right: 20px;
    color: var(--title-text-color);
    font-size: 14px;
    cursor: pointer;
}

/* Add these styles to your existing CSS file */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
}

.overlay-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 80%;
    max-width: 400px; /* Add this line to limit the width */
    max-height: 80%; /* Add this line to limit the height to 80% of the viewport height */
    overflow-y: auto; /* Add this line to enable vertical scrolling if needed */
    background-color: white;
    padding: 20px;
    padding-top: 1%;
    padding-bottom: 2vh;
    border-radius: 5px;
    text-align: left;
    display: flex;
    flex-direction: column;
}

#closeHelp {
    font-family: 'Merriweather', serif;
    font-size: 4vw;
    font-weight: bold;
    padding: 4vw 1vw;
    align-self: center;
    color: var(--button-text);
    border: none;
    border-radius: 2vw;
    cursor: pointer;
    width: 31%;
    height: 10%;
    margin-top: 3%;
    transition: background-color 0.3s;
    background-color: var(--button-background);
}

#complete-game-button {
    font-family: 'Merriweather', serif;
    font-size: 4vw;
    font-weight: bold;
    padding: 4vw 1vw;
    color: var(--button-text);
    background-color: #000000;
    border: none;
    border-radius: 2vw;
    cursor: pointer;
    width: 90vw;
    max-width: 600px;
    margin: 0 auto;
    display: block;
    transition: background-color 0.3s;
    position: fixed;
    bottom: 20px; 
    left: 50%;
    transform: translateX(-50%);
}

#gameCompleteOverlay .overlay-content {
    text-align: center;
    max-width: 80%;
    width: 400px; /* Set a base width */
}

#gameCompleteOverlay h2 {
    font-size: clamp(24px, 7vw, 36px);
    margin-bottom: 10px;
    font-weight: bold;
}

#finalScoreHeader, #bestWordHeader {
    font-size: clamp(20px, 6vw, 30px);
    font-weight: bold;
    margin-bottom: 5px;
}

#finalScore {
    font-size: clamp(18px, 5vw, 28px);
    margin-bottom: 10px;
}

#bestWord {
    font-size: clamp(16px, 4vw, 24px);
    margin-bottom: 20px;
}

#shareButton {
    font-family: 'Merriweather', serif;
    font-size: clamp(16px, 4vw, 24px);
    font-weight: bold;
    padding: clamp(10px, 4vw, 20px) clamp(5px, 1vw, 10px);
    color: var(--button-text);
    background-color: #4CAF50;
    border: none;
    border-radius: clamp(8px, 2vw, 13px);
    cursor: pointer;
    width: 80%;
    max-width: 300px;
    margin: 10px auto;
    transition: background-color 0.3s;
}

@media (min-width: 667px) {
    #complete-game-button,
    #closeHelp,
    #shareButton {
        font-size: 26px;
        padding: 26px 22px;
        border-radius: 13px;
    }
}

/* Add this new class */
.content-wrapper {
    flex-grow: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-bottom: 10%; /* Add padding to account for the fixed button */
}

/* Add this new rule to your existing CSS */
button {
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

/* You may also want to add these properties to your existing button styles */
#shuffle-button,
#submit-button,
#clear-button,
#complete-game-button,
#shareButton,
#closeHelp,
#helpButton {
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

.tile-multiplier2x {
    position: absolute;
    bottom: 0.5vw;
    left: 1.4vw;
    font-size: 3.2vw;
    font-weight: bold;
    color: #e12929;
}

.tile-multiplier3x {
    position: absolute;
    bottom: 0.5vw;
    left: 1.4vw;
    font-size: 3.2vw;
    font-weight: bold;
    color: #e12929;
}

@media (min-width: 667px) {
    .tile-multiplier2x {
        bottom: 3px;
        left: 9px;
        font-size: 21.5px;
    }
    .tile-multiplier3x {
        bottom: 3px;
        left: 9px;
        font-size: 21.5px;
    }
}