/* Import local custom fonts */
@font-face {
    font-family: 'CustomTitle';
    src: url('./fonts/title.otf') format('opentype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'CustomMain';
    src: url('./fonts/all.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
    font-display: swap;
}

/* =================================== */
/* 1. GLOBAL STYLES (Body, Header, Footer) */
/* =================================== */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'CustomMain', Arial, sans-serif;
    color: #333;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    
    /* lighter night-sky gradient matching header colors */
    background: linear-gradient(-45deg, #2c506eff, #0b2a4aff);
    background-size: 400% 400%;
    animation: bodyGradient 30s ease infinite;
}

@keyframes bodyGradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: auto;
    padding: 0; 
}

/* Header Styling */
header {
    color: #fff;
    padding: 5px 0;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    flex-shrink: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    
    /* night sky background */
    background: radial-gradient(circle at 25% 20%, #0b2a4a 0%, #07122a 30%, #020617 100%);
    color: #fff;
    background-size: cover;
}

/* gradientShift keyframes removed; header uses a static gradient now */

header .container {
    padding: 10px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    z-index: 4; 
}

header .title-group {
    text-align: center;
    flex-grow: 0;            /* Prevent full-width expansion */
    display: inline-block;   /* Shrink-wrap to content */
    max-width: fit-content;  /* Ensure content-fit width */
    position: relative;
}

/* Playful multicolor title letters */
.title-letter { display: inline-block; font-weight: 900; font-size: 1.15em; line-height: 1; transition: transform 220ms cubic-bezier(.2,.8,.2,1); }
/* lighter, playful palette: blue, green, pink, purple */
.title-letter:nth-child(5n+1){ color:#6ec8ff; } /* light blue */
.title-letter:nth-child(5n+2){ color:#8ff0a0; } /* light green */
.title-letter:nth-child(5n+3){ color:#ffb6e6; } /* pink */
.title-letter:nth-child(5n+4){ color:#d3b3ff; } /* purple */
.title-letter:nth-child(5n+5){ color:#ffe59e; } /* light yellow */

/* wave animation: letters pop left-to-right every 4s */
@keyframes letterPop {
    0% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 0 rgba(0,0,0,0)); }
    30% { transform: translateY(-10px) scale(1.12); filter: drop-shadow(0 8px 12px rgba(0,0,0,0.12)); }
    100% { transform: translateY(0) scale(1); filter: drop-shadow(0 0 0 rgba(0,0,0,0)); }
}

/* Use JS to trigger the pop effect every 5s; keep CSS as the visual state for the pop */
.title-letter { transition: transform 700ms cubic-bezier(.2,.8,.2,1), filter 700ms ease; }

/* Pop state applied by JS */
.title-letter.pop { transform: translateY(-10px) scale(1.12); filter: drop-shadow(0 8px 12px rgba(0,0,0,0.12)); }

@media (prefers-reduced-motion: reduce) {
    .title-letter { transition: none; animation: none; transform: none; }
}

header h1 {
    margin: 0;
    font-family: 'CustomTitle', Arial, sans-serif;
    font-size: 2.5em; 
    font-weight: 700;
    color: #fff; 
    text-shadow: 3px 3px 6px rgba(0,0,0,1);
    /* Disabled the flash effect to keep title fully opaque */
    animation: none;
    position: relative;
    z-index: 10;
}

@keyframes textFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

header p {
    font-family: 'CustomTitle', Arial, sans-serif;
    font-size: 1.1em;
    margin-top: 5px;
    font-weight: 400;
    text-shadow: 2px 2px 4px rgba(0,0,0,1);
    position: relative;
    z-index: 10;
}

/* Header decorative images and animations have been removed.
    The image files under assets/images/main-header/ are left intact in the repo.
    This keeps the header text (`header h1`, `header p`) and the `.back-button` styles unchanged.
*/

/* Subtle vignette + noise overlay (static, accessibility-friendly)
   - non-animated vignette to focus content
   - tiny SVG noise used as a faint texture via data-URI
   - keeps z-index below title (title has z-index:10) and does not affect .back-button (z-index:20)
*/
header::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 3; /* below header text (z-index:10) and back-button (z-index:20) */
    background-image:
        radial-gradient(ellipse at center, rgba(255,255,255,0) 0%, rgba(0,0,0,0.06) 55%, rgba(0,0,0,0.12) 100%),
        linear-gradient(135deg, rgba(255,255,255,0.02) 0%, rgba(255,255,255,0) 50%, rgba(255,255,255,0.02) 100%),
        url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence baseFrequency='0.9' numOctaves='1' stitchTiles='stitch' seed='2'/></filter><rect width='100%' height='100%' filter='url(%23n)' opacity='0.07' fill='white'/></svg>");
    background-size: cover, cover, 120px 120px;
    background-repeat: no-repeat, no-repeat, repeat;
    mix-blend-mode: multiply;
}

/* Decorative side bubbles (left + right). Transparent, different sizes, slight zoom in/out.
   They are constrained to the sides via width and do not appear in the middle. */
header .container::before,
header .container::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
     /* widen side columns so decorative letters fill more of each side while
         leaving the center area clear (50% + 50% meet at center) */
     width: 50%;
    pointer-events: none;
    z-index: 4; /* below header title (z-index:10) and back-button (z-index:20) */
    filter: none;
     /* use a single SVG per side (set by JS) instead of tiling; CSS variables allow JS to inject
         a randomized data-URI for each side. Fallbacks keep previous visuals if JS is disabled. */
     background-image: var(--side-fallback, none);
     background-repeat: no-repeat;
     background-position: center top;
     background-size: 100% 100%;
    transform-origin: center;
    transition: opacity 0.25s ease;
    opacity: 1;
}
/* left side */
header .container::before {
    left: 0;
    /* floating blurred letters (denser set) */
    /* left side background is set via --left-bg by JS; fallback kept in --side-fallback */
    background-image: var(--left-bg, var(--side-fallback));
    background-position: left center;
    background-size: 100% 100%;
}

/* right side */
header .container::after {
    right: 0;
    /* floating blurred letters (denser set, different scatter) */
    /* right side background is set via --right-bg by JS; fallback kept in --side-fallback */
    background-image: var(--right-bg, var(--side-fallback));
    background-position: right center;
    background-size: 100% 100%;
}

/* New full-width header-side container (used when JS injects .header-sides)
   This element sits behind the title but stretches to the full header width
   so left/right decorations can reach the viewport edges. */
.header-sides {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 3; /* below header text (z-index:10) */
    overflow: hidden;
}
.header-sides .side {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 50%;
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;
    /* subtle blur and slightly reduced opacity for a soft, out-of-focus effect */
    filter: blur(1.6px);
    opacity: 0.95;
    transition: filter 250ms ease, opacity 250ms ease;
}
.header-sides .side.left { left: 0; }
.header-sides .side.right { right: 0; }

/* Style dropdown options for vowel teams (where browser supports option styling) */
select#vowel-type-select {
    padding: 6px 10px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.15);
    background-color: rgba(0,0,0,0.35); color: #fff; backdrop-filter: blur(4px);
}
select#vowel-type-select option.vowel-type-option {
    color: #fff; padding: 6px 8px;
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    header .container::before,
    header .container::after {
    animation: none;
    opacity: 0.95; /* keep static stars subtle */
    }
}


/* Back Button */
.back-button {
    position: absolute; left: 20px; top: 50%;
    background-color: transparent; backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.3); cursor: pointer;
    border-radius: 50%; z-index: 20; width: 45px; height: 45px;
    transition: transform 0.2s ease, background-color 0.2s ease;
    transform: translateY(-50%);
    background-image: url('../assets/images/main-header/back-button.png');
    background-size: 60%; background-position: center; background-repeat: no-repeat;
    filter: invert(0) drop-shadow(1px 1px 2px rgba(0,0,0,0.7));
}
.back-button:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}
.back-button-home {
    display: none !important;
}

/* Footer Styling */
footer {
    background: #494D5F;
    color: #fff;
    text-align: center;
    padding: 3px 0;
    flex-shrink: 0;
    font-size: 0.8em;
    font-family: 'CustomTitle', Arial, sans-serif;
    font-weight: normal;
}
footer .container { padding: 5px 0; }

.footer-content {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
}

.copyright-text {
    margin-right: 15px;
}

.footer-links a {
    color: #fff; margin: 0 8px;
    transition: color 0.2s ease; font-weight: normal;
}
.footer-links a:hover { color: #a9b7ff; }


/* =================================== */
/* 2. LAYOUT & AD STYLES */
/* =================================== */
main {
    flex-grow: 1; padding: 20px 0; display: flex;
    justify-content: center; align-items: flex-start; gap: 20px;
}
.main-content-wrapper {
    display: flex; flex-direction: column;
    gap: 20px; flex-grow: 1; max-width: 800px;
}
.game-page-content-wrapper {
    display: flex; flex-direction: column; flex-grow: 1;
    max-width: 960px; gap: 20px; height: 100%;
}

.sidebar-ad {
    background: transparent;
    padding: 15px;
    border: 1px dashed rgba(204,204,204,0.6);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.06);
    border-radius: 12px;
    width: 160px;
    height: 600px;
    flex-shrink: 0;
    position: -webkit-sticky;
    position: sticky;
    top: 20px;
    align-self: flex-start;
}

.inline-ad {
    background: transparent;
    padding: 15px;
    border: 1px dashed rgba(204,204,204,0.6);
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.06);
    border-radius: 12px;
    min-height: 90px;
}
/* New CSS to handle inline ads inside the game grid on larger screens */
.game-grid > .inline-ad {
    width: 100%;
    margin: 20px 0;
    box-sizing: border-box;
}

.sidebar-ad p {
    color: #888;
    font-style: italic;
    word-break: break-all;
}

.inline-ad p {
    color: #888;
    font-style: italic;
    word-break: break-all;
}


/* =================================== */
/* 3. HOMEPAGE GRID */
/* =================================== */
.game-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px; background: transparent; padding: 20px;
    border-radius: 12px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.game-grid-item-content {
    background: #f8f9fa; border: 1px solid #ddd; padding: 30px;
    text-align: center; border-radius: 12px; min-height: 250px;
    display: flex; flex-direction: column; justify-content: center;
    align-items: center; font-weight: 600; color: #555;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer; height: 100%; box-sizing: border-box;
    position: relative; overflow: hidden;
}
.game-grid-item-content:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.game-grid-item-content h3 {
    margin: 0 0 10px 0; color: #5D5FEF;
    font-size: 1.4em; font-weight: 600;
}
.game-grid-item-content p {
    font-size: 0.9em; color: #666; font-weight: 400;
}
.card-with-bg {
    background-image: url('../assets/images/alphabet-balloons/alphabet-card.png');
    background-size: cover; background-position: center;
    justify-content: center; padding: 20px;
}
.game-grid-item-content[class$="-bg"]::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.2);
    z-index: 1;
}
/* =================================== */
/* 4. FORCE HEADER ELEMENTS OPAQUE (refactored: only text elements kept)
   Decorative pseudo-elements were removed during refactor. */
header,
header h1,
header p {
    opacity: 1 !important;
}
.card-match-bg {
    background-image: url('../assets/images/alphabet-match/alphabet-match-card.png');
    background-size: cover; background-position: center;
    justify-content: center; padding: 20px;
}
.card-cvc-bg {
    background-image: url('../assets/images/cvc-words/cvc-words-card.png');
    background-size: cover; background-position: center;
    justify-content: center; padding: 20px;
}
.card-vowel-teams-bg {
    background-image: url('../assets/images/vowel-teams/vowel-teams-card.png');
    background-size: cover; background-position: center;
    justify-content: center; padding: 20px;
}
.card-text-container {
    position: relative; z-index: 2;
    background-color: rgba(11, 42, 74, 0.7);
    backdrop-filter: blur(9px); -webkit-backdrop-filter: blur(9px);
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-radius: 12px; padding: 20px;
    width: auto; display: inline-block;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}
.card-text-container h3, .card-text-container p {
    color: #fff; text-shadow: 3px 3px 6px rgba(0,0,0,0.9);
}
.card-text-container h3 { margin-bottom: 10px; font-weight: 700; }
.card-text-container p { margin-bottom: 0; font-weight: 500; }


/* =================================== */
/* 4. GENERIC GAME STYLES (Containers, Modals, UI) */
/* =================================== */
.game-container {
    flex-grow: 1; background: #222; color: #fff;
    padding: 20px; border-radius: 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    display: flex; flex-direction: column;
    justify-content: flex-start; align-items: center;
    text-align: center; font-size: 1.2em; font-weight: 600;
    min-height: 400px; position: relative;
    overflow: hidden; gap: 20px;
}
.game-area::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 0;
}
.game-buttons {
    display: flex; justify-content: space-between;
    width: 95%; max-width: 700px; flex-shrink: 0;
    position: relative; z-index: 1;
}
.help-button {
    background-color: #333; color: #fff; border: none;
    width: 50px; height: 50px; border-radius: 50%;
    cursor: pointer; font-size: 1.8em; font-weight: 600;
    transition: background-color 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    display: flex; justify-content: center; align-items: center;
}
.help-button:hover { background-color: #555; }
.start-game-button {
    background: linear-gradient(90deg, #3498db, #2980b9); color: #fff;
    border: 2px solid #fff;
    padding: 15px 30px; border-radius: 12px; cursor: pointer;
    font-size: 1.5em; font-weight: 600;
    font-family: 'CustomMain', Arial, sans-serif;
    transition: background-color 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.4);
}
.start-game-button:hover:not(:disabled) { background: linear-gradient(90deg, #2980b9, #2471a3); }
.start-game-button:disabled {
    background: #555; cursor: not-allowed; opacity: 0.7;
    border: 2px solid #fff;
}
.game-over-screen {
    display: none; position: absolute; top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8); color: #fff; flex-direction: column;
    justify-content: center; align-items: center; z-index: 10;
    text-align: center; gap: 20px; padding: 20px; box-sizing: border-box;
}
.game-over-screen h2 { font-size: 3em; margin-bottom: 10px; color: #2ECC71; }
.game-over-screen p { font-size: 1.8em; margin-bottom: 20px; }
.game-over-screen button {
    background: linear-gradient(90deg, #3498db, #2980b9);
    color: #fff;
    border: 2px solid #fff;
    padding: 15px 30px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.5em;
    font-weight: 600;
    font-family: 'CustomMain', Arial, sans-serif;
    transition: background-color 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.4);
}
.game-over-screen button:hover { background: linear-gradient(90deg, #2980b9, #2471a3); }
.star-rating {
    display: flex; gap: 5px; margin-bottom: 15px;
}
.star { font-size: 2.5em; color: #555; transition: color 0.3s ease; }
.star.filled { color: #f1c40f; }

/* Help Modal */
.help-modal-overlay {
    display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7); z-index: 1000; justify-content: center;
    align-items: center; backdrop-filter: blur(5px); overflow: auto;
}
.help-modal-content {
    background-color: #fff; color: #333; padding: 30px; border-radius: 12px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3); width: 90%; max-width: 500px;
    position: relative; animation: fadeInScale 0.3s ease-out forwards; text-align: left;
    font-family: 'CustomMain', Arial, sans-serif;
    box-sizing: border-box; max-height: 90vh; overflow-y: auto;
}
@keyframes fadeInScale { from { opacity: 0; transform: scale(0.9); } to { opacity: 1; transform: scale(1); } }
.help-modal-content h3 { margin-top: 0; color: #5D5FEF; font-size: 1.8em; margin-bottom: 20px; text-align: center; font-weight: 600; }
.help-modal-content ul { list-style: none; padding: 0; margin: 0; }
.help-modal-content ul li {
    margin-bottom: 15px; font-size: 1.1em; line-height: 1.3; display: block;
    position: relative; padding-left: 25px; word-wrap: break-word;
}
.help-modal-content ul li::before {
    content: '■';
    color: red;
    font-size: 1em;
    position: absolute;
    left: 0;
    top: 0;
}
.help-modal-content ul li strong { color: #5D5FEF; display: inline; font-weight: 600; }
.help-modal-content ul li span.explanation { display: block; font-size: 0.9em; color: #555; line-height: 1.3; font-weight: 400; }
.help-modal-content .red-bold { color: #dc3545; font-weight: 600; }
.help-modal-close {
    position: absolute; top: 15px; right: 15px; font-size: 1.8em;
    font-weight: 600; color: #888; cursor: pointer; border: none; background: none; transition: color 0.2s ease;
}
.help-modal-close:hover { color: #333; }

/* In-game UI common elements (header, score, timer, buttons) */
.game-play-screen {
    display: none;
    flex-direction: column; width: 100%; height: 100%;
    position: absolute; top: 0; left: 0; background-color: transparent;
    justify-content: flex-start; align-items: center;
    color: #fff; overflow: hidden; z-index: 1;
}
.game-header-ui {
    width: 100%; display: flex; justify-content: space-between;
    align-items: center; padding: 8px 15px; box-sizing: border-box;
    background: linear-gradient(90deg, rgba(0, 90, 194, 1) 0%, rgba(13, 55, 122, 1) 50%, rgba(0, 125, 150, 1) 100%);
    z-index: 5; margin-bottom: 0; box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
.game-header-left, .game-header-right { display: flex; align-items: center; gap: 10px; }
.mute-button {
    background-color: #fff; color: #333; border: 1px solid #ddd;
    width: 44px; height: 44px; box-sizing: border-box; border-radius: 12px;
    cursor: pointer; font-size: 1.5em;
    transition: color 0.2s ease, background-color 0.2s ease;
    position: relative; overflow: hidden;
    display: flex; justify-content: center; align-items: center;
}
.mute-button:hover { background-color: #f0f0f0; }
.mute-button.muted { color: #ccc; }
.mute-button.muted::after {
    content: ''; position: absolute; top: 50%; left: -10%;
    width: 120%; height: 3px; background-color: #dc3545;
    transform: rotate(-45deg); transform-origin: center;
}
.score-display, .timer-display {
    display: flex; align-items: center; justify-content: center;
    height: 44px; box-sizing: border-box; padding: 5px 15px;
    border-radius: 12px; font-size: 1.4em; font-weight: 600;
    color: #fff; white-space: nowrap; transition: background-color 0.3s ease;
}
.score-display { background-color: #6c757d; }
.target-letter-display {
    background-color: #9b59b6; width: 44px; height: 44px;
    display: flex; justify-content: center; align-items: center;
    border-radius: 12px; font-size: 1.8em; text-transform: uppercase;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.7); animation: flash 0.5s infinite ease-in-out;
}
@keyframes flash { 50% { background-color: #be8ad0; transform: scale(1.05); } }
.timer-display { background-color: #3498db; }
.timer-display.paused { background-color: #f39c12; }
.close-game-button {
    background-color: #dc3545; color: #fff; border: none;
    width: 44px; height: 44px; box-sizing: border-box; border-radius: 12px;
    cursor: pointer; font-size: 1.8em; font-weight: 600;
    transition: background-color 0.2s ease;
    display: flex; justify-content: center; align-items: center;
    padding: 0; line-height: 1;
}
.close-game-button:hover { background-color: #c82333; }
.pause-button {
    background-color: #f39c12; color: #fff; border: none;
    width: 44px; height: 44px; box-sizing: border-box; border-radius: 12px;
    cursor: pointer; transition: background-color 0.2s ease;
    display: flex; justify-content: center; align-items: center;
    padding: 0; gap: 4px;
}
.pause-button:hover { background-color: #e67e22; }
.pause-icon {
    display: block; width: 4px; height: 16px;
    background-color: #fff; border-radius: 2px;
    box-shadow: 1px 1px 2px rgba(0,0,0,0.4);
}
.play-icon {
    display: none; width: 0; height: 0;
    border-top: 10px solid transparent; border-bottom: 10px solid transparent;
    border-left: 16px solid white; margin-left: 4px;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.5));
}
.pause-button.paused .pause-icon { display: none; }
.pause-button.paused .play-icon { display: block; }
.countdown-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background-color: rgba(0, 0, 0, 0.7); display: none;
    justify-content: center; align-items: center; z-index: 20;
    color: #fff; font-size: 8em; font-weight: 700;
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}
#countdownNumber { animation: countdownScale 1s linear forwards; }
@keyframes countdownScale {
    0% { transform: scale(1.5); opacity: 0; }
    50% { transform: scale(1); opacity: 1; }
    100% { transform: scale(0.8); opacity: 0; }
}

/* Common selection screen styles */
.game-container.selection-active {
    background: linear-gradient(-45deg, #2c3e50, #3498db, #2c3e50);
}
.letter-selection-screen {
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 12px;
    padding: 20px;
    width: 95%;
    max-width: 700px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
    flex-grow: 1;
    position: relative;
    z-index: 1;
    backdrop-filter: blur(5px);
}
.selection-title {
    background: linear-gradient(90deg, #3498db, #2980b9); color: #fff; padding: 10px 25px;
    border-radius: 12px; font-size: 1.5em; font-weight: 600;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2); text-transform: uppercase;
    letter-spacing: 1px; border: none; margin: 0;
}
.letter-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(40px, 1fr));
    gap: 10px; width: 100%;
}
.letter-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);
}
.letter-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);
}
.letter-box:hover:not(.selected) {
    background-color: #bbb; transform: scale(1.03);
}

/* Vowel Teams box styles (same as .letter-box) */
.vowel-team-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);
}
.vowel-team-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);
}
.vowel-team-box:hover:not(.selected) {
    background-color: #bbb; transform: scale(1.03);
}
.selection-controls {
    display: flex; justify-content: space-between;
    align-items: center; width: 100%; padding: 0 10px;
}
.select-all-button {
    background-color: #9b59b6; color: #fff; border: none;
    padding: 10px 15px; border-radius: 8px; cursor: pointer;
    font-size: 1em; font-weight: 600;
    transition: background-color 0.2s ease;
}
.select-all-button:hover { background-color: #8e44ad; }
.toggle-container { display: flex; align-items: center; gap: 8px; }
.toggle-label { font-size: 1em; font-weight: 500; color: white; cursor: pointer; }
.toggle-checkbox { opacity: 0; width: 0; height: 0; }
.toggle-checkbox + .toggle-label::before {
    content: ''; display: inline-block; width: 40px; height: 22px;
    border-radius: 11px; background-color: #ccc;
    transition: background-color 0.2s ease; vertical-align: middle; margin-right: 8px;
}
.toggle-checkbox + .toggle-label::after {
    content: ''; display: inline-block; width: 18px; height: 18px;
    border-radius: 50%; background-color: white; position: absolute;
    top: 50%; left: 2px; transform: translateY(-50%);
    transition: transform 0.2s ease;
}
.toggle-checkbox:checked + .toggle-label::before { background: linear-gradient(90deg, #3498db, #2980b9); }
.toggle-checkbox:checked + .toggle-label::after { transform: translate(18px, -50%); }
.toggle-label { position: relative; display: inline-flex; align-items: center; }

/* =================================== */
/* 5. STATIC PAGE & FORM STYLES        */
/* =================================== */
.static-content-container {
    background: #fff;
    padding: 20px 40px;
    border-radius: 12px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
.static-content-container h1,
.static-content-container h2 {
    color: #5D5FEF;
}
.static-content-container a {
    color: #3498db;
    font-weight: 600;
    text-decoration: none;
}
.static-content-container a:hover {
    text-decoration: underline;
}
.static-content-container ul {
    list-style-position: inside;
    padding-left: 10px;
}
.static-content-container ul li {
    margin-bottom: 10px;
}

.contact-form {
    margin-top: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}
.form-group {
    display: flex;
    flex-direction: column;
}
.form-group label {
    margin-bottom: 8px;
    font-weight: 600;
    color: #555;
}
.form-group input,
.form-group textarea {
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-family: 'CustomMain', Arial, sans-serif;
    font-size: 1em;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #5D5FEF;
    box-shadow: 0 0 0 3px rgba(93, 95, 239, 0.2);
}
.form-submit-button {
    padding: 15px 20px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(90deg, #3498db, #2980b9);
    border: 2px solid #fff;
    color: #fff;
    font-family: 'CustomMain', Arial, sans-serif;
    font-size: 1.1em;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: box-shadow 0.2s ease, background 0.2s ease;
}
.form-submit-button:hover {
    background: linear-gradient(90deg, #2980b9, #2471a3);
}

/* =================================== */
/* 7. RESPONSIVENESS (Common)          */
/* =================================== */
@media (max-width: 1024px) {
    main { justify-content: center; gap: 0; }
    .sidebar-ad { display: none; }
    .game-grid { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); padding: 15px; }
    .inline-ad { padding: 10px; }
    .game-container { padding: 15px; font-size: 1em; }
    .selection-title { font-size: 1.1em; padding: 8px 20px; }
    .start-game-button { padding: 10px 20px; font-size: 1.2em; }
    .help-button { width: 40px; height: 40px; font-size: 1.5em; }
    .score-display, .timer-display { height: 40px; font-size: 1.2em; }
    .target-letter-display { width: 40px; height: 40px; font-size: 1.5em; }
    .close-game-button, .mute-button, .pause-button { width: 40px; height: 40px; font-size: 1.5em; }
}
@media (max-width: 768px) {
    .selection-title { font-size: 1em; }
    .toggle-container { justify-content: center; }
    .toggle-label { font-size: 0.9em; }
    .game-header-ui { padding: 5px 10px; }
    .game-header-left, .game-header-right { gap: 5px; }
    header h1 { font-size: 1.8em; } header p { font-size: 0.9em; }
    header .title-group { margin-left: 0; margin-right: 0; }
    .container { width: 95%; }
    main { padding: 15px 0; }
    .game-grid { grid-template-columns: 1fr; }
    .game-grid-item-content { padding: 20px; }
    .inline-ad { min-height: 70px; }
    .back-button { left: 10px; font-size: 1.5em; }
    .score-display, .timer-display { height: 38px; }
    .target-letter-display { width: 38px; height: 38px; font-size: 1.4em; }
    .close-game-button, .mute-button, .pause-button { width: 38px; height: 38px; font-size: 1.4em; }
}
@media (max-width: 480px) {
    .selection-controls { gap: 10px; }
    .toggle-label { font-size: 0.8em; }
    .select-all-button { font-size: 0.9em; padding: 8px 12px; }
    .game-header-ui { padding: 3px 8px; }
    .game-header-left, .game-header-right { gap: 3px; }
    .score-display, .timer-display { font-size: 0.9em; padding: 3px 8px; }
    header h1 { font-size: 1.5em; } header p { font-size: 0.8em; }
    footer { font-size: 0.7em; }
    footer a { margin: 0 5px; }
    .game-container { font-size: 0.9em; padding: 10px; }
    .selection-title {
        font-size: 1em;
        width: 100%;
    }
    .start-game-button { padding: 8px 15px; font-size: 1em; }
    .help-button { width: 35px; height: 35px; font-size: 1.2em; }
    .score-display, .timer-display { height: 36px; font-size: 1em; }
    .target-letter-display { width: 36px; height: 36px; font-size: 1.3em; }
    .close-game-button, .mute-button, .pause-button { width: 36px; height: 36px; font-size: 1.3em; }
    .footer-content {
        flex-direction: column;
        gap: 5px;
    }
}

/* =================================== */
/* 8. LOADING OVERLAY STYLES           */
/* =================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 2000;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    backdrop-filter: blur(5px);
    transition: opacity 0.5s ease-in-out;
    opacity: 1;
    font-family: Arial, Helvetica, sans-serif;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-content {
    background-color: rgb(27, 27, 29,0.5); /* Dark Charcoal */
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 450px;
    border: 2px solid #3498db; /* Bright Blue Border */
    text-align: center; /* Center all content */
}

.loading-message {
    font-size: 1.2em;
    line-height: 1.6;
    margin-bottom: 30px;
    font-weight: bold;
    color: #ffffff; /* White Text */
}

.loading-message span {
    color: #3498db; /* Bright Blue for "Thanks." */
}

.loading-status-text {
    font-size: 1.5em;
    font-weight: 700;
    margin-bottom: 15px;
    letter-spacing: 1px;
    color: #9e9e9e; /* Bright Gray */
}

.loading-bar-container {
    width: 100%;
    height: 20px;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.loading-bar-progress {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #6ec8ff 0%, #3498db 50%, #2b6fb2 100%);
    border-radius: 10px;
    transition: width 0.3s ease-out;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 480px) {
    .loading-content {
        padding: 25px 20px;
    }

    .loading-message {
        font-size: 90%;
        margin-bottom: 20px;
    }

    .loading-status-text {
        font-size: 1em;
    }
}

/* Full-screen non-closable welcome overlay for index page */
#index-full-overlay {
    position: fixed; inset: 0; background: linear-gradient(180deg, rgba(5,12,30,0.98), rgba(10,20,50,0.96));
    display: flex; align-items: center; justify-content: center; z-index: 99999;
    color: #fff; padding: 20px; transition: opacity 400ms ease;
}
#index-full-overlay .index-overlay-inner { max-width: 900px; width: 100%; display:flex; flex-direction:column; gap:28px; align-items:center; }
#index-full-overlay .index-overlay-text { text-align:center; }
#index-full-overlay .index-overlay-text .line { font-family: 'CustomMain', Arial, sans-serif; font-size: clamp(16px, 3.2vw, 22px); opacity: 0.95; }
#index-full-overlay .index-overlay-text .title { font-family: 'CustomTitle', Arial, sans-serif; font-size: clamp(28px, 6.8vw, 48px); font-weight: 900; margin-top:6px; }
#index-full-overlay .index-progress { width: 100%; display:flex; flex-direction:column; gap:8px; align-items:center; }
#index-full-overlay .index-progress-bar { width: 90%; max-width: 720px; height: 14px; background: rgba(255,255,255,0.08); border-radius: 999px; overflow: hidden; }
#index-full-overlay .index-progress-fill { height:100%; width:0%; background: linear-gradient(90deg,#6ec8ff,#3498db,#2b6fb2); transition: width 220ms ease; }
/* index progress label removed from markup; label styles intentionally omitted */

@media (max-width: 600px) {
    #index-full-overlay .index-overlay-inner { gap:18px; }
    #index-full-overlay .index-overlay-text .title { font-size: clamp(22px, 8vw, 34px); }
}

/* Overlay-only title coloring (copies the title colors without effects) */
#index-full-overlay .overlay-title-letter { display:inline-block; font-weight:900; }
#index-full-overlay .overlay-title-letter:nth-child(5n+1){ color:#6ec8ff; }
#index-full-overlay .overlay-title-letter:nth-child(5n+2){ color:#8ff0a0; }
#index-full-overlay .overlay-title-letter:nth-child(5n+3){ color:#ffb6e6; }
#index-full-overlay .overlay-title-letter:nth-child(5n+4){ color:#d3b3ff; }
#index-full-overlay .overlay-title-letter:nth-child(5n+5){ color:#ffe59e; }

/* Overlay-only subtitle word colors (copy of header subtitle palette: blue, green, red, yellow) */
#index-full-overlay .overlay-sub-word:nth-child(1) { color: #3498db; }
#index-full-overlay .overlay-sub-word:nth-child(2) { color: #2ecc71; }
#index-full-overlay .overlay-sub-word:nth-child(3) { color: #e74c3c; }
#index-full-overlay .overlay-sub-word:nth-child(4) { color: #f1c40f; }