/* Styles specific to Parts of Speech game */

@keyframes float-lightly {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-5px);
    }
}

/* 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;
}

@keyframes background-flash {

    0%,
    100% {
        background: linear-gradient(45deg, #2c3e50, #000000);
        box-shadow: none;
    }

    50% {
        background: #00d9ff;
        box-shadow: 0 0 20px #00d9ff;
    }
}

.parts-of-speech-game .game-area {
    background-image: url('../assets/images/parts-of-speech/parts-of-speech-background.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.parts-of-speech-game .game-elements-container .element-container {
    box-sizing: border-box;
    overflow: auto;
}

.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;
}

/* Ensure the elements container fills the available space so its children can cover it */
.game-elements-container {
    position: relative;
    width: 100%;
    height: 100%;
    flex: 1 1 auto;
}

/* Force progress bar to appear above the elements container and prevent vertical centering from pushing it down */
.game-area>.game-progress-bar {
    order: 0;
    align-self: stretch;
}

.game-area>.game-elements-container {
    order: 1;
    flex: 1 1 auto;
}

/* Mode containers for Words / Sentences modes - absolute so active one covers the game area */
.words-mode-container,
.sentences-mode-container {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.words-mode-container {
    background: transparent;
    color: #fff;
}

.sentences-mode-container {
    background: transparent;
    color: #fff;
}

.mode-placeholder {
    font-size: 1.4rem;
    font-weight: 700;
    padding: 12px 18px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
}

/* Words mode UI: eye and choices */
.words-ui {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding-top: 0;
    box-sizing: border-box;
}

/* Sentences mode: center the sentence plate, word plate, and choices vertically */
.sentences-ui {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 12px 20px;
    box-sizing: border-box;
}

.sentence-plate {
    max-width: 820px;
    min-width: 80%;
    padding: 20px 5px;
    border-radius: 12px;
    /* semi-transparent dark panel (uniform 50% opacity black) */
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0.5) 100%);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-right: 3px solid #ffffff;
    border-left: 3px solid #ffffff;
    box-shadow: inset 0 -6px 18px rgba(0, 0, 0, 0.35), 0 12px 30px rgba(0, 0, 0, 0.45);
    color: #fff;
    font-size: 1.15rem;
    line-height: 1.4;
    box-sizing: border-box;
    text-align: center;
    backdrop-filter: blur(6px);
}

/* Ensure sentence plate is above decorative layers like fireworks in select/sentences mode */
.sentences-mode-container .sentence-plate {
    position: relative;
    /* already set but reinforce stacking context */
    z-index: 10;
    /* above the fireworks layer (which uses z-index:1) */
}

/* Make sentence-plate support curtain animation similar to word plate */
.sentence-plate {
    position: relative;
    overflow: hidden;
}

.sentence-plate .curtain {
    position: absolute;
    top: 0;
    height: 100%;
    width: 50%;
    z-index: 10;
    transform: scaleX(0);
    transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.sentence-plate .left-curtain {
    left: 0;
    background-color: rgba(0, 0, 0, 0.98);
    transform-origin: left;
    box-sizing: border-box;
    border-right: 1px solid rgba(255, 255, 255, 0.95);
}

.sentence-plate .right-curtain {
    right: 0;
    background-color: rgba(0, 0, 0, 0.98);
    transform-origin: right;
    box-sizing: border-box;
    border-left: 1px solid rgba(255, 255, 255, 0.95);
}

.sentence-text {
    padding: 0 1rem;
    color: #fff;
}

.word-plate-center.blink {
    transform: scaleY(0.96);
    transition: transform 150ms linear;
}

.word-plate-center {
    position: relative;
    z-index: 2;
    padding: 6px 18px;
    border-radius: 6px;
    background: linear-gradient(180deg, #0b3a66, #07284a);
    color: #fff;
    font-weight: 700;
    font-family: 'CustomMain', Arial, sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
    height: 40px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.2);
}

.word-plate-center.hidden-during-audio {
    visibility: hidden;
}

.text-container {
    position: relative;
    width: 220px;
    height: 40px !important;
    min-height: 40px !important;
    max-height: 40px !important;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    border-radius: 8px;
    /* cool dark-blue gradient for the plate */
    background: linear-gradient(180deg, #03223e 0%, #001524 100%);
    color: #fff;
    font-size: 1.15rem;
    font-weight: 700;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    /* crisp white left/right borders as requested */
    border-left: 3px solid #ffffff;
    border-right: 3px solid #ffffff;
}

.text-content {
    padding: 0 1rem;
}

/* Prevent container or text fading during curtain animation */
.text-container,
.word-plate-center {
    transition: none !important;
}

/* Add consistent readable shadow to gameplay text */
.word-plate-center,
.text-content,
.sentence-plate,
.pos-choice-btn,
.pos-submit-btn,
.mode-placeholder,
.game-progress-bar .heart {
    text-shadow: 0 3px 8px rgba(0, 0, 0, 0.65), 0 1px 0 rgba(255, 255, 255, 0.03);
}

.curtain {
    position: absolute;
    top: 0;
    height: 100%;
    width: 50%;
    z-index: 10;
    transform: scaleX(0);
    transition: transform 0.6s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.left-curtain {
    left: 0;
    background-color: rgba(0, 0, 0, 0.98);
    transform-origin: left;
}

.right-curtain {
    right: 0;
    background-color: rgba(0, 0, 0, 0.98);
    transform-origin: right;
}

/* Add a single-pixel white outline on the inner edge of each curtain so
    when they close the outlines visually meet in the center */
.left-curtain {
    box-sizing: border-box;
    border-right: 1px solid rgba(255, 255, 255, 0.95);
}

.right-curtain {
    box-sizing: border-box;
    border-left: 1px solid rgba(255, 255, 255, 0.95);
}

.text-container.closed .curtain {
    transform: scaleX(1);
}

.waiting-overlay.fullscreen-overlay {
    /* make overlay fill its positioning container (game area); container should be positioned */
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001 !important;
    background: rgba(0, 0, 0, 0);
}

/* Overlay image that covers the container (game area) */
.waiting-overlay.fullscreen-overlay .overlay-image {
    position: relative;
    z-index: 1000 !important;
    /* center and size image to ~300x300 but allow responsiveness on small screens */
    width: 300px;
    height: 300px;
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    display: block;
    opacity: 0;
    transition: opacity 360ms ease;
}

.waiting-overlay.fullscreen-overlay .overlay-image.visible {
    opacity: 1;
}

.waiting-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    background: rgba(0, 0, 0, 0.35);
}

.spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top-color: #ffffff;
    animation: spin 800ms linear infinite;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

.choices-row {
    /* center buttons and let them size to their content without stretching */
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 0 12px;
    box-sizing: border-box;
    min-height: 84px;
    margin: 0 auto;
}

.pos-choice-btn {
    /* background removed so inline styles can set unique colors */
    color: #fff;
    font-size: 0.9rem;
    padding: 10px 12px;
    border-radius: 8px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    /* let button fit its content */
    max-width: 90%;
    /* avoid overflowing very small screens */
    text-align: center;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pos-choice-btn:hover {
    /* Non-moving hover: subtle brighten and deeper shadow without translating the element */
    filter: brightness(1.06);
    box-shadow: 0 8px 14px rgba(0, 0, 0, 0.28);
}

/* Find-mode sentence token buttons */
.find-word-btn {
    background: #2f2f2f;
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.06);
    padding: 8px 12px;
    margin: 0 0 5px 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    font-weight: 600;
    font-size: 0.9rem;
    letter-spacing: 0.2px;
    transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.find-word-btn:disabled {
    opacity: 0.8;
    cursor: default;
    transform: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

.find-word-btn:not(:disabled) {
    cursor: pointer;
}

.find-word-btn:not(:disabled):hover {
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
    outline: 1px solid #ffffff;
}

.find-word-btn:not(:disabled):active {
    /* no transform, keep subtle pressed appearance via box-shadow */
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.40);
}

/* Placeholder cell when fewer buttons are present to keep grid balanced (optional) */
.choice-placeholder {
    width: 100%;
    height: 100%;
    visibility: hidden;
}

/* Selected state for hard-mode multi-select */
.pos-choice-btn.selected {
    outline: 3px solid #ffffff;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.35);
}

/* Submit button for hard mode */
.pos-submit-btn {
    background: linear-gradient(90deg, #0d2633, #051219);
    color: #fff;
    padding: 8px 14px;
    border-radius: 8px;
    border: 1px solid #ffffff;
    font-weight: 800;
    cursor: pointer;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

.pos-submit-btn.hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

/* Reserve space and keep controls stable so showing/hiding submit doesn't shift layout */
.words-controls {
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}


/* Progress bar (copied from cvc-words to match appearance and position) */
.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 {
    background-color: transparent;
    /* transparent background as requested */
    border: none;
    /* remove borders */
    padding: 0;
    /* remove padding */
    height: 30px;
    /* fixed reduced height */
    border-radius: 999px;
    /* keep pill shape but constrained by height */
    justify-content: center;
    gap: 8px;
    align-items: center;
}

.game-progress-bar .heart {
    font-size: 2rem;
    /* user requested size */
    line-height: 1;
    color: #e11d48;
    /* red */
    text-shadow: 0 0 4px rgba(225, 29, 72, 0.2);
    transition: color 200ms ease, opacity 200ms ease, transform 160ms ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: auto;
    /* allow heart glyph to scale */
    filter: drop-shadow(0px 1px 6px black);
}

.game-progress-bar .heart.lost {
    color: #888888;
    /* gray when lost */
    opacity: 1;
    text-shadow: none;
    transform: scale(0.95);
}

/* Resize category boxes for parts of speech */
/* Category boxes stretch to fill grid cells */
.parts-of-speech-game .pos-box {
    width: 100%;
    height: 100%;
    white-space: normal;
    /* flexible padding and wrapping */
    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;
    /* allow breaking long lines */
    word-break: break-word;
    hyphens: auto;
    /* use Arial font for category labels */
    font-family: Arial, sans-serif;
    aspect-ratio: auto !important;
}

/* Base appearance for POS selection boxes (match vowel-team-box styles) */
.parts-of-speech-game .pos-box {
    background-color: #ccc;
    color: #555;
    aspect-ratio: 1 / 1;
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 12px;
    cursor: pointer;
    /* Reduced base font-size for larger screens (>768px) */
    font-size: clamp(0.95rem, 1.6vw, 1.15rem);
    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);
}

.parts-of-speech-game .pos-box.selected {
    background: linear-gradient(90deg, #3498db, #2980b9);
    color: #fff;
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Small hint shown in Words + Hard mode */
.pos-hint {
    display: none;
    /* toggled by JS */
    text-align: center;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 13px;
    font-weight: 700;
    color: #111111;
    opacity: 1;
    margin: 0 auto;
    max-width: 460px;
    background: linear-gradient(90deg, #fff9d6 0%, #fff4b3 100%);
    padding: 6px 10px;
    border-radius: 8px;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(0, 0, 0, 0.10);
}

.parts-of-speech-game .pos-box:hover:not(.selected) {
    background-color: #bbb;
    transform: scale(1.03);
}

/* Styles for the pre-game hint modal (Words + Hard) */
.pos-prehint-modal {
    position: fixed;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    z-index: 9999;
}

.pos-prehint-hidden {
    display: none;
}

.pos-prehint-visible {
    display: flex;
}

.pos-prehint-content {
    background: #fff;
    color: #111;
    max-width: 320px;
    padding: 18px 22px;
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
    text-align: center;
    font-family: Arial, Helvetica, sans-serif;
}

.pos-prehint-text {
    margin-bottom: 14px;
    font-weight: 700;
    font-size: 15px;
}

.pos-prehint-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.pos-prehint-ok {
    padding: 8px 14px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #0b74de;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

/* (Removed checkbox styles - modal no longer includes checkbox) */
/* Slightly reduce box width on larger screens to respect grid gaps */
@media (min-width: 601px) {
    .parts-of-speech-game .pos-box {
        width: 95%;
        margin: 0 auto;
    }
}

/* Responsive grid for parts-of-speech selection */
.pos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: minmax(80px, auto);
    gap: 10px;
    width: 100%;
}

/* Mobile override: smaller row height for selection grid */
@media (max-width: 600px) {
    .pos-grid {
        grid-auto-rows: 60px;
    }
}

/* Mobile font-size adjustment */
@media (max-width: 600px) {
    .parts-of-speech-game .pos-box {
        font-size: clamp(0.7rem, 2vw, 1.1rem);
    }
}

/* Tweak choices grid for very small screens */
@media (max-width: 480px) {
    .choices-row {
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
        padding: 0 8px;
    }

    .text-container {
        width: 200px;
    }
}

/* Make find-mode word buttons slightly larger on medium+ screens */
@media (min-width: 769px) {

    /* For screens wider than 768px, increase .find-word-btn font size to 1rem */
    .find-word-btn {
        font-size: 1rem;
    }
}

/* Slightly larger gameplay typography on larger screens */
@media (min-width: 900px) {
    .text-content {
        font-size: 1.25rem;
    }

    .word-plate-center {
        font-size: 1.25rem;
        height: 64px;
    }

    .sentence-plate {
        font-size: 1.15rem;
        padding: 20px 5px;
    }

    .pos-choice-btn {
        font-size: 1rem;
        padding: 12px 16px;
    }

    .pos-submit-btn {
        font-size: 1rem;
        padding: 10px 16px;
    }
}

@media (min-width: 1200px) {
    .text-content {
        font-size: 1.4rem;
    }

    .word-plate-center {
        font-size: 1.4rem;
        height: 72px;
    }

    .sentence-plate {
        font-size: 1.3rem;
        padding: 20px 5px;
    }

    .pos-choice-btn {
        font-size: 1.05rem;
        padding: 14px 18px;
    }

    .pos-submit-btn {
        font-size: 1.05rem;
        padding: 12px 18px;
    }
}

/* On small screens, move the toggle controls under the button-group and center them */
@media (max-width: 600px) {
    .parts-of-speech-game .selection-controls {
        display: flex;
        flex-direction: column-reverse;
        /* keep button-group visually above toggles */
        align-items: stretch;
        gap: 8px;
        width: 100%;
        box-sizing: border-box;
        padding: 0 6px;
    }

    /* Keep the button-group on the right */
    .parts-of-speech-game .selection-controls .button-group {
        width: 100%;
        display: flex;
        justify-content: flex-end;
        /* right-align buttons */
        gap: 8px;
        box-sizing: border-box;
    }

    /* Place toggle row under button-group and align left */
    .parts-of-speech-game .selection-controls .toggles-row {
        display: flex;
        justify-content: flex-start;
        /* left-align toggles */
        gap: 8px;
        width: 100%;
        box-sizing: border-box;
        align-items: center;
    }
}

/* Mobile: slightly smaller hearts to fit compact header bars */
@media (max-width: 600px) {
    .game-progress-bar .heart {
        font-size: 1.6rem;
    }
}


/* Parts of Speech specific styles (keyboard, text/audio, and progress bar not used) */

/* Inline warning styling for POS type 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;
    }
}
