/* =====================================================
   DESIGN 2 – MIDNIGHT GALAXY
   Deep-space dark theme. Glassmorphism card.
   Neon-glow tiles. Teal / purple / gold palette.
   Elegant, mysterious, mobile-first.
===================================================== */

:root {
    --space-bg-1: #060614;
    --space-bg-2: #0e0825;
    --glass-bg: rgba(255,255,255,0.045);
    --glass-border: rgba(180,120,255,0.25);
    --glass-shadow: 0 8px 48px rgba(120,0,255,0.2), 0 2px 12px rgba(0,220,255,0.1);
    --neon-purple: #a855f7;
    --neon-teal: #06b6d4;
    --neon-gold: #f59e0b;
    --neon-pink: #ec4899;
    --neon-green: #10b981;
    --tile-glow-purple: 0 0 14px rgba(168,85,247,0.6);
    --tile-glow-teal: 0 0 14px rgba(6,182,212,0.6);
    --tile-glow-gold: 0 0 14px rgba(245,158,11,0.6);
    --tile-glow-pink: 0 0 14px rgba(236,72,153,0.6);
    --text-primary: #e5e0ff;
    --text-muted: rgba(200,190,255,0.6);
    --correct-green: #10b981;
    --incorrect-red: #f43f5e;
    --font-main: 'Space Grotesk', sans-serif;
    --app-frame-max-width: 560px;
    --tile-size: 3.5rem;
    --tile-font-size: 1.6rem;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font-main);
}

/* Star field background */
body {
    background: radial-gradient(ellipse at 20% 30%, #1a0a3a 0%, transparent 50%),
                radial-gradient(ellipse at 80% 70%, #001a2e 0%, transparent 50%),
                linear-gradient(160deg, var(--space-bg-1) 0%, var(--space-bg-2) 100%);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1rem;
    position: relative;
    overflow-x: hidden;
}

/* CSS star field */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 10% 15%, rgba(255,255,255,0.7) 0%, transparent 100%),
        radial-gradient(1px 1px at 20% 55%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 35% 25%, rgba(255,255,255,0.8) 0%, transparent 100%),
        radial-gradient(1px 1px at 42% 70%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 55% 10%, rgba(255,255,255,0.6) 0%, transparent 100%),
        radial-gradient(2px 2px at 60% 45%, rgba(168,85,247,0.7) 0%, transparent 100%),
        radial-gradient(1px 1px at 70% 85%, rgba(255,255,255,0.5) 0%, transparent 100%),
        radial-gradient(1.5px 1.5px at 78% 20%, rgba(6,182,212,0.6) 0%, transparent 100%),
        radial-gradient(1px 1px at 85% 60%, rgba(255,255,255,0.7) 0%, transparent 100%),
        radial-gradient(1px 1px at 92% 35%, rgba(245,158,11,0.5) 0%, transparent 100%),
        radial-gradient(1px 1px at 5% 80%, rgba(255,255,255,0.4) 0%, transparent 100%),
        radial-gradient(1px 1px at 48% 90%, rgba(255,255,255,0.6) 0%, transparent 100%);
    pointer-events: none;
    z-index: 0;
}

/* ── CARD ── */
.game {
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    box-shadow: var(--glass-shadow);
    width: min(100%, var(--app-frame-max-width));
    max-width: var(--app-frame-max-width);
    height: calc(100vh - 2rem);
    max-height: 85vh;
    overflow-x: hidden;
    overflow-y: hidden;
    position: relative;
    z-index: 1;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
}

/* ── HEADER ── */
.game-header {
    padding: 1.25rem 1.5rem 1rem;
    text-align: center;
    border-bottom: 1px solid rgba(168,85,247,0.2);
    position: relative;
}

#gameTitle {
    font-size: 2.2rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    background: linear-gradient(90deg, var(--neon-purple) 0%, var(--neon-teal) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 12px rgba(168,85,247,0.5));
}

#word_of_word {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-top: 0.2rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
}

/* ── TIMER ── */
#timerHolder {
    position: relative;
    height: 1.25rem;
    background: rgba(255,255,255,0.06);
    border-bottom: 1px solid rgba(168,85,247,0.15);
}

#timerbarTxt {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%,-50%);
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-primary);
    z-index: 2;
    letter-spacing: 0.05em;
    text-shadow: 0 1px 3px rgba(0,0,0,0.85), 0 0 8px rgba(6,182,212,0.45);
}

#timerbar {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    appearance: none;
    -webkit-appearance: none;
    border: none;
    background: transparent;
}
#timerbar::-webkit-progress-bar { background: transparent; }
#timerbar::-webkit-progress-value {
    background: linear-gradient(90deg, #4c1d95, #7c3aed, #06b6d4);
    box-shadow: 0 0 8px rgba(124,58,237,0.5);
    transition: width 0.25s linear;
}
#timerbar::-moz-progress-bar {
    background: linear-gradient(90deg, #4c1d95, #7c3aed, #06b6d4);
}

/* ── GAME BODY ── */
.game-body {
    padding: 0.75rem 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

/* ── MESSAGE ── */
#msg {
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    min-height: 1.5rem;
    color: var(--neon-gold);
    text-shadow: 0 0 10px rgba(245,158,11,0.5);
    padding: 0.2rem 0;
    letter-spacing: 0.04em;
}

/* ── TILE AREAS ── */
.jumble, div.solution {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 0;
    user-select: none;
    -webkit-user-select: none;
}

/* Source letter tiles */
div.letters {
    width: var(--tile-size);
    height: var(--tile-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--tile-font-size);
    font-weight: 700;
    border-radius: 0.6rem;
    cursor: pointer;
    transition: transform 0.12s ease, box-shadow 0.2s ease;
    text-transform: uppercase;
    border: 1px solid;
}

div.letters:nth-child(6n+1) {
    background: rgba(168,85,247,0.15);
    border-color: var(--neon-purple);
    color: var(--neon-purple);
    box-shadow: var(--tile-glow-purple);
}
div.letters:nth-child(6n+2) {
    background: rgba(6,182,212,0.15);
    border-color: var(--neon-teal);
    color: var(--neon-teal);
    box-shadow: var(--tile-glow-teal);
}
div.letters:nth-child(6n+3) {
    background: rgba(245,158,11,0.15);
    border-color: var(--neon-gold);
    color: var(--neon-gold);
    box-shadow: var(--tile-glow-gold);
}
div.letters:nth-child(6n+4) {
    background: rgba(236,72,153,0.15);
    border-color: var(--neon-pink);
    color: var(--neon-pink);
    box-shadow: var(--tile-glow-pink);
}
div.letters:nth-child(6n+5) {
    background: rgba(16,185,129,0.15);
    border-color: var(--neon-green);
    color: var(--neon-green);
    box-shadow: 0 0 14px rgba(16,185,129,0.6);
}
div.letters:nth-child(6n+6) {
    background: rgba(168,85,247,0.12);
    border-color: var(--neon-teal);
    color: #c4b5fd;
    box-shadow: 0 0 14px rgba(196,181,253,0.4);
}

@media (hover: hover) and (pointer: fine) {
    div.letters:hover {
        transform: translateY(-3px) scale(1.1);
        filter: brightness(1.3);
    }
}

@media (hover: none), (pointer: coarse) {
    div.letters:active {
        transform: translateY(-1px) scale(1.04);
        filter: brightness(1.2);
    }
}

/* Empty solution slots */
div.empty_tile {
    width: var(--tile-size);
    height: var(--tile-size);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--tile-font-size);
    font-weight: 700;
    background: rgba(255,255,255,0.04);
    border: 1px dashed rgba(168,85,247,0.4);
    border-radius: 0.6rem;
}

div.drag_enter { background-color: rgba(16,185,129,0.25); border-color: var(--neon-green); }
div.drag_fail  { background-color: rgba(244,63,94,0.25); border-color: var(--incorrect-red); }

div.matched { animation: matched 1.25s linear; border-color: var(--neon-green); color: var(--neon-green); }
div.nomatch { animation: shake .8s linear; border-color: var(--incorrect-red); color: var(--incorrect-red); }

/* Hint-locked solution tiles: subtle visual cue that tile is fixed in place */
.solution > div[data-hintplaced='1'] {
    border: 1px solid transparent;
    background:
        linear-gradient(rgba(255,255,255,0.04), rgba(255,255,255,0.04)) padding-box,
        linear-gradient(130deg,
            rgba(245,158,11,0.28) 0%,
            rgba(245,158,11,0.88) 35%,
            rgba(251,191,36,0.92) 50%,
            rgba(245,158,11,0.88) 65%,
            rgba(245,158,11,0.28) 100%) border-box;
    background-size: 100% 100%, 240% 240%;
    background-position: 0 0, 0% 50%;
    animation: hintBorderShimmer 2.4s linear infinite;
    box-shadow: 0 0 0 1px rgba(245,158,11,0.35), inset 0 0 10px rgba(245,158,11,0.14);
    filter: saturate(1.06);
    color: #000000;
}

/* ── SECTION DIVIDER ── */
.tile-divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(168,85,247,0.3), rgba(6,182,212,0.3), transparent);
    margin: 0.25rem 0;
}

/* ── SUMMARY ── */
div.summary {
    display: flex;
    gap: 0.6rem;
    padding: 0.4rem 0;
}

div.summary-child {
    flex: 1;
    border: 1px solid rgba(168,85,247,0.2);
    border-radius: 0.75rem;
    background: rgba(168,85,247,0.05);
    padding: 0.4rem;
    min-height: 8rem;
    max-height: 8rem;
    overflow-y: auto;
    font-size: 0.85rem;
    line-height: 1.8;
    display: flex;
    flex-direction: column;
}

div.summary-child::-webkit-scrollbar { width: 3px; }
div.summary-child::-webkit-scrollbar-thumb {
    background: rgba(168,85,247,0.5);
    border-radius: 4px;
}

/* Attempt row container – card styling, status rail, alternating tint */
.attempt-row {
    padding: 0.4rem 0.5rem;
    margin-bottom: 0.3rem;
    border-left: 3px solid transparent;
    border-radius: 0.3rem;
    background: rgba(168,85,247,0.02);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.2);
    word-wrap: break-word;
    word-break: break-word;
}

/* Alternating row tint for visual separation */
.attempt-row:nth-child(odd) {
    background: rgba(168,85,247,0.05);
}

/* Status rail colors tied to match/valid/nomatch states */
.attempt-row.attempt-matched {
    border-left-color: var(--neon-green);
}

.attempt-row.attempt-valid {
    border-left-color: var(--neon-gold);
}

.attempt-row.attempt-nomatch {
    border-left-color: var(--incorrect-red);
}

/* Fade/slide animation for new entries */
@keyframes attemptFadeSlide {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.attempt-new {
    animation: attemptFadeSlide 0.25s ease-out forwards;
}

/* Respect user's motion preference */
@media (prefers-reduced-motion: reduce) {
    .attempt-new {
        animation: none;
    }
}

/* Symbol alignment and spacing */
.attempt-symbol {
    display: inline-block;
    min-width: 1.2em;
    text-align: center;
}

#controls {
    overflow: hidden;
}

/* ── SCORE ── */
#scoreHolder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 0.25rem;
}

#score {
    width: 100%;
    text-align: center;
    font-size: clamp(1rem, 4vw, 2.4rem);
    font-weight: 700;
    word-break: break-word;
    overflow: hidden;
    background: linear-gradient(90deg, var(--neon-gold), var(--neon-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 8px rgba(245,158,11,0.5));
}

span.attempt-matched { color: var(--neon-green); font-weight: 700; text-transform: capitalize; }
span.attempt-valid { color: var(--neon-gold); font-weight: 700; text-transform: capitalize; }
span.attempt-nomatch { color: var(--incorrect-red); font-weight: 600; text-transform: capitalize; }

.attempt-word {
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ── CONTROLS ── */
#help {
    /* border-top: 1px solid rgba(168,85,247,0.2); */
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 0;
}

button.icons {
    background: none;
    border: none;
    font-size: 2.25rem;
    cursor: pointer;
    color: var(--neon-purple);
    transition: transform 0.3s ease, filter 0.3s;
    text-shadow: 0 0 12px rgba(168,85,247,0.7);
    line-height: 1;
    padding: 0.25rem;
}
button.icons:hover {
    transform: rotateZ(-20deg);
    filter: brightness(1.5) drop-shadow(0 0 8px var(--neon-teal));
}

button.icons-end {
    color: var(--incorrect-red);
    text-shadow: 0 0 12px rgba(244,63,94,0.65);
}

button.icons-hint {
    color: var(--neon-gold);
    text-shadow: 0 0 12px rgba(245,158,11,0.65);
}

button.icons-skip {
    color: var(--neon-teal);
    text-shadow: 0 0 12px rgba(6,182,212,0.65);
}

button.icons:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    transform: none;
    filter: none;
}

/* ── FOOTER ── */
div.footer {
    text-align: center;
    font-size: 0.65rem;
    padding: 0.5rem;
    color: var(--text-muted);
}
div.footer a {
    color: var(--neon-teal);
    text-decoration: none;
    font-size: 1.2em;
    font-weight: 600;
    text-shadow: 0 0 6px rgba(6,182,212,0.7), 0 1px 2px rgba(0,0,0,0.65);
    transition: color 0.2s ease, text-shadow 0.2s ease, filter 0.2s ease;
}
div.footer a:hover {
    color: #67e8f9;
    text-underline-offset: 0.14em;
    text-decoration-thickness: 1px;
    text-shadow: 0 0 10px rgba(6,182,212,0.9), 0 0 18px rgba(6,182,212,0.6), 0 1px 2px rgba(0,0,0,0.75);
    filter: brightness(1.22);
}

/* ── OVERLAY ── */
#overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(6,1,20,1);
    backdrop-filter: none;
    border-radius: 1.5rem;
    padding: 2rem 1.5rem;
    overflow: hidden;
}

#overlay.hidden { display: none; }

#overlay_main {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
    gap: 0.6rem;
}

#overlay_main_title {
    font-size: 2.2rem;
    font-weight: 700;
    text-align: center;
    letter-spacing: 0.1em;
    background: linear-gradient(90deg, var(--neon-purple), var(--neon-teal));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 14px rgba(168,85,247,0.6));
    margin-bottom: 0.5rem;
}

#overlay_main_desc {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0;
}

#overlay_main_menu {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    width: 80%;
    margin: 0 auto;
}

#overlay_main_menu button {
    background: linear-gradient(135deg, rgba(124,58,237,0.8), rgba(6,182,212,0.6));
    border: 1px solid rgba(168,85,247,0.5);
    border-radius: 2rem;
    color: #e5e0ff;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 1rem;
    font-weight: 700;
    padding: 0.8rem 1.5rem;
    text-align: center;
    transition: box-shadow 0.2s, transform 0.2s;
    box-shadow: 0 0 20px rgba(124,58,237,0.3);
    letter-spacing: 0.04em;
}
#overlay_main_menu button:hover {
    box-shadow: 0 0 30px rgba(124,58,237,0.55), 0 0 12px rgba(6,182,212,0.4);
    transform: translateY(-2px);
}
#overlay_main_menu button:disabled {
    background: rgba(80,80,120,0.3);
    border-color: rgba(168,85,247,0.15);
    color: rgba(200,190,255,0.4);
    cursor: not-allowed;
    box-shadow: none;
}

#overlay_main_volume {
    width: 100%;
    margin: auto auto 0 auto;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
}
.game-volume {
    margin-top: auto;
    margin-bottom: 0.15rem;
    display: flex;
    justify-content: center;
}
.volumeWidget {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}
.volumeIcon {
    border: 1px solid rgba(168,85,247,0.45);
    border-radius: 50%;
    width: 2.2rem;
    height: 2.2rem;
    font-size: 1.25rem;
    color: var(--text-muted);
    background: rgba(14,8,37,0.85);
    box-shadow: 0 0 8px rgba(6,182,212,0.2);
    cursor: pointer;
    transition: color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}
.volumeIcon:hover {
    color: var(--neon-teal);
    box-shadow: 0 0 14px rgba(6,182,212,0.45);
    transform: translateY(-1px);
}
.volumeSlider {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: clamp(120px, 24vw, 200px);
    padding: 0.35rem 0.55rem;
    border: 1px solid rgba(168,85,247,0.35);
    border-radius: 0.6rem;
    background: rgba(14,8,37,0.96);
    box-shadow: 0 0 14px rgba(124,58,237,0.28);
    z-index: 5;
}
.volumeWidget:hover .volumeSlider,
.volumeWidget:focus-within .volumeSlider {
    display: block;
}

#overlay_main > .footer,
.game-body > .footer {
    margin-top: 0;
}
input[type=range] {
    width: 100%;
    height: 2rem;
    accent-color: var(--neon-purple);
}

/* ── HOW TO PLAY MODAL ── */
#howToPlayOverlay {
    position: fixed;
    inset: 0;
    background: rgba(6,1,20,0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
#howToPlayOverlay.hidden { display: none; }

#howToPlayCard {
    background: rgba(14,8,37,0.95);
    border: 1px solid rgba(168,85,247,0.35);
    border-radius: 1.25rem;
    padding: 1.1rem;
    width: min(92vw, 620px);
    max-height: min(84vh, 760px);
    box-shadow: 0 0 40px rgba(168,85,247,0.25), 0 0 16px rgba(6,182,212,0.15);
    animation: slideIn 0.2s ease-out;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

#howToPlayHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.8rem;
}

#howToPlayTitle {
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0;
    background: linear-gradient(90deg, var(--neon-purple), var(--neon-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#howToPlayClose {
    background: linear-gradient(135deg, rgba(124,58,237,0.7), rgba(6,182,212,0.5));
    border: 1px solid rgba(168,85,247,0.4);
    border-radius: 2rem;
    color: #e5e0ff;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 0.92rem;
    font-weight: 700;
    padding: 0.35rem 0.95rem;
    transition: box-shadow 0.2s, transform 0.2s;
}

#howToPlayClose:hover {
    box-shadow: 0 0 20px rgba(124,58,237,0.5);
    transform: translateY(-2px);
}

#howToPlayBody {
    overflow-y: auto;
    min-height: 0;
    max-height: min(68vh, 620px);
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
    padding-right: 0.25rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(168,85,247,0.65) rgba(6,1,20,0.55);
}

#howToPlayBody::-webkit-scrollbar {
    width: 0.5rem;
}

#howToPlayBody::-webkit-scrollbar-track {
    background: rgba(6,1,20,0.55);
    border-radius: 999px;
}

#howToPlayBody::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(168,85,247,0.95), rgba(6,182,212,0.85));
    border-radius: 999px;
    border: 1px solid rgba(168,85,247,0.2);
}

.howToPlay_section {
    border: 1px solid rgba(168,85,247,0.25);
    border-radius: 0.75rem;
    background: rgba(168,85,247,0.06);
    padding: 0.75rem 1rem;
}

.howToPlay_section_title {
    font-size: 0.98rem;
    font-weight: 700;
    margin-bottom: 0.45rem;
    letter-spacing: 0.03em;
    color: #ddd6fe;
}

.howToPlay_rules {
    margin: 0;
    padding-left: 1.6rem;
    font-size: 0.82rem;
    color: var(--text-primary);
    line-height: 1.65;
}

.howToPlay_rules li {
    margin-bottom: 0.35rem;
}

.howToPlay_rules li:last-child {
    margin-bottom: 0;
}

.howToPlay_prefs_desc {
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--text-primary);
}

.howToPlay_prefs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 0.6rem;
}

.howToPlay_prefs button {
    background: linear-gradient(135deg, rgba(124,58,237,0.7), rgba(6,182,212,0.5));
    border: 1px solid rgba(168,85,247,0.4);
    border-radius: 2rem;
    color: #e5e0ff;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.4rem 0.9rem;
    transition: box-shadow 0.2s, transform 0.2s;
}

.howToPlay_prefs button:hover {
    box-shadow: 0 0 18px rgba(124,58,237,0.45);
    transform: translateY(-1px);
}

.howToPlay_warning {
    font-size: 0.78rem;
    color: #fda4af;
    margin-top: 0.55rem;
    line-height: 1.4;
}

/* ── CONFIRM MODAL ── */
#confirmOverlay {
    position: fixed;
    inset: 0;
    background: rgba(6,1,20,0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
}
#confirmOverlay.hidden { display: none; }

#confirmCard {
    background: rgba(14,8,37,0.95);
    border: 1px solid rgba(168,85,247,0.35);
    border-radius: 1.25rem;
    padding: 1.5rem;
    width: 90%;
    max-width: 340px;
    box-shadow: 0 0 40px rgba(168,85,247,0.25), 0 0 16px rgba(6,182,212,0.15);
    animation: slideIn 0.2s ease-out;
    text-align: center;
    color: var(--text-primary);
}

#confirmTitle {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    background: linear-gradient(90deg, var(--neon-purple), var(--neon-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#confirmBody {
    font-size: 0.95rem;
    margin-bottom: 1rem;
}

#confirmButtons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
}

#confirmButtons button {
    background: linear-gradient(135deg, rgba(124,58,237,0.7), rgba(6,182,212,0.5));
    border: 1px solid rgba(168,85,247,0.4);
    border-radius: 2rem;
    color: #e5e0ff;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.5rem 1.2rem;
    transition: box-shadow 0.2s, transform 0.2s;
}

#confirmButtons button:hover {
    box-shadow: 0 0 20px rgba(124,58,237,0.5);
    transform: translateY(-2px);
}

/* ── GAME OVER ── */
#gameOverOverlay {
    position: fixed;
    inset: 0;
    background: rgba(6,1,20,0.75);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
#gameOverOverlay.hidden { display: none; }

#gameOverCard {
    background: rgba(14,8,37,0.95);
    border: 1px solid rgba(168,85,247,0.35);
    border-radius: 1.25rem;
    padding: 2rem;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 0 40px rgba(168,85,247,0.25), 0 0 16px rgba(6,182,212,0.15);
    animation: slideIn 0.3s ease-out;
    text-align: center;
    color: var(--text-primary);
}

#gameOverTitle {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(90deg, var(--neon-purple), var(--neon-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#gameOverBody {
    font-size: 0.9rem;
    max-height: 50vh;
    overflow-y: auto;
    margin-bottom: 1rem;
}
#gameOverBody span {
    color: var(--neon-green);
    font-weight: 700;
    font-size: 1.4rem;
    display: block;
    text-shadow: 0 0 10px rgba(16,185,129,0.5);
}

#gameOverBody .gameOverCallout {
    color: #ddd6fe;
    font-weight: 700;
    margin: 0.35rem 0 0.8rem;
}

#gameOverButtons {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}
#gameOverButtons button {
    background: linear-gradient(135deg, rgba(124,58,237,0.7), rgba(6,182,212,0.5));
    border: 1px solid rgba(168,85,247,0.4);
    border-radius: 2rem;
    color: #e5e0ff;
    cursor: pointer;
    font-family: var(--font-main);
    font-size: 0.95rem;
    font-weight: 700;
    padding: 0.65rem 1.4rem;
    transition: box-shadow 0.2s, transform 0.2s;
}
#gameOverButtons button:hover {
    box-shadow: 0 0 20px rgba(124,58,237,0.5);
    transform: translateY(-2px);
}

/* ── ANIMATIONS ── */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@keyframes matched {
    0%   { transform: rotate(0deg); }
    50%  { transform: rotate(180deg); }
    100% { transform: rotate(360deg); }
}

@keyframes hintBorderShimmer {
    0% {
        background-position: 0 0, 0% 50%;
    }
    100% {
        background-position: 0 0, 220% 50%;
    }
}

@media (max-width: 640px) {
    :root {
        --tile-size: 3.2rem;
        --tile-font-size: 1.45rem;
    }

    body {
        padding: 0.25rem;
    }

    .game {
        width: 99%;
        max-width: 99%;
        height: 99svh;
        max-height: 99svh;
        border-radius: 1rem;
    }

    .game-header {
        padding: 1rem 1rem 0.75rem;
    }

    .game-body {
        padding: 0.65rem 0.75rem;
    }

    .jumble,
    div.solution {
        gap: 0.35rem;
        padding: 0.6rem 0;
    }

    div.summary {
        flex-direction: column;
    }

    div.summary-child {
        min-height: 6.5rem;
        max-height: 6.5rem;
    }

    #overlay {
        border-radius: 1rem;
        padding: 1rem 0.85rem;
    }

    #overlay_main {
        gap: 0.45rem;
    }

    #overlay_main_menu {
        width: 100%;
    }

    #overlay_main_volume { width: 100%; }

    .volumeSlider {
        width: clamp(110px, 42vw, 180px);
    }
}

@media (orientation: landscape) and (max-height: 560px) {
    :root {
        --tile-size: 2.4rem;
        --tile-font-size: 1.05rem;
    }

    body {
        padding: 0.2rem;
    }

    .game {
        width: 100%;
        max-width: 100%;
        height: 100svh;
        max-height: 100svh;
        border-radius: 0.75rem;
    }

    .game-header {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        text-align: left;
        padding: 0.3rem 0.8rem;
    }

    #gameTitle {
        font-size: 1.35rem;
        text-align: left;
        flex: 1;
    }

    #word_of_word {
        font-size: 0.65rem;
        text-align: right;
        margin-top: 0;
        flex-shrink: 0;
    }

    #timerHolder {
        height: 1rem;
    }

    #timerbarTxt {
        font-size: 0.62rem;
    }

    .game-body {
        padding: 0.35rem 0.6rem;
    }

    .jumble,
    div.solution {
        gap: 0.25rem;
        padding: 0.3rem 0;
    }

    #msg {
        font-size: 0.72rem;
        min-height: 1.1rem;
        padding: 0.05rem 0;
    }

    div.summary {
        gap: 0.35rem;
    }

    div.summary-child {
        min-height: 3.5rem;
        max-height: 3.5rem;
        padding: 0.25rem;
        font-size: 0.72rem;
    }

    #scoreHolder {
        flex-direction: row;
        gap: 0.4rem;
        align-items: baseline;
    }

    #score {
        font-size: clamp(0.85rem, 2.7vw, 1.6rem);
        line-height: 1;
    }

    #help {
        gap: 0.35rem;
        padding: 0.25rem 0;
    }

    button.icons {
        font-size: 1.6rem;
    }

    .game-volume {
        margin-bottom: 0.05rem;
    }

    .volumeIcon {
        width: 1.9rem;
        height: 1.9rem;
        font-size: 1.05rem;
    }

    .footer {
        font-size: 0.55rem;
        padding: 0.25rem;
    }
}