/* 🦁 LION ADVENTURE STYLESHEET */
:root {
    --primary: #4361ee;
    --secondary: #3f37c9;
    --accent: #4895ef;
    --success: #4cc9f0;
    --warning: #f72585;
    --danger: #e63946;
    --background: #f8f9fa;
    --card-bg: rgba(255, 255, 255, 0.9);
    --text: #1a1e2e;
    --text-light: #64748b;
    --radius: 24px;
    --shadow-sm: 0 4px 10px rgba(0,0,0,0.06);
    --shadow-md: 0 10px 25px rgba(0,0,0,0.1);
    --shadow-lg: 0 20px 40px rgba(0,0,0,0.15);
    --glass: rgba(255, 255, 255, 0.85);
    --glass-border: rgba(255, 255, 255, 0.4);
    --streak-color: #f72585;
}

[data-theme="dark"] {
    --background: #0f1422;
    --card-bg: rgba(30, 41, 59, 0.85);
    --text: #f8fafc;
    --text-light: #cbd5e1;
    --glass: rgba(15, 23, 42, 0.8);
    --glass-border: rgba(255, 255, 255, 0.15);
    --shadow-sm: 0 4px 10px rgba(0,0,0,0.3);
    --shadow-md: 0 10px 25px rgba(0,0,0,0.4);
    --shadow-lg: 0 20px 40px rgba(0,0,0,0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Nunito', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--background);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background-attachment: fixed;
    background-image:
        radial-gradient(at 0% 0%, hsla(253,16%,7%,0.1) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225,39%,30%,0.05) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(339,49%,30%,0.1) 0, transparent 50%);
}

[data-theme="light"] body {
    background-image:
        radial-gradient(at 0% 0%, hsla(197,100%,82%,0.2) 0, transparent 50%),
        radial-gradient(at 50% 0%, hsla(225,100%,90%,0.2) 0, transparent 50%),
        radial-gradient(at 100% 0%, hsla(282,100%,92%,0.2) 0, transparent 50%);
}

[data-theme="space"] {
    --background: #090312;
    --card-bg: rgba(30, 20, 60, 0.85);
    --text: #ffffff;
    --text-light: #d6ccff;
    --glass: rgba(20, 10, 40, 0.8);
}
[data-theme="space"] body { background-image: radial-gradient(circle at 50% 50%, #200f46 0%, #090312 100%); }

[data-theme="jungle"] {
    --background: #081c15;
    --card-bg: rgba(20, 50, 30, 0.85);
    --text: #f0f8f2;
    --text-light: #a3d9b8;
    --glass: rgba(10, 30, 15, 0.8);
}
[data-theme="jungle"] body { background-image: linear-gradient(135deg, #1b4332 0%, #081c15 100%); }

[data-theme="ocean"] {
    --background: #03045e;
    --card-bg: rgba(10, 50, 100, 0.85);
    --text: #e0f0ff;
    --text-light: #90cdff;
    --glass: rgba(5, 20, 50, 0.8);
}
[data-theme="ocean"] body { background-image: linear-gradient(180deg, #0077b6 0%, #03045e 100%); }

/* ── ANIMATIONS ── */
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }
@keyframes shake { 0%, 100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes pulse { 0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(67, 97, 238, 0.4); } 70% { transform: scale(1.05); box-shadow: 0 0 0 10px rgba(67, 97, 238, 0); } 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(67, 97, 238, 0); } }
@keyframes xpPulse { 0% { opacity: 1; } 50% { opacity: 0.7; } 100% { opacity: 1; } }

.animate-fade { animation: fadeIn 0.4s ease-out forwards; }
.animate-scale { animation: scaleIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.animate-float { animation: float 3.5s ease-in-out infinite; }
.shake { animation: shake 0.4s ease-in-out; }
.xp-pulse { animation: xpPulse 0.6s ease-out; }

/* ── DIFFICULTY / CATEGORY PILLS ── */
.diff-pill, .cat-pill {
    white-space: nowrap;
    cursor: pointer;
    flex-shrink: 0;
    background: var(--glass);
    border: 2px solid var(--glass-border);
    transition: all 0.2s;
}
.active-pill {
    background: var(--primary) !important;
    color: white !important;
    border-color: var(--primary) !important;
}

/* ── LAYOUT ── */
#lock {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--background);
    background: var(--background);
}

.lock-box {
    background: var(--card-bg);
    padding: 3.5rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-lg);
    border: 2px solid var(--glass-border);
    max-width: 420px;
    width: 90%;
}

#app { display: none; }

header {
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 2000;
    background: var(--glass);
    border-bottom: 2px solid var(--glass-border);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'Fredoka One', cursive;
    font-size: 1.6rem;
    color: var(--primary);
    text-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.status-pills {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.pill {
    background: var(--glass);
    padding: 0.5rem 1rem;
    border-radius: 50px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    border: 2px solid var(--glass-border);
    box-shadow: var(--shadow-sm);
    color: var(--text);
    transition: transform 0.2s;
    font-size: 0.9rem;
}

.pill:hover { transform: translateY(-2px); }

/* ── NAV ── */
nav {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.25rem;
    flex-wrap: wrap;
    background: rgba(0,0,0,0.02);
}

.nav-btn {
    background: var(--glass);
    border: 2px solid var(--glass-border);
    padding: 0.85rem 1.75rem;
    border-radius: 50px;
    cursor: pointer;
    font-family: 'Fredoka One', cursive;
    font-size: 0.95rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text);
    box-shadow: var(--shadow-sm);
}

.nav-btn:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

.nav-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    box-shadow: 0 8px 20px rgba(67, 97, 238, 0.4);
}

/* ── SECTIONS ── */
.section {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem 8rem;
    display: none;
}

.section.active {
    display: block;
    animation: fadeIn 0.5s ease-out;
}

/* ── CARDS ── */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.75rem;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    border: 2px solid var(--glass-border);
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.card:hover {
    transform: translateY(-12px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary);
}

.card .emoji { font-size: 3.5rem; margin-bottom: 1.25rem; }
.card h3 { font-family: 'Fredoka One', cursive; margin-bottom: 0.5rem; color: var(--text); }
.card p { color: var(--text-light); line-height: 1.4; }

.locked-badge {
    opacity: 0.4 !important;
    pointer-events: none;
}

/* ── TYPING ── */
.typing-box {
    background: var(--card-bg);
    border: 3px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 3.5rem;
    position: relative;
    min-height: 250px;
    font-size: 2rem;
    line-height: 1.7;
    text-align: left;
    box-shadow: var(--shadow-md);
}

.char {
    transition: all 0.1s;
    position: relative;
    color: var(--text-light);
    border-bottom: 2px solid transparent;
}
.char.correct { color: var(--text); }
.char.correct-hl { color: #10b981; }
.char.wrong { color: #ef4444; background: rgba(239, 68, 68, 0.12); border-radius: 4px; }
.char.current {
    color: var(--text);
    border-bottom: 4px solid var(--primary);
}

/* ── MODALS ── */
.modal-bg {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    background: rgba(0,0,0,0.8);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    padding: 1rem;
}

.modal-bg.active { display: flex; animation: fadeIn 0.3s; }

.modal {
    background: var(--background);
    padding: 2rem;
    border-radius: var(--radius);
    width: 100%;
    max-width: 650px;
    position: relative;
    box-shadow: var(--shadow-lg);
    max-height: 90vh;
    overflow-y: auto;
}

.close-btn {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    background: var(--glass);
    border: 2px solid var(--glass-border);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-light);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.close-btn:hover { background: var(--danger); color: white; transform: rotate(90deg); }

/* ── TOASTS ── */
#toast-container {
    position: fixed;
    top: 25px;
    right: 25px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--glass);
    background: var(--card-bg);
    color: var(--text);
    padding: 1.25rem 2rem;
    border-radius: 18px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    border: 2px solid var(--glass-border);
    transform: translateX(130%);
    transition: transform 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show { transform: translateX(0); }

/* ── TRAINING CENTER CONTRAST FIX ── */
.training-center-title {
    font-family: 'Fredoka One';
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text);
}

/* ── MEMORY MATCH ── */
.memory-card {
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 4rem;
    padding: 1rem 0.5rem;
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
}

.memory-card .card-back {
    font-family: 'Fredoka One';
    font-size: 2.5rem;
    color: var(--primary);
}

.memory-card.flipped {
    background: linear-gradient(135deg, rgba(67,97,238,0.12), rgba(72,149,239,0.08));
    border-color: var(--primary);
    box-shadow: 0 6px 20px rgba(67,97,238,0.25);
    transform: scale(1.05);
}

.memory-card.matched {
    background: linear-gradient(135deg, rgba(16,185,129,0.18), rgba(5,150,105,0.1));
    border-color: #10b981;
    box-shadow: 0 6px 20px rgba(16,185,129,0.3);
    pointer-events: none;
}

.memory-card .card-word {
    font-family: 'Fredoka One';
    font-size: 0.75rem;
    color: var(--text-light);
    letter-spacing: 0.5px;
}

.memory-card.matched .card-word { color: #10b981; font-weight: 900; }

#memoryGrid {
    grid-template-columns: repeat(4, 1fr) !important;
}

/* ── CATEGORY SORT ── */
.catsort-word {
    user-select: none;
}

/* ── WIN ACTIONS ── */
#winActions {
    display: flex;
    gap: 12px;
    margin-top: 1.5rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── HANGMAN FIXED KEYBOARD ── */
#hmKeys .nav-btn.used {
    background: #e2e8f0;
    color: #94a3b8;
    text-decoration: line-through;
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
    transform: none;
    box-shadow: none;
}
[data-theme="dark"] #hmKeys .nav-btn.used {
    background: #1e293b;
    color: #475569;
}

/* ── MOBILE NAV ── */
/* ── MOBILE OPTIMIZATIONS ── */
@media (max-width: 768px) {
    header {
        padding: 0.75rem 1rem;
    }

    header .logo {
        font-size: 1.2rem;
    }

    header .logo span:not(.user-avatar):not(#headerAvatar) {
        display: none;
    }

    .status-pills {
        gap: 0.4rem;
    }

    .pill {
        padding: 0.4rem 0.6rem;
        font-size: 0.8rem;
        gap: 0.3rem;
    }

    .pill[style*="min-width: 110px"] {
        min-width: 70px !important;
    }

    nav {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        background: var(--glass);
        backdrop-filter: blur(15px);
        -webkit-backdrop-filter: blur(15px);
        padding: 0.5rem 1rem calc(0.5rem + env(safe-area-inset-bottom));
        z-index: 3000;
        border-top: 2px solid var(--glass-border);
        justify-content: space-around;
        gap: 0;
        box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
    }

    .nav-btn {
        flex-direction: column;
        padding: 0.5rem;
        background: none;
        border: none;
        box-shadow: none;
        gap: 0.1rem;
        flex: 1;
        border-radius: 0;
    }

    .nav-btn:hover { transform: none; }

    .nav-btn .icon {
        font-size: 1.4rem;
        transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    .nav-btn span:not(.icon) {
        font-size: 0.65rem;
        opacity: 0.7;
        font-family: 'Nunito', sans-serif;
        font-weight: 700;
    }

    .nav-btn.active {
        background: none;
        color: var(--primary);
        box-shadow: none;
    }

    .nav-btn.active .icon {
        transform: translateY(-4px) scale(1.1);
    }

    .nav-btn.active span:not(.icon) {
        opacity: 1;
        font-weight: 800;
        color: var(--primary);
    }

    .section {
        padding: 1.5rem 1rem 6rem;
    }

    .grid {
        grid-template-columns: 1fr 1fr;
        gap: 1rem;
    }

    /* Refining fonts for small mobile */
    @media (max-width: 480px) {
        .card h3 { font-size: 1rem !important; }
        .card .emoji { font-size: 2.5rem !important; }
        header .logo { font-size: 1rem; }
    }

    /* Toast repositioning */
    #toast-container {
        top: 15px;
        right: 15px;
        left: 15px;
        align-items: center;
    }

    .toast {
        width: 100%;
        max-width: 400px;
        padding: 1rem 1.5rem;
        transform: translateY(-130%);
    }

    .toast.show { transform: translateY(0); }

    /* Target specific span-2 cards to not force column if they have list-like content */
    .card[style*="grid-column: span 2"]:not(:has(#dailyChallengesGrid)):not(:has(#progressMap)) {
        flex-direction: column !important;
        text-align: center !important;
    }

    .card[style*="grid-column: span 2"] div:first-child {
        text-align: center !important;
    }

    .card[style*="grid-column: span 2"] h2 {
        font-size: 1.5rem !important;
    }

    .card[style*="grid-column: span 2"] .animate-float {
        font-size: 3rem !important;
    }

    /* Modal adjustments */
    .modal {
        padding: 1.5rem;
        border-radius: 20px;
    }

    .modal h2 {
        font-size: 1.8rem !important;
        margin-bottom: 1.5rem !important;
    }

    .close-btn {
        top: 1rem;
        right: 1rem;
        width: 32px;
        height: 32px;
    }

    /* Special game UI scaling */
    #memoryGrid {
        gap: 8px !important;
    }

    .memory-card {
        min-height: 90px;
        font-size: 2.5rem !important;
        padding: 0.5rem;
    }

    .memory-card .card-back {
        font-size: 1.8rem;
    }

    .memory-card .card-word {
        font-size: 0.6rem;
    }

    #scrambleWord {
        font-size: 2.5rem !important;
    }

    #spellInput, #scrambleInput, #typeraceInput {
        font-size: 1.3rem !important;
        padding: 1rem !important;
    }
    /* Profile Card fix */
    .profile-card {
        padding: 1.5rem !important;
    }

    /* Progress Map scaling */
    #progressMap {
        gap: 6px !important;
    }
    #progressMap div span:first-child {
        font-size: 1.5rem !important;
    }
    #progressMap div span:last-child {
        font-size: 0.5rem !important;
    }

    /* Alphabet grid 3-4 columns */
    #alphaGrid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)) !important;
        gap: 0.75rem !important;
    }
    #alphaGrid .card {
        padding: 1rem !important;
    }
    #alphaGrid h2 {
        font-size: 1.8rem !important;
    }
}

@media (max-width: 380px) {
    .grid {
        grid-template-columns: 1fr;
    }

    header .status-pills .pill:nth-child(4) {
        display: none; /* Hide progress bar on very narrow screens */
    }
}
