/* Definition modal styles */
.definition-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.definition-modal .modal-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    position: relative;
}

.definition-modal .close-button {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    cursor: pointer;
}

/* Word list grid inside the vocab selection modal */
#select-words-modal .words-list {
    margin-top: 5px;
}

/* Modal control buttons (Select All / Clear / Done) */
#select-words-modal button#select-all,
#select-words-modal button#clear-all,
#select-words-modal button#done {
    background: #3b82f6;
    /* blue */
    color: #ffffff;
    /* white text */
    border: none;
    padding: 6px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

#select-words-modal button#select-all:hover,
#select-words-modal button#clear-all:hover,
#select-words-modal button#done:hover {
    background: #2563eb;
}

#select-words-modal button#select-all:focus-visible,
#select-words-modal button#clear-all:focus-visible,
#select-words-modal button#done:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 3px;
    box-shadow: none;
}

/* Close button in the select-words modal: red background */
#select-words-modal .close-button {
    background: #ef4444;
    /* red */
    color: #fff;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}

#select-words-modal .close-button:hover {
    background: #dc2626;
}

#select-words-modal .close-button:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 3px;
    box-shadow: none;
}

@keyframes background-flash {

    0%,
    100% {
        background: linear-gradient(45deg, #2c3e50, #000000);
        box-shadow: none;
    }

    50% {
        background: #00d9ff;
        box-shadow: 0 0 20px #00d9ff;
    }
}


/* Game area background */
.game-area {
    background-image: url('../assets/images/vocab-flashcards/flashcards-bg.png');
}

/* Layout for game-area sub-containers */

/* Bring containers above game-area background and add border */
.progress-bar-container {
    position: relative;
    z-index: 10;
}

/* Ensure game elements layout */

/* Vertical layout for main game elements */
.game-elements-container {
    display: flex;
    flex-direction: column;
    height: 95%;
}

/* Ensure progress bar has minimum height */
.progress-bar-container {
    /* fixed height for progress bar */
    height: 30px;
    min-height: 30px;
    position: relative;
    overflow: visible;
    /* allow rabbit/turtle to show off-screen */
}

/* Place the main game elements above other background layers but below UI chrome */
.game-elements-container {
    z-index: 5;
    position: relative;
}

.game-elements-container .image-display {
    /* Make image display vertically flexible */
    flex: 1 1 auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: linear-gradient(145deg, #00000063, #00000063);
}

/* Make drop zone height fit content, not fixed percentage */

.game-elements-container .text-display {
    flex: 0 0 auto;
    height: fit-content;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.game-elements-container .control-and-answer-btns {
    flex: 0 0 20%;
    height: 20%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
}

@media (max-width: 600px) {
    .game-elements-container .control-and-answer-btns {
        height: 25%;
    }
}

.image-display img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.image-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(0, 0, 0, 0.5);
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    padding: 12px;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

/* Text display styling */
.text-display {
    background: rgba(255, 255, 255, 80%);
    padding: 4px;
    box-sizing: border-box;
    min-height: 60px;
    flex-direction: column;
    gap: 6px;
    justify-content: center;
}

.text-display .drop-placeholder {
    color: rgba(0, 0, 0, 0.5);
    font-style: italic;
}

/* Ensure these styles apply even if  wrapper is missing */
.game-elements-container .text-display .drop-placeholder,
.text-display .drop-placeholder {
    color: rgba(0, 0, 0, 0.6);
    font-style: italic;
}

.text-display .text-line {
    font-size: clamp(1.2rem, 2.8vw, 2rem);
    font-weight: 700;
    color: #0f172a;
    text-align: center;
}

.control-and-answer-btns {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    max-width: 620px;
    margin: 0 auto;
}

.control-and-answer-btns[data-layout="phase-a"]>* {
    flex: 0 1 auto;
}

.control-and-answer-btns[data-layout="phase-b"] {
    align-items: center;
}

.control-and-answer-btns[data-layout="phase-b"]>.answer-button {
    flex: 1 1 calc(33.333% - 18px);
    max-width: calc(33.333% - 18px);
    min-width: 88px;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
}

/* Quiz mode: allow buttons to be their natural width, only wrap when necessary */
.control-and-answer-btns[data-layout="phase-b"][data-mode="quiz"]>.answer-button {
    flex: 0 1 auto;
    max-width: none;
}

.next-button,
.answer-button {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    border: none;
    border-radius: 10px;
    color: #fff;
    padding: clamp(6px, 1.2vw, 10px) clamp(10px, 3vw, 18px);
    font-size: clamp(0.82rem, 2.4vw, 1rem);
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 12px rgba(37, 99, 235, 0.2);
    transition: background 0.15s ease, box-shadow 0.15s ease;
    min-height: 32px;
}

.next-button:hover,
.answer-button:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    box-shadow: 0 8px 16px rgba(30, 64, 175, 0.28);
}

.next-button:active,
.answer-button:active {
    background: linear-gradient(135deg, #1e3a8a, #1d4ed8);
    box-shadow: 0 4px 10px rgba(29, 78, 216, 0.25);
}

.answer-button.correct {
    background: linear-gradient(135deg, #16a34a, #15803d);
    box-shadow: 0 6px 12px rgba(22, 163, 74, 0.3);
}

.answer-button.incorrect {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    box-shadow: 0 6px 12px rgba(220, 38, 38, 0.3);
}

.answer-button:disabled {
    cursor: default;
    opacity: 0.85;
}

.speaker-button {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border: none;
    border-radius: 10px;
    color: #fff;
    padding: clamp(6px, 1.2vw, 10px) clamp(9px, 2.4vw, 14px);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    cursor: pointer;
    box-shadow: 0 6px 12px rgba(217, 119, 6, 0.18);
    transition: background 0.15s ease, box-shadow 0.15s ease;
    min-height: 32px;
}

.speaker-button svg {
    display: block;
}

.speaker-button:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    box-shadow: 0 8px 16px rgba(180, 83, 9, 0.28);
}

.speaker-button:active {
    background: linear-gradient(135deg, #b45309, #92400e);
    box-shadow: 0 4px 10px rgba(146, 64, 14, 0.24);
}

/* Scale the emoji icon visually without changing button layout (transform doesn't affect layout) */
.speaker-button .speaker-emoji {
    display: inline-block;
    font-size: 18px;
    /* base size before scaling */
    line-height: 1;
    transform: scale(1.2);
    transform-origin: center;
    vertical-align: middle;
}

/* Tile and keyboard styles are defined in each game's CSS file */

.game-area {
    /* Generic game area style if needed, specific background handled above */
    position: relative;
    flex-grow: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}



/* Responsive grid for topic tiles */


.grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: minmax(80px, auto);
    gap: 10px;
    width: 100%;
    /* limit vertical growth so page chrome (start button / ads) remain visible */
    max-height: 300px;
    overflow: auto;
    overflow-x: hidden;
    padding: 5px;
}


/* Game visual assets and progress bar styles */

.progress-bar-container,
#progressBarContainer {
    background: transparent;
    position: relative;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 3px 0;
    height: 20px;
    min-height: 20px;
}

.progress-bar-container::before,
#progressBarContainer::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: repeating-linear-gradient(to right,
            #fff,
            #fff 20px,
            rgba(255, 255, 255, 0) 20px,
            rgba(255, 255, 255, 0) 40px);
    transform: translateY(-50%);
}

/* New progress road: two colors meet in the middle. The left side percent
   is set via the --left CSS variable by JS (e.g. --left: 60%). */
.progress-bar-container .progress-road,
#progressBarContainer .progress-road {
    width: 100%;
    height: 125%;
    overflow: hidden;
    position: relative;
    background: linear-gradient(to right, #3b82f6 0%, #3b82f6 var(--left, 50%), #ef4444 var(--left, 50%), #ef4444 100%);
}

/* Progress pusher image styling */
.progress-bar-container .progress-road .progress-pusher,
#progressBarContainer .progress-road .progress-pusher {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    height: 35px;
    width: auto;
    z-index: 10;
    pointer-events: none;
    filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.3));
    transition: left 0.3s ease-out;
}

/* Vehicle-specific rules are kept in each game's CSS; this file defines vocab visuals */

/* Inline warning styling for category selection */
.category-warning {
    color: #e74c3c;
    font-size: 0.9rem;
    margin-top: 4px;
    text-align: center;
    animation: fadeInOut 2s ease;
}

.warning-border {
    border: 2px solid #e74c3c !important;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
    }

    10% {
        opacity: 1;
    }

    90% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

/* Styles for topic tiles */
.topics-box {
    background-color: #ccc;
    color: #555;
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    cursor: pointer;
    font-size: clamp(1em, 3vw, 1.8em);
    font-weight: 600;
    font-family: 'CustomMain', Arial, sans-serif;
    text-transform: uppercase;
    transition: background-color 0.2s ease, transform 0.1s ease;
    user-select: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    position: relative;
}

/* Info button styling to mirror parts-of-speech selection */
.topics-box .info-button {
    position: absolute;
    top: -8px;
    right: -8px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
    cursor: pointer;
}

.selection-screen * {
    /* Alias placeholder rules to preserve specificity for selection screen */
    grid-auto-rows: 60px;
}

.topics-box.selected {
    background: linear-gradient(90deg, #3498db, #2980b9);
    color: #fff;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.topics-box:hover:not(.selected) {
    background-color: #bbb;
    transform: scale(1.03);
}

/* Ensure grid cells size similarly to original selection boxes */
.topics-box,
.topics-box {
    width: 100%;
    height: 100%;
    white-space: normal;
    padding: clamp(5px, 1vw, 10px);
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    font-size: clamp(0.8rem, 2vw, 1.1rem);
    line-height: 1.2;
    word-break: break-word;
    hyphens: auto;
    font-family: Arial, sans-serif;
    aspect-ratio: auto !important;
}

/* Ensure topic tiles use capitalization regardless of global rules */
.topics-box {
    text-transform: capitalize !important;
}

@media (min-width: 601px) {
    .topics-box {
        width: 95%;
        margin: 0 auto;
    }
}

/* Word card keyboard focus ring inside topic modal */
.word-card {
    position: relative;
    outline: none;
}

.word-card:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 3px;
}
