/* 🦁 LION ADVENTURE STYLESHEET */
:root {
    --primary: #f59e0b;
    --secondary: #d97706;
    --accent: #3b82f6;
    --success: #10b981;
    --warning: #f43f5e;
    --danger: #ef4444;
    --background: #fffbeb;
    --card-bg: rgba(255, 255, 255, 0.95);
    --text: #451a03;
    --text-light: #78350f;
    --radius: 32px;
    --shadow-sm: 0 6px 15px rgba(245, 158, 11, 0.15);
    --shadow-md: 0 12px 25px rgba(245, 158, 11, 0.2);
    --shadow-lg: 0 20px 40px rgba(245, 158, 11, 0.25);
    --glass: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(255, 255, 255, 0.7);
    --streak-color: #f43f5e;
}

[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);
}

html {
    width: 100%;
    height: 100%;
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

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

body {
    width: 100%;
    height: 100%;
    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%);
}

/* Ensure hidden elements stay hidden */
#lock[style*="display: none"],
#app[style*="display: none"],
#maintenance[style*="display: none"],
.modal-bg[style*="display: none"],
[style*="display: none;"] {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
}

[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);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}

.lock-box {
    background: var(--card-bg);
    padding: 3.5rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.1);
    border: 1px solid var(--glass-border);
    max-width: 420px;
    width: 90%;
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.auth-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 2rem;
    border-bottom: 2px solid rgba(0,0,0,0.05);
}

.auth-tab {
    flex: 1;
    padding: 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    font-weight: 800;
    font-size: 1rem;
    color: var(--text-light);
    transition: all 0.3s;
    border-bottom: 3px solid transparent;
}

.auth-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

#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 ── */
/* ── MOBILE OVERHAUL ── */
@media (max-width: 768px) {
    :root {
        --radius: 20px;
    }

    header {
        padding: 0.75rem 1.25rem;
        border-bottom: 1px solid var(--glass-border);
    }

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

    .status-pills {
        gap: 0.4rem;
    }

    .pill {
        padding: 0.35rem 0.6rem;
        font-size: 0.75rem;
        gap: 0.25rem;
        border-width: 1px;
    }

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

    /* PREMIUM MOBILE NAV */
    nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--glass);
        backdrop-filter: blur(20px) saturate(180%);
        -webkit-backdrop-filter: blur(20px) saturate(180%);
        padding: 0.6rem 1rem calc(0.6rem + env(safe-area-inset-bottom));
        z-index: 3000;
        border-top: 1px solid var(--glass-border);
        display: flex;
        justify-content: space-around;
        align-items: center;
        gap: 0;
        box-shadow: 0 -10px 30px rgba(0,0,0,0.08);
    }

    .nav-btn {
        flex: 1;
        flex-direction: column;
        padding: 0.4rem 0;
        background: transparent;
        border: none;
        box-shadow: none;
        gap: 0.2rem;
        border-radius: 12px;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
    }

    .nav-btn:active {
        transform: scale(0.92);
        background: rgba(0,0,0,0.03);
    }

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

    .nav-btn span:not(.icon) {
        font-size: 0.65rem;
        font-weight: 700;
        color: var(--text-light);
        transition: all 0.2s;
    }

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

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

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

    .nav-btn.active::after {
        content: '';
        position: absolute;
        top: -0.6rem;
        left: 50%;
        transform: translateX(-50%);
        width: 24px;
        height: 3px;
        background: var(--primary);
        border-radius: 0 0 4px 4px;
        box-shadow: 0 2px 10px rgba(67, 97, 238, 0.4);
    }

    .section {
        padding: 1rem 1.25rem 7rem;
    }

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

    .card {
        padding: 1.25rem;
        border-radius: 18px;
    }

    .card .emoji {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }

    .card h3 {
        font-size: 1rem;
    }

    .card p {
        font-size: 0.8rem;
    }

    /* SPECIAL CARD HANDLING */
    .card-welcome {
        grid-column: span 2 !important;
        flex-direction: column !important;
        text-align: center !important;
        padding: 1.75rem !important;
        gap: 0.75rem !important;
    }

    .welcome-text { text-align: center !important; }
    .welcome-text h2 { font-size: 1.5rem !important; }
    .welcome-text p { font-size: 1rem !important; }
    .welcome-emoji { font-size: 3.5rem !important; }

    /* MODALS */
    .modal {
        padding: 1.5rem;
        border-radius: 24px;
        width: 95%;
        max-height: 85vh;
    }

    .modal h2 {
        font-size: 1.6rem !important;
        margin-bottom: 1.25rem !important;
    }

    .close-btn {
        top: 0.75rem;
        right: 0.75rem;
        width: 36px;
        height: 36px;
    }

    /* GAME UI SCALING */
    #memoryGrid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 6px !important;
    }

    .memory-card {
        min-height: 80px;
        padding: 0.4rem;
    }

    .memory-card span:first-child { font-size: 2.2rem !important; }
    .memory-card .card-back { font-size: 1.6rem !important; }
    .memory-card .card-word { font-size: 0.55rem !important; }

    #alphabet .grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.6rem !important;
    }

    #alphaGrid .card { padding: 1rem 0.5rem !important; }
    #alphaGrid h2 { font-size: 1.75rem !important; }

    #spellInput, #scrambleInput, #typeraceInput {
        font-size: 1.25rem !important;
        padding: 0.85rem !important;
        border-width: 3px !important;
    }

    /* PREVENT ZOOM ON INPUT */
    input[type="text"], input[type="password"] {
        font-size: 16px !important; /* Minimum to prevent auto-zoom on iOS */
    }

    /* TOASTS */
    #toast-container {
        top: auto;
        bottom: 6rem;
        left: 1.25rem;
        right: 1.25rem;
        align-items: center;
    }

    .toast {
        width: 100%;
        max-width: none;
        padding: 0.85rem 1.25rem;
        border-radius: 16px;
        transform: translateY(150%);
    }

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

    /* PROFILE */
    .profile-card {
        padding: 2rem 1.25rem !important;
    }

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

    .level-count, .star-count {
        font-size: 1.5rem !important;
    }

    /* DAILY CHALLENGES */
    #dailyChallengesGrid > div {
        padding: 0.75rem 1rem !important;
        font-size: 0.9rem;
    }
}

@media (max-width: 380px) {
    .grid { grid-template-columns: 1fr; }
    header .status-pills .pill:nth-child(4) { display: none; }
    .welcome-emoji { font-size: 3rem !important; }
    .modal h2 { font-size: 1.4rem !important; }

    /* Lock screen adjustments for very small phones */
    .lock-box { padding: 1.5rem !important; max-width: 95vw !important; }
    .lock-box h1 { font-size: 1.5rem !important; margin-bottom: 1.25rem !important; }
    input[type="email"], input[type="password"], input[type="text"] {
        padding: 1rem !important;
        font-size: 16px !important;
        border-radius: 10px !important;
    }
    button { font-size: 1rem !important; }
}

/* ── TABLET & MEDIUM SCREENS (768px - 1024px) ── */
@media (min-width: 769px) and (max-width: 1024px) {
    :root { --radius: 28px; }

    header {
        padding: 1rem 2rem;
    }

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

    nav {
        display: flex;
        position: relative;
        flex-direction: row;
        bottom: auto;
        background: transparent;
        padding: 1.5rem 2rem;
        border-top: none;
        justify-content: center;
        gap: 1rem;
        box-shadow: none;
    }

    .nav-btn {
        flex: 0 1 auto;
        padding: 0.75rem 1.5rem;
        flex-direction: row;
        gap: 0.5rem;
    }

    .nav-btn span:not(.icon) {
        display: inline;
        font-size: 0.95rem;
    }

    .nav-btn .icon {
        font-size: 1.3rem;
    }

    .section {
        padding: 2rem;
    }

    .grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
}

/* ── DESKTOP & LARGE SCREENS (1025px+) ── */
@media (min-width: 1025px) {
    :root { --radius: 32px; }

    header {
        padding: 1.25rem 3rem;
    }

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

    nav {
        display: flex;
        position: relative;
        flex-direction: row;
        bottom: auto;
        background: transparent;
        padding: 2rem 3rem;
        border-top: none;
        justify-content: center;
        gap: 1.5rem;
        box-shadow: none;
    }

    .nav-btn {
        flex: 0 1 auto;
        padding: 0.8rem 2rem;
        flex-direction: row;
        gap: 0.7rem;
        border-radius: 16px;
        font-size: 1rem;
    }

    .nav-btn .icon {
        font-size: 1.5rem;
    }

    .section {
        padding: 2.5rem 3rem;
        max-width: 1400px;
        margin: 0 auto;
    }

    .grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2rem;
    }

    .modal {
        max-width: 600px;
        padding: 3rem;
    }

    .card {
        padding: 2rem;
    }
}

/* ── LANDSCAPE MODE ADJUSTMENTS ── */
@media (max-height: 600px) {
    nav {
        padding: 0.4rem 1rem !important;
    }

    .nav-btn {
        padding: 0.3rem 0.6rem !important;
    }

    .section {
        padding-top: 1rem !important;
    }
}

/* ── TOUCH DEVICE OPTIMIZATIONS ── */
@media (hover: none) and (pointer: coarse) {
    .nav-btn {
        padding: 0.6rem 1.2rem;
        min-height: 48px;
        min-width: 48px;
    }

    button {
        min-height: 48px;
        min-width: 48px;
    }

    input[type="email"],
    input[type="password"],
    input[type="text"] {
        min-height: 48px;
        font-size: 16px;
    }
}
