/* Base Styles & Layout */
body {
    margin: 0; min-height: 100vh; background-color: #000000;
    color: #ffffff; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
    transition: box-shadow 0.5s ease;
}

/* Active Boost Visual Effect & Speed Overrides */
body.boost-active-bg::after { 
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    box-shadow: inset 0 0 150px rgba(255, 23, 68, 0.4);
    pointer-events: none;
    z-index: 9999;
}

body.boost-active-bg .card-inner { transition-duration: 0.2s !important; }
body.boost-active-bg .anim-pop-common,
body.boost-active-bg .anim-pop-uncommon,
body.boost-active-bg .anim-pop-rare,
body.boost-active-bg .anim-pop-core-parts {
    animation: none !important;
    box-shadow: none !important;
}
body.boost-active-bg .anim-pop-epic      { animation-duration: 0.25s  !important; }
body.boost-active-bg .anim-pop-legendary { animation-duration: 0.25s  !important; }
body.boost-active-bg .anim-pop-mythic    { animation-duration: 0.25s  !important; }
body.boost-active-bg .anim-pop-prismatic { animation-duration: 0.4s  !important; }
body.boost-active-bg .anim-epic-thud     { animation-duration: 0.1s !important; }
body.boost-active-bg .screen-shake-epic  { animation-duration: 0.1s !important; }
body.boost-active-bg .screen-shake       { animation-duration: 0.15s  !important; }
body.boost-active-bg .screen-shake-mythic{ animation-duration: 0.2s !important; }
body.boost-active-bg .vignette-legendary,
body.boost-active-bg .vignette-mythic    { animation-duration: 0.25s !important; }
body.boost-active-bg .vignette-prismatic { animation-duration: 0.35s  !important; }
body.boost-active-bg .show-legendary-text{ animation-duration: 0.6s  !important; }

body.boost-active-bg .tease-uncommon,
body.boost-active-bg .tease-rare,
body.boost-active-bg .tease-core-parts { animation-duration: 0.5s  !important; }
body.boost-active-bg .tease-epic,
body.boost-active-bg .tease-legendary,
body.boost-active-bg .tease-mythic { animation-duration: 0.3s  !important; }
body.boost-active-bg .new-badge { animation-delay: 0.1s !important; animation-duration: 0.2s !important; }

/* --- Tabs Navigation --- */
.top-nav {
    display: flex; justify-content: center; background: rgba(0, 0, 0, 0.6); padding: 15px 20px 0; border-bottom: 2px solid #b922ff; gap: 8px; margin-bottom: 20px; width: 100%; box-sizing: border-box; backdrop-filter: blur(5px); border-radius: 16px 16px 0 0; transition: border-color 0.3s;
}
.tab-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: rgba(0, 0, 0, 0.5); color: #888; border: 1px solid rgba(255, 255, 255, 0.1); border-bottom: none; border-radius: 12px 12px 0 0; padding: 12px 16px; font-size: 15px; font-weight: bold; cursor: pointer; transition: 0.2s; position: relative; bottom: 0; white-space: nowrap; backdrop-filter: blur(5px);
}
.tab-btn:hover { background: rgba(0, 0, 0, 0.8); color: #fff; }
.tab-btn.active {
    background: #000000; color: #b922ff; border-color: #b922ff; padding-bottom: 12px; box-shadow: 0 -5px 15px rgba(185, 34, 255, 0.2); z-index: 10; transition: all 0.3s;
}

.tab-pane { display: none; width: 100%; animation: fadeInTab 0.3s ease; flex: 1; min-height: 0; }
.tab-pane.active { display: flex; flex-direction: column; align-items: center; gap: 15px; }
@keyframes fadeInTab { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

.tab-container {
    width: 100%; max-width: 1000px; margin: 0 auto; background: rgba(0, 0, 0, 0.75); backdrop-filter: blur(8px); border-radius: 16px; padding: 30px; box-sizing: border-box; box-shadow: 0 10px 30px rgba(0,0,0,0.6); border: 1px solid rgba(255, 255, 255, 0.1);
    display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: visible; position: relative;
}

/* Main Flex Container */
.game-wrapper { 
    display: flex; flex-direction: row; align-items: flex-start; justify-content: center;
    width: 1400px; height: 900px; max-width: 1400px; flex-shrink: 0; margin: 0 auto; padding-top: 15px; padding-bottom: 15px; gap: 30px; box-sizing: border-box;
    contain: layout size; /* Prevent CLS from internal rendering */
}

.left-panel { flex: 1 1 65%; display: flex; flex-direction: column; align-items: center; gap: 15px; min-width: 0; height: 100%; position: relative; z-index: 10; background: #0a0a0a url('assets/BoardUI.webp') center/cover no-repeat; border-radius: 16px; overflow: visible; box-shadow: inset 0 0 150px 50px #000000; contain: layout; }
.right-panel { flex: 0 0 35%; min-width: 320px; max-width: 480px; display: flex; flex-direction: column; height: 100%; position: relative; z-index: 5; background: #0a0a0a url('assets/CardLibraryUI.webp') center/cover no-repeat; border-radius: 16px; overflow: hidden; contain: layout; }

/* Premium Card Dim Overlay */
.left-panel::before {
    content: '';
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 900;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.4s ease-out;
}
body.dim-background .left-panel::before {
    opacity: 1;
}

/* --- Dynamic Tab Ember Color Palettes --- */
:root {
    --ember-1: #6e0065; --ember-2: #eb50ff; --ember-3: #336aff; --ember-4: #b922ff; --ember-5: #94006f; --ember-6: #65c1ff;
    --ember-a1: #1472ff; --ember-a2: #2e1fff; --ember-a3: #7e005e; --ember-a4: #118aec; --ember-a5: #00299b;
    --ember-glow-1: #9e0dff; --ember-glow-2: #5b00a5;
}

body[data-active-tab="missions"] {
    --ember-1: #1b5e20; --ember-2: #4caf50; --ember-3: #81c784; --ember-4: #2e7d32; --ember-5: #388e3c; --ember-6: #aed581;
    --ember-a1: #388e3c; --ember-a2: #66bb6a; --ember-a3: #2e7d32; --ember-a4: #81c784; --ember-a5: #1b5e20;
    --ember-glow-1: #4caf50; --ember-glow-2: #1b5e20;
}

body[data-active-tab="core"] {
    --ember-1: #006064; --ember-2: #00e5ff; --ember-3: #00bcd4; --ember-4: #0097a7; --ember-5: #00838f; --ember-6: #84ffff;
    --ember-a1: #00bcd4; --ember-a2: #4dd0e1; --ember-a3: #0097a7; --ember-a4: #84ffff; --ember-a5: #006064;
    --ember-glow-1: #00e5ff; --ember-glow-2: #00838f;
}

body[data-active-tab="forge"] {
    --ember-1: #e65100; --ember-2: #ff8f00; --ember-3: #ffb300; --ember-4: #f57c00; --ember-5: #ef6c00; --ember-6: #ffe082;
    --ember-a1: #f57c00; --ember-a2: #ffca28; --ember-a3: #ef6c00; --ember-a4: #ffe082; --ember-a5: #e65100;
    --ember-glow-1: #ff8f00; --ember-glow-2: #e65100;
}

body[data-active-tab="shop"] {
    --ember-1: #4a148c; --ember-2: #ba68c8; --ember-3: #ab47bc; --ember-4: #7b1fa2; --ember-5: #8e24aa; --ember-6: #e1bee7;
    --ember-a1: #ab47bc; --ember-a2: #ce93d8; --ember-a3: #8e24aa; --ember-a4: #e1bee7; --ember-a5: #4a148c;
    --ember-glow-1: #ba68c8; --ember-glow-2: #4a148c;
}

body[data-active-tab="achievements"] {
    --ember-1: #00e5ff; --ember-2: #ffb300; --ember-3: #4fc3f7; --ember-4: #ffca28; --ember-5: #0288d1; --ember-6: #ffe082;
    --ember-a1: #ffb300; --ember-a2: #84ffff; --ember-a3: #ffca28; --ember-a4: #4fc3f7; --ember-a5: #ffe082;
    --ember-glow-1: #00e5ff; --ember-glow-2: #ffb300;
}

body[data-active-tab="account"] {
    --ember-1: #01579b; --ember-2: #4fc3f7; --ember-3: #0288d1; --ember-4: #03a9f4; --ember-5: #0277bd; --ember-6: #81d4fa;
    --ember-a1: #0288d1; --ember-a2: #4dd0e1; --ember-a3: #03a9f4; --ember-a4: #81d4fa; --ember-a5: #01579b;
    --ember-glow-1: #4fc3f7; --ember-glow-2: #01579b;
}

body[data-active-tab="rank"] {
    --ember-1: #ff8f00; --ember-2: #ffb300; --ember-3: #ffca28; --ember-4: #ffc107; --ember-5: #ffd54f; --ember-6: #ffe082;
    --ember-a1: #ffc107; --ember-a2: #ffd54f; --ember-a3: #ffb300; --ember-a4: #ffe082; --ember-a5: #ff8f00;
    --ember-glow-1: #ffb300; --ember-glow-2: #ff8f00;
}

/* Active Tab Dynamic Highlights */
body[data-active-tab="missions"] .tab-btn.active { color: #81c784; border-color: #81c784; box-shadow: 0 -5px 15px rgba(129, 199, 132, 0.2); }
body[data-active-tab="missions"] .top-nav { border-bottom-color: #81c784; }

body[data-active-tab="core"] .tab-btn.active { color: #00e5ff; border-color: #00e5ff; box-shadow: 0 -5px 15px rgba(0, 229, 255, 0.2); }
body[data-active-tab="core"] .top-nav { border-bottom-color: #00e5ff; }

body[data-active-tab="forge"] .tab-btn.active { color: #ffb300; border-color: #ffb300; box-shadow: 0 -5px 15px rgba(255, 179, 0, 0.2); }
body[data-active-tab="forge"] .top-nav { border-bottom-color: #ffb300; }

body[data-active-tab="shop"] .tab-btn.active { color: #ba68c8; border-color: #ba68c8; box-shadow: 0 -5px 15px rgba(186, 104, 200, 0.2); }
body[data-active-tab="shop"] .top-nav { border-bottom-color: #ba68c8; }

body[data-active-tab="achievements"] .tab-btn.active { color: #00e5ff; border-color: #00e5ff; box-shadow: 0 -5px 15px rgba(0, 229, 255, 0.2); }
body[data-active-tab="achievements"] .top-nav { border-bottom-color: #00e5ff; }

body[data-active-tab="account"] .tab-btn.active { color: #4fc3f7; border-color: #4fc3f7; box-shadow: 0 -5px 15px rgba(79, 195, 247, 0.2); }
body[data-active-tab="account"] .top-nav { border-bottom-color: #4fc3f7; }

body[data-active-tab="rank"] .tab-btn.active { color: #ffb300; border-color: #ffb300; box-shadow: 0 -5px 15px rgba(255, 179, 0, 0.2); }
body[data-active-tab="rank"] .top-nav { border-bottom-color: #ffb300; }

/* Tab Icon Glow & Hover Animation */
.tab-btn img, .tab-btn .tab-icon {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.3s ease;
    display: inline-block;
    flex-shrink: 0;
    object-fit: contain;
}
.tab-btn.active img, .tab-btn.active .tab-icon {
    filter: drop-shadow(0 0 6px currentColor);
}
.tab-btn:hover img, .tab-btn:hover .tab-icon {
    transform: scale(1.15) translateY(-2px);
    filter: drop-shadow(0 0 8px currentColor) brightness(1.2);
}
.tab-btn.active:hover img, .tab-btn.active:hover .tab-icon {
    filter: drop-shadow(0 0 12px currentColor) brightness(1.2);
}

/* Floating Magical Embers Background */
.magical-embers {
    position: absolute;
    top: 0; left: -20px; right: -20px; bottom: 0;
    pointer-events: none;
    z-index: 1; /* Below UI elements, above background */
    mix-blend-mode: screen;
    opacity: 0.8;
    /* Mask so embers mostly show at the bottom and fade completely before the top */
    -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 60%);
    mask-image: linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 60%);
    
    background-image: 
        radial-gradient(3px 3px at 15% 55%, var(--ember-1) 20%, transparent),
        radial-gradient(2px 2px at 25% 15%, var(--ember-2) 20%, transparent),
        radial-gradient(2.5px 2.5px at 45% 75%, var(--ember-3) 20%, transparent),
        radial-gradient(4px 4px at 65% 25%, var(--ember-4) 20%, transparent),
        radial-gradient(2px 2px at 85% 65%, var(--ember-5) 20%, transparent),
        radial-gradient(3px 3px at 95% 35%, var(--ember-6) 20%, transparent);
    background-size: 250px 250px;
    animation: floatEmbersMain 18s linear infinite, swayEmbers 8s ease-in-out infinite;
    filter: drop-shadow(0 0 5px var(--ember-glow-1)) drop-shadow(0 0 10px var(--ember-glow-2));
    transition: filter 0.5s ease;
}

.magical-embers::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: 
        radial-gradient(2px 2px at 5% 85%, var(--ember-a1) 20%, transparent),
        radial-gradient(3.5px 3.5px at 35% 35%, var(--ember-a2) 20%, transparent),
        radial-gradient(2.5px 2.5px at 55% 95%, var(--ember-a3) 20%, transparent),
        radial-gradient(4px 4px at 75% 45%, var(--ember-a4) 20%, transparent),
        radial-gradient(2px 2px at 85% 85%, var(--ember-a5) 20%, transparent);
    background-size: 350px 350px;
    animation: floatEmbersAfter 12s linear infinite;
}

body.boost-active-bg {
    --ember-1: #ff1744 !important; --ember-2: #ff5252 !important; --ember-3: #ff8a80 !important; --ember-4: #d50000 !important; --ember-5: #ff8f00 !important; --ember-6: #ffb300 !important;
    --ember-a1: #ff5252 !important; --ember-a2: #d50000 !important; --ember-a3: #ff1744 !important; --ember-a4: #ff8a80 !important; --ember-a5: #b71c1c !important;
    --ember-glow-1: #ff1744 !important; --ember-glow-2: #d50000 !important;
}

@keyframes floatEmbersMain { 0% { background-position: 0px 0px; } 100% { background-position: 0px -250px; } }
@keyframes floatEmbersAfter { 0% { background-position: 0px 0px; } 100% { background-position: 0px -350px; } }
@keyframes swayEmbers { 0%, 100% { transform: translateX(0px); } 50% { transform: translateX(20px); } }

/* Auth Modal Embers */
.auth-embers {
    left: 0; right: 0;
    border-radius: 16px;
    overflow: hidden;
    z-index: 0;
    
    /* Let embers travel to the very top before fading out */
    -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 95%);
    mask-image: linear-gradient(to top, rgba(0,0,0,1) 0%, rgba(0,0,0,0) 95%);
    
    /* Fade in smoothly on load and move significantly faster */
    animation: authEmberFadeIn 3s ease-out forwards, floatEmbersMain 10s linear infinite, swayEmbers 5s ease-in-out infinite;
    
    --ember-1: #7b1fa2; --ember-2: #b922ff; --ember-3: #ab47bc; --ember-4: #4a148c; --ember-5: #8e24aa; --ember-6: #e1bee7;
    --ember-a1: #ab47bc; --ember-a2: #ce93d8; --ember-a3: #8e24aa; --ember-a4: #e1bee7; --ember-a5: #4a148c;
    --ember-glow-1: #b922ff; --ember-glow-2: #7b1fa2;
}

.auth-embers::after { animation: floatEmbersAfter 7s linear infinite; }
@keyframes authEmberFadeIn { 0% { opacity: 0; } 100% { opacity: 0.8; } }

/* Top Stats */
.gem-stat, .stardust-stat {
    background: rgba(0, 0, 0, 0.7);
    padding: 6px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(4px);
    font-weight: bold;
    display: inline-flex;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.5);
}
.gem-stat { color: #4fc3f7; border-color: rgba(79, 195, 247, 0.3); }
.stardust-stat { color: #ba68c8; border-color: rgba(186, 104, 200, 0.3); }

@keyframes popCurrency {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); filter: brightness(1.5); text-shadow: 0 0 10px rgba(255,255,255,0.5); }
    100% { transform: scale(1); }
}
.currency-pop {
    animation: popCurrency 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Pity Progress Bar */
.pity-bar-bg { width: 100%; height: 10px; background: #333; border-radius: 5px; overflow: hidden; box-shadow: inset 0 1px 3px rgba(0,0,0,0.5); position: relative; border: 1px solid #444; box-sizing: border-box; }
.pity-bar-bg::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background-image: linear-gradient(90deg, transparent calc(25% - 1px), rgba(0,0,0,0.6) calc(25% - 1px), rgba(0,0,0,0.6) calc(25% + 1px), transparent calc(25% + 1px), transparent calc(50% - 1px), rgba(0,0,0,0.6) calc(50% - 1px), rgba(0,0,0,0.6) calc(50% + 1px), transparent calc(50% + 1px), transparent calc(75% - 1px), rgba(0,0,0,0.6) calc(75% - 1px), rgba(0,0,0,0.6) calc(75% + 1px), transparent calc(75% + 1px));
    pointer-events: none; z-index: 10;
}
.pity-bar-fill { height: 100%; width: 0%; transition: width 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), background 0.3s; background: linear-gradient(90deg, #ff8f00, #ffb300); }

.action-btn { background: #333; color: #fff; font-size: 13px; padding: 8px 14px; border: none; border-radius: 8px; cursor: pointer; transition: 0.2s; font-weight: bold; }

/* Gem & Energy Refill Buttons */
.action-btn.gem-buy, .btn-buy-energy, .btn-buy-max { 
    background: linear-gradient(135deg, #0288d1, #00b0ff) !important; 
    border: 1px solid #4fc3f7 !important; 
    box-shadow: 0 4px 10px rgba(0, 176, 255, 0.3) !important; 
    position: relative; 
    overflow: hidden; 
    color: #fff !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5) !important; 
}
.action-btn.boost-buy { 
    background: linear-gradient(135deg, #d50000, #ff1744) !important; 
    border: 1px solid #ff8a80 !important; 
    box-shadow: 0 4px 10px rgba(255, 23, 68, 0.3) !important; 
    position: relative; 
    overflow: hidden; 
    color: #fff !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.5) !important; 
}
.quick-refill-panel {
    justify-content: center !important;
}
.action-btn.gem-buy::after, .btn-buy-energy::after, .btn-buy-max::after, .action-btn.boost-buy::after {
    content: ''; position: absolute; top: 0; left: -100%; width: 50%; height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.4) 50%, rgba(255,255,255,0) 100%);
    transform: skewX(-25deg); animation: buttonShine 3s infinite;
}
@keyframes buttonShine {
    0% { left: -100%; } 20% { left: 200%; } 100% { left: 200%; }
}
.action-btn.gem-buy:hover:not(:disabled), .btn-buy-energy:hover:not(:disabled), .btn-buy-max:hover:not(:disabled) { 
    background: linear-gradient(135deg, #00b0ff, #4fc3f7) !important; 
    transform: translateY(-2px) scale(1.02); 
    box-shadow: 0 6px 15px rgba(0, 176, 255, 0.6) !important; 
}
.action-btn.boost-buy:hover:not(:disabled) { 
    background: linear-gradient(135deg, #ff1744, #ff5252) !important; 
    transform: translateY(-2px) scale(1.02); 
    box-shadow: 0 6px 15px rgba(255, 23, 68, 0.6) !important; 
}
.action-btn.gem-buy:disabled, .btn-buy-energy:disabled, .btn-buy-max:disabled, .action-btn.boost-buy:disabled {
    background: #555 !important; border-color: #444 !important; box-shadow: none !important;
    color: #888 !important; text-shadow: none !important; transform: none !important;
}
.action-btn.gem-buy:disabled::after, .btn-buy-energy:disabled::after, .btn-buy-max:disabled::after, .action-btn.boost-buy:disabled::after { display: none; }

.action-btn.stardust-buy:hover:not(:disabled) { background: #7b1fa2; }

.action-btn.quest-success-btn { transition: 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); }
.action-btn.quest-success-btn:hover:not(:disabled) { 
    transform: translateY(-2px) scale(1.02); 
    box-shadow: 0 6px 15px rgba(76, 175, 80, 0.6) !important; 
    background: #66bb6a !important; 
}

.action-btn.achievements-btn { background: #00897b; }
.action-btn.achievements-btn:hover { background: #009688; }

/* Solid background for dashboard quests to improve readability */
#dashboard-missions-list > div {
    background: rgba(0, 0, 0, 0.85) !important;
    backdrop-filter: blur(4px) !important;
    border-radius: 6px !important;
}
@keyframes availableQuestPulse {
    0% { opacity: 0.6; }
    100% { opacity: 1; }
}
.available-quest-slot {
    background: rgba(150, 150, 150, 0.1) !important;
    border-color: rgba(150, 150, 150, 0.6) !important;
    box-shadow: inset 0 0 15px rgba(150, 150, 150, 0.2) !important;
    animation: availableQuestPulse 1.5s infinite alternate;
}
.available-quest-slot:hover {
    background: rgba(150, 150, 150, 0.2) !important;
}
/* Forge Button Specifics */
.action-btn.forge-btn { background: linear-gradient(135deg, #e65100, #ff8f00); box-shadow: 0 0 10px rgba(255, 143, 0, 0.4); }
.action-btn.forge-btn:hover { transform: scale(1.05); box-shadow: 0 0 20px rgba(255, 143, 0, 0.6); }

/* Glowing Achievement Tab */
.tab-btn.has-rewards {
    color: #00e5ff;
    position: relative;
}
.tab-btn.has-rewards::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    box-shadow: 0 -10px 20px rgba(0,229,255,0.4);
    border-radius: inherit; pointer-events: none;
    animation: pulseAchievementTab 1.5s infinite alternate;
}
@keyframes pulseAchievementTab {
    0% { opacity: 0.2; }
    100% { opacity: 1; }
}

/* Boost Button & Glowing Active State */
.action-btn.boost { background: linear-gradient(135deg, #b71c1c, #d50000); color: #fff; text-shadow: 1px 1px 2px #000; box-shadow: 0 0 10px rgba(213, 0, 0, 0.4); }
.action-btn.boost:hover:not(:disabled) { background: linear-gradient(135deg, #d50000, #ff1744); transform: scale(1.05); box-shadow: 0 0 15px rgba(255, 23, 68, 0.6); }
.action-btn.boost.active { 
    background: #ff1744 !important; 
    border: 1px solid #ff8a80 !important;
    box-shadow: 0 0 30px #ff1744, inset 0 0 15px #ffffff !important; 
    pointer-events: none; 
    color: #fff !important; font-weight: 900;
    text-shadow: 1px 1px 2px #000 !important;
    animation: none !important;
}

.boost-segment {
    height: 6px;
    flex: 1;
    background: #333;
    border-radius: 2px;
    transition: background 0.3s, box-shadow 0.3s;
    border: 1px solid #111;
}
.boost-segment.filled {
    background: linear-gradient(90deg, #ff1744, #ff5252);
    box-shadow: 0 0 8px rgba(255, 23, 68, 0.6);
    border-color: #ff8a80;
}

/* Boost Overlays & Timers */
.boost-countdown-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    display: none; justify-content: center; align-items: center;
    z-index: 2000; background: rgba(0,0,0,0.6); pointer-events: none; border-radius: 12px;
}
.boost-countdown-overlay.active { display: flex; }
#boost-countdown-text {
    font-size: 4rem; margin: 0; color: #ff1744; font-weight: 900;
    text-shadow: 0 0 20px #d50000, 0 0 40px #ff1744, 5px 5px 0px #000;
    animation: pulseCountdown 0.5s infinite alternate;
}
@keyframes pulseCountdown { 0% { transform: scale(1); opacity: 0.8; } 100% { transform: scale(1.1); opacity: 1; text-shadow: 0 0 50px #ff1744, 0 0 100px #ff5252, 5px 5px 0px #000; } }

.boost-timer-bar {
    position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%) scale(0.8);
    background: radial-gradient(circle, rgba(213,0,0,0.8) 0%, transparent 70%);
    color: #fff; font-size: 16px; font-weight: 900; padding: 10px 20px;
    z-index: 1500; pointer-events: none; transition: top 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    text-shadow: 0 0 15px #ff1744, 2px 2px 4px #000; text-transform: uppercase; letter-spacing: 2px;
    opacity: 0; white-space: nowrap; border-radius: 50%; pointer-events: none; transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s;
}
.boost-timer-bar.active { transform: translate(-50%, -50%) scale(1); opacity: 1; }

.action-btn.info { border-radius: 50%; width: 40px; height: 40px; padding: 0; font-size: 18px; background: #555; }
.action-btn.info:hover { background: #777; }
.action-btn:disabled, .action-btn.is-inactive { background: #555 !important; color: #888 !important; cursor: not-allowed; box-shadow: none !important; text-shadow: none !important; }

/* Reusable Magic Sparkle Twinkle */
.has-sparkles { position: relative; }
.has-sparkles::before, .has-sparkles::after {
    content: ''; position: absolute;
    background: #fff;
    clip-path: polygon(50% 0%, 53% 47%, 100% 50%, 53% 53%, 50% 100%, 47% 53%, 0% 50%, 47% 47%);
    pointer-events: none; z-index: 20; opacity: 0;
    filter: drop-shadow(0 0 4px #fff) drop-shadow(0 0 10px #00e5ff);
    will-change: transform, opacity;
}
.has-sparkles::before {
    top: -8px; right: -8px; width: 24px; height: 24px;
    animation: twinkleAnim 2.5s infinite ease-in-out;
}
.has-sparkles::after {
    bottom: -4px; left: -6px; width: 16px; height: 16px;
    animation: twinkleAnim 3s infinite ease-in-out 1.2s;
}
@keyframes twinkleAnim {
    0%, 100% { transform: scale(0.2) rotate(0deg); opacity: 0; }
    50% { transform: scale(1.2) rotate(90deg); opacity: 1; }
}

#draw-six-btn { 
    background: transparent url('assets/Draw4.png') center/contain no-repeat !important; 
    color: transparent !important; font-size: 0;
    min-height: 55px;
    border: none; box-shadow: none;
    position: relative; overflow: visible; 
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), filter 0.3s ease;
    transform: scale(1.3);
    left: -2px;
}
#draw-six-btn:hover:not(:disabled):not(.is-inactive) { 
    transform: scale(1.38) translateY(-2px); 
    filter: brightness(1.1) drop-shadow(0 4px 6px rgba(0, 229, 255, 0.3)) drop-shadow(0 0 8px rgba(255, 179, 0, 0.2)); 
}
#draw-six-btn:active:not(:disabled):not(.is-inactive) {
    transform: scale(1.22) translateY(4px);
    filter: brightness(0.9) drop-shadow(0 1px 3px rgba(0, 229, 255, 0.2));
    transition: transform 0.1s cubic-bezier(0.4, 0.0, 0.2, 1), filter 0.1s ease-out;
}
#draw-six-btn:disabled, #draw-six-btn.is-inactive {
    background: transparent url('assets/Draw4.png') center/contain no-repeat !important;
    background: transparent url('assets/Draw4.png') center/contain no-repeat !important;
    filter: grayscale(100%) brightness(0.6) opacity(0.7);
}

/* Modal */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.85); display: none; justify-content: center; align-items: center; z-index: 1000; opacity: 0; transition: opacity 0.3s; }
.modal-overlay.active { display: flex; opacity: 1; }
.modal-content { background: #1e1e1e; padding: 30px; border-radius: 12px; max-width: 400px; text-align: left; border: 2px solid #4fc3f7; max-height: 80vh; overflow-y: auto; position: relative; }
.modal-content h2 { margin-top: 0; color: #4fc3f7; padding-right: 30px; }
.close-modal { margin-top: 20px; width: 100%; background: #555; border: none; padding: 10px; color: white; border-radius: 8px; cursor: pointer;}
.close-modal:hover { background: #777; }

.modal-close-icon {
    position: absolute;
    top: 15px;
    right: 20px;
    background: transparent;
    border: none;
    color: #888;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: 0.2s;
    z-index: 10;
}
.modal-close-icon:hover { color: #ff5252; transform: scale(1.1); }

/* Auth Modal Specifics */
#auth-modal .auth-box, #auth-modal .modal-content {
    width: 30%;
    max-width: 100%;
    min-width: 320px;
}

/* Forge Window Elements */
#forge-modal .modal-content, #tab-forge .tab-container, #forge-container {
    background: url('assets/ForgeUI.webp') center/cover no-repeat !important;
    backdrop-filter: blur(5px);
}

/* Core Window Elements */
#tab-core .tab-container {
    background: url('assets/CoreUI.webp') center/cover no-repeat !important;
    backdrop-filter: blur(5px);
}

/* Shop Window Elements */
#tab-shop .tab-container {
    background: url('assets/ShopUI.webp') center/cover no-repeat !important;
    backdrop-filter: blur(5px);
}

/* Forge Core Animation */
.forge-core {
    position: absolute;
    top: 60%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border-radius: 30%;
    background: radial-gradient(circle at center, rgba(255, 179, 0, 0.8) 0%, rgba(255, 159, 16, 0.575) 40%, transparent 0%);
    pointer-events: none;
    z-index: 0;
    mix-blend-mode: screen;
    animation: faintForgePulse 3s infinite alternate ease-in-out;
}

@keyframes faintForgePulse {
    0% { opacity: 0.20; box-shadow: 0 0 100px rgba(255, 179, 0, 0.8); }
    100% { opacity: 0.4; box-shadow: 0 0 150px rgba(255, 179, 0, 0.8); }
}

/* Chaotic Forge Sparks */
.forge-core::before,
.forge-core::after {
    content: '';
    position: absolute;
    top: 20%; left: 20%; right: 20%; bottom: 20%;
    border-radius: 50%;
    pointer-events: none;
    z-index: 5;
    mix-blend-mode: screen;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
}

.forge-core::before {
    background: radial-gradient(circle at center, #fff 0%, #ffeb3b 15%, #ff9800 40%, #ff3d00 75%, transparent 100%);
    -webkit-mask-image: 
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%);
    -webkit-mask-size: 8px 8px, 13px 13px, 6.5px 6.5px, 10.5px 10.5px, 8px 8px, 12px 12px;
    mask-image: 
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%);
    mask-size: 8px 8px, 13px 13px, 6.5px 6.5px, 10.5px 10.5px, 8px 8px, 12px 12px;
    animation: forgeChaosOrbit1 4s linear infinite;
    filter: drop-shadow(0 0 6px #ffb300) drop-shadow(0 0 12px #ff8f00);
}

.forge-core::after {
    background: radial-gradient(circle at center, #fff 0%, #ffeb3b 15%, #ff9800 40%, #ff3d00 75%, transparent 100%);
    -webkit-mask-image: 
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%);
    -webkit-mask-size: 5px 5px, 10.5px 10.5px, 15.5px 15.5px, 6.5px 6.5px, 13px 13px, 8px 8px;
    mask-image: 
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%),
        radial-gradient(circle, #fff 40%, transparent 60%);
    mask-size: 5px 5px, 10.5px 10.5px, 15.5px 15.5px, 6.5px 6.5px, 13px 13px, 8px 8px;
    animation: forgeChaosOrbit2 5.5s linear infinite;
    filter: drop-shadow(0 0 8px #ff9800) drop-shadow(0 0 16px #ff6d00);
}

@keyframes forgeChaosOrbit1 {
    0% { 
        transform: rotate(0deg) scale(0.6); 
        opacity: 0.4; 
        -webkit-mask-position: 
            20% 20%, 80% 30%, 30% 80%, 
            70% 70%, 50% 10%, 10% 50%;
        mask-position: 
            20% 20%, 80% 30%, 30% 80%, 
            70% 70%, 50% 10%, 10% 50%;
    }
    33% {
        transform: rotate(-120deg) scale(1.0); 
        opacity: 1; 
        -webkit-mask-position: 
            15% 25%, 85% 20%, 35% 85%, 
            60% 75%, 45% 15%, 5% 40%;
        mask-position: 
            15% 25%, 85% 20%, 35% 85%, 
            60% 75%, 45% 15%, 5% 40%;
    }
    66% {
        transform: rotate(-240deg) scale(0.75); 
        opacity: 0.6; 
        -webkit-mask-position: 
            25% 15%, 75% 35%, 20% 70%, 
            75% 65%, 55% 5%, 15% 55%;
        mask-position: 
            25% 15%, 75% 35%, 20% 70%, 
            75% 65%, 55% 5%, 15% 55%;
    }
    100% { 
        transform: rotate(-360deg) scale(0.6); 
        opacity: 0.4; 
        -webkit-mask-position: 
            20% 20%, 80% 30%, 30% 80%, 
            70% 70%, 50% 10%, 10% 50%;
        mask-position: 
            20% 20%, 80% 30%, 30% 80%, 
            70% 70%, 50% 10%, 10% 50%;
    }
}

@keyframes forgeChaosOrbit2 {
    0% { 
        transform: rotate(0deg) scale(0.9); 
        opacity: 0.6; 
        -webkit-mask-position: 
            25% 75%, 75% 25%, 15% 50%, 
            85% 85%, 50% 90%, 90% 50%;
        mask-position: 
            25% 75%, 75% 25%, 15% 50%, 
            85% 85%, 50% 90%, 90% 50%;
    }
    33% {
        transform: rotate(-120deg) scale(0.6); 
        opacity: 0.3; 
        -webkit-mask-position: 
            30% 70%, 70% 30%, 10% 55%, 
            90% 80%, 45% 95%, 85% 45%;
        mask-position: 
            30% 70%, 70% 30%, 10% 55%, 
            90% 80%, 45% 95%, 85% 45%;
    }
    66% {
        transform: rotate(-240deg) scale(1.1); 
        opacity: 1; 
        -webkit-mask-position: 
            20% 80%, 80% 20%, 20% 45%, 
            80% 90%, 55% 85%, 95% 55%;
        mask-position: 
            20% 80%, 80% 20%, 20% 45%, 
            80% 90%, 55% 85%, 95% 55%;
    }
    100% { 
        transform: rotate(-360deg) scale(0.9); 
        opacity: 0.6; 
        -webkit-mask-position: 
            25% 75%, 75% 25%, 15% 50%, 
            85% 85%, 50% 90%, 90% 50%;
        mask-position: 
            25% 75%, 75% 25%, 15% 50%, 
            85% 85%, 50% 90%, 90% 50%;
    }
}
.forge-slot { 
    width: 106px !important; height: 162px !important; 
    border: 2px dashed rgba(255, 143, 0, 0.3); 
    border-radius: 8px !important; padding: 4px !important;
    display: flex; flex-direction: column; align-items: center; justify-content: center; 
    font-size: 24px; color: rgba(255, 143, 0, 0.5); 
    background: linear-gradient(180deg, rgba(0, 0, 0, 0.8) 0%, rgba(21, 21, 21, 0.5) 100%); 
    box-shadow: inset 0 10px 20px rgba(0,0,0,0.9), inset 0 0 15px rgba(0,0,0,0.8), 0 2px 4px rgba(255,255,255,0.05);
    cursor: pointer; position: relative; transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, filter 0.3s ease;
    box-sizing: border-box;
}

/* Extended invisible drop zone to make placing cards easier */
.forge-slot::after {
    content: '';
    position: absolute;
    top: -25px; left: -25px; right: -25px; bottom: -25px;
    background: transparent;
    border-radius: 12px;

}

#forge-slots {
    margin-top: -40px;
}

#forge-slots > :nth-child(1) { grid-column: 1 / 3; justify-self: center; z-index: 2; }
#forge-slots > :nth-child(2), #forge-slots > :nth-child(3) { margin-top: -10px; z-index: 1; }

.forge-slot:not(.filled) { animation: pulseForgeSlot 2s infinite alternate; }
@keyframes pulseForgeSlot {
    0% { opacity: 0.7; }
    100% { opacity: 1; border-color: rgba(255, 143, 0, 0.6); }
}
.forge-slot.filled { 
    border: 2px solid #ff8f00; 
    box-shadow: 0 0 15px rgba(255, 143, 0, 0.4), inset 0 10px 20px rgba(0,0,0,0.9), inset 0 0 20px rgba(255, 143, 0, 0.2); 
    transform: scale(1.05);
}
.forge-slot.filled:hover { transform: scale(1.1) !important; filter: brightness(1.2); border-color: #ffb300; box-shadow: 0 0 20px rgba(255, 179, 0, 0.6), inset 0 10px 20px rgba(0,0,0,0.9); }

/* Glow effect when holding a dragged card over an empty slot */
.forge-slot.drag-over { border-color: #00e5ff; background: linear-gradient(180deg, rgba(0, 26, 30, 0.8) 0%, rgba(0, 51, 58, 0.6) 100%); box-shadow: 0 0 20px rgba(0, 229, 255, 0.4), inset 0 10px 20px rgba(0,0,0,0.9), inset 0 0 20px rgba(0, 229, 255, 0.2); transform: scale(1.05); }

/* Pulse empty slots globally when a card is picked up */
body.is-dragging-card .forge-slot:not(.filled) {
    border-color: #ffb300; background: rgba(255, 179, 0, 0.1); box-shadow: 0 0 20px rgba(255, 179, 0, 0.4), inset 0 10px 20px rgba(0,0,0,0.9);
}
body.is-dragging-card .core-slot:not(.filled) {
    border-color: #00e5ff; background: rgba(0, 229, 255, 0.1); box-shadow: 0 0 20px rgba(0, 229, 255, 0.4);
}

/* Core Elements */
.core-slot { 
    width: 86px !important; height: 125px !important; 
    border: 2px dashed rgba(0, 229, 255, 0.4); 
    border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; 
    font-size: 24px; color: rgba(0, 229, 255, 0.5); 
    background: radial-gradient(circle at center, rgba(255,255,255,0.05) 0%, rgba(0,0,0,0.6) 100%); 
    cursor: pointer; position: absolute !important; transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease, filter 0.3s ease;
    box-sizing: border-box;
}
.core-slot.locked {
    animation: none !important;
    border-color: #555 !important;
    color: #555 !important;
    opacity: 0.5;
    cursor: not-allowed;
}
.core-slot:not(.filled) { animation: pulseCoreSlot 2s infinite alternate; }
@keyframes pulseCoreSlot {
    0% { opacity: 0.6; border-color: rgba(0, 229, 255, 0.2); }
    100% { opacity: 1; border-color: rgba(0, 229, 255, 0.6); }
}
.core-slot.filled { border: 2px solid #00e5ff; box-shadow: 0 0 15px rgba(0, 229, 255, 0.4), inset 0 0 20px rgba(0, 229, 255, 0.2); transform: scale(1.05) !important; }
.core-slot.filled:hover { filter: brightness(1.2); border-color: #84ffff; box-shadow: 0 0 20px rgba(132, 255, 255, 0.6); z-index: 10; transform: scale(1.1) !important; }
.core-slot.drag-over { border-color: #ffb300; background: rgba(255, 179, 0, 0.2); box-shadow: 0 0 20px rgba(255, 179, 0, 0.4); transform: scale(1.05); }

/* Catalyst Slot Specifics */
.core-slot.catalyst-slot {
    width: 129px !important;
    height: 188px !important;
    font-size: 36px;
}

#execute-forge-btn:not(:disabled) {
    background: linear-gradient(135deg, #ff8f00, #ff5252);
    border: 1px solid #ffb300;
}
#execute-forge-btn:not(:disabled)::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    border-radius: inherit; box-shadow: 0 0 40px rgba(255, 143, 0, 0.9), inset 0 0 10px #fff;
    opacity: 0; pointer-events: none; animation: forgeReadyPulse 1.5s infinite alternate;
}
@keyframes forgeReadyPulse {
    0% { opacity: 0; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.05); }
}

/* Core Upgrade Button */
#core-upgrade-btn:not(:disabled) {
    background: linear-gradient(135deg, #00838f, #00e5ff);
    border: 1px solid #84ffff;
    color: #fff;
}
#core-upgrade-btn:not(:disabled)::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    border-radius: inherit; box-shadow: 0 0 25px rgba(0, 229, 255, 0.8), inset 0 0 8px rgba(255,255,255,0.5);
    opacity: 0; pointer-events: none; animation: coreUpgradePulse 1.5s infinite alternate;
}
#core-upgrade-btn:not(:disabled):hover {
    transform: scale(1.05);
}
@keyframes coreUpgradePulse {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

/* Discover Modal Elements */
#discover-modal .modal-content { 
    background: radial-gradient(circle at center, rgba(0, 229, 255, 0.15) 0%, rgba(18, 18, 18, 0.95) 70%); 
    box-shadow: 0 0 50px rgba(0, 229, 255, 0.2); 
    border: 1px solid rgba(0, 229, 255, 0.3); 
    text-align: center; 
    overflow: visible; 
    padding: 40px 20px; 
    border-radius: 20px; 
    max-width: 800px;
    backdrop-filter: blur(5px);
}
.card.discover-wrap { width: 140px; height: 200px; perspective: 1000px; cursor: pointer; transition: transform 0.3s; position: relative; flex-shrink: 0;}
.discover-wrap:hover { transform: scale(1.05); z-index: 50; }
.card.discover-wrap.picked { z-index: 100; pointer-events: none; animation: claimReward 1.2s cubic-bezier(0.2, 0.8, 0.2, 1) forwards !important; }
.card.discover-wrap.rejected { opacity: 0; transform: scale(0.6) translateY(40px) !important; pointer-events: none; transition: all 0.6s ease-in; filter: grayscale(100%) blur(4px); }

@keyframes claimReward {
    0% { transform: scale(1.05); }
    30% { transform: scale(1.3) translateY(-20px); box-shadow: 0 0 40px rgba(255,255,255,0.8); border-radius: 12px; }
    70% { transform: scale(1.35) translateY(-30px); box-shadow: 0 0 80px #00e5ff, 0 0 30px #fff; border-radius: 12px; opacity: 1; filter: brightness(1.2); }
    100% { transform: scale(0.5) translateY(-100px); box-shadow: 0 0 100px #00e5ff; opacity: 0; filter: brightness(2) blur(4px); }
}

/* Boost Summary Modal Specifics */
#boost-summary-modal .modal-content { 
    max-width: 800px; text-align: center; border-color: #ffb300; 
    box-shadow: 0 0 50px rgba(255, 179, 0, 0.3); 
    background: radial-gradient(circle at top, rgba(255, 179, 0, 0.15) 0%, rgba(18, 18, 18, 0.95) 60%);
    backdrop-filter: blur(5px);
}
#boost-summary-grid { margin-top: 20px; display: flex; flex-direction: column; justify-content: center; }

.stagger-pop {
    opacity: 0; /* Start invisible */
    animation: popInCard 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}
@keyframes popInCard {
    0% { transform: scale(0.1); opacity: 0; }
    60% { transform: scale(1.15); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

/* Achievements Tab */
.achievement-list { 
    display: flex; flex-direction: column; gap: 5px; margin-top: 10px; 
    overflow-y: auto; padding-right: 10px; flex: 1; min-height: 0; /* Ensures it fills remaining height and scrolls */
}
.achievement-list::-webkit-scrollbar { width: 6px; }
.achievement-list::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 4px; }
.achievement-list::-webkit-scrollbar-thumb { background: rgba(0, 229, 255, 0.4); border-radius: 4px; }
.achievement-list::-webkit-scrollbar-thumb:hover { background: rgba(0, 229, 255, 0.8); }

.ach-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 5px; margin-bottom: 5px; }
@media (max-width: 800px) { .ach-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 500px) { .ach-grid { grid-template-columns: 1fr; } }
.achievement-item { background: #2a2a2a; border: 1px solid #444; border-radius: 6px; padding: 5px; display: flex; transition: 0.3s; }
.achievement-item.unlocked { border-color: #ffb300; background: linear-gradient(180deg, #3a2e0d, #2a2a2a); box-shadow: inset 0 0 10px rgba(255, 179, 0, 0.2); }
.ach-icon { filter: grayscale(100%); opacity: 0.3; }
.achievement-item.unlocked .ach-icon { filter: none; opacity: 1; }
.ach-title { font-weight: bold; font-size: 10px; color: #fff; margin-bottom: 1px; }
.achievement-item.unlocked .ach-title { color: #ffb300; }
.ach-desc { font-size: 9px; color: #aaa; line-height: 1.1; }

.tier-header.has-rewards {
    animation: pulseAchievement 1.5s infinite;
    border-color: #00e5ff !important;
}
.ach-alert {
    background: #00e5ff; color: #000; border-radius: 50%; width: 18px; height: 18px;
    display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: bold;
    box-shadow: 0 0 15px #00b0ff; animation: pulseAchAlert 1.5s infinite alternate; margin-left: 5px;
}
@keyframes pulseAchAlert {
    0% { opacity: 0.5; transform: scale(1); }
    100% { opacity: 1; transform: scale(1.1); }
}

/* Achievement Claim All Button */
.action-btn.ach-claim-all-btn {
    background: #00e5ff;
    color: #000;
    border-radius: 10px;
    white-space: nowrap;
    flex-shrink: 0;
    padding: 3px 10px;
    font-size: 10px;
    font-weight: bold;
    position: relative;
    overflow: hidden;
    border: 1px solid #00b0ff;
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
    transition: 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.action-btn.ach-claim-all-btn::after {
    content: ''; position: absolute; top: 0; left: -100%; width: 50%; height: 100%;
    background: linear-gradient(to right, rgba(255,255,255,0) 0%, rgba(255,255,255,0.6) 50%, rgba(255,255,255,0) 100%);
    transform: skewX(-25deg); animation: buttonShine 3s infinite;
}
.action-btn.ach-claim-all-btn:hover {
    background: #84ffff;
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.8);
}

/* Achievement Progress Bar */
.ach-progress-bar-bg {
    width: 90%;
    height: 6px;
    background: #333;
    border-radius: 3px;
    overflow: hidden;
    margin-top: 5px;
    position: relative;
}
.ach-progress-bar-bg::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    background-image: repeating-linear-gradient(90deg, transparent, transparent calc(20% - 1px), rgba(0,0,0,0.8) calc(20% - 1px), rgba(0,0,0,0.8) 20%);
    pointer-events: none; z-index: 10;
}
.ach-progress-bar-fill {
    height: 100%; width: 0%; background: linear-gradient(90deg, #4fc3f7, #00e5ff); transition: width 0.3s ease-out;
}

.shop-container { max-width: 900px !important; }
.shop-grid { 
    display: grid; 
    grid-template-columns: repeat(8, 56px); 
    column-gap: 32px; 
    row-gap: 0;
    justify-content: center; 
    padding: 15px 10px 20px 10px; 
}

/* Staggered Honeycomb Layout for 7 Cards */
.card.shop-wrap:nth-child(5) { grid-column: 2 / 4; margin-top: -32px; z-index: 5; }
.card.shop-wrap:nth-child(6) { grid-column: 4 / 6; margin-top: -32px; z-index: 5; }
.card.shop-wrap:nth-child(7) { grid-column: 6 / 8; margin-top: -32px; z-index: 5; }

.card.shop-wrap:nth-child(1) { grid-column: 1 / 3; z-index: 2; }
.card.shop-wrap:nth-child(2) { grid-column: 3 / 5; z-index: 2; }
.card.shop-wrap:nth-child(3) { grid-column: 5 / 7; z-index: 2; }
.card.shop-wrap:nth-child(4) { grid-column: 7 / 9; z-index: 2; }

/* Mobile Fallback to prevent squishing on tiny screens */
@media (max-width: 650px) {
    .shop-grid { display: flex; flex-wrap: wrap; gap: 30px; }
    .card.shop-wrap:nth-child(n) { margin-top: 0; }
}

.card.shop-wrap { width: 112px; height: 160px; perspective: 1000px; cursor: pointer; transition: transform 0.2s; position: relative; flex-shrink: 0; margin: 0 auto; }
.card.shop-wrap:hover:not(.sold) { transform: scale(1.05) translateY(-5px); z-index: 20; box-shadow: 0 10px 20px rgba(0,0,0,0.5); border-radius: 12px; }
.card.shop-wrap.sold { opacity: 0.4; cursor: not-allowed; filter: grayscale(100%); }
.card.shop-wrap:hover:not(.sold) .shop-card-glow { opacity: 0.5 !important; filter: blur(25px) !important; }

.shop-price-tag {
    position: absolute;
    bottom: -22px;
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(180deg, #1a1a1a, #000);
    padding: 6px 14px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 14px;
    color: #ba68c8;
    border: 2px solid #ba68c8;
    box-shadow: 0 4px 10px rgba(0,0,0,0.8), inset 0 1px 2px rgba(255,255,255,0.1);
    white-space: nowrap;
    z-index: 20;
    display: flex;
    align-items: center;
}
.shop-price-tag.sold-tag { color: #888; border-color: #444; background: #222; }

.shop-item-box { 
    transition: 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    cursor: pointer;
}
.shop-item-box:hover { transform: translateY(-5px); border-color: #ba68c8 !important; box-shadow: 0 10px 20px rgba(0,0,0,0.5), inset 0 0 15px rgba(186, 104, 200, 0.1); }

/* Sub-Tabs (Shop & Missions) */
.shop-tab-btn, .mission-tab-btn {
    background: #1e1e1e; color: #888; border: 1px solid #444; border-bottom: none; border-radius: 8px 8px 0 0; padding: 10px 20px; font-size: 14px; font-weight: bold; cursor: pointer; transition: 0.2s; position: relative; bottom: 0; white-space: nowrap;
}
.shop-tab-btn:hover, .mission-tab-btn:hover { background: #333; color: #fff; }
.shop-tab-btn.active {
    background: #000000; color: #ba68c8; border-color: #ba68c8; padding-bottom: 10px; z-index: 10;
}
.mission-tab-btn.active {
    background: #000000; color: #81c784; border-color: #81c784; padding-bottom: 10px; z-index: 10;
}
.mission-pane { display: none; animation: fadeInTab 0.3s ease; }
.mission-pane.active { display: block; }

/* --- Echo Raids Map Styles --- */
#raid-map-container::-webkit-scrollbar { display: none; }

.raid-map-line {
    position: absolute;
    top: calc(50% + 5px); /* Offset slightly due to top padding */
    left: 20px;
    right: 20px;
    height: 4px;
    background: #333;
    z-index: 1;
    transform: translateY(-50%);
    border-radius: 2px;
}

.raid-map-line-fill {
    height: 100%;
    background: linear-gradient(90deg, #4fc3f7, #ba68c8);
    width: 0%;
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(186, 104, 200, 0.6);
    transition: width 0.5s ease-out;
}

.raid-node {
    position: relative;
    z-index: 2;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
    transition: transform 0.3s, filter 0.3s;
}

.raid-node-trash {
    width: 20px;
    height: 20px;
    background: #222;
    border: 2px solid #555;
    border-radius: 50%;
    margin: 0 15px;
}

.raid-node-boss {
    width: 32px;
    height: 32px;
    background: #111;
    border: 2px solid #ffb300;
    transform: rotate(45deg);
    margin: 0 25px;
    box-shadow: 0 0 10px rgba(255, 179, 0, 0.2);
}

.raid-node-boss-icon {
    transform: rotate(-45deg);
    font-size: 18px;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

.raid-node.completed { background: #4a148c; border-color: #ba68c8; box-shadow: 0 0 10px rgba(186, 104, 200, 0.5); }
.raid-node.active { border-color: #ff5252; animation: pulseActiveNode 1.5s infinite alternate; }
.raid-node-boss.active { animation: pulseActiveBossNode 1.5s infinite alternate; box-shadow: 0 0 20px rgba(255, 82, 82, 0.6); }
.raid-node.locked { opacity: 0.5; filter: grayscale(100%); }

@keyframes pulseActiveNode { 0% { transform: scale(1); filter: brightness(1); } 100% { transform: scale(1.2); filter: brightness(1.5); } }
@keyframes pulseActiveBossNode { 0% { transform: scale(1) rotate(45deg); filter: brightness(1); } 100% { transform: scale(1.2) rotate(45deg); filter: brightness(1.5); } }

.raid-node-tooltip {
    position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%) translateY(-10px);
    background: rgba(0,0,0,0.9); border: 1px solid #555; color: #fff; padding: 6px 10px; border-radius: 6px;
    font-size: 11px; white-space: nowrap; opacity: 0; visibility: hidden; transition: 0.2s; pointer-events: none; z-index: 10;
}
.raid-node-boss .raid-node-tooltip { transform: translateX(-50%) translateY(-20px) rotate(-45deg); }
.raid-node:hover .raid-node-tooltip { opacity: 1; visibility: visible; transform: translateX(-50%) translateY(-5px); }
.raid-node-boss:hover .raid-node-tooltip { transform: translateX(-50%) translateY(-15px) rotate(-45deg); }

/* Toast Notifications */
.toast-container { position: fixed; bottom: 220px; right: 20px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; pointer-events: none; transition: bottom 0.3s ease; }
.toast { background: linear-gradient(135deg, #1e1e1e, #2a2a2a); border: 1px solid #ffb300; color: #fff; padding: 15px 20px; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.5); display: flex; align-items: center; gap: 15px; transform: translateX(120%); opacity: 0; transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.4s; }
.toast.show { transform: translateX(0); opacity: 1; }
.toast-icon { font-size: 24px; }
.toast-text { display: flex; flex-direction: column; }
.toast-title { font-weight: bold; color: #ffb300; font-size: 14px; }
.toast-desc { font-size: 12px; color: #ccc; }

/* Game Board */
.game-board { display: flex; flex-direction: column; gap: 10px; align-items: center; justify-content: flex-start; width: 100%; max-width: 800px; box-sizing: border-box; min-height: 0; overflow: visible; padding-bottom: 20px; }
.card-slot { display: flex; flex-direction: column; align-items: center; position: relative; }

.slot-label { font-size: 18px; text-transform: uppercase; color: #888; display: flex; flex-direction: column; align-items: center; gap: 5px;}
.deck-header-row { display: flex; align-items: center; gap: 8px; }
.deck-counter { font-size: 14px; color: #ccc; font-weight: bold; }

/* Fan Layout Area */
#display-area { 
    display: block; position: relative; max-width: 600px; width: 100%; min-height: 340px; margin-top: 40px;
}

.fan-slot {
    width: 160px; height: 228px;
}

.card { width: 100%; height: 100%; perspective: 1000px; position: relative; margin: 0; will-change: transform; }
.deck-card {
    z-index: 10; cursor: default; width: 120px; height: 172px;
    margin: 0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.6);
    animation: deckFloat 3s ease-in-out infinite;
    will-change: transform;
}
@keyframes deckFloat {
    0%, 100% { transform: translateY(0) rotateX(2deg) rotateY(-2deg); box-shadow: -2px 4px 12px rgba(0,0,0,0.6), 0 0 20px rgba(186, 104, 200, 0.3); }
    50% { transform: translateY(-8px) rotateX(-2deg) rotateY(2deg); box-shadow: -8px 16px 24px rgba(0,0,0,0.8), 0 5px 40px rgba(186, 104, 200, 0.7); }
}
.deck-card.disabled { opacity: 0.3; cursor: not-allowed; animation: none; border-color: transparent; box-shadow: 0 4px 12px rgba(0,0,0,0.6); }

/* Active Boost Deck Glow */
body.boost-active-bg .deck-card:not(.disabled) {
    animation: deckBoostFloat 1s ease-in-out infinite;
}
@keyframes deckBoostFloat {
    0%, 100% { transform: translateY(0) rotateX(2deg) rotateY(-2deg); box-shadow: -2px 4px 12px rgba(0,0,0,0.6), 0 0 20px #ff1744, inset 0 0 15px #ff1744; border-color: #ff1744; }
    50% { transform: translateY(-8px) rotateX(-2deg) rotateY(2deg); box-shadow: -8px 16px 24px rgba(0,0,0,0.8), 0 0 50px #ff5252, 0 0 30px #ff1744, inset 0 0 25px #ff5252; border-color: #ff8a80; }
}

.card-inner { width: 100%; height: 100%; position: relative; transition: transform 0.75s cubic-bezier(0.5, -0.15, 0.15, 1.15); transform-style: preserve-3d; will-change: transform; }
.card.flipped .card-inner { transform: rotateY(180deg); }

/* NEW DYNAMIC FLIP MODIFIER */
.card.flipped.flipped-reverse .card-inner { transform: rotateY(-180deg); }

@keyframes pulseOnlineDot {
    0% { transform: scale(0.9); opacity: 0.8; box-shadow: 0 0 4px #4caf50; }
    50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 10px #4caf50; }
    100% { transform: scale(0.9); opacity: 0.8; box-shadow: 0 0 4px #4caf50; }
}
.online-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #4caf50;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
    animation: pulseOnlineDot 2s infinite ease-in-out;
}
.offline-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #555;
    border-radius: 50%;
    margin-right: 6px;
    flex-shrink: 0;
}

/* Floating Cards */
.float-container {
    width: 100%; height: 100%;
    transform-style: preserve-3d;
    animation: cardFloat 4s ease-in-out infinite;
    will-change: transform;
}
@keyframes cardFloat {
    0%, 100% { transform: translateY(0px) rotateX(var(--rx1, 3deg)) rotateY(var(--ry1, -3deg)); }
    50% { transform: translateY(var(--ty, -12px)) rotateX(var(--rx2, -3deg)) rotateY(var(--ry2, 3deg)); }
}

/* Occasional Magic Instability Shake */
@keyframes occasionalShake {
    0%, 92%, 100% { transform: rotateZ(0deg) translateX(0) translateY(0); }
    93% { transform: rotateZ(-1deg) translateX(-1px) translateY(-1px); }
    95% { transform: rotateZ(1.5deg) translateX(1px) translateY(1px); }
    96% { transform: rotateZ(-0.5deg) translateX(-1px) translateY(0); }
    98% { transform: rotateZ(1deg) translateX(0.5px) translateY(-0.5px); }
    99% { transform: rotateZ(-1.5deg) translateX(-0.5px) translateY(1px); }
}

.unrevealed { transition: transform 0.2s; }
.interactive-hover:hover { transform: scale(1.08); cursor: pointer; }

.card-face {
    width: 100%; height: 100%; position: absolute; backface-visibility: hidden; border-radius: 12px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; box-sizing: border-box;
    box-shadow: -4px 10px 20px rgba(0,0,0,0.6), inset 0 1px 1px rgba(255,255,255,0.2); padding: 10px;
    background-color: #1a1a1a; /* Fallback placeholder color before spritesheet loads */
    will-change: transform;
}

/* Colored Card Backs */
.card-back { 
    background-image: url('assets/TestGrid3.webp'); 
    background-size: 700% 500%; 
    background-position: 66.666% 100%; 
    background-repeat: no-repeat; 
}
.back-common { animation: occasionalShake 10s ease-in-out infinite; }
.back-uncommon { border: 4px solid #4caf50; }
.back-rare { border: 4px solid #4fc3f7; }
.back-epic { border: 4px solid #ba68c8; }
.back-legendary { border: 4px solid #ffb300; }
.back-mythic { border: 4px solid #ff1744; }

/* Vibrant Reveal Animations */
@keyframes popCommon { 0% { transform: scale(1) translateY(0); } 50% { transform: scale(1.1) translateY(-10px); z-index: 20;} 100% { transform: scale(1) translateY(0); } }
@keyframes popUncommon { 0% { transform: scale(1) translateY(0); } 50% { transform: scale(1.12) translateY(-12px); z-index: 20;} 100% { transform: scale(1) translateY(0); } }
@keyframes popRare { 0% { transform: scale(1) translateY(0); } 50% { transform: scale(1.15) translateY(-15px); z-index: 20;} 100% { transform: scale(1) translateY(0); } }
@keyframes popCoreParts { 0% { transform: scale(1) translateY(0); } 50% { transform: scale(1.12) translateY(-12px); z-index: 20;} 100% { transform: scale(1) translateY(0); } }

@keyframes popEpic {
    0%   { transform: scale(1) translateY(0) rotate(0deg); }
    40%  { transform: scale(2.15) translateY(-98px) rotate(-7deg); z-index: 20; }
    100% { transform: scale(1) translateY(0) rotate(0deg); }
}
@keyframes popLegendary {
    0%   { transform: scale(1) translateY(0) rotate(0deg); }
    10%  { transform: scale(1.4) translateY(-28px) rotate(-5deg); z-index: 30; }
    25%  { transform: scale(2.05) translateY(-88px) rotate(9deg); z-index: 30; }
    40%  { transform: scale(2.15) translateY(-98px) rotate(-7deg); z-index: 30; }
    53%  { transform: scale(2.1) translateY(-93px) rotate(4deg); z-index: 30; }
    68%  { transform: scale(1.55) translateY(-42px) rotate(-3deg); z-index: 30; }
    84%  { transform: scale(1.12) translateY(-8px) rotate(1deg); z-index: 30; }
    100% { transform: scale(1) translateY(0) rotate(0deg); }
}
@keyframes popMythic {
    0%   { transform: scale(1) translateY(0) rotate(0deg); }
    10%  { transform: scale(1.4) translateY(-28px) rotate(-5deg); z-index: 40; }
    25%  { transform: scale(2.05) translateY(-88px) rotate(9deg); z-index: 40; }
    40%  { transform: scale(2.15) translateY(-98px) rotate(-7deg); z-index: 40; }
    53%  { transform: scale(2.1) translateY(-93px) rotate(4deg); z-index: 40; }
    68%  { transform: scale(1.55) translateY(-42px) rotate(-3deg); z-index: 40; }
    84%  { transform: scale(1.12) translateY(-8px) rotate(1deg); z-index: 40; }
    100% { transform: scale(1) translateY(0) rotate(0deg); }
}
@keyframes popPrismatic {
    0%   { transform: scale(1) rotate(0deg); }
    10%  { transform: scale(1.65) rotate(-20deg); z-index: 50; }
    22%  { transform: scale(2.45) rotate(24deg); z-index: 50; }
    36%  { transform: scale(2.65) rotate(-18deg); z-index: 50; }
    50%  { transform: scale(2.55) rotate(14deg); z-index: 50; }
    64%  { transform: scale(1.7) rotate(-10deg); z-index: 50; }
    78%  { transform: scale(1.15) rotate(5deg); z-index: 50; }
    100% { transform: scale(1) rotate(0deg); }
}

.anim-pop-common    { animation: popCommon    0.5s cubic-bezier(0.5, -0.15, 0.15, 1.15) forwards; }
.anim-pop-uncommon  { animation: popUncommon  0.5s cubic-bezier(0.5, -0.15, 0.15, 1.15) forwards; }
.anim-pop-rare      { animation: popRare      0.5s cubic-bezier(0.5, -0.15, 0.15, 1.15) forwards; }
.anim-pop-epic      { animation: popEpic      1.0s cubic-bezier(0.2, 0.8, 0.2, 1)          forwards; }
.anim-pop-core-parts{ animation: popCoreParts 0.5s cubic-bezier(0.5, -0.15, 0.15, 1.15) forwards; }
.anim-pop-legendary { animation: popLegendary 1.0s cubic-bezier(0.2, 0.8, 0.2, 1)          forwards; }
.anim-pop-mythic    { animation: popMythic    1.0s cubic-bezier(0.2, 0.8, 0.2, 1)          forwards; }
.anim-pop-prismatic { animation: popPrismatic 1.6s cubic-bezier(0.2, 0.8, 0.2, 1)          forwards; }

/* Pre-Flip Teases */
@keyframes pulseUncommon  { 0% { box-shadow: 0 0 5px #2e7d32; } 50% { box-shadow: 0 0 18px #81c784; } 100% { box-shadow: 0 0 5px #2e7d32; } }
@keyframes pulseRare      { 0% { box-shadow: 0 0 5px #1976d2; } 50% { box-shadow: 0 0 25px #4fc3f7; } 100% { box-shadow: 0 0 5px #1976d2; } }

.tease-uncommon  { animation: pulseUncommon  1.5s  infinite ease-in-out, occasionalShake 6s infinite ease-in-out; }
.tease-rare      { animation: pulseRare      1.5s  infinite ease-in-out, occasionalShake 4s infinite ease-in-out; }
.tease-epic      { animation: occasionalShake 2.5s infinite ease-in-out; }
@keyframes pulseCoreParts { 0% { box-shadow: 0 0 5px #00838f; } 50% { box-shadow: 0 0 18px #00e5ff; } 100% { box-shadow: 0 0 5px #00838f; } }
.tease-core-parts{ animation: pulseCoreParts 1.5s  infinite ease-in-out, occasionalShake 4s infinite ease-in-out; }
.tease-legendary { animation: occasionalShake 2s infinite ease-in-out; }
.tease-mythic    { animation: occasionalShake 1.5s infinite ease-in-out; }

/* Fade Out & Error Shake Animations */
@keyframes errorShake {
    0%, 100% { transform: translateX(0); box-shadow: 0 0 15px rgba(255,255,255,0.1); }
    20%, 60% { transform: translateX(-8px); box-shadow: 0 0 30px #ff5252; border-radius: 12px; }
    40%, 80% { transform: translateX(8px); box-shadow: 0 0 30px #ff5252; border-radius: 12px; }
}

@keyframes deckErrorShake {
    0%, 100% { transform: translateX(0); box-shadow: 0 0 15px rgba(255,255,255,0.1); }
    20%, 60% { transform: translateX(-8px); box-shadow: 0 0 30px #ff5252; border-radius: 8px; }
    40%, 80% { transform: translateX(8px); box-shadow: 0 0 30px #ff5252; border-radius: 8px; }
}

@keyframes highlightUnrevealed {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0px transparent; border-radius: 12px; }
    50% { transform: scale(1.1); box-shadow: 0 0 30px #00e5ff, 0 0 60px #00e5ff; border-radius: 12px; z-index: 50; }
}

@keyframes fadeAway {
    from { opacity: 1; transform: scale(1); }
    to { opacity: 0; transform: scale(0.85); }
}
.fade-away { animation: fadeAway 0.5s ease forwards !important; pointer-events: none; }

/* Epic Thud Anticipation */
@keyframes epicThud {
    0%   { transform: scale(1); }
    30%  { transform: scale(0.8); box-shadow: 0 0 80px #7b1fa2, inset 0 0 25px rgba(186,104,200,0.6); }
    70%  { transform: scale(1.08); box-shadow: 0 0 35px #ba68c8; }
    100% { transform: scale(1); box-shadow: 0 0 0px transparent; }
}
.anim-epic-thud { animation: epicThud 0.25s cubic-bezier(.36,.07,.19,.97) forwards; }

/* Card Face Colors */
.card-front { transform: rotateY(180deg); justify-content: space-between; padding: 12px 6px 6px 6px; }
.card-border-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image: url('assets/TestGrid3.webp');
    background-size: 700% 500%;
    background-repeat: no-repeat;
    pointer-events: none;
    z-index: 15;
    border-radius: inherit;
    transform: translateZ(0);
    will-change: transform;
}
.card-border-overlay.border-common { background-position: 0% 75%; }
.card-border-overlay.border-uncommon { background-position: 16.666% 75%; }
.card-border-overlay.border-rare { background-position: 33.333% 75%; }
.card-border-overlay.border-epic { background-position: 50% 75%; }
.card-border-overlay.border-legendary { background-position: 66.666% 75%; }
.card-border-overlay.border-mythic { background-position: 83.333% 75%; }
.card-border-overlay.border-core-parts { background-position: 0% 75%; }
.card-rarity { font-size: 4.5px; text-transform: uppercase; opacity: 0.8; margin-bottom: 2px; margin-top: 0; letter-spacing: 1px; }
.card-name { font-size: 14px; font-weight: 900; text-transform: uppercase; margin-bottom: auto; margin-top: 0; line-height: 1.1; }
.card-stats { width: 100%; font-size: 10px; font-weight: bold; background: #000; color: #fff; padding: 5px; border-radius: 6px; box-sizing: border-box; text-shadow: none; border: 1px solid rgba(255,255,255,0.1); }

.common { 
    background-image: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 40%), var(--card-bg, none), linear-gradient(135deg, #e0e0e0, #f5f5f5);
    background-position: bottom, var(--sprite-x, center) var(--sprite-y, center), center;
    background-size: 100% 100%, var(--sprite-size, cover), cover;
    background-repeat: no-repeat;
    border-color: #9e9e9e; color: #fff; text-shadow: 1px 1px 3px rgba(0,0,0,0.8); 
}
.uncommon { 
    background-image: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 40%), var(--card-bg, none), linear-gradient(135deg, #81c784, #4caf50);
    background-position: bottom, var(--sprite-x, center) var(--sprite-y, center), center;
    background-size: 100% 100%, var(--sprite-size, cover), cover;
    background-repeat: no-repeat;
    border-color: #2e7d32; color: #fff; text-shadow: 1px 1px 3px rgba(0,0,0,0.8); 
}
.rare { 
    background-image: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 40%), var(--card-bg, none), linear-gradient(135deg, #1976d2, #4fc3f7);
    background-position: bottom, var(--sprite-x, center) var(--sprite-y, center), center;
    background-size: 100% 100%, var(--sprite-size, cover), cover;
    background-repeat: no-repeat;
    border-color: #0d47a1; color: #ffffff; text-shadow: 1px 1px 3px rgba(0,0,0,0.8); 
}
.epic { 
    background-image: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 40%), var(--card-bg, none), linear-gradient(135deg, #7b1fa2, #ba68c8);
    background-position: bottom, var(--sprite-x, center) var(--sprite-y, center), center;
    background-size: 100% 100%, var(--sprite-size, cover), cover;
    background-repeat: no-repeat;
    border-color: #4a148c; color: #ffffff; text-shadow: 1px 1px 3px rgba(0,0,0,0.8); 
}
.legendary { 
    background-image: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 40%), var(--card-bg, none), url('assets/Legendary_Face.jpg');
    background-position: bottom, var(--sprite-x, center) var(--sprite-y, center), center;
    background-size: 100% 100%, var(--sprite-size, cover), cover;
    background-repeat: no-repeat;
    border-color: #ff8f00; color: #fff8e1; text-shadow: 2px 2px 4px rgba(0,0,0,0.8); 
}
.mythic { 
    background-image: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 40%), var(--card-bg, none), url('assets/Mythic_Face.jpg');
    background-position: bottom, var(--sprite-x, center) var(--sprite-y, center), center;
    background-size: 100% 100%, var(--sprite-size, cover), cover;
    background-repeat: no-repeat;
    border-color: #ff1744; color: #fff; text-shadow: 2px 2px 5px #000; box-shadow: inset 0 0 15px rgba(255, 23, 68, 0.5); 
}
.core-parts { 
    background-image: linear-gradient(to top, rgba(0,0,0,0.7) 0%, transparent 40%), var(--card-bg, none), linear-gradient(135deg, #006064, #00e5ff);
    background-position: bottom, var(--sprite-x, center) var(--sprite-y, center), center;
    background-size: 100% 100%, var(--sprite-size, cover), cover;
    background-repeat: no-repeat;
    border-color: #00838f; color: #fff; text-shadow: 1px 1px 3px rgba(0,0,0,0.8); 
}

/* Holographic Foil "Shine" for Premium Cards (Legendary, Mythic) */
.legendary::after, .mythic::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: inherit;
    background: linear-gradient(
        115deg, 
        transparent 20%, 
        rgba(255, 100, 200, 0.1) 35%, 
        rgba(255, 255, 255, 0.25) 45%, 
        rgba(255, 255, 255, 0.45) 50%, 
        rgba(100, 255, 255, 0.25) 55%, 
        rgba(100, 100, 255, 0.1) 65%, 
        transparent 80%
    );
    background-size: 200% 200%;
    mix-blend-mode: screen; /* Changed from color-dodge for high-res sprite performance */
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.3s ease;
    transform: translateZ(0);
}

.card:hover .legendary:not(.prismatic)::after, .card:hover .mythic:not(.prismatic)::after,
.mini-card:hover .legendary:not(.prismatic)::after, .mini-card:hover .mythic:not(.prismatic)::after,
.card-detail-overlay .legendary:not(.prismatic)::after, .card-detail-overlay .mythic:not(.prismatic)::after {
    opacity: 0.75;
    animation: holoFoilShine 3.5s ease-in-out infinite alternate;
}

@keyframes holoFoilShine {
    0% { background-position: 0% center; }
    100% { background-position: 100% center; }
}

/* PRISMATIC CSS */
.prismatic {
    border-color: #fff !important;
    color: #fff !important;
    text-shadow: 1px 1px 3px #000, 0 0 10px #fff !important;
    box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.4);
}

/* Holographic Rainbow Foil Layer */
.prismatic::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: inherit;
    background: linear-gradient(
        115deg, 
        transparent 0%, 
        rgba(255, 0, 100, 0.15) 15%, 
        rgba(255, 200, 0, 0.15) 30%, 
        rgba(0, 255, 100, 0.15) 45%, 
        rgba(0, 255, 255, 0.3) 50%, 
        rgba(0, 100, 255, 0.15) 55%, 
        rgba(200, 0, 255, 0.15) 70%, 
        transparent 85%
    );
    background-size: 250% 250%;
    mix-blend-mode: screen;
    animation: prismaticHolo 4s linear infinite;
    pointer-events: none;
    z-index: 5;
    transform: translateZ(0);
    will-change: background-position, transform;
}
@keyframes prismaticHolo {
    0% { background-position: 100% 100%; }
    100% { background-position: 0% 0%; }
}

/* Sweeping Shine Overlay for Prismatic Cards */
.prismatic::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: inherit;
    background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.4) 50%, transparent 65%);
    background-size: 200% 200%;
    mix-blend-mode: screen;
    animation: prismaticShine 3s linear infinite;
    pointer-events: none;
    z-index: 6;
    transform: translateZ(0);
    will-change: background-position, transform;
}
@keyframes prismaticShine {
    0% { background-position: 200% center; }
    100% { background-position: -200% center; }
}

/* New Discovery Badge */
.new-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff1744;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    padding: 4px 8px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.6), 0 0 10px #ff1744;
    text-transform: uppercase;
    z-index: 150;
    opacity: 0;
    transform: scale(0.5) rotate(15deg);
    animation: badgePop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    animation-delay: 0.3s;
}
@keyframes badgePop {
    100% { opacity: 1; transform: scale(1) rotate(15deg); }
}

/* New Level Up Badge */
.levelup-badge {
    position: absolute;
    top: -8px;
    left: -20px;
    background: #4caf50;
    color: #fff;
    font-size: 11px;
    font-weight: 900;
    padding: 4px 8px;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.6), 0 0 10px #4caf50;
    text-transform: uppercase;
    z-index: 150;
    opacity: 0;
    transform: scale(0.5) rotate(-15deg);
    animation: levelUpPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
    animation-delay: 0.3s;
}
@keyframes levelUpPop {
    100% { opacity: 1; transform: scale(1) rotate(-15deg); }
}

/* Level Up Pulsing Arrow */
.lvl-arrow {
    display: inline-block;
    color: #ccff90;
    margin-left: 2px;
    animation: arrowPulseUp 1s infinite ease-in-out;
}
@keyframes arrowPulseUp {
    0% { transform: translateY(3px); opacity: 0; }
    50% { transform: translateY(0px); opacity: 1; }
    100% { transform: translateY(-4px); opacity: 0; }
}

/* Detailed Card Hover Overlay */
.card-detail-overlay {
    position: fixed; top: 0; left: 0;
    z-index: 3000; pointer-events: none;
    opacity: 0; visibility: hidden; transition: opacity 0.2s ease, visibility 0.2s ease;
}
.card-detail-overlay.visible {
    opacity: 1; visibility: visible;
}

@keyframes detailFadeIn {
    0% { opacity: 0; transform: scale(0.8) translateY(15px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}
.card-detail-overlay.visible .card {
    animation: detailFadeIn 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

.empty-display {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 12px;
    color: #555; display: flex; flex-direction: column; align-items: center; justify-content: center;
    width: 100%; height: 100%; margin: 0; box-sizing: border-box; font-weight: bold; text-align: center; gap: 10px;
}

/* Library / Gallery (Right Panel) */
.progression-section {
    width: 97%; height: 100%; background: transparent; padding: 20px; border-radius: 16px; box-sizing: border-box;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5); display: flex; flex-direction: column; align-items: center; min-height: 0; left: 10px;
    position: relative;
}
.gallery-header { display: flex; justify-content: space-between; width: 100%; align-items: center; margin-bottom: 20px; padding-bottom: 10px; border-bottom: 2px solid #000000; }
.gallery-header h2 { margin: 0; color: #fff; font-size: 20px; }
.collection-tracker { font-size: 16px; color: #4fc3f7; font-weight: bold; }

.search-container { position: relative; width: 100%; margin-bottom: 15px; }

#gallery-container { flex: 1; min-height: 0; overflow-y: auto; width: 100%; padding-right: 5px; }
.library-search {
    width: 100%; padding: 10px 100px 10px 10px; border-radius: 8px; border: 1px solid #444; background: #2a2a2a; color: #fff; margin-bottom: 0; box-sizing: border-box; font-size: 14px;
}
.library-search:focus { outline: none; border-color: #4fc3f7; }

.filter-toggle-btn {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    background: #333; border: 1px solid #555; color: #ccc;
    font-size: 11px; padding: 5px 8px; border-radius: 6px; cursor: pointer; transition: 0.2s; font-weight: bold;
    display: flex; align-items: center; gap: 4px; z-index: 10;
}
.filter-toggle-btn:hover { background: #444; color: #fff; border-color: #4fc3f7; }

.filter-dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 5px);
    background: #222; border: 1px solid #444; border-radius: 8px; box-shadow: 0 5px 15px rgba(0,0,0,0.8);
    display: flex; flex-direction: column; min-width: 120px; z-index: 200;
    opacity: 0; visibility: hidden; transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
    transform: translateY(-10px); padding: 5px;
}
.filter-dropdown-menu.show { opacity: 1; visibility: visible; transform: translateY(0); }

.dropdown-filter-item {
    background: transparent; border: none; color: #ccc; text-align: left; padding: 8px 12px;
    font-size: 12px; cursor: pointer; border-radius: 4px; transition: 0.2s; font-weight: bold;
}
.dropdown-filter-item:hover { background: #333; color: #fff; }
.dropdown-filter-item.active { background: rgba(79, 195, 247, 0.2); color: #4fc3f7; }

.clear-search-btn {
    position: absolute; right: 80px; top: 50%; transform: translateY(-50%);
    background: transparent; border: none; color: #888; font-size: 20px; font-weight: bold; cursor: pointer; padding: 0; line-height: 1; z-index: 10;
}
.clear-search-btn:hover { color: #ff5252; }

/* Back to Top Button */
.back-to-top-btn {
    position: absolute;
    bottom: 30px;
    right: 30px;
    background: linear-gradient(135deg, #0288d1, #00e5ff);
    color: #fff;
    border: 2px solid #84ffff;
    border-radius: 50%;
    width: 54px;
    height: 54px;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 6px 15px rgba(0, 229, 255, 0.5);
    z-index: 1000;
}
.back-to-top-btn.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(-5px);
}
.back-to-top-btn:hover {
    transform: translateY(-10px) scale(1.1);
    box-shadow: 0 8px 25px rgba(0, 229, 255, 0.8);
}

.tier-section { width: 100%; margin-bottom: 15px; content-visibility: auto; contain-intrinsic-size: auto 500px; }
.tier-header {
    padding: 6px 12px; border-radius: 6px; margin-bottom: 0px;
    font-weight: bold; text-transform: uppercase; letter-spacing: 1px; font-size: 13px;
    display: flex; justify-content: space-between; align-items: center;
    cursor: pointer; transition: filter 0.2s, transform 0.2s;
    backdrop-filter: blur(5px);
    position: sticky;
    top: 0;
    z-index: 100;
}
.tier-header:hover { filter: brightness(1.2); transform: translateX(4px); }
.tier-header.common { background: linear-gradient(90deg, rgba(66,66,66,0.85), rgba(30,30,30,0.4)); color: #fff; border: 1px solid rgba(158,158,158,0.3); border-left: 5px solid #9e9e9e; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.tier-header.uncommon { background: linear-gradient(90deg, rgba(46,125,50,0.85), rgba(27,94,32,0.4)); color: #fff; border: 1px solid rgba(76,175,80,0.3); border-left: 5px solid #4caf50; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.tier-header.rare { background: linear-gradient(90deg, rgba(21,101,192,0.85), rgba(13,71,161,0.4)); color: #fff; border: 1px solid rgba(79,195,247,0.3); border-left: 5px solid #4fc3f7; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.tier-header.epic { background: linear-gradient(90deg, rgba(106,27,154,0.85), rgba(74,20,140,0.4)); color: #fff; border: 1px solid rgba(186,104,200,0.3); border-left: 5px solid #ba68c8; box-shadow: 0 4px 10px rgba(0,0,0,0.5); }
.tier-header.legendary { background: linear-gradient(90deg, rgba(255,143,0,0.85), rgba(255,111,0,0.4)); color: #fff; border: 1px solid rgba(255,179,0,0.4); border-left: 5px solid #ffb300; box-shadow: 0 4px 15px rgba(255, 179, 0, 0.2); text-shadow: 1px 1px 2px #000; }
.tier-header.mythic { background: linear-gradient(90deg, rgba(213,0,0,0.85), rgba(183,28,28,0.4)); color: #fff; border: 1px solid rgba(255,23,68,0.4); border-left: 5px solid #ff1744; box-shadow: 0 4px 15px rgba(255, 23, 68, 0.3); text-shadow: 1px 1px 3px #000; }
.tier-header.core-parts { background: linear-gradient(90deg, rgba(0,131,143,0.85), rgba(0,96,100,0.4)); color: #fff; border: 1px solid rgba(0,229,255,0.3); border-left: 5px solid #00e5ff; box-shadow: 0 4px 15px rgba(0, 229, 255, 0.2); }

/* Sort & Upgrade Buttons */
.sort-btn {
    background: rgba(0,0,0,0.4); border: 1px solid rgba(255,255,255,0.2); color: #fff;
    font-size: 10px; padding: 4px 8px; border-radius: 4px; cursor: pointer; text-transform: uppercase;
    box-shadow: 0 2px 4px rgba(0,0,0,0.5); transition: 0.2s;
}
.sort-btn:hover { background: rgba(255,255,255,0.2); border-color: rgba(255,255,255,0.5); }

.gallery-grid { 
    display: grid; grid-template-columns: repeat(auto-fill, minmax(115px, 1fr)); gap: 20px 15px; width: 100%; justify-items: center; padding: 20px 15px 25px 15px; box-sizing: border-box;
}
#gallery-container::-webkit-scrollbar { width: 6px; }
#gallery-container::-webkit-scrollbar-track { background: rgba(0,0,0,0.2); border-radius: 4px; }
#gallery-container::-webkit-scrollbar-thumb { background: rgba(0, 229, 255, 0.4); border-radius: 4px; }
#gallery-container::-webkit-scrollbar-thumb:hover { background: rgba(0, 229, 255, 0.8); }

.mini-card {
    width: 115px; height: 175px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
    font-size: 13px; font-weight: bold; text-align: center; padding: 6px; box-sizing: border-box; position: relative; transition: transform 0.3s, box-shadow 0.3s, filter 0.3s, opacity 0.3s, border-color 0.3s;
}
.mini-card.locked { background: #222; border: 2px dashed #444; color: #666; filter: grayscale(100%); justify-content: center;}
.mini-card.unlocked { transform: scale(1.05); box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5); cursor: pointer; }
.mini-card.unlocked:hover { transform: scale(1.1) translateY(-5px); box-shadow: 0 12px 24px rgba(0, 0, 0, 0.8); z-index: 150; }

.mini-card.unlocked.disabled { opacity: 0.4; filter: grayscale(100%); cursor: not-allowed; transform: scale(1) !important; box-shadow: none !important; z-index: 1 !important; }
.mini-card.unlocked.forge-selectable { border: 2px solid #ff8f00; box-shadow: 0 0 15px rgba(255, 143, 0, 0.6); animation: pulseSelectable 1.5s infinite alternate; z-index: 10; cursor: grab; }
.mini-card.unlocked.forge-selectable:active { cursor: grabbing; }
@keyframes pulseSelectable {
    0% { box-shadow: 0 0 5px rgba(255, 143, 0, 0.4); }
    100% { box-shadow: 0 0 20px rgba(255, 143, 0, 0.9); }
}

/* Effect while physically dragging the card */
.mini-card.dragging { opacity: 0.5; cursor: grabbing !important; transform: scale(1.05); }

/* Leveling Visuals */
.card-lvl { font-size: 12px; background: rgba(0,0,0,0.5); padding: 3px 6px; border-radius: 10px; }

/* Dev Wipe Button */
.wipe-save-btn { background: transparent; color: #ff5252; border: 1px solid #ff5252; padding: 5px 10px; border-radius: 5px; cursor: pointer; font-size: 12px; margin-top: 20px;}
.wipe-save-btn:hover { background: #ff5252; color: #fff; }

/* Effects — three escalating shake tiers */
@keyframes shakeEpic {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    20% { transform: translate(-2px, -1px) rotate(-1deg); }
    40% { transform: translate(1px, 2px) rotate(1deg); }
    60% { transform: translate(-1px, -1px) rotate(-0.5deg); }
    80% { transform: translate(2px, 1px) rotate(0.5deg); }
}
@keyframes shakeEpic {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-3px, -2px) rotate(-1.5deg); }
    20% { transform: translate(2px,  1px) rotate( 1deg); }
    30% { transform: translate(-2px,  3px) rotate(-1deg); }
    40% { transform: translate(3px, -1px) rotate( 1.5deg); }
    50% { transform: translate(-1px,  2px) rotate(-0.5deg); }
    60% { transform: translate(2px, -2px) rotate( 1deg); }
    70% { transform: translate(-3px,  1px) rotate(-1deg); }
    80% { transform: translate(1px,  -1px) rotate( 0.5deg); }
    90% { transform: translate(-1px,  2px) rotate(-0.5deg); }
}
@keyframes shakeMythic {
    0%, 100% { transform: translate(0, 0) rotate(0deg); }
    10% { transform: translate(-5px, -3px) rotate(-2deg); }
    20% { transform: translate( 3px,  4px) rotate( 2.5deg); }
    30% { transform: translate(-4px, -1px) rotate(-1.5deg); }
    40% { transform: translate( 5px, -2px) rotate( 2deg); }
    50% { transform: translate(-3px,  5px) rotate(-2.5deg); }
    60% { transform: translate( 4px, -4px) rotate( 1.5deg); }
    70% { transform: translate(-6px,  2px) rotate(-2deg); }
    80% { transform: translate( 2px, -1px) rotate( 1deg); }
    90% { transform: translate(-3px,  3px) rotate(-1.5deg); }
}
.screen-shake-epic  { animation: shakeEpic   0.25s cubic-bezier(.36,.07,.19,.97) both; }
.screen-shake       { animation: shake       0.35s cubic-bezier(.36,.07,.19,.97) both; }
.screen-shake-mythic{ animation: shakeMythic 0.45s cubic-bezier(.36,.07,.19,.97) both; }

/* Screen vignette flash on premium reveals */
@keyframes vignetteFlashLegendary {
    0%   { box-shadow: inset 0 0   0px rgba(255,179,0,0); }
    15%  { box-shadow: inset 0 0 200px rgba(255,179,0,0.65); }
    100% { box-shadow: inset 0 0   0px rgba(255,179,0,0); }
}
@keyframes vignetteFlashMythic {
    0%   { box-shadow: inset 0 0   0px rgba(255,23,68,0); }
    15%  { box-shadow: inset 0 0 280px rgba(255,23,68,0.85); }
    100% { box-shadow: inset 0 0   0px rgba(255,23,68,0); }
}
@keyframes vignetteFlashPrismatic {
    0%   { box-shadow: inset 0 0   0px rgba(255,0,255,0); }
    12%  { box-shadow: inset 0 0 320px rgba(255,0,255,0.75); }
    35%  { box-shadow: inset 0 0 320px rgba(0,255,255,0.75); }
    65%  { box-shadow: inset 0 0 320px rgba(255,255,0,0.55); }
    100% { box-shadow: inset 0 0   0px rgba(255,0,255,0); }
}
.vignette-legendary { animation: vignetteFlashLegendary 0.8s ease-out forwards; }
.vignette-mythic    { animation: vignetteFlashMythic    0.8s ease-out forwards; }
.vignette-prismatic { animation: vignetteFlashPrismatic 1.2s ease-out forwards; }

/* Ongoing card glow FX post-reveal */
.legendary-fx { z-index: 10; }
.mythic-fx { z-index: 10; }
.prismatic-fx { animation: prismaticPulse 0.8s infinite ease-in-out; z-index: 10; }
@keyframes prismaticPulse {
    0%   { box-shadow: 0 0 55px #ff00ff, 0 0 28px #00ffff; }
    33%  { box-shadow: 0 0 130px #ff0000, 0 0 65px #ffff00; }
    66%  { box-shadow: 0 0 155px #0000ff, 0 0 78px #00ffff, inset 0 0 90px rgba(255,255,255,0.75); }
    100% { box-shadow: 0 0 55px #ff00ff, 0 0 28px #00ffff; }
}

/* Rarity announcement text */
.legendary-text-container { position: absolute; top: 60%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; z-index: 9999; width: 100%; text-align: center; }
.legendary-text { font-size: 7rem; font-weight: 900; color: #ffe082; text-transform: uppercase; text-shadow: 0 0 20px #ff8f00, 0 0 40px #ffb300, 5px 5px 0px #000; opacity: 0; margin: 0; letter-spacing: 4px; }
@keyframes popText {
    0%   { opacity: 0; transform: scale(0.05) rotate(-15deg); filter: blur(20px); }
    15%  { opacity: 1; transform: scale(1.55) rotate(6deg);  filter: blur(0px); }
    26%  { transform: scale(1.0) rotate(-2deg); opacity: 1; }
    38%  { transform: scale(1.12) rotate(0deg); opacity: 1; }
    75%  { opacity: 1; transform: scale(1.06) rotate(0deg); filter: blur(0px); }
    100% { opacity: 0; transform: scale(2.1);  filter: blur(15px); }
}
.show-legendary-text { animation: popText 2.0s forwards; }
#confetti { position: fixed; top: 0; left: 0; width: 100%; height: 100%; pointer-events: none; z-index: 1500; }

/* Dev Tools Panel */
.dev-tools-panel {
    position: fixed;
    top: 20px;
    right: 20px;
    background: radial-gradient(circle at top right, rgba(50, 50, 50, 0.15) 0%, rgba(18, 18, 18, 0.95) 100%);
    border: 1px dashed #444;
    border-radius: 12px;
    padding: 12px 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    z-index: 1000;
    backdrop-filter: blur(5px);
    width: 170px;
    transition: all 0.3s ease;
}

.live-stats-grid { display: grid; grid-template-columns: auto 1fr; gap: 4px 15px; }
.live-stats-grid span:nth-child(even) { text-align: right; font-weight: bold; font-variant-numeric: tabular-nums; }

@media (max-width: 950px) {
    .game-wrapper { flex-direction: column; align-items: center; width: 100% !important; height: auto !important; }
    .left-panel { width: 100%; }
    .right-panel { width: 100%; max-width: 800px; }
    .game-board { flex-direction: column; align-items: center; gap: 30px; width: 100%; flex-shrink: 1; }
    .legendary-text { font-size: 3rem; }
}
@media (max-width: 600px) {
    .dev-tools-panel { transform: scale(0.85); transform-origin: top right; top: 10px; right: 10px; }
    .toast-container { bottom: 180px; right: 10px; }
    
    /* Make the Top Nav horizontally scrollable */
    .top-nav {
        justify-content: flex-start;
        overflow-x: auto;
        flex-wrap: nowrap;
        padding-bottom: 2px;
        -ms-overflow-style: none;  /* IE and Edge */
        scrollbar-width: none;  /* Firefox */
    }
    .top-nav::-webkit-scrollbar { display: none; /* Chrome/Safari */ }
    .tab-btn { padding: 10px 12px; font-size: 13px; flex-shrink: 0; }
    
    /* Compact the Action Panel to save vertical space */
    .action-panel {
        flex-direction: row;
        margin-top: -60px;
        padding: 10px;
        width: 100%;
        justify-content: center;
        gap: 15px;
    }
    .action-buttons { width: auto; flex: 1; max-width: 220px; justify-content: center; }
    
    /* Scale down the Auth Box logo so it doesn't clip off the top of the screen */
    .auth-box {
        padding: 70px 15px 25px 15px !important;
        margin-top: 60px !important;
    }
    header .auth-logo {
        max-width: 200px !important;
        top: -85px !important;
    }
}
@media (max-width: 480px) {
    .card.discover-wrap { width: 115px; height: 175px; }
}

/* Quest Reroll Animation (Split-Flap Train Board Effect) */
@keyframes splitFlapSpin {
    0% { transform: perspective(600px) rotateX(0deg); }
    25% { transform: perspective(600px) rotateX(90deg); filter: brightness(0.5); }
    25.1% { transform: perspective(600px) rotateX(-90deg); filter: brightness(0.5); }
    50% { transform: perspective(600px) rotateX(0deg); filter: brightness(1); }
    75% { transform: perspective(600px) rotateX(90deg); filter: brightness(0.5); }
    75.1% { transform: perspective(600px) rotateX(-90deg); filter: brightness(0.5); }
    100% { transform: perspective(600px) rotateX(0deg); filter: brightness(1); }
}
.anim-quest-reroll {
    animation: splitFlapSpin 0.5s ease-in-out forwards;
    transform-style: preserve-3d;
    transform-origin: center;
}

@keyframes nodeBounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-4px); }
}

/* Action Panel (Draw Controls) */
.action-panel {
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-radius: 16px;
    max-width: 520px;
    box-sizing: border-box;
    flex-shrink: 0;
    margin-top: -120px;
}

.deck-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.deck-wrapper {
    position: relative;
    width: 120px;
    height: 172px;
}

.deck-label {
    font-size: 10px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: bold;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 220px;
    flex-shrink: 0;
}

.action-buttons > button {
    width: 100%;
    flex: 1;
}

#boost-btn {
    letter-spacing: 0.5px;
    box-sizing: border-box;
}

/* Segmented Volume Sliders */
.segmented-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 10px;
    margin: 0;
    padding: 0;
    background: 
        repeating-linear-gradient(to right, transparent, transparent calc(5% - 2px), #111 calc(5% - 2px), #111 5%),
        linear-gradient(to right, #4fc3f7 var(--val, 5%), #444 var(--val, 5%));
    border-radius: 4px;
    outline: none;
    border: 1px solid #222;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.8);
}
.segmented-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 20px;
    background: #4fc3f7;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #fff;
    box-shadow: 0 0 5px rgba(79, 195, 247, 0.8);
}
.segmented-slider::-moz-range-thumb {
    width: 14px;
    height: 20px;
    background: #4fc3f7;
    cursor: pointer;
    border-radius: 4px;
    border: 1px solid #fff;
    box-shadow: 0 0 5px rgba(79, 195, 247, 0.8);
}

/* --- Mobile Performance Overrides --- */
/* Fix: Removed native CSS nesting to ensure compatibility with older mobile browsers */
/* Disable expensive blur filters to save GPU and battery */
body.is-mobile-device .tab-container, 
body.is-mobile-device .top-nav, 
body.is-mobile-device .tab-btn, 
body.is-mobile-device .action-panel, 
body.is-mobile-device .tier-header, 
body.is-mobile-device #forge-modal .modal-content, 
body.is-mobile-device #tab-forge .tab-container, 
body.is-mobile-device #forge-container,
body.is-mobile-device #tab-core .tab-container, 
body.is-mobile-device #tab-shop .tab-container, 
body.is-mobile-device #discover-modal .modal-content,
body.is-mobile-device #boost-summary-modal .modal-content, 
body.is-mobile-device .dev-tools-panel,
body.is-mobile-device[data-active-tab] .tab-btn.active {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    background-color: rgba(0, 0, 0, 0.95) !important; 
}

/* Hide extremely heavy gradient masking animations & blurs */
body.is-mobile-device .magical-embers, 
body.is-mobile-device .auth-embers,
body.is-mobile-device .forge-core::before,
body.is-mobile-device .forge-core::after,
body.is-mobile-device .shop-card-glow {
    display: none !important;
}

/* Simplify premium card holographics */
body.is-mobile-device .legendary::after, 
body.is-mobile-device .mythic::after, 
body.is-mobile-device .prismatic::before, 
body.is-mobile-device .prismatic::after {
    animation: none !important;
}

/* Disable filter animations on the Legendary drop text */
body.is-mobile-device .legendary-text {
    filter: none !important;
}

/* Loading Spinner */
@keyframes spin { 100% { transform: rotate(360deg); } }
.loading-spinner {
    width: 60px; height: 60px;
    border: 4px solid rgba(0, 229, 255, 0.2);
    border-top-color: #00e5ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    box-shadow: 0 0 15px rgba(0, 229, 255, 0.2);
}