.cvc-words-game .game-area {
    background-image: url('../assets/images/cvc-words/cvc-words-background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    padding: 0 15px 15px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    position: relative;
    flex-grow: 1;
    width: 100%;
    height: 100%;
    gap: 15px;
}

/* Custom styles for the letter selection boxes in the CVC Words game */
.cvc-words-game .letter-box {
    width: 80px;
    height: 80px;
    font-size: 3em;
}

@media (max-width: 1024px) {
    .cvc-words-game .letter-box {
        width: 70px;
        height: 70px;
        font-size: 2.5em;
    }
}

@media (max-width: 768px) {
    .cvc-words-game .letter-box {
        width: 60px;
        height: 60px;
        font-size: 2.2em;
    }
}

@media (max-width: 480px) {
    .cvc-words-game .letter-box {
        width: 50px;
        height: 50px;
        font-size: 2em;
    }

    .cvc-words-game .game-area {
        padding: 0 15px;
        gap: 5px;
    }
}

/* New style to reduce the width of the letter grid to 80% */
.cvc-words-game .letter-grid {
    width: 80%;
}

@media (max-width: 480px) {
    .cvc-words-game .letter-grid {
        width: 100%;
    }
}

.cvc-main-content {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    flex-grow: 1;
    gap: 15px;
    overflow: hidden;
}

.celebration-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    z-index: 100;
}

@keyframes fall {
    0% {
        transform: translateY(-10vh) rotate(0deg);
        opacity: 1;
    }

    100% {
        transform: translateY(110vh) rotate(720deg);
        opacity: 0;
    }
}

@keyframes flash {
    50% {
        background-color: #ffffff;
    }
}

/* FIX: Updated animation for flashing a solved image to use a yellow border and glow */
@keyframes image-flash {

    0%,
    100% {
        border-color: #2ecc71;
        transform: scale(1);
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    }

    50% {
        border-color: #f1c40f;
        transform: scale(1.05);
        box-shadow: 0 0 20px 5px #f1c40f;
    }
}

.falling-star {
    position: absolute;
    font-size: 2em;
    color: #f1c40f;
    animation: fall 2s linear forwards;
    text-shadow: 0 0 5px #fff;
}

.game-progress-bar {
    width: 100%;
    max-width: none;
    align-self: stretch;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 10px;
    padding: 5px;
    box-sizing: border-box;
    display: flex;
    justify-content: space-around;
    align-items: center;
    border: 2px solid rgba(255, 255, 255, 0.2);
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.game-progress-bar .star {
    font-size: 1.5em;
    color: gray;
}

.game-progress-bar .star.filled {
    color: #f1c40f;
    text-shadow: 0 0 5px #fff, 0 0 10px #f1c40f;
}

.cvc-problem-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-grow: 1;
    position: relative;
    z-index: 1;
    min-width: 0;
}

.cvc-image-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    width: 100%;
    max-width: 250px;
}

.cvc-image-container {
    aspect-ratio: 1 / 1;
    background-color: #fff;
    border: 5px solid #e74c3c;
    border-radius: 5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    display: flex;
    justify-content: center;
    align-items: center;
    box-sizing: border-box;
    transition: border-color 0.5s ease, transform 0.3s ease;
}

.cvc-image-container.animate-image-flash {
    animation: image-flash 0.5s ease-in-out;
    animation-iteration-count: 2;
}

.cvc-image-container.solved {
    border-color: #2ecc71;
    transform: scale(1.05);
}

/* Blue flashing border while audio is playing from user click */
@keyframes playing-flash {
    0% {
        box-shadow: 0 0 0 0 rgba(52, 152, 219, 0);
    }

    50% {
        box-shadow: 0 0 12px 4px rgba(52, 152, 219, 0.35);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(52, 152, 219, 0);
    }
}

.cvc-image-container.playing-audio {
    border-color: #3498db;
    animation: playing-flash 1s linear infinite;
}

.cvc-image-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.cvc-drop-zone {
    display: flex;
    gap: 1px;
}

.cvc-letter-slot {
    width: 70px;
    height: 70px;
    background-color: rgba(0, 0, 0, 0.7);
    border: 3px solid #fff;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5em;
    font-weight: bold;
    color: #fff;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    transition: background-color 0.3s, border-color 0.3s, transform 0.2s;
    cursor: pointer;
    flex-shrink: 0;
}

.cvc-letter-slot:hover {
    background-color: #000;
}

.cvc-letter-slot:first-child {
    border-right: none;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.cvc-letter-slot:nth-child(2) {
    border-left: 1px solid darkgray;
    border-right: 1px solid darkgray;
    border-radius: 0;
}

.cvc-letter-slot:last-child {
    border-left: none;
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}


.cvc-letter-choices {
    height: 100%;
    max-height: 400px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    box-sizing: border-box;
    position: relative;
    z-index: 1;
    flex: 0 1 180px;
    align-content: center;
    /* allow shrink in flex container */
    min-width: 0;
}

.letter-card {
    aspect-ratio: 2 / 1;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.2em;
    font-weight: bold;
    font-family: 'CustomMain', Arial, sans-serif;
    color: #fff;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.3s ease;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    /* allow shrink in grid */
    min-width: 0;
}

.letter-card.flash-hint {
    animation: flash 0.5s 3;
}

.letter-card.selected {
    transform: scale(1.1);
    box-shadow: 0 0 20px #3498db;
}

.letter-card.hidden {
    opacity: 0.2;
    pointer-events: none;
}

.selection-options-container {
    display: flex;
    justify-content: center;
    gap: 15px;
    width: 100%;
    margin-top: 20px;
}

.difficulty-button,
.select-cvc-words {
    padding: 10px 20px;
    width: 150px;
    font-family: 'CustomMain', Arial, sans-serif;
    font-size: 1.2em;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s, transform 0.2s;
}

.difficulty-button {
    background-color: #bdc3c7;
    color: #4c5255;
}

.difficulty-button.selected,
.select-cvc-words {
    background: linear-gradient(90deg, #3498db, #2980b9);
    border: 2px solid #fff;
    color: #fff;
    transform: scale(1.05);
}

.difficulty-button.selected:hover,
.select-cvc-words:hover {
    background: linear-gradient(90deg, #2980b9, #2471a3);
    border: 2px solid #fff;
}

.hint-button {
    height: 44px;
    width: 80px;
    padding: 0;
    font-family: 'CustomMain', Arial, sans-serif;
    font-size: 1.2em;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    background-color: #3498db;
    color: #fff;
    transition: background-color 0.2s;
}

.hint-button:hover {
    background-color: #2980b9;
}

.hint-button.hidden {
    display: none;
}

@media (max-width: 768px) {
    .cvc-problem-container {
        max-width: 200px;
    }

    .cvc-letter-choices {
        flex-basis: 140px;
    }

    .cvc-letter-slot {
        width: 50px;
        height: 50px;
        font-size: 2em;
    }

    .hint-button {
        height: 40px;
        width: 70px;
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    .game-progress-bar .star {
        font-size: 1.2em;
    }

    .cvc-main-content {
        gap: 5px;
    }

    .cvc-letter-choices {
        grid-template-columns: 1fr;
        flex-basis: 80px;
        padding: 5px;
        gap: 5px;
    }

    .letter-card {
        font-size: 1.5em;
    }

    .selection-options-container {
        flex-direction: column;
        align-items: center;
    }

    .hint-button {
        height: 38px;
        width: 60px;
        font-size: 0.9em;
    }
}

/* New styles for the word selection modal */
.selection-modal-overlay,
.help-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
    overflow: auto;
}

.selection-modal-content {
    background-color: #fff;
    color: #333;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 800px;
    position: relative;
    animation: fadeInScale 0.3s ease-out forwards;
    font-family: 'CustomMain', Arial, sans-serif;
    box-sizing: border-box;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 2em;
    font-weight: 600;
    color: #888;
    cursor: pointer;
    border: none;
    background: none;
    transition: color 0.2s ease;
}

.modal-close:hover {
    color: #333;
}

.modal-title {
    margin-top: 0;
    color: #5D5FEF;
    font-size: 1.8em;
    margin-bottom: 5px;
    text-align: center;
    font-weight: 600;
}

.modal-subtitle {
    margin: 0 0 20px 0;
    text-align: center;
    font-size: 1em;
    color: #666;
}

.word-selection-grid {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding: 10px;
}

.vowel-group-container {
    background-color: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    border: 1px solid #ddd;
}

.vowel-group-title {
    margin: 0 0 10px 0;
    color: #5D5FEF;
    font-size: 1.5em;
    border-bottom: 2px solid #5D5FEF;
    padding-bottom: 5px;
}

.words-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.word-select-item {
    padding: 8px 12px;
    background-color: #ecf0f1;
    border: 2px solid #ecf0f1;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: #555;
    transition: background-color 0.2s, transform 0.2s, border-color 0.2s;
    user-select: none;
}

.word-select-item:hover {
    background-color: #bdc3c7;
}

.word-select-item.selected {
    background: linear-gradient(90deg, #3498db, #2980b9);
    border: 2px solid #fff;
    color: #fff;
    transform: scale(1.05);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Make word items keyboard-focusable visible for accessibility */
.word-select-item:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 3px;
}

.modal-buttons-container {
    position: sticky;
    bottom: 0;
    z-index: 10;
    background-color: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    border-radius: 12px;
}

.modal-buttons-container button {
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: box-shadow 0.2s;
}

.modal-buttons-container button:hover {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}