:root {
    --fn-bg: #0b0d13;
    --fn-panel-bg: #181c25;
    --fn-yellow: #f4c430;
    --fn-border: #3b4253;
    --fn-neon-cyan: #00f0ff;
    --fn-unreleased: #ef4444;
    --fn-collected: #22c55e;
    --fn-lime: #32cd32;
    --fn-mastered: #ffd700;

    /* Precise Fortnite Locker Hex Codes */
    --color-Rare: #004A8E;
    --color-Epic: #511D7F;
    --color-Legendary: #8E4122;
    --color-Mythic: #80622A;
    
    /* Custom Special Rainbow Palette */
    --color-Special: linear-gradient(135deg, #51f7cc 0%, #7da9fc 28%, #e374ee 62%, #ffb6a1 85%, #b5f69e 100%);

    /* Text Colors for Rarities */
    --text-Rare: #00FFFB;
    --text-Epic: #ED2BFF;
    --text-Legendary: #FBC568;
    --text-Mythic: #FFF1A9;
    --text-Special: #000000;

    /* Base Rarity Solid Backgrounds */
    --bg-Rare: linear-gradient(180deg, #104273 0%, #081a35 100%);
    --bg-Epic: linear-gradient(180deg, #4d1566 0%, #1e052c 100%);
    --bg-Legendary: linear-gradient(180deg, #743e0a 0%, #301702 100%);
    --bg-Mythic: linear-gradient(180deg, #70531c 0%, #2e2107 100%);
    
    /* Dynamic theme variants */
    --theme-bg-Basic: linear-gradient(180deg, #1c2436 0%, #0c0f17 100%);
    --theme-bg-Gold: linear-gradient(180deg, #61460b 0%, #241a02 100%);
    --theme-bg-Candy: linear-gradient(180deg, #6b183f 0%, #260514 100%);
    --theme-bg-Galaxy: linear-gradient(180deg, #1f1145 0%, #080314 100%);
    --theme-bg-Gem: linear-gradient(180deg, #114c47 0%, #041a18 100%);
    --theme-bg-Holofoil: linear-gradient(180deg, #204454 0%, #09171f 100%);
    --theme-bg-Rift: linear-gradient(180deg, #154b5e 0%, #04161c 100%);
}

* {
    box-sizing: border-box;
    font-family: 'Oswald', sans-serif;
    text-transform: uppercase;
}

body {
    background-color: var(--fn-bg);
    background-image: radial-gradient(circle at 50% 50%, #1c2333 0%, #0b0d13 100%);
    color: #ffffff;
    margin: 0;
    padding: 20px;
    letter-spacing: 0.5px;
}

.view-mode-banner {
    background-color: #1a2233;
    border: 2px solid var(--fn-neon-cyan);
    color: #ffffff;
    padding: 12px 20px;
    text-align: center;
    font-weight: 700;
    font-style: italic;
    margin-bottom: 25px;
    border-radius: 4px;
}

.view-mode-banner a {
    color: var(--fn-yellow);
    margin-left: 10px;
    text-decoration: underline;
}

.fn-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 4px solid #ffffff;
    padding-bottom: 10px;
    margin-bottom: 30px;
    gap: 15px;
}

.brand-container {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.brand-mascot {
    width: 42px;
    height: 42px;
    object-fit: contain;
    filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.5));
}

.brand-title {
    font-size: 38px;
    font-weight: 900;
    font-style: italic;
    text-shadow: 2px 2px 0px #000;
}

.nav-controls-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.progress-wrapper {
    display: flex;
    gap: 15px;
}

.live-progress-box {
    background-color: var(--fn-panel-bg);
    border: 2px solid var(--fn-border);
    border-radius: 4px;
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 190px;
}

.live-progress-text {
    font-size: 13px;
    font-weight: 700;
    color: #8a929e;
    display: flex;
    justify-content: space-between;
}

.live-progress-text span { color: #fff; }

.live-progress-bar-bg {
    background: #0e1117;
    height: 12px;
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.05);
}

.live-progress-bar-fill {
    background: linear-gradient(90deg, #22c55e, #4ade80);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

.live-progress-bar-fill.mastery-fill {
    background: linear-gradient(90deg, #e6b800, var(--fn-mastered));
}

.share-btn, .image-btn, .missing-image-btn {
    font-size: 20px;
    font-weight: 700;
    font-style: italic;
    background: linear-gradient(90deg, transparent, rgba(244,196,48,0.15));
    color: #ffffff;
    padding: 8px 24px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    height: 100%;
    display: inline-flex;
    align-items: center;
}

.share-btn { border-right: 4px solid var(--fn-yellow); }
.image-btn { border-right: 4px solid var(--fn-lime); background: linear-gradient(90deg, transparent, rgba(50,205,50,0.15)); }
.missing-image-btn { border-right: 4px solid var(--fn-unreleased); background: linear-gradient(90deg, transparent, rgba(239,68,68,0.15)); }

.share-btn:hover { background: linear-gradient(90deg, transparent, rgba(244,196,48,0.3)); border-color: rgba(255,255,255,0.2); }
.image-btn:hover { background: linear-gradient(90deg, transparent, rgba(50,205,50,0.3)); border-color: rgba(255,255,255,0.2); }
.missing-image-btn:hover { background: linear-gradient(90deg, transparent, rgba(239,68,68,0.3)); border-color: rgba(255,255,255,0.2); }

.app-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    align-items: start;
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel-box {
    background-color: var(--fn-panel-bg);
    border: 3px solid var(--fn-border);
    border-radius: 8px;
    padding: 20px;
    box-shadow: inset 0 0 15px rgba(0,0,0,0.5);
}

.filter-header {
    font-size: 14px;
    color: #8a929e;
    margin: 0 0 8px 0;
    font-style: italic;
}

.fn-input, .fn-select {
    width: 100%;
    background-color: #0e1117;
    border: 2px solid var(--fn-border);
    color: #fff;
    padding: 10px;
    font-size: 16px;
    border-radius: 4px;
    margin-bottom: 12px;
}

.toggle-container {
    display: flex;
    background: #0e1117;
    border: 2px solid var(--fn-border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 12px;
}

.toggle-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #8a929e;
    padding: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease-out;
}

.toggle-btn.active {
    background: var(--fn-neon-cyan);
    color: #000;
}

.switch-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 2px;
    margin-top: 4px;
}

.switch-label { font-size: 14px; font-weight: 700; }

.switch-input {
    appearance: none;
    width: 44px;
    height: 22px;
    background: #0e1117;
    border: 2px solid var(--fn-border);
    border-radius: 11px;
    position: relative;
    cursor: pointer;
    transition: background 0.2s;
}

.switch-input:checked { background: var(--fn-unreleased); border-color: var(--fn-unreleased); }

.switch-input::before {
    content: '';
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    top: 2px;
    left: 2px;
    transition: transform 0.2s;
}

.switch-input:checked::before { transform: translateX(22px); }

.creator-card { text-align: center; display: flex; flex-direction: column; align-items: center; }
.creator-title { font-size: 20px; font-weight: 900; color: var(--fn-yellow); margin-bottom: 12px; font-style: italic; }

.creator-link {
    display: block;
    text-decoration: none;
    border: 2px solid var(--fn-border);
    border-radius: 6px;
    overflow: hidden;
    transition: border-color 0.15s;
    background: #0e1117;
    max-width: 50%;
    margin: 0 auto;
}
.creator-link:hover { border-color: #ff0000; }
.creator-img { width: 100%; height: auto; display: block; }
.creator-subtext { font-size: 13px; color: #a0aec0; margin-top: 10px; line-height: 1.4; font-weight: 500; }

.sub-btn {
    display: inline-block;
    background-color: #ff0000;
    color: #ffffff;
    font-weight: 700;
    padding: 6px 16px;
    margin-top: 10px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.15s;
    border: none;
    cursor: pointer;
}
.sub-btn:hover { background-color: #cc0000; }

.sprite-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}

.sprite-card {
    border: 3px solid #1a2233;
    background-color: #0f141d;
    border-radius: 0px; 
    padding: 0px;
    position: relative;
    cursor: pointer;
    aspect-ratio: 1 / 1.25;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
    transition: transform 0.15s, border-color 0.15s;
}

.sprite-card:hover {
    transform: translate3d(0, -4px, 0);
    border-color: #ffffff;
    z-index: 10;
}

.sprite-card.rarity-Rare .card-inner-display { background: var(--bg-Rare); }
.sprite-card.rarity-Epic .card-inner-display { background: var(--bg-Epic); }
.sprite-card.rarity-Legendary .card-inner-display { background: var(--bg-Legendary); }
.sprite-card.rarity-Mythic .card-inner-display { background: var(--bg-Mythic); }

.sprite-card.rarity-Special.theme-Basic .card-inner-display { background: var(--theme-bg-Basic); }
.sprite-card.rarity-Special.theme-Gold .card-inner-display { background: var(--theme-bg-Gold); }
.sprite-card.rarity-Special.theme-Candy .card-inner-display { background: var(--theme-bg-Candy); }
.sprite-card.rarity-Special.theme-Galaxy .card-inner-display { background: var(--theme-bg-Galaxy); }
.sprite-card.rarity-Special.theme-Gem .card-inner-display { background: var(--theme-bg-Gem); }
.sprite-card.rarity-Special.theme-Holofoil .card-inner-display { background: var(--theme-bg-Holofoil); }
.sprite-card.rarity-Special.theme-Rift .card-inner-display { background: var(--theme-bg-Rift); }

.card-inner-display {
    flex: 1;
    width: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.sprite-img {
    max-width: 82%;
    max-height: 82%;
    object-fit: contain;
    filter: drop-shadow(0px 10px 12px rgba(0,0,0,0.6));
    z-index: 2;
}

.sprite-card.obtained { border-color: var(--fn-lime); box-shadow: 0 0 20px rgba(50, 205, 80, 0.45); }
.sprite-card.obtained.mastered { border-color: var(--fn-mastered) !important; box-shadow: 0 0 20px rgba(255, 215, 0, 0.6) !important; }

.status-badge.unreleased { position: absolute; top: 6px; left: 6px; background: var(--fn-unreleased); color: #fff; font-size: 10px; font-weight: 900; padding: 1px 6px; z-index: 4; transform: skewX(-10deg); }
.status-badge.collected { position: absolute; top: 6px; left: 6px; background: var(--fn-collected); color: #fff; font-size: 10px; font-weight: 900; padding: 1px 6px; z-index: 4; transform: skewX(-10deg); }
.status-badge.mastered-badge { position: absolute; top: 6px; left: 6px; background: linear-gradient(90deg, #b8860b, var(--fn-mastered)); color: #000; font-size: 10px; font-weight: 900; padding: 1px 6px; z-index: 4; transform: skewX(-10deg); }

/* FLOATING HEAD CROWN (Animation stripped to remove lag) */
.rendered-head-crown {
    position: absolute;
    top: 12%;
    font-size: 26px;
    z-index: 6;
    pointer-events: none;
    line-height: 1;
    filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.6));
}

/* POSITIONED ACTION CROWN */
.crown-action-icon {
    position: absolute;
    bottom: 65px; 
    left: 3px;    
    font-size: 19px;
    z-index: 9;
    cursor: pointer;
    line-height: 1;
    filter: drop-shadow(0px 2px 4px rgba(0,0,0,0.9));
    transition: transform 0.1s ease;
    user-select: none;
}
.crown-action-icon:hover { transform: scale(1.25); }

.fortnite-rarity-tag {
    position: absolute;
    bottom: 0px;
    left: 0px;
    font-size: 11px;
    font-weight: 900;
    padding: 2px 14px 2px 6px;
    z-index: 4;
    clip-path: polygon(0 0, 84% 0, 100% 100%, 0 100%);
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.sprite-card.rarity-Rare .fortnite-rarity-tag { background: var(--color-Rare); color: var(--text-Rare); }
.sprite-card.rarity-Epic .fortnite-rarity-tag { background: var(--color-Epic); color: var(--text-Epic); }
.sprite-card.rarity-Legendary .fortnite-rarity-tag { background: var(--color-Legendary); color: var(--text-Legendary); }
.sprite-card.rarity-Mythic .fortnite-rarity-tag { background: var(--color-Mythic); color: var(--text-Mythic); }
.sprite-card.rarity-Special .fortnite-rarity-tag { background: var(--color-Special); color: var(--text-Special); }

.card-title-footer {
    height: 38px;
    padding: 0px 4px;
    color: #ffffff;
    z-index: 3;
    position: relative;
    background-color: rgba(15, 20, 29, 0.9);
    border-top: 1px solid rgba(255,255,255,0.06);
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.card-title-footer span {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-align: center;
}

.creator-card {
    position: relative;
}

.close-creator-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: transform 0.1s ease;
    z-index: 5;
}

.close-creator-btn:hover {
    transform: scale(1.2);
}

.sprite-card::after { content: ''; position: absolute; bottom: 0; left: 0; right: 0; height: 4px; z-index: 5; }
.sprite-card.rarity-Rare::after { background: var(--color-Rare); }
.sprite-card.rarity-Epic::after { background: var(--color-Epic); }
.sprite-card.rarity-Legendary::after { background: var(--color-Legendary); }
.sprite-card.rarity-Mythic::after { background: var(--color-Mythic); }
.sprite-card.rarity-Special::after { background: var(--color-Special); }
.sprite-card.mastered::after { background: var(--fn-mastered) !important; }

/* LOW FIDELITY OVERRIDES */
body.low-fidelity .sprite-card.rarity-Rare .card-inner-display { background: #104273 !important; }
body.low-fidelity .sprite-card.rarity-Epic .card-inner-display { background: #4d1566 !important; }
body.low-fidelity .sprite-card.rarity-Legendary .card-inner-display { background: #743e0a !important; }
body.low-fidelity .sprite-card.rarity-Mythic .card-inner-display { background: #70531c !important; }
body.low-fidelity .sprite-card.rarity-Special .card-inner-display { background: #1c2436 !important; }


/* ==========================================
   COMPLETE MOBILE UI OPTIMIZATION (<= 768px)
   ========================================== */
@media (max-width: 768px) {
    body {
        padding: 12px; 
    }

    .app-layout {
        display: flex;
        flex-direction: column;
        gap: 16px;
    }

    .sidebar {
        display: flex;
        flex-direction: column;
        gap: 16px;
        display: contents; 
    }

    .sidebar .panel-box:not(.creator-card) {
        order: 1;
        width: 100%;
    }

    .sprite-grid {
        order: 2;
        width: 100%;
    }

    .creator-card {
        order: 3;
        width: 100%;
    }

    .fn-navbar {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        padding-bottom: 14px;
        border-bottom-width: 3px;
    }

    .brand-container {
        justify-content: center; 
    }

    .brand-title {
        font-size: 28px; 
    }

    .nav-controls-right {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
        gap: 10px;
    }

    .progress-wrapper {
        flex-direction: column; 
        gap: 8px;
        width: 100%;
    }

    .live-progress-box {
        min-width: 100%; 
    }

    .nav-controls-right > .share-btn,
    .nav-controls-right > .image-btn,
    .nav-controls-right > .missing-image-btn {
        display: flex;
        justify-content: center;
        font-size: 16px;
        padding: 10px 16px;
        height: auto;
        width: 100%;
        border-right: none;
        border-bottom: 3px solid transparent;
    }

    .share-btn { border-bottom-color: var(--fn-yellow) !important; }
    .image-btn { border-bottom-color: var(--fn-lime) !important; }
    .missing-image-btn { border-bottom-color: var(--fn-unreleased) !important; }

    .panel-box {
        padding: 14px; 
    }

    .fn-input, .fn-select, .toggle-container {
        margin-bottom: 8px;
        font-size: 15px;
        padding: 8px;
    }

    .sprite-grid {
        grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); 
        gap: 8px;
    }

    .card-title-footer {
        height: 32px; 
        font-size: 12px;
    }

    .fortnite-rarity-tag {
        font-size: 9px;
        padding: 1px 10px 1px 4px;
    }

    .crown-action-icon {
        bottom: 40px; 
        font-size: 16px;
    }

    .creator-card {
        padding: 12px;
        margin-top: 10px; 
    }

    .creator-link {
        max-width: 120px; 
        margin: 0 auto;   
        display: block;
    }

    .creator-img {
        width: 80px;      
        height: 80px;
        border-radius: 50%;
        object-fit: cover;
    }

    .creator-title {
        font-size: 18px;
        margin-bottom: 6px;
    }

    .creator-subtext {
        font-size: 12px;
        margin-top: 6px;
    }
}

/* ==========================================
   LANDSCAPE MOBILE OPTIMIZATION
   ========================================== */
@media (max-width: 932px) and (orientation: landscape) {
    .app-layout {
        display: flex;
        flex-direction: column;
        align-items: center; 
        width: 100%;
    }

    .sidebar {
        display: contents; 
    }

    .sidebar .panel-box:not(.creator-card) {
        order: 1;
        width: 100%;
        max-width: 500px; 
        text-align: center;
        margin: 0 auto;
    }

    .sprite-grid {
        order: 2;
        width: 100%;
        justify-content: center; 
        grid-template-columns: repeat(auto-fill, minmax(115px, 1fr));
        gap: 10px;
    }

    .creator-card {
        order: 3;
        width: 100%;
        max-width: 500px;
        margin: 15px auto 0 auto;
        text-align: center;
    }
}

/* ==========================================
   SETTINGS BOX ACTIVE SWITCHES (GREEN)
   ========================================== */
.sidebar .switch-input:checked {
    accent-color: #22c55e !important; 
    background-color: #22c55e !important;
    border-color: #32cd32 !important;
}