:root {
    /* Palette: Deep Cosmic */
    --bg-dark: #050508;
    --bg-light: #1a1a2e;
    
    --accent: #7b2cbf; /* Royal Purple */
    --accent-light: #9d4edd;
    --accent-glow: rgba(123, 44, 191, 0.4);
    
    --text-main: #ffffff;
    --text-dim: rgba(255, 255, 255, 0.6);
    
    --glass-bg: rgba(20, 20, 30, 0.65);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-blur: 20px;
    
    --gold: #ffd700;
    --danger: #ff4b4b;
    --success: #a6e3a1;
    
    /* Tiers */
    --tier-0-color: #a0a0a0;
    --tier-1-color: #4caf50;
    --tier-2-color: #03a9f4;
    --tier-3-color: #e91e63;
    --tier-4-color: #ff9800;
    --tier-god-color: #00e5ff;
    
    /* Новые улучшенные переменные */
    --glow-intensity: 0.6;
    --shadow-depth: 20px;
    --transition-smooth: cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Themes override variables */
body.theme-nature { --accent: #2e7d32; --accent-light: #4caf50; --accent-glow: rgba(76, 175, 80, 0.4); }
body.theme-fire { --accent: #c62828; --accent-light: #ef5350; --accent-glow: rgba(244, 67, 54, 0.4); }
body.theme-gold { --accent: #ff8f00; --accent-light: #ffca28; --accent-glow: rgba(255, 193, 7, 0.4); }

* { 
    box-sizing: border-box; 
    -webkit-tap-highlight-color: transparent; 
    outline: none;
    /* Улучшения производительности */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    margin: 0; 
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    height: 100vh; height: 100dvh;
    display: flex; flex-direction: column;
    overflow: hidden;
    user-select: none; -webkit-user-select: none;
    transition: background 0.5s ease;
    -webkit-font-smoothing: antialiased;
    /* Улучшения для мобильных устройств */
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: pan-y;
}

/* --- BACKGROUND --- */
.bg-mesh {
    position: fixed; inset: 0; z-index: -1;
    background: 
        radial-gradient(ellipse 120% 80% at 10% 20%, rgba(123, 44, 191, 0.22) 0%, transparent 45%),
        radial-gradient(ellipse 100% 100% at 90% 80%, rgba(157, 78, 221, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(123, 44, 191, 0.06) 0%, transparent 60%);
    opacity: 1;
    transition: background 0.5s ease;
    animation: meshPulse 12s ease-in-out infinite alternate;
    /* Улучшения производительности */
    will-change: opacity;
    backface-visibility: hidden;
}

@keyframes meshPulse {
    0% { opacity: 0.92; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.02); }
    100% { opacity: 0.92; transform: scale(1); }
}

/* Дополнительные анимации для красоты */
@keyframes float {
    0%, 100% { transform: translateY(0px); }
    50% { transform: translateY(-10px); }
}

@keyframes shimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

@keyframes glow {
    0%, 100% { box-shadow: 0 0 20px var(--accent-glow), 0 0 40px var(--accent-glow); }
    50% { box-shadow: 0 0 30px var(--accent-glow), 0 0 60px var(--accent-glow), 0 0 80px var(--accent-glow); }
}

@keyframes rotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes scaleIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Theme-specific background gradients */
body.theme-nature .bg-mesh {
    background: 
        radial-gradient(circle at 15% 50%, rgba(46, 125, 50, 0.15) 0%, transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(76, 175, 80, 0.1) 0%, transparent 25%);
}

body.theme-fire .bg-mesh {
    background: 
        radial-gradient(circle at 15% 50%, rgba(198, 40, 40, 0.15) 0%, transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(239, 83, 80, 0.1) 0%, transparent 25%);
}

body.theme-gold .bg-mesh {
    background: 
        radial-gradient(circle at 15% 50%, rgba(255, 143, 0, 0.15) 0%, transparent 25%),
        radial-gradient(circle at 85% 30%, rgba(255, 202, 40, 0.1) 0%, transparent 25%);
}

/* Grid Pattern */
.bg-grid {
    position: fixed; inset: 0; z-index: -1;
    background-image: 
        linear-gradient(rgba(255,255,255,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    mask-image: radial-gradient(ellipse 120% 120% at 50% 50%, black 30%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse 120% 120% at 50% 50%, black 30%, transparent 75%);
    /* Улучшения производительности */
    will-change: auto;
    backface-visibility: hidden;
    /* Красивая анимация сетки */
    animation: float 20s ease-in-out infinite;
}

/* Дополнительные частицы на фоне */
.bg-grid::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image: 
        radial-gradient(2px 2px at 20% 30%, rgba(123, 44, 191, 0.3), transparent),
        radial-gradient(2px 2px at 60% 70%, rgba(157, 78, 221, 0.3), transparent),
        radial-gradient(1px 1px at 50% 50%, rgba(255, 255, 255, 0.2), transparent),
        radial-gradient(1px 1px at 80% 20%, rgba(123, 44, 191, 0.2), transparent);
    background-size: 200% 200%;
    animation: float 15s ease-in-out infinite reverse;
    opacity: 0.6;
}

/* --- HEADER --- */
header {
    height: 64px; padding: 0 20px;
    display: flex; align-items: center; justify-content: space-between;
    background: rgba(12, 12, 22, 0.75);
    backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
    border-bottom: 1px solid var(--glass-border);
    z-index: 50;
    box-shadow: 0 4px 40px rgba(0,0,0,0.35), 0 1px 0 rgba(255,255,255,0.03) inset;
    /* Улучшения для мобильных */
    position: sticky;
    top: 0;
    will-change: transform;
}

.logo {
    font-weight: 900; font-size: 1.15rem; letter-spacing: 2px;
    background: linear-gradient(135deg, #fff 0%, var(--accent-light) 50%, #c77dff 100%);
    background-size: 200% auto;
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
    cursor: pointer;
    transition: all 0.3s var(--transition-smooth);
    position: relative;
    animation: shimmer 3s linear infinite;
    filter: drop-shadow(0 0 10px var(--accent-glow));
}

.logo:hover { 
    filter: brightness(1.2) drop-shadow(0 0 15px var(--accent-glow)); 
    transform: scale(1.05);
    background-position: 100% center;
}

.logo:active { transform: scale(0.98); }

.header-actions { display: flex; gap: 12px; align-items: center; }

.currency-pill {
    background: linear-gradient(135deg, rgba(255,215,0,0.12) 0%, rgba(255,215,0,0.04) 100%);
    border: 1px solid rgba(255,215,0,0.3);
    border-radius: 20px; padding: 6px 14px;
    font-size: 0.9rem; font-weight: 700; color: var(--gold);
    display: flex; align-items: center; gap: 6px;
    cursor: pointer; 
    transition: all 0.3s var(--transition-smooth);
    box-shadow: 0 0 20px rgba(255,215,0,0.1),
                0 0 30px rgba(255,215,0,0.05);
    position: relative;
    overflow: hidden;
}

.currency-pill::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,215,0,0.2), transparent);
    transform: rotate(45deg);
    transition: all 0.6s;
    opacity: 0;
}

.currency-pill:hover::before {
    animation: shimmer 1.5s infinite;
    opacity: 1;
}

.currency-pill:hover { 
    border-color: rgba(255,215,0,0.6); 
    box-shadow: 0 0 30px rgba(255,215,0,0.25),
                0 0 50px rgba(255,215,0,0.15);
    transform: translateY(-2px) scale(1.05);
}

.currency-pill:active { 
    transform: translateY(0) scale(0.98);
}

.icon-btn {
    width: 40px; height: 40px; border-radius: 12px;
    background: rgba(255,255,255,0.06); border: 1px solid var(--glass-border);
    color: var(--text-dim); display: flex; align-items: center; justify-content: center;
    font-size: 1.2rem; cursor: pointer; 
    transition: all 0.3s var(--transition-smooth);
    position: relative;
    overflow: hidden;
}

.icon-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.4s, height 0.4s;
}

.icon-btn:hover::before {
    width: 100px;
    height: 100px;
}

.icon-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #fff;
    transform: translateY(-3px) scale(1.05);
    border-color: rgba(123, 44, 191, 0.4);
    box-shadow: 0 6px 20px rgba(0,0,0,0.3), 
                0 0 15px rgba(123, 44, 191, 0.2);
}

.icon-btn:active { 
    transform: translateY(-1px) scale(0.95);
}
.icon-btn.shop-btn { background: var(--accent); color: white; border: none; box-shadow: 0 4px 15px var(--accent-glow); }
.icon-btn.active-quest { border-color: var(--accent-light); box-shadow: 0 0 10px var(--accent-glow); }

.user-avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(255,255,255,0.1); border: 2px solid var(--glass-border);
    display: flex; align-items: center; justify-content: center; font-size: 1.2rem;
    cursor: pointer; transition: 0.2s;
}
.user-avatar:hover { border-color: var(--accent-light); }

/* --- QUEST BAR (Mini) --- */
#mini-quest-bar {
    background: linear-gradient(90deg, rgba(123, 44, 191, 0.2), rgba(157, 78, 221, 0.1));
    border-bottom: 1px solid var(--glass-border); padding: 8px 15px; font-size: 0.85rem;
    display: flex; justify-content: space-between; align-items: center; color: var(--text-dim);
    animation: slideDown 0.5s ease;
}
.quest-target { color: var(--accent-light); font-weight: 800; text-transform: uppercase; }
@keyframes slideDown { from { transform: translateY(-100%); } to { transform: translateY(0); } }

/* --- WORKSPACE --- */
#workspace {
    flex: 1; position: relative; overflow: hidden;
    padding: 20px; min-height: 200px;
    display: flex; flex-wrap: wrap; gap: 15px; align-content: flex-start;
    background: rgba(0,0,0,0.2); border-radius: 16px;
    margin: 0 20px 20px 20px;
    border: 2px dashed var(--glass-border);
    overflow-y: auto; overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    /* Улучшения для мобильных - увеличиваем размер рабочей области */
}

/* Улучшения workspace для мобильных */
@media (max-width: 768px) {
    #workspace {
        min-height: calc(100vh - 180px);
        padding: 15px;
        margin: 0 10px 10px 10px;
        gap: 12px;
    }
}

@media (max-width: 480px) {
    #workspace {
        min-height: calc(100vh - 160px);
        padding: 12px;
        margin: 0 8px 8px 8px;
        gap: 10px;
    }
}

/* --- INVENTORY PANEL --- */
#inventory-panel {
    height: 40vh;
    background: rgba(10, 10, 22, 0.82);
    backdrop-filter: blur(var(--glass-blur)); -webkit-backdrop-filter: blur(var(--glass-blur));
    border-top: 1px solid var(--glass-border);
    display: flex; flex-direction: column;
    z-index: 40;
    box-shadow: 0 -15px 50px rgba(0,0,0,0.4), 0 -1px 0 rgba(255,255,255,0.04) inset;
    transition: height 0.3s ease;
    /* Улучшения для мобильных */
    position: sticky;
    bottom: 0;
    will-change: height;
}

.inventory-header {
    padding: 12px 20px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid var(--glass-border);
    gap: 15px;
}

.search-bar {
    flex: 1; position: relative;
    background: rgba(0,0,0,0.2); border-radius: 12px;
    display: flex; align-items: center;
    border: 1px solid transparent; transition: 0.2s;
}
.search-bar:focus-within { border-color: var(--accent); background: rgba(0,0,0,0.3); }

.search-icon { padding-left: 12px; opacity: 0.5; font-size: 0.9rem; }
.search-input {
    width: 100%; border: none; background: transparent; padding: 10px;
    color: white; font-size: 0.95rem; font-weight: 500;
}
.search-input::placeholder { color: rgba(255,255,255,0.3); }

.inventory-tools { display: flex; gap: 8px; }

#inventory-grid {
    flex: 1; padding: 20px;
    overflow-y: auto; overflow-x: hidden;
    overflow-scrolling: touch;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 16px; align-content: start;
    scroll-behavior: smooth;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Улучшения для мобильных устройств */
@media (max-width: 768px) {
    /* Улучшения для скролла на мобильных */
    #inventory-grid, #book-content, #achievements-list {
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        scrollbar-width: thin;
    }
    
    #inventory-grid {
        grid-template-columns: repeat(auto-fill, minmax(85px, 1fr));
        gap: 12px;
        padding: 12px;
    }
    
    /* Улучшения для workspace на мобильных - увеличиваем размер */
    #workspace {
        padding: 15px;
        margin: 0 10px 10px 10px;
        gap: 12px;
        min-height: calc(100vh - 150px);
        flex: 1 1 auto;
    }
    
    /* Улучшения для модальных окон */
    .modal-overlay {
        padding: 10px;
    }
    
    .modal-card {
        max-height: calc(100vh - 20px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Улучшения для главного контейнера игры */
    body {
        overflow: hidden;
    }
    
    /* Улучшения для header на мобильных */
    header {
        flex-shrink: 0;
    }
}
/* --- CUSTOM SCROLLBAR --- */
::-webkit-scrollbar { width: 10px; }
::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.2);
    border-radius: 10px;
    margin: 4px;
}
::-webkit-scrollbar-thumb {
    background: linear-gradient(180deg, rgba(123, 44, 191, 0.6) 0%, rgba(157, 78, 221, 0.5) 100%);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: background 0.2s;
}
::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(180deg, rgba(123, 44, 191, 0.8) 0%, rgba(157, 78, 221, 0.7) 100%);
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:active {
    background: linear-gradient(180deg, rgba(123, 44, 191, 1) 0%, rgba(157, 78, 221, 0.9) 100%);
    background-clip: padding-box;
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: rgba(123, 44, 191, 0.6) rgba(0,0,0,0.2);
}

/* --- ELEMENTS (The "Chips") --- */
.element {
    width: 72px; height: 72px;
    background: linear-gradient(145deg, rgba(255,255,255,0.09) 0%, rgba(255,255,255,0.04) 100%);
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.12);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: grab; position: absolute;
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.25s, background 0.2s, border-color 0.2s;
    user-select: none; touch-action: none;
    will-change: transform;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

#inventory-grid .element {
    position: relative; width: 100%; height: auto; aspect-ratio: 1; left: auto !important; top: auto !important;
    content-visibility: auto;
    contain-intrinsic-size: 72px 72px;
    padding: 8px 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.element:hover {
    background: linear-gradient(145deg, rgba(255,255,255,0.16) 0%, rgba(255,255,255,0.1) 100%);
    border-color: rgba(123, 44, 191, 0.4);
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 10px 30px rgba(0,0,0,0.4), 
                0 0 20px rgba(123, 44, 191, 0.3),
                0 0 0 1px rgba(255,255,255,0.1);
    z-index: 10;
}

.element:active { 
    cursor: grabbing; 
    transform: translateY(-2px) scale(1.02);
}

.element.dragging {
    z-index: 1000;
    box-shadow: 0 25px 60px rgba(0,0,0,0.6), 
                0 0 0 3px var(--accent), 
                0 0 50px var(--accent-glow),
                0 0 80px rgba(123, 44, 191, 0.4);
    transform: scale(1.15) rotate(5deg);
    background: linear-gradient(145deg, rgba(30, 30, 50, 0.98) 0%, rgba(20, 20, 35, 0.98) 100%);
    border-color: var(--accent-light);
    animation: glow 1s ease-in-out infinite;
}

.element.hint-highlight {
    background: rgba(255, 215, 0, 0.25) !important;
    border: 3px solid var(--gold) !important;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.8), 
                0 0 50px rgba(255, 215, 0, 0.5),
                0 0 70px rgba(255, 215, 0, 0.3) !important;
    animation: hintPulse 1.5s ease-in-out infinite, glow 2s ease-in-out infinite;
    z-index: 999;
    transform: scale(1.1);
}

@keyframes hintPulse {
    0%, 100% { 
        transform: scale(1);
        box-shadow: 0 0 20px rgba(255, 215, 0, 0.6), 0 0 40px rgba(255, 215, 0, 0.3);
    }
    50% { 
        transform: scale(1.05);
        box-shadow: 0 0 30px rgba(255, 215, 0, 0.8), 0 0 60px rgba(255, 215, 0, 0.5);
    }
}

.el-icon { font-size: 32px; margin-bottom: 4px; filter: drop-shadow(0 4px 6px rgba(0,0,0,0.2)); pointer-events: none; }
.el-name { 
    font-size: 10px; font-weight: 700; color: rgba(255,255,255,0.9); 
    text-align: center; width: 100%; 
    padding: 0 2px;
    overflow: hidden; 
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.2;
    max-height: 2.4em;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    pointer-events: none; text-transform: uppercase; letter-spacing: 0.3px;
}

/* Tier Indicators (Subtle bottom border) */
.element::after {
    content: ''; position: absolute; bottom: 0; left: 15%; width: 70%; height: 3px;
    border-radius: 3px 3px 0 0; background: var(--tier-0-color); opacity: 0.7;
}
.element[data-tier="1"]::after { background: var(--tier-1-color); }
.element[data-tier="2"]::after { background: var(--tier-2-color); }
.element[data-tier="3"]::after { background: var(--tier-3-color); }
.element[data-tier="4"]::after { background: var(--tier-4-color); }
.element[data-tier="5"]::after { background: var(--tier-4-color); box-shadow: 0 0 8px var(--tier-4-color); }
.element[data-tier="6"]::after, .element[data-tier="7"]::after, .element[data-tier="8"]::after { 
    background: var(--tier-god-color); box-shadow: 0 0 10px var(--tier-god-color); 
}

/* --- MODALS & OVERLAYS --- */
.modal-overlay {
    position: fixed; inset: 0; z-index: 2000;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; 
    transition: all 0.4s var(--transition-smooth);
    animation: fadeIn 0.4s var(--transition-smooth);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: linear-gradient(165deg, #1a1928 0%, #141320 50%, #0f0e18 100%);
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 24px;
    padding: 30px; width: 90%; max-width: 420px; text-align: center;
    transform: scale(0.92) translateY(10px);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s;
    box-shadow: 0 30px 70px rgba(0,0,0,0.6), 0 0 0 1px rgba(255,255,255,0.04), 0 0 60px rgba(123, 44, 191, 0.08);
    max-height: 85vh; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    position: relative;
    z-index: 1;
}
.modal-overlay.active .modal-card {
    transform: scale(1) translateY(0);
}
.modal-overlay {
    cursor: pointer;
}
.modal-overlay .modal-card {
    cursor: default;
}

.modal-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 0; color: #fff; }

.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px;
}
.modal-header--book { align-items: flex-start; }
.modal-title--book { font-size: 1.5rem; }
.modal-subtitle { font-size: 0.85rem; opacity: 0.7; margin-top: 5px; }
.modal-section {
    text-align: left;
    margin-bottom: 20px;
}
.modal-section-title {
    font-weight: 700; font-size: 0.95rem; opacity: 0.9;
    margin-bottom: 10px; letter-spacing: 0.3px;
}
.modal-section:last-child { margin-bottom: 0; }

/* --- SHOP --- */
.modal-card--shop { max-width: 420px; }
.shop-balance-bar {
    background: linear-gradient(135deg, rgba(255,215,0,0.12) 0%, rgba(255,215,0,0.04) 100%);
    border: 1px solid rgba(255,215,0,0.3);
    border-radius: 14px; padding: 12px 16px; margin-bottom: 16px;
    font-weight: 700; color: var(--gold); font-size: 1rem;
    box-shadow: 0 0 20px rgba(255,215,0,0.06);
}
.shop-cta-subscribe { margin-bottom: 20px; }
.shop-subscribe-btn { margin: 0 !important; }
.shop-grid { margin-bottom: 0; }

/* --- PROFILE --- */
.modal-card--profile { max-width: 420px; text-align: left; }
.profile-hero {
    display: flex; align-items: center; gap: 16px;
    background: linear-gradient(135deg, rgba(255,255,255,0.06) 0%, rgba(255,255,255,0.02) 100%);
    padding: 18px; border-radius: 16px; margin-bottom: 16px;
    border: 1px solid var(--glass-border);
}
.profile-avatar { font-size: 2.8rem; line-height: 1; filter: drop-shadow(0 4px 12px rgba(0,0,0,0.3)); }
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-weight: 800; font-size: 1.25rem; margin-bottom: 4px; }
.profile-stats-row { font-size: 0.9rem; opacity: 0.85; margin-bottom: 6px; }
.profile-stats-num { color: var(--accent-light); font-weight: 800; }
.profile-hint-regen {
    font-size: 0.8rem; opacity: 0.75; margin-top: 4px;
    color: var(--text-dim);
}
.profile-hint-regen--full { color: var(--success); opacity: 1; }
.profile-active-bonuses {
    margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; min-height: 24px;
}
.profile-active-bonuses--active .profile-bonus-tag {
    display: inline-block;
    background: rgba(255, 193, 7, 0.15); color: var(--gold);
    padding: 4px 10px; border-radius: 10px; font-size: 0.75rem; font-weight: 700;
    border: 1px solid rgba(255,215,0,0.25);
}
.profile-quick-actions {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px;
}
.profile-quick-btn {
    padding: 12px; border-radius: 12px; font-size: 0.9rem; font-weight: 700;
    background: rgba(255,255,255,0.06); border: 1px solid var(--glass-border);
    color: #fff; cursor: pointer; transition: 0.2s;
}
.profile-quick-btn:hover {
    background: rgba(255,255,255,0.1); border-color: var(--accent);
}
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.theme-grid .big-btn { margin: 0; font-size: 0.9rem; }
.big-btn--danger {
    border-color: rgba(255, 75, 75, 0.4); color: #ff6b6b;
    margin-top: 8px;
}
.big-btn--danger:hover { background: rgba(255, 75, 75, 0.15); border-color: #ff6b6b; }

/* --- WALLET --- */
.wallet-status {
    display: flex; flex-direction: column; gap: 12px;
}

/* Connected State */
.wallet-connected {
    display: flex; flex-direction: column; gap: 16px;
}
.wallet-connected-header {
    display: flex; align-items: center; gap: 12px;
    padding: 16px; background: rgba(123, 44, 191, 0.1);
    border-radius: 12px; border: 1px solid rgba(123, 44, 191, 0.3);
}
.wallet-avatar {
    width: 48px; height: 48px; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-light), var(--accent-dark));
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.2rem; color: #000;
    flex-shrink: 0; border: 2px solid rgba(255,255,255,0.2);
}
.wallet-connected-info {
    flex: 1; min-width: 0;
}
.wallet-connected-address {
    font-family: 'Courier New', monospace; font-size: 0.95rem;
    font-weight: 700; color: var(--accent-light);
    word-break: break-all; margin-bottom: 4px;
}
.wallet-connected-details {
    display: flex; align-items: center; gap: 12px;
    font-size: 0.8rem; color: var(--text-dim);
}
.wallet-connected-network {
    padding: 2px 8px; background: rgba(123, 44, 191, 0.2);
    border-radius: 6px; font-weight: 600;
}
.wallet-connected-balance {
    font-weight: 600; color: var(--accent-light);
}
.wallet-connected-actions {
    display: flex; gap: 10px;
}
.wallet-action-btn {
    flex: 1; padding: 10px 16px; background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border); border-radius: 10px;
    color: var(--text-main); cursor: pointer; transition: all 0.2s;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    font-size: 0.9rem; font-weight: 600;
}
.wallet-action-btn:hover {
    background: rgba(255,255,255,0.1); border-color: var(--accent-light);
    transform: translateY(-1px);
}
.wallet-action-btn--danger {
    background: rgba(239, 68, 68, 0.1); border-color: rgba(239, 68, 68, 0.3);
    color: #ef4444;
}
.wallet-action-btn--danger:hover {
    background: rgba(239, 68, 68, 0.2); border-color: rgba(239, 68, 68, 0.5);
}

/* Not Connected State */
.wallet-not-connected {
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    padding: 24px; text-align: center;
}
.wallet-connect-prompt {
    display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.wallet-connect-icon {
    font-size: 3rem; opacity: 0.7;
}
.wallet-connect-text {
    font-size: 0.9rem; color: var(--text-dim);
}
.wallet-connect-main-btn {
    padding: 12px 24px; background: linear-gradient(135deg, var(--accent-light), var(--accent-dark));
    border: none; border-radius: 12px; color: #000;
    font-weight: 700; font-size: 1rem; cursor: pointer;
    transition: all 0.2s; box-shadow: 0 4px 12px rgba(123, 44, 191, 0.3);
}
.wallet-connect-main-btn:hover {
    transform: translateY(-2px); box-shadow: 0 6px 16px rgba(123, 44, 191, 0.4);
}
.wallet-connect-main-btn:active {
    transform: translateY(0);
}

/* Wallet Connect Modal (RainbowKit Style) */
.wallet-connect-modal {
    backdrop-filter: blur(8px);
    animation: fadeIn 0.2s ease-out;
}
.wallet-connect-card {
    max-width: 400px; width: 90%; max-height: 90vh;
    animation: slideUp 0.3s ease-out;
}
.wallet-connect-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--glass-border);
}
.wallet-connect-title {
    font-size: 1.25rem; font-weight: 700; color: var(--text-main);
}
.wallet-connect-close {
    width: 32px; height: 32px; border-radius: 8px;
    background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border);
    color: var(--text-dim); transition: all 0.2s;
}
.wallet-connect-close:hover {
    background: rgba(255,255,255,0.1); color: var(--text-main);
}
.wallet-connect-content {
    padding: 20px 24px; max-height: calc(90vh - 100px);
    overflow-y: auto;
}
.wallet-list {
    display: flex; flex-direction: column; gap: 8px;
}
.wallet-item {
    display: flex; align-items: center; gap: 12px;
    padding: 16px; background: rgba(255,255,255,0.03);
    border: 1px solid var(--glass-border); border-radius: 12px;
    cursor: pointer; transition: all 0.2s; text-align: left;
    width: 100%;
}
.wallet-item:hover {
    background: rgba(255,255,255,0.08); border-color: var(--accent-light);
    transform: translateX(4px);
}
.wallet-item:active {
    transform: translateX(2px);
}
.wallet-item-icon {
    font-size: 2rem; line-height: 1; flex-shrink: 0;
    width: 40px; height: 40px; display: flex; align-items: center; justify-content: center;
}
.wallet-item-info {
    flex: 1; min-width: 0;
}
.wallet-item-name {
    font-size: 1rem; font-weight: 700; color: var(--text-main);
    margin-bottom: 2px;
}
.wallet-item-desc {
    font-size: 0.8rem; color: var(--text-dim);
}
.wallet-item-arrow {
    font-size: 1.2rem; color: var(--text-dim); flex-shrink: 0;
    transition: transform 0.2s;
}
.wallet-item:hover .wallet-item-arrow {
    transform: translateX(4px); color: var(--accent-light);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Network Selector */
.network-list {
    display: flex; flex-direction: column; gap: 8px;
}
.network-btn {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; background: rgba(255,255,255,0.05);
    border: 2px solid var(--glass-border); border-radius: 12px;
    color: var(--text-main); cursor: pointer; transition: all 0.2s;
    text-align: left;
}
.network-btn:hover {
    background: rgba(255,255,255,0.1); border-color: var(--accent-light);
    transform: translateX(4px);
}
.network-btn--active {
    border-color: var(--accent-light);
    background: rgba(123, 44, 191, 0.15);
}
.network-info {
    display: flex; flex-direction: column; gap: 4px;
}
.network-name {
    font-size: 0.95rem; font-weight: 700;
}
.network-symbol {
    font-size: 0.8rem; opacity: 0.7; color: var(--text-dim);
}
.network-check {
    color: var(--accent-light); font-size: 1.2rem; font-weight: 700;
}

@media (max-width: 768px) {
    .wallet-connected-header {
        padding: 12px; gap: 10px;
    }
    .wallet-avatar {
        width: 40px; height: 40px; font-size: 1rem;
    }
    .wallet-connected-address {
        font-size: 0.85rem;
    }
    .wallet-connected-details {
        font-size: 0.75rem; flex-direction: column; align-items: flex-start; gap: 4px;
    }
    .wallet-connected-actions {
        flex-direction: column;
    }
    .wallet-connect-card {
        max-width: 95%; width: 95%;
    }
    .wallet-connect-header {
        padding: 16px 20px;
    }
    .wallet-connect-content {
        padding: 16px 20px;
    }
    .wallet-item {
        padding: 12px;
    }
    .wallet-item-icon {
        font-size: 1.5rem; width: 36px; height: 36px;
    }
    .wallet-item-name {
        font-size: 0.9rem;
    }
    .wallet-item-desc {
        font-size: 0.75rem;
    }
}

/* --- QUESTS --- */
.modal-card--quests { max-width: 420px; }
.quest-current-block {
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.15) 0%, rgba(123, 44, 191, 0.06) 100%);
    padding: 16px; border-radius: 14px; margin-bottom: 20px; text-align: left;
    border: 1px solid rgba(123, 44, 191, 0.35);
    box-shadow: 0 4px 20px rgba(123, 44, 191, 0.2),
                0 0 30px rgba(123, 44, 191, 0.1);
    position: relative;
    overflow: hidden;
    animation: slideUp 0.5s var(--transition-smooth);
}

.quest-current-block::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(123, 44, 191, 0.1), transparent);
    animation: shimmer 3s infinite;
}
.quest-current-label { font-size: 0.7rem; text-transform: uppercase; color: var(--accent-light); font-weight: 800; letter-spacing: 1px; margin-bottom: 6px; }
.quest-current-row { display: flex; justify-content: space-between; align-items: center; }
.quest-target-name { font-size: 1.1rem; font-weight: 800; }
.quest-reward { color: var(--gold); font-weight: 800; }
.achievements-list { max-height: 260px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* --- STATS --- */
.modal-card--stats { max-width: 420px; text-align: left; }
.stats-content { margin-bottom: 20px; }
.stats-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stats-actions .big-btn { margin: 0; }

/* --- BOOK --- */
.modal-card--book { max-width: 650px; text-align: left; }
.book-search-wrap { margin-bottom: 16px; }
.book-search { margin-bottom: 0 !important; }
.book-content { max-height: 450px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* --- SUBSCRIBE --- */
.modal-card--subscribe { max-width: 560px; text-align: left; }
.subscribe-desc { text-align: left; margin-bottom: 20px; opacity: 0.85; font-size: 0.95rem; }
.subscribe-list { display: flex; flex-direction: column; gap: 12px; max-height: 450px; overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* --- LEADERBOARD --- */
.modal-card--leaderboard { max-width: 500px; text-align: left; }
.leaderboard-tabs {
    display: flex; gap: 8px; margin-bottom: 20px; border-bottom: 1px solid var(--glass-border);
}
.leaderboard-tab {
    padding: 10px 16px; border: none; background: transparent; color: var(--text-dim);
    font-weight: 600; font-size: 0.9rem; cursor: pointer; border-bottom: 2px solid transparent;
    transition: 0.2s; margin-bottom: -1px;
}
.leaderboard-tab:hover { color: var(--text-main); }
.leaderboard-tab.active {
    color: var(--accent-light); border-bottom-color: var(--accent-light);
}
.leaderboard-content { min-height: 200px; }
.leaderboard-loading {
    text-align: center; padding: 40px; opacity: 0.6; display: none;
}
.leaderboard-list { display: flex; flex-direction: column; gap: 8px; }
.leaderboard-item {
    display: flex; align-items: center; gap: 12px; padding: 12px;
    background: rgba(255,255,255,0.04); border-radius: 12px;
    border: 1px solid transparent; 
    transition: all 0.3s var(--transition-smooth);
    position: relative;
    overflow: hidden;
    animation: slideUp 0.4s var(--transition-smooth) backwards;
}

.leaderboard-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-light);
    transform: scaleY(0);
    transition: transform 0.3s var(--transition-smooth);
}

.leaderboard-item:hover::before {
    transform: scaleY(1);
}

.leaderboard-item:hover {
    background: rgba(255,255,255,0.08); 
    border-color: var(--glass-border);
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.leaderboard-item--current {
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.2) 0%, rgba(123, 44, 191, 0.1) 100%);
    border-color: rgba(123, 44, 191, 0.4);
    box-shadow: 0 0 20px rgba(123, 44, 191, 0.2);
    animation: glow 2s ease-in-out infinite;
}

.leaderboard-item--current::before {
    transform: scaleY(1);
    width: 4px;
}
.leaderboard-rank {
    font-size: 1.2rem; font-weight: 800; width: 30px; text-align: center;
    color: var(--accent-light);
    text-shadow: 0 0 10px var(--accent-glow);
    animation: float 3s ease-in-out infinite;
}
.leaderboard-avatar { font-size: 2rem; width: 40px; text-align: center; }
.leaderboard-info { flex: 1; min-width: 0; }
.leaderboard-name {
    font-weight: 700; font-size: 1rem; margin-bottom: 4px;
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.leaderboard-you {
    font-size: 0.75rem; color: var(--accent-light); opacity: 0.8;
}
.leaderboard-meta {
    font-size: 0.85rem; opacity: 0.7; color: var(--text-dim);
}
.big-btn--leaderboard {
    margin-top: 10px; background: linear-gradient(135deg, rgba(255, 193, 7, 0.2) 0%, rgba(255, 193, 7, 0.1) 100%);
    border-color: rgba(255, 193, 7, 0.3); color: var(--gold);
}
.big-btn--leaderboard:hover {
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.3) 0%, rgba(255, 193, 7, 0.15) 100%);
    border-color: rgba(255, 193, 7, 0.5);
}
.big-btn--match3 {
    margin-top: 10px; background: linear-gradient(135deg, rgba(123, 44, 191, 0.2) 0%, rgba(123, 44, 191, 0.1) 100%);
    border-color: rgba(123, 44, 191, 0.3); color: var(--accent-light);
}
.big-btn--match3:hover {
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.3) 0%, rgba(123, 44, 191, 0.15) 100%);
    border-color: rgba(123, 44, 191, 0.5);
}

/* --- LEADERBOARD WIDGET --- */
.leaderboard-widget {
    position: fixed; top: 80px; right: 20px; width: 280px;
    background: linear-gradient(165deg, rgba(26, 25, 40, 0.95) 0%, rgba(20, 19, 32, 0.98) 100%);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 16px; padding: 16px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5), 0 0 0 1px rgba(255,255,255,0.05);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    z-index: 100; max-height: calc(100vh - 120px);
    display: flex; flex-direction: column;
}
.leaderboard-widget-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--glass-border);
}
.leaderboard-widget-title { font-weight: 800; font-size: 0.95rem; }
.leaderboard-widget-close {
    width: 24px; height: 24px; border-radius: 6px;
    background: rgba(255,255,255,0.05); border: none; color: var(--text-dim);
    cursor: pointer; font-size: 0.85rem; display: flex; align-items: center; justify-content: center;
    transition: 0.2s;
}
.leaderboard-widget-close:hover { background: rgba(255,255,255,0.1); color: #fff; }
.leaderboard-widget-tabs {
    display: flex; gap: 6px; margin-bottom: 12px;
}
.leaderboard-widget-tab {
    flex: 1; padding: 6px; border: none; background: rgba(255,255,255,0.05);
    border-radius: 8px; font-size: 0.75rem; font-weight: 700; color: var(--text-dim);
    cursor: pointer; transition: 0.2s;
}
.leaderboard-widget-tab:hover { background: rgba(255,255,255,0.08); }
.leaderboard-widget-tab.active {
    background: var(--accent); color: #fff;
}
.leaderboard-widget-content {
    flex: 1; min-height: 0; overflow-y: auto;
}
.leaderboard-widget-loading {
    text-align: center; padding: 20px; opacity: 0.6; font-size: 0.85rem;
}
.leaderboard-widget-list { display: flex; flex-direction: column; gap: 6px; }
.leaderboard-widget-item {
    display: flex; align-items: center; gap: 8px; padding: 8px;
    background: rgba(255,255,255,0.03); border-radius: 10px;
    font-size: 0.85rem; transition: 0.2s;
}
.leaderboard-widget-item:hover {
    background: rgba(255,255,255,0.06);
}
.leaderboard-widget-item--current {
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.15) 0%, rgba(123, 44, 191, 0.06) 100%);
    border: 1px solid rgba(123, 44, 191, 0.3);
}
.leaderboard-widget-rank { font-weight: 800; width: 24px; text-align: center; font-size: 0.9rem; }
.leaderboard-widget-name {
    flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    font-weight: 600;
}
.leaderboard-widget-value {
    font-weight: 800; color: var(--accent-light); font-size: 0.9rem;
}
.leaderboard-widget-more {
    margin-top: 12px; padding: 8px; border-radius: 10px;
    background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border);
    color: var(--text-main); font-size: 0.85rem; font-weight: 700; cursor: pointer;
    transition: 0.2s; width: 100%;
}
.leaderboard-widget-more:hover {
    background: rgba(255,255,255,0.1); border-color: var(--accent);
}

/* --- AVATAR SELECTOR --- */
.profile-avatar-wrapper {
    position: relative; display: inline-block;
}
.profile-avatar-edit {
    position: absolute; bottom: -4px; right: -4px;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--accent); border: 2px solid var(--bg-dark);
    color: #fff; font-size: 0.85rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: 0.2s; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.profile-avatar-edit:hover {
    transform: scale(1.1); background: var(--accent-light);
}
.avatar-selector {
    margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--glass-border);
}
.avatar-grid {
    display: grid; grid-template-columns: repeat(8, 1fr); gap: 8px;
    max-height: 200px; overflow-y: auto; padding: 8px;
}
.avatar-option {
    width: 100%; aspect-ratio: 1; border-radius: 10px;
    background: rgba(255,255,255,0.05); border: 2px solid transparent;
    font-size: 1.5rem; cursor: pointer; transition: 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.avatar-option:hover {
    background: rgba(255,255,255,0.1); border-color: var(--glass-border);
    transform: scale(1.1);
}
.avatar-option--selected {
    background: var(--accent); border-color: var(--accent-light);
    box-shadow: 0 0 15px var(--accent-glow);
}

/* --- SHOP IMPROVEMENTS --- */
.shop-grid--hints { grid-template-columns: repeat(3, 1fr); }
.shop-grid--materials { grid-template-columns: repeat(2, 1fr); }
.shop-item--material {
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.1) 0%, rgba(123, 44, 191, 0.05) 100%);
    border-color: rgba(123, 44, 191, 0.3);
}
.shop-item--material:hover {
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.2) 0%, rgba(123, 44, 191, 0.1) 100%);
    border-color: var(--accent-light);
}
.shop-item--popular { border-color: rgba(255, 193, 7, 0.4); position: relative; }
.shop-item--best { border-color: rgba(255, 215, 0, 0.5); position: relative; }
.shop-badge {
    position: absolute; top: -8px; right: 8px;
    background: var(--gold); color: #000; font-size: 0.65rem;
    font-weight: 800; padding: 2px 6px; border-radius: 8px;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.shop-item--popular .shop-badge { background: rgba(255, 193, 7, 0.9); }
.shop-item--best .shop-badge { background: var(--gold); }

/* --- MATCH-3 MINI GAME --- */
.modal-card--match3 { max-width: 500px; }
.match3-info-bar {
    display: flex; justify-content: space-around; gap: 15px;
    padding: 14px; background: linear-gradient(135deg, rgba(255,255,255,0.08) 0%, rgba(255,255,255,0.03) 100%);
    border-radius: 14px; margin-bottom: 18px;
    border: 1px solid var(--glass-border);
}
.match3-info-bar > div {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    flex: 1;
    position: relative;
}
.match3-label { 
    font-size: 0.75rem; opacity: 0.7; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.5px;
}
.match3-value {
    font-weight: 900; font-size: 1.3rem; color: var(--accent-light);
    text-shadow: 0 0 10px currentColor;
    transition: all 0.3s ease;
}
.match3-score .match3-value { color: var(--gold); }
.match3-timer .match3-value { color: var(--text-main); }
.match3-combo .match3-value { color: var(--success); }
.match3-hint-btn {
    padding: 10px 16px; background: linear-gradient(135deg, rgba(123, 44, 191, 0.3) 0%, rgba(123, 44, 191, 0.2) 100%);
    border: 2px solid var(--accent-light); border-radius: 12px;
    font-size: 1.5rem; cursor: pointer; transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(123, 44, 191, 0.3);
    flex-shrink: 0;
}
.match3-hint-btn:hover {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 6px 20px rgba(123, 44, 191, 0.5);
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.4) 0%, rgba(123, 44, 191, 0.3) 100%);
}
.match3-hint-btn:active {
    transform: translateY(0) scale(1);
}
.match3-hint-btn--disabled {
    opacity: 0.5; cursor: not-allowed !important;
    background: rgba(100, 100, 100, 0.2) !important;
    border-color: rgba(255,255,255,0.1) !important;
}
.match3-hint-btn--disabled:hover {
    transform: none !important;
    box-shadow: 0 4px 12px rgba(123, 44, 191, 0.3) !important;
}
.match3-value-updated {
    animation: scoreUpdate 0.3s ease-out;
}
@keyframes scoreUpdate {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); color: var(--gold); }
    100% { transform: scale(1); }
}
.match3-combo-active {
    animation: comboGlow 1s ease-in-out infinite;
    text-shadow: 0 0 10px currentColor;
}
@keyframes comboGlow {
    0%, 100% { text-shadow: 0 0 10px currentColor, 0 0 20px currentColor; }
    50% { text-shadow: 0 0 20px currentColor, 0 0 30px currentColor, 0 0 40px currentColor; }
}
.match3-bonus-clickable {
    cursor: pointer !important;
    position: relative;
}
.match3-bonus-clickable:hover {
    transform: scale(1.1) !important;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.6) !important;
    border-color: rgba(255, 215, 0, 0.8) !important;
}
.match3-bonus-clickable::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 12px;
    padding: 2px;
    background: linear-gradient(45deg, #ffd700, #ff6b6b, #4ecdc4, #ffd700);
    background-size: 300% 300%;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: bonusBorderRotate 2s linear infinite;
    opacity: 0;
    transition: opacity 0.3s;
}
.match3-bonus-clickable:hover::before {
    opacity: 1;
}
@keyframes bonusBorderRotate {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
.match3-bonus-clicked {
    animation: bonusClick 0.3s ease-out;
}
@keyframes bonusClick {
    0% { transform: scale(1); }
    50% { transform: scale(1.3) rotate(5deg); }
    100% { transform: scale(1); }
}
.match3-particle {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
}
.match3-explode {
    animation: explodeEffect 0.3s ease-out;
}
@keyframes explodeEffect {
    0% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: scale(1.3) rotate(180deg);
        opacity: 0.8;
    }
    100% {
        transform: scale(0) rotate(360deg);
        opacity: 0;
    }
}
.match3-cell {
    background: linear-gradient(145deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.06) 100%);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3), inset 0 1px 0 rgba(255,255,255,0.1);
}
.match3-cell:hover {
    background: linear-gradient(145deg, rgba(255,255,255,0.18) 0%, rgba(255,255,255,0.1) 100%);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.15), 0 0 15px rgba(123, 44, 191, 0.3);
}
.match3-bonus {
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 193, 7, 0.1) 100%);
    border-color: rgba(255, 215, 0, 0.5);
    box-shadow: 0 4px 15px rgba(255, 215, 0, 0.3), inset 0 1px 0 rgba(255,255,255,0.2);
}
.match3-bonus:hover {
    box-shadow: 0 6px 25px rgba(255, 215, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.3), 0 0 20px rgba(255, 215, 0, 0.6);
}
.match3-bonus-freeze {
    animation: freezePulse 2s ease-in-out infinite;
}
.match3-bonus-bomb {
    animation: bombPulse 1.5s ease-in-out infinite;
}
.match3-bonus-rainbow {
    animation: rainbowGlow 2s ease-in-out infinite;
    filter: drop-shadow(0 0 8px rgba(255, 0, 255, 0.6));
}

/* Дополнительные улучшения производительности */
.match3-cell, .match3-icon, .element {
    contain: layout style paint;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Улучшения для анимаций на мобильных */
@media (max-width: 768px) {
    .match3-icon {
        animation-duration: 5s; /* Медленнее на мобильных для экономии батареи */
    }
    
    /* Улучшения производительности на мобильных */
    .match3-cell {
        will-change: auto; /* Оптимизация для мобильных */
    }
    
    /* Отключаем некоторые эффекты на слабых устройствах */
    @media (prefers-reduced-motion: reduce) {
        .match3-icon {
            animation: none;
        }
        .match3-bonus-freeze,
        .match3-bonus-bomb,
        .match3-bonus-rainbow {
            animation: none;
        }
    }
}

/* Дополнительные улучшения для очень маленьких экранов */
@media (max-width: 360px) {
    .match3-icon {
        animation-duration: 6s; /* Еще медленнее на очень маленьких экранах */
    }
    
    /* Упрощаем анимации для экономии ресурсов */
    .match3-cell {
        transition-duration: 0.15s;
    }
}
@keyframes freezePulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 5px rgba(100, 181, 246, 0.6)); }
    50% { transform: scale(1.1); filter: drop-shadow(0 0 15px rgba(100, 181, 246, 1)); }
}
@keyframes bombPulse {
    0%, 100% { transform: scale(1); filter: drop-shadow(0 0 5px rgba(255, 87, 34, 0.6)); }
    50% { transform: scale(1.15); filter: drop-shadow(0 0 20px rgba(255, 87, 34, 1)); }
}
@keyframes rainbowGlow {
    0% { filter: drop-shadow(0 0 8px rgba(255, 0, 255, 0.6)) hue-rotate(0deg); }
    33% { filter: drop-shadow(0 0 12px rgba(0, 255, 255, 0.8)) hue-rotate(120deg); }
    66% { filter: drop-shadow(0 0 12px rgba(255, 255, 0, 0.8)) hue-rotate(240deg); }
    100% { filter: drop-shadow(0 0 8px rgba(255, 0, 255, 0.6)) hue-rotate(360deg); }
}
.match3-hint {
    position: relative;
    box-shadow: 0 0 20px rgba(123, 44, 191, 0.8), 0 0 40px rgba(123, 44, 191, 0.5) !important;
    border: 3px solid var(--accent-light) !important;
    z-index: 10;
}
.match3-hint-pulse {
    animation: hintPulse 1s ease-in-out infinite;
}
@keyframes hintPulse {
    0%, 100% {
        box-shadow: 0 0 20px rgba(123, 44, 191, 0.8), 0 0 40px rgba(123, 44, 191, 0.5);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 30px rgba(123, 44, 191, 1), 0 0 60px rgba(123, 44, 191, 0.8);
        transform: scale(1.05);
    }
}
.match3-value:has-text("⏸️") {
    animation: freezeGlow 1s ease-in-out infinite;
}
@keyframes freezeGlow {
    0%, 100% { text-shadow: 0 0 10px currentColor; }
    50% { text-shadow: 0 0 20px currentColor, 0 0 30px var(--accent-light); }
}
.match3-board {
    display: grid; gap: 6px; padding: 12px;
    background: rgba(0,0,0,0.3); border-radius: 12px;
    aspect-ratio: 1; max-width: 100%;
    margin: 0 auto;
    /* Размер доски будет динамически определяться через JavaScript */
    /* По умолчанию 6x6, но будет переопределено для мобильных */
    grid-template-columns: repeat(6, 1fr);
    grid-template-rows: repeat(6, 1fr);
    /* Улучшения производительности */
    contain: layout style paint;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}
.match3-cell {
    aspect-ratio: 1; background: linear-gradient(145deg, rgba(255,255,255,0.1) 0%, rgba(255,255,255,0.05) 100%);
    border-radius: 12px; border: 2px solid transparent;
    display: flex; align-items: center; justify-content: center;
    cursor: grab; transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative; overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    touch-action: manipulation;
    user-select: none;
    min-height: 55px;
    min-width: 55px;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.match3-cell:active {
    cursor: grabbing;
}
.match3-cell:not(.match3-dragging):not(.match3-swapping) {
    pointer-events: auto;
}
.match3-cell:hover {
    background: linear-gradient(145deg, rgba(255,255,255,0.15) 0%, rgba(255,255,255,0.08) 100%);
    border-color: var(--glass-border);
    transform: scale(1.08);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.match3-cell.selected {
    border-color: var(--accent-light);
    background: linear-gradient(145deg, rgba(123, 44, 191, 0.3) 0%, rgba(123, 44, 191, 0.15) 100%);
    box-shadow: 0 0 20px var(--accent-glow), 0 4px 12px rgba(0,0,0,0.3);
    transform: scale(1.1);
}
.match3-cell.match3-dragging {
    opacity: 0.6; transform: scale(1.15);
    z-index: 100; cursor: grabbing;
    box-shadow: 0 8px 24px rgba(123, 44, 191, 0.5);
}
.match3-cell.match3-swapping {
    animation: match3Swap 0.2s ease-in-out;
}
.match3-cell.match3-drag-over {
    border-color: rgba(255, 0, 0, 0.5);
    background: rgba(255, 0, 0, 0.1);
    transform: scale(0.95);
}
.match3-cell.match3-drag-valid {
    border-color: var(--success);
    background: rgba(76, 175, 80, 0.3);
    box-shadow: 0 0 20px rgba(76, 175, 80, 0.6);
    transform: scale(1.05);
    animation: validPulse 0.5s ease-in-out infinite;
}
@keyframes validPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(76, 175, 80, 0.6); }
    50% { box-shadow: 0 0 30px rgba(76, 175, 80, 0.9); }
}
.match3-icon {
    font-size: 2.5rem; filter: drop-shadow(0 3px 6px rgba(0,0,0,0.4));
    pointer-events: none;
    transition: transform 0.2s;
    position: relative; z-index: 1;
    animation: iconWiggle 4s ease-in-out infinite;
    will-change: transform;
    /* Улучшения производительности */
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
}
.match3-cell:hover .match3-icon {
    transform: scale(1.1);
    animation: iconWiggleHover 2s ease-in-out infinite;
}
@keyframes iconWiggle {
    0%, 100% { 
        transform: rotate(0deg) translateY(0) translateZ(0); 
    }
    20% { 
        transform: rotate(-1.5deg) translateY(-1px) translateZ(0); 
    }
    40% { 
        transform: rotate(0deg) translateY(0) translateZ(0); 
    }
    60% { 
        transform: rotate(1.5deg) translateY(-1px) translateZ(0); 
    }
    80% { 
        transform: rotate(0deg) translateY(0) translateZ(0); 
    }
}
@keyframes iconWiggleHover {
    0%, 100% { 
        transform: scale(1.1) rotate(0deg) translateY(0) translateZ(0); 
    }
    25% { 
        transform: scale(1.12) rotate(-2deg) translateY(-2px) translateZ(0); 
    }
    50% { 
        transform: scale(1.1) rotate(0deg) translateY(0) translateZ(0); 
    }
    75% { 
        transform: scale(1.12) rotate(2deg) translateY(-2px) translateZ(0); 
    }
}
.match3-bonus-indicator {
    position: absolute; top: 2px; right: 2px;
    font-size: 0.8rem; z-index: 2;
    animation: bonusPulse 1.5s ease-in-out infinite;
}
.match3-bonus {
    background: linear-gradient(145deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 193, 7, 0.1) 100%);
    border-color: rgba(255, 215, 0, 0.5);
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
}
.match3-bonus-freeze {
    animation: freezePulse 2s ease-in-out infinite;
}
.match3-bonus-bomb {
    animation: bombPulse 1s ease-in-out infinite;
}
.match3-bonus-rainbow {
    animation: rainbowPulse 1.5s ease-in-out infinite;
    filter: hue-rotate(0deg);
}
.match3-cell.match3-explode {
    animation: match3Explode 0.25s ease-out forwards;
    pointer-events: none;
}
@keyframes match3Explode {
    0% { 
        transform: scale(1); 
        opacity: 1; 
        filter: brightness(1) blur(0px);
    }
    30% { 
        transform: scale(1.5); 
        opacity: 0.8; 
        filter: brightness(2.5) blur(2px) drop-shadow(0 0 15px rgba(255, 255, 255, 1));
    }
    60% { 
        transform: scale(0.3); 
        opacity: 0.3; 
        filter: brightness(3) blur(4px) drop-shadow(0 0 20px rgba(255, 215, 0, 1));
    }
    100% { 
        transform: scale(0); 
        opacity: 0; 
        filter: brightness(0) blur(8px);
    }
}
@keyframes match3Swap {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}
@keyframes bonusPulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.8; }
}
@keyframes freezePulse {
    0%, 100% { filter: brightness(1) hue-rotate(0deg); }
    50% { filter: brightness(1.3) hue-rotate(180deg); }
}
@keyframes bombPulse {
    0%, 100% { transform: scale(1); filter: brightness(1); }
    50% { transform: scale(1.1); filter: brightness(1.5); }
}
@keyframes rainbowPulse {
    0% { filter: hue-rotate(0deg) brightness(1.2); }
    25% { filter: hue-rotate(90deg) brightness(1.2); }
    50% { filter: hue-rotate(180deg) brightness(1.2); }
    75% { filter: hue-rotate(270deg) brightness(1.2); }
    100% { filter: hue-rotate(360deg) brightness(1.2); }
}
.match3-game-over {
    position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(0,0,0,0.95) 0%, rgba(20,10,30,0.98) 100%);
    backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px);
    display: flex; align-items: center; justify-content: center;
    border-radius: 24px; z-index: 10;
    border: 1px solid rgba(255,255,255,0.1);
}
.match3-game-over-content {
    text-align: center; padding: 40px 30px;
    max-width: 90%;
}
.match3-game-over-title {
    font-size: 2.2rem; font-weight: 900; margin-bottom: 20px;
    background: linear-gradient(135deg, #fff 0%, var(--accent-light) 50%, #c77dff 100%);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    text-shadow: 0 0 30px var(--accent-glow);
}
.match3-game-over-score {
    font-size: 1.4rem; margin-bottom: 30px; opacity: 0.95;
    font-weight: 700;
}
.match3-game-over-score span {
    color: var(--gold); font-weight: 900; font-size: 1.8rem;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.5);
    display: inline-block; margin-left: 8px;
}
.match3-game-over-actions {
    display: flex; flex-direction: column; gap: 12px;
}
@keyframes pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.7; transform: scale(1.05); }
}

/* Match-3 improvements */
.match3-cell {
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}
.match3-cell:active {
    transform: scale(0.95);
}
.match3-info-bar {
    flex-wrap: wrap;
}
.match3-game-over {
    animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.big-btn {
    width: 100%; padding: 16px; margin-bottom: 12px; border-radius: 14px;
    font-size: 1rem; font-weight: 700; cursor: pointer; border: 1px solid var(--glass-border);
    background: linear-gradient(180deg, rgba(255,255,255,0.07) 0%, rgba(255,255,255,0.03) 100%);
    color: #fff; 
    transition: all 0.3s var(--transition-smooth);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.big-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.big-btn:hover::before {
    width: 300px;
    height: 300px;
}

.big-btn:hover {
    background: linear-gradient(180deg, rgba(255,255,255,0.12) 0%, rgba(255,255,255,0.08) 100%);
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.4), 0 0 20px rgba(123, 44, 191, 0.2);
}

.big-btn:active { 
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.big-btn.primary {
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    border-color: var(--accent-light);
    color: white;
    box-shadow: 0 4px 20px var(--accent-glow), 0 0 30px rgba(123, 44, 191, 0.3);
    position: relative;
    overflow: hidden;
}

.big-btn.primary::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(45deg, transparent, rgba(255,255,255,0.2), transparent);
    transform: rotate(45deg);
    animation: shimmer 3s infinite;
}

.big-btn.primary:hover {
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
    box-shadow: 0 8px 30px var(--accent-glow), 
                0 0 50px rgba(123, 44, 191, 0.4),
                0 0 70px rgba(123, 44, 191, 0.2);
    transform: translateY(-4px) scale(1.02);
    animation: glow 2s ease-in-out infinite;
}

.big-btn.primary:active {
    transform: translateY(-2px) scale(1);
}
.big-btn.telegram-btn {
    background: linear-gradient(135deg, #0088cc 0%, #0066aa 100%);
    color: #fff; border: none; 
    box-shadow: 0 6px 24px rgba(0, 136, 204, 0.4), 0 1px 0 rgba(255,255,255,0.1) inset;
}
.big-btn.telegram-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 32px rgba(0, 136, 204, 0.6), 0 1px 0 rgba(255,255,255,0.15) inset;
    background: linear-gradient(135deg, #0066aa 0%, #0088cc 100%);
}

.form-input {
    width: 100%; padding: 15px; border-radius: 12px; background: rgba(0,0,0,0.3);
    border: 1px solid var(--glass-border); color: white; margin-bottom: 12px; font-size: 1rem;
    transition: 0.2s;
}
.form-input:focus { border-color: var(--accent); background: rgba(0,0,0,0.4); }
.form-error { color: var(--danger); font-size: 0.85rem; margin-bottom: 15px; font-weight: 600; min-height: 1.2em; }

.theme-btn.active { background: var(--accent) !important; border-color: var(--accent-light) !important; box-shadow: 0 5px 20px var(--accent-glow) !important; }

.stat-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px; background: rgba(255,255,255,0.03); border-radius: 10px;
    margin-bottom: 8px; border: 1px solid transparent; transition: 0.2s;
}
.stat-item:hover { background: rgba(255,255,255,0.05); border-color: var(--glass-border); }
.stat-item--highlight {
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.15) 0%, rgba(123, 44, 191, 0.05) 100%);
    border-color: rgba(123, 44, 191, 0.3);
}
.stat-label { font-weight: 600; opacity: 0.8; }
.stat-value { font-weight: 800; color: var(--accent-light); }

/* --- SHOP GRID --- */
.shop-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.shop-item {
    background: rgba(255,255,255,0.05); border-radius: 16px; padding: 15px; border: 1px solid var(--glass-border);
    display: flex; flex-direction: column; align-items: center; gap: 5px; cursor: pointer; transition: 0.2s;
}
.shop-item:hover { background: rgba(255,255,255,0.1); border-color: var(--accent); }
.shop-item:active { transform: scale(0.96); }
.shop-icon { font-size: 2rem; margin-bottom: 5px; }
.shop-name { font-size: 0.9rem; font-weight: 700; }
.shop-price { color: var(--gold); font-size: 0.85rem; font-weight: 800; }

/* --- ACHIEVEMENT ROW --- */
.ach-row {
    display: flex; align-items: center; gap: 15px; background: rgba(255,255,255,0.03);
    padding: 12px; border-radius: 14px; margin-bottom: 10px; text-align: left;
    border: 1px solid transparent; transition: 0.3s;
}
.ach-row.completed { border-color: var(--success); background: rgba(76, 175, 80, 0.1); }
.ach-icon { font-size: 1.5rem; width: 40px; height: 40px; background: rgba(0,0,0,0.2); border-radius: 50%; display: flex; align-items: center; justify-content: center; filter: grayscale(1); opacity: 0.5; }
.ach-row.completed .ach-icon { filter: grayscale(0); opacity: 1; background: var(--success); color: #000; }
.ach-info h4 { margin: 0; font-size: 0.95rem; }
.ach-info p { margin: 0; font-size: 0.75rem; opacity: 0.6; }

/* --- NOTIFICATION --- */
#notification {
    position: fixed; top: 80px; left: 50%; transform: translateX(-50%) translateY(-20px) scale(0.9);
    background: linear-gradient(135deg, rgba(30, 28, 48, 0.95) 0%, rgba(20, 18, 35, 0.98) 100%);
    backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    padding: 14px 28px; border-radius: 50px;
    display: flex; align-items: center; gap: 12px;
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 15px 50px rgba(0,0,0,0.5), 
                0 0 0 1px rgba(255,255,255,0.05), 
                0 0 40px var(--accent-glow),
                0 0 60px rgba(123, 44, 191, 0.2);
    opacity: 0; pointer-events: none; 
    transition: all 0.4s var(--transition-bounce); 
    z-index: 3000;
    position: relative;
    overflow: hidden;
}

#notification::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    animation: shimmer 2s infinite;
}

#notification.active {
    opacity: 1;
    transform: translateX(-50%) translateY(0) scale(1);
    animation: slideUp 0.4s var(--transition-bounce), glow 2s ease-in-out infinite;
    pointer-events: auto;
}

@keyframes notifIn {
    0% { opacity: 0; transform: translateX(-50%) translateY(-15px) scale(0.92); }
    100% { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

.notif-icon { 
    font-size: 1.5rem; 
    filter: drop-shadow(0 0 10px var(--accent-glow)); 
    animation: float 3s ease-in-out infinite;
}

.notif-text { 
    font-weight: 700; 
    font-size: 0.95rem; 
    letter-spacing: 0.3px; 
}

/* --- HELPERS --- */
.hidden { display: none !important; }
.trash-zone { 
    position: absolute; bottom: 0; left: 0; width: 100%; height: 100%; 
    background: rgba(255, 75, 75, 0.15); display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 1.2rem; letter-spacing: 2px; color: #ffadad;
    opacity: 0; pointer-events: none; transition: 0.2s; z-index: 50; text-transform: uppercase;
}
#inventory-panel.drag-over .trash-zone { opacity: 1; }
#inventory-panel.drag-over .inventory-header, #inventory-panel.drag-over #inventory-grid { opacity: 0.2; }

/* --- SMOOTH SCROLL CONTAINERS (mobile) --- */
#book-content, #achievements-list, #subscribe-list, #inventory-grid, #workspace, .modal-card, .leaderboard-content, .craft-content {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
    overscroll-behavior-x: contain;
    transform: translateZ(0);
    /* Улучшения производительности */
    will-change: scroll-position;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Улучшения для плавного скролла */
    scroll-behavior: smooth;
    scrollbar-width: thin;
    scrollbar-color: rgba(123, 44, 191, 0.3) transparent;
}

/* Кастомный скроллбар для веб-китов */
#book-content::-webkit-scrollbar,
#achievements-list::-webkit-scrollbar,
#subscribe-list::-webkit-scrollbar,
#inventory-grid::-webkit-scrollbar,
#workspace::-webkit-scrollbar,
.modal-card::-webkit-scrollbar,
.leaderboard-content::-webkit-scrollbar,
.craft-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

#book-content::-webkit-scrollbar-track,
#achievements-list::-webkit-scrollbar-track,
#subscribe-list::-webkit-scrollbar-track,
#inventory-grid::-webkit-scrollbar-track,
#workspace::-webkit-scrollbar-track,
.modal-card::-webkit-scrollbar-track,
.leaderboard-content::-webkit-scrollbar-track,
.craft-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

#book-content::-webkit-scrollbar-thumb,
#achievements-list::-webkit-scrollbar-thumb,
#subscribe-list::-webkit-scrollbar-thumb,
#inventory-grid::-webkit-scrollbar-thumb,
#workspace::-webkit-scrollbar-thumb,
.modal-card::-webkit-scrollbar-thumb,
.leaderboard-content::-webkit-scrollbar-thumb,
.craft-content::-webkit-scrollbar-thumb {
    background: rgba(123, 44, 191, 0.5);
    border-radius: 3px;
}

#book-content::-webkit-scrollbar-thumb:hover,
#achievements-list::-webkit-scrollbar-thumb:hover,
#subscribe-list::-webkit-scrollbar-thumb:hover,
#inventory-grid::-webkit-scrollbar-thumb:hover,
#workspace::-webkit-scrollbar-thumb:hover,
.modal-card::-webkit-scrollbar-thumb:hover,
.leaderboard-content::-webkit-scrollbar-thumb:hover,
.craft-content::-webkit-scrollbar-thumb:hover {
    background: rgba(123, 44, 191, 0.7);
}

#book-content .recipe-item,
#achievements-list .ach-row,
#subscribe-list > div {
    content-visibility: auto;
}

/* --- BOOK OF ALCHEMY --- */
.book-tier-section {
    margin-bottom: 25px;
}

.book-tier-title {
    font-size: 0.9rem; font-weight: 800; text-transform: uppercase;
    color: var(--accent-light); margin-bottom: 12px; padding-bottom: 8px;
    border-bottom: 2px solid rgba(123, 44, 191, 0.3); letter-spacing: 1px;
}

.recipe-item {
    display: flex; align-items: center; gap: 15px; padding: 14px;
    background: rgba(255,255,255,0.04); border-radius: 14px; margin-bottom: 10px;
    border: 1px solid transparent; transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    text-align: left; cursor: pointer;
}

.recipe-item:hover { 
    background: rgba(255,255,255,0.08); 
    border-color: var(--glass-border); 
    transform: translateX(5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.recipe-item.unlocked {
    border-left: 3px solid var(--success);
    background: rgba(76, 175, 80, 0.1);
}

.recipe-item.available {
    border-left: 3px solid var(--accent);
    background: rgba(123, 44, 191, 0.1);
}

.recipe-item.hint-highlight {
    animation: hintPulse 1s ease-in-out;
    border-color: var(--gold) !important;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.5) !important;
}

@keyframes hintPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.02); }
}

.recipe-icon { 
    font-size: 2.2rem; width: 55px; height: 55px; 
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.2); border-radius: 12px;
    flex-shrink: 0;
}

.recipe-info { flex: 1; min-width: 0; }

.recipe-name { 
    font-weight: 700; font-size: 1.05rem; margin-bottom: 6px;
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}

.recipe-badge {
    font-size: 0.75rem; padding: 3px 8px; border-radius: 10px;
    font-weight: 800; display: inline-flex; align-items: center;
}

.unlocked-badge {
    background: var(--success); color: #000;
}

.available-badge {
    background: var(--accent); color: #fff;
}

.recipe-formula { 
    font-size: 0.9rem; opacity: 0.8; 
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}

.recipe-formula .el-small { font-size: 1rem; }

.recipe-status {
    font-size: 0.75rem; font-weight: 700; padding: 5px 12px;
    border-radius: 12px; text-transform: uppercase; letter-spacing: 0.5px;
    flex-shrink: 0;
}

.unlocked-status {
    background: rgba(76, 175, 80, 0.2); color: var(--success);
}

.available-status {
    background: rgba(123, 44, 191, 0.2); color: var(--accent-light);
}

/* --- MOBILE MENU --- */
.mobile-menu-overlay {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(0, 0, 0, 0.85); backdrop-filter: blur(10px);
    display: flex; align-items: flex-start; justify-content: flex-end;
    opacity: 0; visibility: hidden; transition: all 0.3s ease;
    padding-top: 60px;
}
.mobile-menu-overlay.active {
    opacity: 1; visibility: visible;
}
.mobile-menu-content {
    width: 280px; max-width: 85vw; height: 100%;
    background: linear-gradient(135deg, rgba(20, 20, 30, 0.98) 0%, rgba(15, 15, 25, 0.98) 100%);
    border-left: 1px solid var(--glass-border);
    box-shadow: -10px 0 50px rgba(0, 0, 0, 0.5);
    display: flex; flex-direction: column;
    transform: translateX(100%); transition: transform 0.3s ease;
}
.mobile-menu-overlay.active .mobile-menu-content {
    transform: translateX(0);
}
.mobile-menu-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 20px; border-bottom: 1px solid var(--glass-border);
}
.mobile-menu-title {
    font-size: 1.3rem; font-weight: 800; color: var(--text-main);
}
.mobile-menu-items {
    flex: 1; overflow-y: auto; padding: 10px 0;
}
.mobile-menu-item {
    width: 100%; display: flex; align-items: center; gap: 15px;
    padding: 16px 20px; background: transparent;
    border: none; color: var(--text-main);
    font-size: 1rem; font-weight: 600;
    cursor: pointer; transition: all 0.2s;
    text-align: left;
}
.mobile-menu-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--accent-light);
}
.mobile-menu-item:active {
    background: rgba(123, 44, 191, 0.1);
}
.mobile-menu-icon {
    font-size: 1.5rem; width: 30px; text-align: center;
}
.mobile-menu-text {
    flex: 1;
}
.mobile-menu-btn {
    display: none;
}
.header-btn-desktop {
    display: flex;
}

/* --- MOBILE ADAPTATION --- */
@media (max-width: 768px) {
    header {
        height: 56px; padding: 0 12px;
    }
    
    .logo { font-size: 0.95rem; }
    
    /* Match-3 улучшения для планшетов */
    .match3-info-bar {
        padding: 12px;
        gap: 10px;
    }
    .match3-board {
        /* Размер сетки будет установлен динамически через JavaScript */
        /* По умолчанию 6x6 для планшетов */
        gap: 5px;
        padding: 10px;
    }
    .match3-cell {
        min-height: 52px;
        min-width: 52px;
    }
    .match3-icon {
        font-size: 2.2rem;
    }
    
    /* Улучшения для модальных окон */
    .modal-card {
        padding: 18px;
        width: 96%;
        max-height: 92vh;
    }
    
    /* Улучшения для элементов */
    #inventory-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 12px;
        padding: 12px;
    }
    .element {
        width: 90px;
        height: 90px;
    }
    .el-icon {
        font-size: 34px;
    }
    .el-name {
        font-size: 10px;
    }
    
    /* Улучшения для кнопок */
    .big-btn {
        padding: 13px;
        font-size: 0.92rem;
    }
    
    /* Улучшения для магазина */
    .shop-grid {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    .shop-item {
        padding: 14px;
    }
    
    /* Улучшения для профиля */
    .profile-section {
        padding: 14px;
    }
    .profile-quick-actions {
        gap: 10px;
    }
    
    /* Улучшения для героя */
    .hero-container {
        padding: 14px;
    }
    .hero-character {
        min-height: 280px;
    }
    .hero-avatar {
        font-size: 4rem;
        width: 110px;
        height: 110px;
    }
    .hero-equipment {
        width: 220px;
        height: 220px;
    }
    .equipment-slot {
        width: 48px;
        height: 48px;
    }
    
    /* Улучшения для крафта */
    .craft-item {
        padding: 14px;
    }
    .craft-item-icon {
        width: 55px;
        height: 55px;
        font-size: 2rem;
    }
    
    /* Улучшения для лидерборда */
    .leaderboard-item {
        padding: 11px;
    }
    .leaderboard-rank {
        font-size: 1.1rem;
        width: 28px;
    }
    .leaderboard-avatar {
        font-size: 1.6rem;
        width: 38px;
    }
    
    .header-actions { gap: 8px; }
    
    .icon-btn {
        width: 36px; height: 36px; font-size: 1rem;
    }
    
    .currency-pill {
        font-size: 0.8rem; padding: 5px 10px;
    }
    
    #mini-quest-bar {
        font-size: 0.75rem; padding: 6px 10px;
    }
    
    /* Скрываем кнопки на мобильных, показываем меню */
    .header-btn-desktop {
        display: none !important;
    }
    .mobile-menu-btn {
        display: flex !important;
    }
    
    #inventory-panel {
        height: 45vh;
    }
    
    .inventory-header {
        padding: 10px 12px; gap: 10px;
    }
    
    #inventory-grid {
        padding: 12px; grid-template-columns: repeat(auto-fill, minmax(85px, 1fr)); gap: 14px;
    }
    
    #inventory-grid .element { contain-intrinsic-size: 85px 85px; }
    
    .element {
        width: 85px; height: 85px;
        padding: 8px 4px;
    }
    
    .el-icon { font-size: 36px; }
    .el-name { 
        font-size: 10px; 
        line-height: 1.2;
        padding: 0 2px;
        word-break: break-word;
        overflow-wrap: break-word;
        hyphens: auto;
        max-height: 2.4em;
        overflow: hidden;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    
    /* Улучшения для workspace на планшетах */
    #workspace {
        padding: 15px;
        margin: 0 15px 15px 15px;
        gap: 12px;
    }
    
    .modal-card {
        padding: 20px; width: 95%; max-height: 90vh; border-radius: 20px;
    }
    
    .modal-title { font-size: 1.5rem; margin-bottom: 15px; }
    
    .big-btn {
        padding: 14px; font-size: 0.95rem; margin-bottom: 10px;
    }
    
    .shop-grid {
        grid-template-columns: 1fr; gap: 8px;
    }
    
    .theme-btn {
        font-size: 0.85rem !important;
    }
    
    .stat-item {
        padding: 10px; font-size: 0.9rem;
    }
    
    .recipe-item {
        padding: 10px; gap: 10px;
    }
    
    .recipe-icon {
        width: 45px; height: 45px; font-size: 1.8rem;
    }
    
    .recipe-name { font-size: 0.95rem; }
    
    /* Улучшения для header на планшетах */
    header {
        padding: 0 12px;
    }
    .header-actions {
        gap: 8px;
    }
    .currency-pill {
        font-size: 0.8rem;
        padding: 5px 10px;
    }
    .recipe-formula { font-size: 0.8rem; }
}

@media (max-width: 480px) {
    header {
        height: 52px; padding: 0 10px;
    }
    
    .logo { font-size: 0.85rem; }
    
    /* Match-3 улучшения для маленьких экранов */
    .match3-info-bar {
        padding: 10px; gap: 8px;
        flex-wrap: wrap;
    }
    .match3-info-bar > div {
        min-width: calc(50% - 4px);
    }
    .match3-label {
        font-size: 0.65rem;
    }
    .match3-value {
        font-size: 1.1rem;
    }
    .match3-hint-btn {
        width: 100%;
        margin-top: 8px;
        order: 10;
    }
    .match3-board {
        gap: 4px;
        padding: 8px;
    }
    .match3-cell {
        min-height: 50px;
        min-width: 50px;
    }
    .match3-icon {
        font-size: 2rem;
    }
    
    /* Улучшения для модальных окон */
    .modal-card {
        padding: 16px;
        width: 98%;
        max-height: 95vh;
    }
    .modal-header {
        padding: 12px 16px;
    }
    .modal-title {
        font-size: 1.3rem;
    }
    
    /* Улучшения для элементов */
    .element {
        width: 80px;
        height: 80px;
        padding: 6px 3px;
    }
    .el-icon {
        font-size: 32px;
    }
    .el-name {
        font-size: 9px;
    }
    
    /* Улучшения для кнопок */
    .big-btn {
        padding: 12px;
        font-size: 0.9rem;
    }
    
    /* Улучшения для магазина */
    .shop-grid {
        gap: 6px;
    }
    .shop-item {
        padding: 12px;
    }
    .shop-icon {
        font-size: 1.8rem;
    }
    .shop-name {
        font-size: 0.85rem;
    }
    .shop-price {
        font-size: 0.8rem;
    }
    
    /* Улучшения для профиля */
    .profile-section {
        padding: 12px;
    }
    .profile-quick-actions {
        flex-direction: column;
        gap: 8px;
    }
    .profile-quick-btn {
        width: 100%;
        padding: 12px;
    }
    
    /* Улучшения для героя */
    .hero-container {
        padding: 12px;
    }
    .hero-character {
        min-height: 250px;
    }
    .hero-avatar {
        font-size: 3.5rem;
        width: 100px;
        height: 100px;
    }
    .hero-equipment {
        width: 200px;
        height: 200px;
    }
    .equipment-slot {
        width: 45px;
        height: 45px;
    }
    
    /* Улучшения для крафта */
    .craft-tabs {
        flex-wrap: wrap;
        gap: 6px;
    }
    .craft-tab {
        padding: 8px 12px;
        font-size: 0.85rem;
    }
    .craft-item {
        padding: 12px;
    }
    .craft-item-icon {
        width: 50px;
        height: 50px;
        font-size: 1.8rem;
    }
    
    /* Улучшения для лидерборда */
    .leaderboard-item {
        padding: 10px;
        gap: 8px;
    }
    .leaderboard-rank {
        font-size: 1rem;
        width: 25px;
    }
    .leaderboard-avatar {
        font-size: 1.5rem;
        width: 35px;
    }
    .leaderboard-name {
        font-size: 0.9rem;
    }
    .leaderboard-meta {
        font-size: 0.75rem;
    }
    
    .icon-btn {
        width: 32px; height: 32px; font-size: 0.9rem;
    }
    
    .currency-pill {
        font-size: 0.75rem; padding: 4px 8px;
    }
    
    .user-avatar {
        width: 32px; height: 32px; font-size: 1rem;
    }
    
    #inventory-panel {
        height: 50vh;
    }
    
    #inventory-grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr)); gap: 12px;
    }
    
    #inventory-grid .element { contain-intrinsic-size: 75px 75px; }
    
    .element {
        width: 75px; height: 75px;
        padding: 6px 3px;
    }
    
    .el-icon { font-size: 32px; }
    .el-name { font-size: 9px; }
    
    /* Мобильное меню для маленьких экранов */
    .mobile-menu-content {
        width: 260px; max-width: 90vw;
    }
    
    .hero-character { min-height: auto; }
    .hero-equipment-layout { flex-direction: column; gap: 15px; }
    .equipment-column { flex-direction: row; gap: 10px; }
    .hero-center { order: 1; }
    .equipment-column--left { order: 2; }
    .equipment-column--right { order: 3; }
    .hero-avatar { font-size: 4rem; width: 120px; height: 120px; }
    .equipment-slot { width: 70px; height: 70px; }
    .equipment-slot-label { font-size: 0.6rem; }
    
    .modal-card {
        padding: 15px; width: 98%; max-height: 95vh;
    }
    
    .modal-title { font-size: 1.3rem; }
    
    .big-btn {
        padding: 12px; font-size: 0.9rem;
    }
    
    .el-icon { font-size: 24px; }
    .el-name { font-size: 8px; }
    
    .modal-card {
        padding: 16px; border-radius: 16px;
        max-height: 96vh;
    }
    
    .modal-title { font-size: 1.3rem; }
    
    #mini-quest-bar {
        display: none; /* Hide on very small screens */
    }
    
    /* Улучшения для workspace на очень маленьких экранах */
    #workspace {
        padding: 8px;
        margin: 0 10px 10px 10px;
        gap: 10px;
    }
    
    /* Улучшения для header */
    header {
        padding: 0 8px;
    }
    .header-actions {
        gap: 6px;
    }
    .currency-pill {
        font-size: 0.7rem;
        padding: 4px 8px;
    }
    .icon-btn {
        width: 30px;
        height: 30px;
        font-size: 1rem;
    }
    
    /* Улучшения для инвентаря */
    #inventory-panel {
        height: 50vh;
    }
    .inventory-header {
        padding: 8px 10px;
    }
    #inventory-grid {
        padding: 8px;
        gap: 10px;
    }
    
    .leaderboard-widget {
        width: 240px; top: 70px; right: 10px;
        max-height: calc(100vh - 100px);
    }
    
    .leaderboard-widget-title { font-size: 0.85rem; }
    .leaderboard-widget-tab { font-size: 0.7rem; padding: 5px; }
    .leaderboard-widget-item { font-size: 0.8rem; padding: 6px; }
    .leaderboard-widget-rank { width: 20px; font-size: 0.85rem; }
    .leaderboard-widget-value { font-size: 0.85rem; }
}

/* --- HERO SYSTEM --- */
.modal-card--hero { max-width: 900px; }
.hero-container {
    display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
.hero-character {
    display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.hero-equipment-layout {
    display: flex; align-items: center; justify-content: center; gap: 20px;
    width: 100%; max-width: 500px; margin: 0 auto;
}
.equipment-column {
    display: flex; flex-direction: column; gap: 15px;
    align-items: center;
}
.equipment-column--left {
    order: 1;
}
.equipment-column--right {
    order: 3;
}
.hero-center {
    display: flex; flex-direction: column; align-items: center; gap: 15px;
    order: 2;
}
.hero-avatar {
    font-size: 6rem; width: 150px; height: 150px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.3) 0%, rgba(123, 44, 191, 0.1) 100%);
    border-radius: 50%; border: 3px solid var(--accent-light);
    box-shadow: 0 0 30px var(--accent-glow);
    flex-shrink: 0;
}
.equipment-slot {
    width: 80px; height: 80px;
    background: rgba(255,255,255,0.05); border: 2px dashed rgba(255,255,255,0.2);
    border-radius: 12px; display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.3s;
    position: relative;
}
.equipment-slot:hover {
    background: rgba(255,255,255,0.1); border-color: var(--accent-light);
    transform: scale(1.05);
}
.equipment-slot--selected {
    border-color: var(--accent-light); background: rgba(123, 44, 191, 0.2);
    box-shadow: 0 0 20px var(--accent-glow);
}
.equipment-slot-label {
    font-size: 0.65rem; font-weight: 700; opacity: 0.7;
    text-align: center; margin-top: 4px;
    color: var(--text-dim);
    transition: all 0.2s;
}
.equipment-slot:hover .equipment-slot-label {
    opacity: 1; color: var(--accent-light);
}
.equipment-slot--selected .equipment-slot-label {
    opacity: 1; color: var(--accent-light); font-weight: 800;
}
.equipment-slot-icon {
    font-size: 0.7rem; opacity: 0.5; font-weight: 800;
    display: none; /* Скрываем старые иконки с цифрами */
}
.equipment-item {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    align-items: center; justify-content: center; border-radius: 12px;
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 193, 7, 0.1) 100%);
    border: 2px solid rgba(255, 215, 0, 0.5);
}
.equipment-item-icon { font-size: 2rem; }
.equipment-item-level {
    font-size: 0.65rem; font-weight: 800; color: var(--gold);
    margin-top: 2px;
}
.hero-stats {
    display: grid; grid-template-columns: 1fr 1fr; gap: 12px; width: 100%;
    margin-top: 20px;
}
.hero-stat {
    display: flex; justify-content: space-between; align-items: center;
    padding: 10px; background: rgba(255,255,255,0.05);
    border-radius: 10px; border: 1px solid var(--glass-border);
}
.hero-stat-label { font-weight: 600; opacity: 0.8; }
.hero-stat-value {
    font-weight: 800; color: var(--accent-light); font-size: 1.1rem;
}
.hero-inventory {
    display: flex; flex-direction: column;
}
.hero-inventory-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 15px;
}
.icon-btn-small {
    width: 32px; height: 32px; padding: 0; font-size: 1rem;
    background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border);
}
.craft-btn-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-light) 100%);
    border: 2px solid var(--accent-light);
    border-radius: 12px;
    color: #fff;
    font-weight: 800;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(123, 44, 191, 0.3);
}
.craft-btn-header:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(123, 44, 191, 0.5);
    background: linear-gradient(135deg, var(--accent-light) 0%, var(--accent) 100%);
}
.craft-btn-header:active {
    transform: translateY(0);
}
.craft-btn-icon {
    font-size: 1.2rem;
    line-height: 1;
}
.craft-btn-text {
    font-weight: 800;
    letter-spacing: 0.5px;
}
.hero-materials {
    margin-bottom: 15px;
}
.hero-materials-empty {
    text-align: center; padding: 15px; opacity: 0.7;
    background: rgba(0,0,0,0.2); border-radius: 10px;
    font-size: 0.85rem;
}
.hero-materials-list {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 10px; background: rgba(0,0,0,0.2); border-radius: 10px;
}
.hero-material-item {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px; background: rgba(255,255,255,0.05);
    border: 1px solid var(--glass-border); border-radius: 8px;
    font-size: 0.9rem;
}
.hero-material-icon {
    font-size: 1.2rem;
}
.hero-material-count {
    font-weight: 700; color: var(--accent-light);
}
.hero-inventory-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 10px; max-height: 400px; overflow-y: auto;
    padding: 10px; background: rgba(0,0,0,0.2); border-radius: 12px;
}
.inventory-item {
    aspect-ratio: 1; background: rgba(255,255,255,0.05);
    border: 2px solid transparent; border-radius: 12px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    cursor: pointer; transition: all 0.2s; position: relative;
}
.inventory-item:hover {
    background: rgba(255,255,255,0.1); border-color: var(--glass-border);
    transform: scale(1.05);
}
.inventory-item--equipped {
    border-color: var(--success); background: rgba(76, 175, 80, 0.2);
}
.inventory-item--available {
    border-color: var(--accent-light); box-shadow: 0 0 15px var(--accent-glow);
}
.inventory-item-icon { font-size: 2rem; }
.inventory-item-level {
    font-size: 0.7rem; font-weight: 800; color: var(--gold);
    margin-top: 4px;
}
.inventory-item-badge {
    position: absolute; top: 4px; right: 4px;
    width: 20px; height: 20px; background: var(--success);
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 0.7rem; font-weight: 800; color: #000;
}
.empty-inventory {
    text-align: center; padding: 40px; opacity: 0.6;
    font-size: 0.9rem;
}

/* --- CRAFT SYSTEM --- */
.modal-card--craft { max-width: 700px; }
.craft-tabs {
    display: flex; gap: 10px; margin-bottom: 20px;
    border-bottom: 2px solid rgba(255,255,255,0.1);
}
.craft-tab {
    padding: 12px 20px; background: transparent; border: none;
    border-bottom: 3px solid transparent; color: var(--text-dim);
    font-weight: 700; cursor: pointer; transition: all 0.2s;
}
.craft-tab:hover { color: var(--text-main); }
.craft-tab.active {
    color: var(--accent-light); border-bottom-color: var(--accent-light);
}
.craft-info {
    background: linear-gradient(135deg, rgba(123, 44, 191, 0.15) 0%, rgba(123, 44, 191, 0.05) 100%);
    border: 1px solid var(--accent-light);
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 20px;
}
.craft-info-title {
    font-weight: 800;
    font-size: 1rem;
    color: var(--accent-light);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}
.craft-info-text {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.craft-info-item {
    font-size: 0.9rem;
    opacity: 0.9;
    line-height: 1.5;
}
.craft-info-item strong {
    color: var(--accent-light);
    font-weight: 700;
}
.craft-content {
    max-height: 500px; overflow-y: auto;
}
.craft-list {
    display: flex; flex-direction: column; gap: 12px;
}
.craft-item {
    display: flex; align-items: center; gap: 15px; padding: 15px;
    background: rgba(255,255,255,0.05); border-radius: 12px;
    border: 1px solid var(--glass-border); transition: all 0.2s;
}
.craft-item:hover:not(.craft-item--disabled) {
    background: rgba(255,255,255,0.08); border-color: var(--accent-light);
    transform: translateX(5px);
}
.craft-item--disabled {
    opacity: 0.5; cursor: not-allowed;
}
.craft-item-icon {
    font-size: 3rem; width: 70px; height: 70px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,0.2); border-radius: 12px;
    flex-shrink: 0;
}
.craft-item-info {
    flex: 1; min-width: 0;
}
.craft-item-name {
    font-weight: 800; font-size: 1.1rem; margin-bottom: 8px;
    display: flex; align-items: center; gap: 8px;
}
.craft-item-level {
    font-size: 0.75rem; color: var(--gold); font-weight: 800;
    padding: 2px 8px; background: rgba(255, 215, 0, 0.2);
    border-radius: 8px;
}
.craft-item-stats {
    font-size: 0.9rem; opacity: 0.8; margin-bottom: 8px;
    display: flex; gap: 12px; flex-wrap: wrap;
}
.craft-materials {
    display: flex; flex-wrap: wrap; gap: 8px;
}
.craft-material {
    font-size: 0.85rem; padding: 4px 10px;
    background: rgba(255,255,255,0.05); border-radius: 8px;
    border: 1px solid var(--glass-border);
}
.craft-material--missing {
    background: rgba(255, 0, 0, 0.2); border-color: rgba(255, 0, 0, 0.5);
    color: var(--danger);
}
.craft-btn {
    padding: 10px 20px; background: var(--accent);
    border: none; border-radius: 10px; color: #fff;
    font-weight: 800; cursor: pointer; transition: all 0.2s;
}
.craft-btn:hover {
    background: var(--accent-light); transform: scale(1.05);
}
.craft-btn--disabled {
    background: rgba(255,255,255,0.1); color: var(--text-dim);
    cursor: not-allowed;
}
.empty-craft {
    text-align: center; padding: 40px; opacity: 0.6;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .hero-container { grid-template-columns: 1fr; }
    .hero-character { min-height: 300px; }
    .hero-avatar { font-size: 4rem; width: 120px; height: 120px; }
    .hero-equipment { width: 240px; height: 240px; }
    .equipment-slot { width: 50px; height: 50px; }
    .equipment-slot--weapon { transform: translateY(-50%) translateX(10px) !important; }
    .equipment-slot--shield { transform: translateY(-50%) translateX(-10px) !important; }
    .hero-stats { grid-template-columns: 1fr; }
    .hero-inventory-grid { grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)); }
    .craft-item { flex-direction: column; text-align: center; }
    .craft-item-info { width: 100%; }
    .match3-board { 
        /* Размер сетки будет установлен динамически через JavaScript */
        /* По умолчанию 6x6 для планшетов */
        gap: 5px; 
        padding: 12px;
        max-width: 100%;
    }
    .match3-cell { 
        min-height: 60px; 
        min-width: 60px;
        touch-action: manipulation;
        aspect-ratio: 1;
    }
    .match3-icon { font-size: 2.5rem; }
    .match3-info-bar {
        flex-wrap: wrap; gap: 8px;
        padding: 10px;
    }
    .match3-label { font-size: 0.7rem; }
    .match3-value { font-size: 1rem; }
    .match3-hint-btn {
        padding: 8px 12px; font-size: 1.2rem;
    }
}

@media (max-width: 360px) {
    .leaderboard-widget {
        width: calc(100vw - 20px); right: 10px; left: 10px;
    }
    
    /* Match-3 для очень маленьких экранов */
    .match3-board {
        /* Размер сетки будет установлен динамически через JavaScript */
        /* По умолчанию 5x5 для очень маленьких экранов */
        gap: 4px;
        padding: 8px;
    }
    .match3-cell {
        min-height: 50px;
        min-width: 50px;
    }
    .match3-icon {
        font-size: 2rem;
    }
    .match3-info-bar {
        padding: 8px;
        gap: 6px;
    }
    .match3-info-bar > div {
        min-width: calc(50% - 3px);
    }
    .match3-label {
        font-size: 0.6rem;
    }
    .match3-value {
        font-size: 1rem;
    }
    
    /* Общие улучшения для очень маленьких экранов */
    .modal-card {
        padding: 12px;
        width: 99%;
    }
    .modal-title {
        font-size: 1.2rem;
    }
    .element {
        width: 75px;
        height: 75px;
    }
    .el-icon {
        font-size: 28px;
    }
    .el-name {
        font-size: 8px;
    }
    .big-btn {
        padding: 10px;
        font-size: 0.85rem;
    }
    
    .match3-board {
        /* Размер сетки будет установлен динамически через JavaScript */
        /* По умолчанию 5x5 для маленьких экранов */
        gap: 4px;
        padding: 8px;
        max-width: 100%;
    }
    
    .match3-cell {
        min-height: 50px;
        min-width: 50px;
        aspect-ratio: 1;
    }
    
    .match3-icon {
        font-size: 2rem;
    }
    
    .match3-info-bar { 
        flex-direction: column; 
        gap: 6px; 
        padding: 8px;
    }
    .match3-info-bar > div { 
        width: 100%; 
        text-align: center; 
    }
    .match3-hint-btn {
        width: 100%;
        margin-top: 4px;
    }
    .modal-card--match3 { max-width: 98vw; }
    
    .mobile-menu-content {
        width: 240px; max-width: 95vw;
    }
    
    .hero-character { min-height: 220px; }
    .hero-avatar { font-size: 3rem; width: 90px; height: 90px; }
    .hero-equipment { width: 180px; height: 180px; }
    .equipment-slot { width: 40px; height: 40px; }
    
    .modal-card {
        padding: 12px; width: 100%; max-height: 98vh;
    }
    
    .mobile-menu-item {
        padding: 14px 16px; font-size: 0.95rem;
    }
    
    .mobile-menu-icon {
        font-size: 1.3rem; width: 25px;
    }
}



/* === 1. ГЛОБАЛЬНЫЕ НАСТРОЙКИ (Фикс мобилок) === */
:root {
    --bg-color: #121212;
    --panel-color: #1e1e1e;
    --accent: #f39c12;
    --text: #ffffff;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent; /* Убирает мигание */
    user-select: none; /* Запрет выделения текста */
    touch-action: manipulation;
}

body {
    margin: 0;
    padding: 0;
    background: var(--bg-color);
    color: var(--text);
    font-family: system-ui, -apple-system, sans-serif;
    
    /* ЖЕСТКАЯ ФИКСАЦИЯ ЭКРАНА */
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* === 2. ЭКРАН АВТОРИЗАЦИИ (Красивый) === */
#auth-screen {
    position: fixed;
    z-index: 9999;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.9);
    backdrop-filter: blur(5px);
    display: none; /* Скрыто по умолчанию */
    align-items: center;
    justify-content: center;
}

#auth-screen.active { display: flex; }

.auth-card {
    background: var(--panel-color);
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid #333;
}

.auth-tabs { display: flex; gap: 10px; margin-bottom: 20px; }
.tab-btn {
    flex: 1; padding: 10px; border: none; background: #333; color: #aaa;
    border-radius: 8px; font-size: 16px;
}
.tab-btn.active { background: var(--accent); color: #000; font-weight: bold; }

input {
    width: 100%; padding: 12px; margin-bottom: 10px;
    background: #2a2a2a; border: 1px solid #444; color: white;
    border-radius: 8px; font-size: 16px; outline: none;
}

.main-btn {
    width: 100%; padding: 12px; background: var(--accent); border: none;
    border-radius: 8px; font-weight: bold; font-size: 16px; color: #000;
    margin-top: 10px;
}

.hidden { display: none; }
.divider { margin: 20px 0; color: #666; font-size: 14px; }
.error-msg { color: #ff4444; margin-top: 10px; font-size: 14px; }

/* === 3. ИГРОВОЙ ИНТЕРФЕЙС === */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

/* Шапка */
.top-bar {
    height: 50px;
    background: var(--panel-color);
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 15px;
}

/* Игровое поле (Занимает все место) */
.game-area {
    flex: 1;
    position: relative;
    background: radial-gradient(circle at center, #1a1a1a 0%, #0d0d0d 100%);
    overflow: hidden;
    touch-action: none;
}

/* Элемент на поле */
.element-on-field {
    position: absolute;
    transform: translate3d(0,0,0); /* GPU ускорение */
}

/* Инвентарь (Низ экрана) */
.sidebar {
    height: 40vh; /* 40% высоты экрана */
    background: var(--panel-color);
    border-top: 2px solid #333;
    display: flex;
    flex-direction: column;
    padding: 10px;
    z-index: 100;
    
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.sidebar-header { margin-bottom: 10px; }

/* Сетка элементов */
.elements-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(65px, 1fr));
    gap: 8px;
    padding-bottom: 40px;
}

.element {
    background: #2d2d2d;
    border: 1px solid #444;
    border-radius: 12px;
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    transform: translate3d(0,0,0);
}

/* Если нет картинки, рисуем кружок */
.element img {
    width: 35px; height: 35px; pointer-events: none;
    background: #444; border-radius: 50%; display: block;
}

.element span { font-size: 11px; margin-top: 4px; color: #ccc; }

/* Перетаскиваемый клон */
.dragging {
    position: absolute; z-index: 9999; pointer-events: none;
    width: 70px; height: 70px;
    background: #333; border: 2px solid var(--accent); border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    opacity: 0.9;
}
.dragging span { display: none; }
