/**
 * БЁРЧИ | Мини-игры Криттера - Стили
 * Версия 5.0 | ИНТЕГРАЦИЯ: Режим Строителя (Сетка + Снос)
 */

/* ==========================================
   1. ОВЕРЛЕЙ И БАЗА МОДАЛКИ
   ========================================== */
.critter-game-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(8, 12, 18, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.critter-game-overlay.active {
    display: flex;
    opacity: 1;
}

.critter-game-modal {
    background: linear-gradient(145deg, #1e1f20 0%, #131314 100%);
    border: 1px solid rgba(168, 199, 250, 0.2);
    border-radius: 24px;
    width: 95%;
    max-width: 420px;
    height: 88vh;
    max-height: 800px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.8), 0 0 30px rgba(168, 199, 250, 0.1);
    transform: scale(0.9) translateY(20px);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    user-select: none;
}

.critter-game-overlay.active .critter-game-modal {
    transform: scale(1) translateY(0);
}

/* Кнопка закрытия */
.cg-close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
    color: #708499;
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 100;
}

.cg-close-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* ==========================================
   2. НАВИГАЦИЯ (ВКЛАДКИ) И ИНВЕНТАРЬ
   ========================================== */
.cg-nav-bar {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    padding: 15px 15px 0 15px;
    gap: 10px;
}

.cg-nav-tab {
    flex: 1;
    text-align: center;
    padding: 12px 0;
    color: #708499;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 3px solid transparent;
}

.cg-nav-tab.active {
    color: #fff;
    border-bottom-color: #10b981;
}

.cg-inventory-bar {
    display: flex;
    justify-content: space-between;
    padding: 10px 20px;
    background: rgba(0,0,0,0.2);
    border-bottom: 1px solid rgba(255,255,255,0.02);
    font-size: 12px;
    font-weight: 700;
    color: #a8c7fa;
}

.cg-inv-item {
    display: flex;
    align-items: center;
    gap: 6px;
}

.cg-inv-item span {
    font-size: 16px;
}

/* Контейнеры вкладок */
.cg-tab-content {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow-y: auto;
}

.cg-tab-content.active {
    display: flex;
}

/* Кастомизация скроллбара */
.cg-tab-content::-webkit-scrollbar {
    width: 6px;
}

.cg-tab-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

/* ==========================================
   3. ЗОНА КЛИКЕРА И СЕТКА ПОСТРОЕК
   ========================================== */
.cg-clicker-zone {
    padding: 15px 20px 5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: radial-gradient(circle at top, rgba(168, 199, 250, 0.05) 0%, transparent 70%);
}

.cg-score-board {
    text-align: left;
}

.cg-score-title {
    font-size: 11px;
    color: #708499;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.cg-score-value {
    font-size: 28px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px rgba(168, 199, 250, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
}

.cg-score-cps {
    font-size: 12px;
    color: #a8c7fa;
    font-weight: 600;
    margin-top: 5px;
}

/* Анимация клика (Улитка) */
.cg-main-target {
    font-size: 60px;
    cursor: pointer;
    filter: drop-shadow(0 10px 20px rgba(0,0,0,0.5));
    transition: transform 0.1s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    -webkit-tap-highlight-color: transparent;
    animation: targetBreathe 3s ease-in-out infinite;
}

.cg-main-target:active {
    transform: scale(0.9) !important;
    filter: drop-shadow(0 5px 10px rgba(0,0,0,0.8));
    animation: none;
}

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

/* Вылетающие цифры */
.cg-floating-text {
    position: absolute;
    color: #10b981;
    font-weight: 900;
    font-size: 20px;
    pointer-events: none;
    transform: translate(-50%, -50%);
    animation: floatUp 0.8s cubic-bezier(0.25, 1, 0.5, 1) forwards;
    z-index: 10;
    text-shadow: 0 2px 5px rgba(0,0,0,0.8);
}

@keyframes floatUp {
    0% { transform: translate(-50%, -50%) scale(0.5); opacity: 1; }
    20% { transform: translate(-50%, -80px) scale(1.2); opacity: 1; }
    100% { transform: translate(-50%, -150px) scale(1); opacity: 0; }
}

/* --- СЕТКА 4x4 (РЕЖИМ СТРОИТЕЛЯ) --- */
.cg-land-area {
    padding: 10px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    background: rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cg-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    width: 100%;
    max-width: 300px;
    aspect-ratio: 1/1;
    background: rgba(255,255,255,0.02);
    padding: 8px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.05);
    transition: all 0.3s ease;
}

.cg-cell {
    background: rgba(0,0,0,0.4);
    border-radius: 10px;
    border: 1px dashed rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.cg-cell:hover {
    background: rgba(255,255,255,0.05);
}

.cg-cell.filled {
    border-style: solid;
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.05);
}

/* Подсветка режимов (Строительство и Снос) */
.cg-land-area.build-mode .cg-grid {
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
    border-color: rgba(16, 185, 129, 0.5);
}

.cg-land-area.build-mode .cg-cell:not(.filled) {
    animation: pulseCell 1s infinite alternate;
}

.cg-land-area.sell-mode .cg-grid {
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.5);
}

.cg-land-area.sell-mode .cg-cell.filled {
    border-color: #ef4444;
    cursor: crosshair;
}

.cg-land-area.sell-mode .cg-cell.filled:hover {
    background: rgba(239, 68, 68, 0.2);
}

@keyframes pulseCell {
    0% { background: rgba(0,0,0,0.4); }
    100% { background: rgba(16, 185, 129, 0.2); }
}

.cg-build-controls {
    display: flex;
    justify-content: space-between;
    width: 100%;
    max-width: 300px;
    margin-top: 10px;
}

.cg-cancel-btn {
    background: #374151;
    color: #fff;
    border: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    display: none;
    text-transform: uppercase;
}

.cg-sell-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
}

/* ==========================================
   4. МАГАЗИН (ВКЛАДКА ФЕРМА)
   ========================================== */
.cg-shop-container {
    padding: 10px 20px 20px;
}

.cg-section-title {
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    margin: 15px 0 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cg-upgrade-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 16px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.cg-upgrade-item:not(.disabled):hover {
    background: rgba(168, 199, 250, 0.08);
    border-color: rgba(168, 199, 250, 0.3);
    transform: translateY(-2px);
}

.cg-upgrade-item.disabled {
    opacity: 0.5;
    filter: grayscale(100%);
}

.cg-upg-icon {
    font-size: 28px;
    width: 45px;
    height: 45px;
    background: rgba(0,0,0,0.3);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.cg-upg-info {
    flex: 1;
}

.cg-upg-title {
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    margin: 0 0 4px 0;
}

.cg-upg-desc {
    font-size: 11px;
    color: #a8c7fa;
    margin: 0;
}

.cg-upg-buy {
    background: #10b981;
    color: #131314;
    border: none;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.2s ease;
    min-width: 80px;
}

.cg-upgrade-item:not(.disabled) .cg-upg-buy:hover {
    background: #34d399;
    transform: scale(1.05);
}

.cg-upgrade-item.disabled .cg-upg-buy {
    background: #374151;
    color: #9ca3af;
    cursor: not-allowed;
}

.cg-upg-cost {
    display: flex;
    align-items: center;
    gap: 4px;
}

.cg-upg-owned {
    font-size: 10px;
    opacity: 0.8;
    margin-top: 2px;
}

/* Предметы MMO (Щиты, отмычки) */
.cg-mmo-item .cg-upg-buy {
    background: #3b82f6;
}

.cg-mmo-item:not(.disabled) .cg-upg-buy:hover {
    background: #60a5fa;
}

/* ==========================================
   5. ТАБЛИЦА ЛИДЕРОВ И РЕЙДЫ (ВКЛАДКА ТОП)
   ========================================== */
.cg-players-list {
    padding: 15px 20px;
}

.cg-player-card {
    background: rgba(0,0,0,0.3);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 16px;
    padding: 12px;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    overflow: hidden;
}

.cg-player-card.is-me {
    border-color: rgba(16, 185, 129, 0.4);
    background: rgba(16, 185, 129, 0.05);
}

.cg-rank {
    font-size: 16px;
    font-weight: 900;
    color: #708499;
    width: 25px;
    text-align: center;
}

.cg-rank.top-1 { color: #f59e0b; text-shadow: 0 0 10px rgba(245, 158, 11, 0.5); }
.cg-rank.top-2 { color: #d1d5db; }
.cg-rank.top-3 { color: #b45309; }

.cg-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid rgba(255,255,255,0.1);
}

.cg-player-info {
    flex: 1;
}

.cg-player-name {
    font-size: 14px;
    font-weight: 800;
    color: #fff;
    margin: 0 0 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cg-shield-badge {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    padding: 2px 6px;
    border-radius: 8px;
    font-size: 10px;
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.cg-player-stats {
    font-size: 12px;
    color: #10b981;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
}

.cg-player-stats span {
    color: #708499;
    font-weight: 500;
    font-size: 10px;
    margin-left: 5px;
}

.cg-raid-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
}

.cg-raid-btn:hover {
    background: #ef4444;
    color: #fff;
    transform: scale(1.05);
}

.cg-raid-btn:active {
    transform: scale(0.95);
}

.cg-raid-btn:disabled {
    background: transparent;
    border-color: rgba(255,255,255,0.1);
    color: #708499;
    cursor: not-allowed;
    transform: none;
}

/* ==========================================
   6. АНИМАЦИИ И УВЕДОМЛЕНИЯ
   ========================================== */
.cg-toast {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(50px);
    background: #10b981;
    color: #131314;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 800;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
    z-index: 200;
    text-align: center;
    box-shadow: 0 10px 20px rgba(0,0,0,0.5);
}

.cg-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.cg-toast.error {
    background: #ef4444;
    color: #fff;
}

/* Анимация Взлома (Рейда) */
.cg-raid-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.85);
    z-index: 150;
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.cg-raid-overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease forwards;
}

.cg-raid-spinner {
    font-size: 60px;
    margin-bottom: 20px;
    animation: spinHacker 1s linear infinite;
}

.cg-raid-text {
    color: #ef4444;
    font-size: 18px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 2px;
    animation: pulseText 0.5s infinite alternate;
}

@keyframes spinHacker {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
}

@keyframes pulseText {
    0% { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.05); opacity: 0.8; }
}