: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;
    --fn-magenta: #ed2bff;

    /* 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;
    flex-wrap: wrap;
    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;
    flex-wrap: wrap;
    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, .unmastered-image-btn, .mastered-image-btn {
    font-size: 20px;
    font-weight: 700;
    font-style: italic;
    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-magenta); background: linear-gradient(90deg, transparent, rgba(237,43,255,0.15)); }
.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)); }
.unmastered-image-btn { border-right: 4px solid var(--fn-neon-cyan); background: linear-gradient(90deg, transparent, rgba(0,240,255,0.15)); }
.mastered-image-btn { border-right: 4px solid var(--fn-mastered); background: linear-gradient(90deg, transparent, rgba(255,215,0,0.15)); }

.share-btn:hover { background: linear-gradient(90deg, transparent, rgba(237,43,255,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); }
.unmastered-image-btn:hover { background: linear-gradient(90deg, transparent, rgba(0,240,255,0.3)); border-color: rgba(255,255,255,0.2); }
.mastered-image-btn:hover { background: linear-gradient(90deg, transparent, rgba(255,215,0,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); }

.progress-pct {
    color: var(--fn-yellow);
    font-size: 11px;
    margin-left: 6px;
}

.action-btn-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.discord-btn, .view-toggle-btn {
    background: #4338ca;
    color: #fff;
    border: none;
    border-bottom: 3px solid #312e81;
    font-weight: 700;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    transition: filter 0.15s;
}
.discord-btn:hover, .view-toggle-btn:hover { filter: brightness(1.15); }
.view-toggle-btn { background: #334155; border-bottom-color: #1e293b; }

.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-img.img-missing {
    opacity: 0.25;
    filter: grayscale(1);
}

.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); }
.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 {
    min-height: 52px;
    padding: 4px 4px 5px;
    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;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 3px;
    overflow: hidden;
}

.card-title-row {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.card-title-row span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    white-space: nowrap;
    text-align: center;
    font-size: 14px;
    line-height: 1.1;
}

.mastery-btn {
    font-family: 'Oswald', sans-serif;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 1px;
    padding: 2px 10px;
    border-radius: 3px;
    border: 2px solid transparent;
    cursor: pointer;
    line-height: 1.2;
    transition: transform 0.1s, filter 0.1s, background 0.1s;
    text-transform: uppercase;
}

.mastery-btn.is-master {
    background: linear-gradient(180deg, #a16207, #854d0e);
    color: #fff;
    border-color: var(--fn-mastered);
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.35);
}

.mastery-btn.is-master:hover {
    filter: brightness(1.15);
    transform: scale(1.05);
}

.mastery-btn.is-mastered {
    background: linear-gradient(90deg, #b8860b, var(--fn-mastered));
    color: #000;
    border-color: #fde047;
    cursor: pointer;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

.mastery-btn.is-mastered:hover {
    filter: brightness(1.08);
}

.mastery-label.is-mastered {
    font-family: 'Oswald', sans-serif;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 1px;
    padding: 2px 10px;
    border-radius: 3px;
    background: linear-gradient(90deg, #b8860b, var(--fn-mastered));
    color: #000;
    border: 2px solid #fde047;
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* Stats sidebar */
.stats-list { display: flex; flex-direction: column; gap: 5px; }
.stat-row { display: flex; align-items: center; gap: 6px; font-size: 11px; }
.stat-label { width: 68px; text-align: right; opacity: 0.75; flex-shrink: 0; }
.stat-bar-bg { flex: 1; height: 8px; background: #0e1117; border-radius: 2px; overflow: hidden; }
.stat-bar-fill { height: 100%; transition: width 0.3s; }
.stat-count { width: 36px; text-align: right; font-variant-numeric: tabular-nums; flex-shrink: 0; }

.rarest-list { font-size: 12px; line-height: 1.6; }
.rarest-item { color: #fda4af; padding: 2px 0; }
.rarest-done { color: var(--fn-collected); }

/* Tools panel */
.bulk-btn-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tool-btn {
    background: #334155;
    color: #fff;
    border: 1px solid var(--fn-border);
    padding: 6px 8px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 3px;
    transition: background 0.15s;
}
.tool-btn:hover { background: #475569; }
.tool-btn-full { width: 100%; margin-top: 6px; }
.tool-btn-green { background: #166534; border-color: #14532d; }
.tool-btn-green:hover { background: #15803d; }
.tool-btn-gold { background: #854d0e; border-color: #713f12; }
.tool-btn-gold:hover { background: #a16207; }
.tool-btn-danger { background: #7f1d1d; border-color: #991b1b; color: #fca5a5; }
.tool-btn-danger:hover { background: #991b1b; }

/* Checklist table view */
.sprite-grid.table-mode {
    display: block;
    overflow-x: auto;
}
.checklist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    background: #0f141d;
}
.checklist-table th {
    background: #181c25;
    padding: 8px 6px;
    border: 1px solid var(--fn-border);
    text-align: center;
    font-weight: 700;
}
.checklist-table td {
    border: 1px solid var(--fn-border);
    padding: 4px;
    vertical-align: middle;
}
.checklist-name { font-weight: 700; padding-left: 10px !important; white-space: nowrap; }
.checklist-cell { text-align: center; }
.checklist-thumb {
    position: relative;
    width: 56px;
    height: 56px;
    margin: 0 auto;
    cursor: pointer;
    border: 2px solid #3b4253;
    border-radius: 4px;
    overflow: hidden;
    background: #0b0d13;
    transition: border-color 0.15s;
}
.checklist-thumb:hover { border-color: #fff; }
.checklist-thumb.owned { border-color: var(--fn-collected); }
.checklist-thumb.mastered { border-color: var(--fn-mastered); }
.checklist-thumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.checklist-thumb img.img-missing { opacity: 0.3; filter: grayscale(1); }
.checklist-mark {
    position: absolute;
    bottom: 1px;
    right: 2px;
    font-size: 10px;
    color: var(--fn-collected);
    font-weight: 900;
}
.checklist-na { opacity: 0.3; }

/* FAQ & footer */
.faq-section { margin-top: 30px; max-width: 800px; }
.faq-item {
    background: var(--fn-panel-bg);
    border: 1px solid var(--fn-border);
    border-radius: 4px;
    margin-bottom: 8px;
    padding: 0 14px;
}
.faq-item summary {
    cursor: pointer;
    font-weight: 700;
    padding: 12px 0;
    color: var(--fn-yellow);
    list-style: none;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item p {
    margin: 0 0 14px;
    font-size: 13px;
    line-height: 1.5;
    text-transform: none;
    color: #a0aec0;
    font-weight: 400;
}
.site-footer {
    margin-top: 24px;
    padding: 16px 0;
    border-top: 1px solid var(--fn-border);
    font-size: 11px;
    color: #64748b;
    text-transform: none;
    font-weight: 400;
    line-height: 1.5;
}
.site-footer p { margin: 0; }

/* Toast */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 10px 18px;
    border-radius: 4px;
    font-size: 13px;
    z-index: 9999;
    border: 1px solid var(--fn-border);
    text-transform: none;
}
.toast.hidden { display: none; }

.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 {
        order: 1;
        width: 100%;
    }

    .sprite-grid {
        order: 2;
        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%; 
    }

    .action-btn-row {
        flex-direction: column;
        width: 100%;
    }

    .action-btn-row > button {
        display: flex;
        justify-content: center;
        font-size: 14px;
        padding: 10px 16px;
        width: 100%;
    }

    .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 {
        min-height: 46px;
    }

    .card-title-row span {
        font-size: 12px;
    }

    .mastery-btn {
        font-size: 10px;
        padding: 2px 8px;
    }

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

}

/* ==========================================
   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 {
        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;
    }
}

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