/* === PWA SAFE AREAS (ГЛОБАЛЬНЫЕ ПЕРЕМЕННЫЕ) === */
:root {
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-left: env(safe-area-inset-left, 0px);
    --safe-right: env(safe-area-inset-right, 0px);
}

/* === ОБЩИЕ АНИМАЦИИ === */
@keyframes popIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* === МОДАЛКИ И ЛАЙТБОКС === */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Адаптация под мобильные экраны (чтобы не заезжало за челку) */
    padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
    box-sizing: border-box;
}

.lightbox img {
    max-width: 90%;
    max-height: 90%;
    border-radius: 12px;
    cursor: zoom-out;
}

/* === АВТОРИЗАЦИЯ === */
.auth-container {
    background: var(--yz-surface);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    padding: 32px;
    /* Увеличиваем нижний отступ на мобильных устройствах */
    padding-bottom: calc(32px + var(--safe-bottom));
    width: 100%;
    max-width: 360px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

.auth-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.auth-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.close-auth {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    padding: 0;
}

.close-auth:hover {
    color: var(--text-primary);
}

.auth-input {
    background: var(--yz-surface-2);
    border: 1px solid var(--border-light);
    padding: 14px 16px;
    border-radius: 12px;
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: 0.2s;
    width: 100%;
    box-sizing: border-box;
}

.auth-input:focus {
    border-color: var(--yz-accent-line);
    background: var(--yz-surface-2);
}

select.auth-input option {
    background: var(--surface);
    color: var(--text-primary);
}

.auth-btn, .profile-btn {
    background: var(--text-primary);
    color: var(--yz-bg);
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 15px;
    cursor: pointer;
    transition: 0.2s;
    margin-top: 8px;
    width: 100%;
}

.auth-btn:hover, .profile-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255,255,255,0.2);
}

.auth-error {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    text-align: center;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* === СОЦИАЛЬНЫЕ КНОПКИ === */
.social-login-block {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.social-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: 0.2s;
    border: none;
    color: #fff;
    width: 100%;
}

.social-btn:hover {
    transform: translateY(-2px);
}

.google-btn {
    background: #ea4335;
}

.google-btn:hover {
    background: #d33828;
    box-shadow: 0 4px 12px rgba(234, 67, 53, 0.3);
}

.vk-btn {
    background: #0077FF;
}

.vk-btn:hover {
    background: #0066d9;
    box-shadow: 0 4px 12px rgba(0, 119, 255, 0.3);
}

.input-hint {
    font-size: 12px;
    color: #10b981;
    margin: 0 0 10px 0;
    line-height: 1.4;
    text-align: center;
    background: rgba(16, 185, 129, 0.1);
    padding: 8px;
    border-radius: 8px;
}

.input-hint strong {
    color: var(--yz-text);
}

/* === УПРАВЛЕНИЕ ДРУЗЬЯМИ (МОДАЛКА) === */
.friends-container {
    background: var(--yz-surface);
    border: 1px solid var(--border-light);
    border-radius: 24px;
    padding: 24px;
    /* Увеличиваем нижний отступ на мобильных устройствах */
    padding-bottom: calc(24px + var(--safe-bottom));
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.6);
    max-height: 80vh;
    animation: popIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    box-sizing: border-box;
}

.friends-list-scroll {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 5px;
}

.friend-item {
    background: var(--yz-surface-2);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: opacity 0.2s;
}

.remove-friend-btn {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 14px;
    font-weight: bold;
    transition: 0.2s;
}

.remove-friend-btn:hover {
    background: rgba(239, 68, 68, 0.3);
    transform: scale(1.05);
}

.request-item {
    background: var(--yz-surface-2);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.req-user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.req-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.req-name {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.req-uname {
    font-size: 12px;
    color: var(--text-secondary);
}

.req-actions {
    display: flex;
    gap: 8px;
}

.req-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.req-btn.accept {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.req-btn.accept:hover {
    background: rgba(16, 185, 129, 0.4);
}

.req-btn.reject {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.req-btn.reject:hover {
    background: rgba(239, 68, 68, 0.4);
}

/* === ПРОЧЕЕ (PREMIUM И Т.Д.) === */
.premium-lock {
    color: #d4af37;
    font-size: 11px;
    margin-left: 6px;
    font-weight: 700;
    text-transform: uppercase;
    background: rgba(212, 175, 55, 0.1);
    padding: 2px 6px;
    border-radius: 6px;
}

.premium-buy-btn {
    width: auto;
    margin-top: 0;
    background: linear-gradient(90deg, #d4af37, #f3e5ab);
    color: #000;
    font-weight: 700;
    border: none;
    transition: 0.2s;
    box-shadow: 0 0 10px rgba(212, 175, 55, 0.2);
}

.premium-buy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.4);
}

.clickable-box {
    cursor: pointer;
    transition: 0.2s;
}

.clickable-box:hover {
    background: var(--yz-border);
    border-color: var(--yz-border-strong);
    transform: translateY(-2px);
}

/* === БЕЙДЖИ ПОДПИСКИ 2026 (BRC-BADGE, премиум-редизайн) === */
/* Градиенты тарифов задаются через data-tier (plus/premium/ultra), кастом — через --badge-color */
.brc-badge {
    --b-grad: linear-gradient(135deg, var(--badge-color, #e8b54a), color-mix(in srgb, var(--badge-color, #e8b54a) 62%, #000));
    --b-glow: color-mix(in srgb, var(--badge-color, #e8b54a) 45%, transparent);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--b-grad);
    border: none;
    box-shadow: 0 2px 10px var(--b-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
    cursor: pointer;
    transition: transform 0.28s var(--yz-spring, cubic-bezier(0.34, 1.45, 0.5, 1)), box-shadow 0.28s;
    vertical-align: middle;
    flex-shrink: 0;
    z-index: 1;
    overflow: visible;
}
.brc-badge[data-tier="plus"] { --b-grad: var(--yz-badge-plus); --b-glow: var(--yz-badge-plus-glow); }
.brc-badge[data-tier="premium"] { --b-grad: var(--yz-badge-premium); --b-glow: var(--yz-badge-premium-glow); }
.brc-badge[data-tier="ultra"] {
    --b-grad: var(--yz-badge-ultra);
    --b-glow: var(--yz-badge-ultra-glow);
    background-size: 170% 170%;
    animation: yzUltraFlow 6s ease infinite;
}

/* Блик, пробегающий по бейджу */
.brc-badge .brc-badge-ring {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    overflow: hidden;
    display: grid;
    place-items: center;
    isolation: isolate;
}
.brc-badge .brc-badge-ring::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(115deg, transparent 32%, rgba(255, 255, 255, 0.55) 48%, transparent 62%);
    transform: translateX(-110%);
    animation: yzBadgeShine 4.2s cubic-bezier(0.22, 1, 0.36, 1) infinite;
}

/* Иконка внутри */
.brc-badge i {
    font-size: inherit;
    color: #fff;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.35));
    pointer-events: none;
    position: relative;
    z-index: 1;
}

/* Ховер и активное состояние */
.brc-badge:hover,
.brc-badge.active {
    transform: scale(1.14) rotate(-4deg);
    box-shadow: 0 4px 18px var(--b-glow), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

/* Размеры */
.brc-badge-profile { width: 27px; height: 27px; }
.brc-badge-profile i { font-size: 13px; }
.brc-badge-feed { width: 21px; height: 21px; }
.brc-badge-feed i { font-size: 10px; }
.brc-badge-mini { width: 17px; height: 17px; }
.brc-badge-mini i { font-size: 9px; }

/* Тултип над бейджем */
.brc-badge-tooltip {
    position: absolute;
    bottom: calc(100% + 9px);
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: var(--yz-glass-strong, rgba(15, 15, 20, 0.94));
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    border: 1px solid var(--yz-border-strong, rgba(255, 255, 255, 0.15));
    color: var(--yz-text, #fff);
    padding: 6px 12px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.06em;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.28s var(--yz-spring, cubic-bezier(0.34, 1.45, 0.5, 1));
    box-shadow: var(--yz-shadow-md, 0 5px 15px rgba(0, 0, 0, 0.5));
    pointer-events: none;
    text-transform: uppercase;
    z-index: 1000;
}
.brc-badge:not(.active):hover .brc-badge-tooltip,
.brc-badge.active .brc-badge-tooltip {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* Скрыть тултип, если открыто меню выбора иконки (владелец) */
#brc-badge-container.active .brc-badge-tooltip {
    opacity: 0;
    visibility: hidden;
}

@keyframes yzBadgeShine {
    0%, 62% { transform: translateX(-110%); }
    78%, 100% { transform: translateX(110%); }
}
@keyframes yzUltraFlow {
    0%, 100% { background-position: 0% 30%; }
    50% { background-position: 100% 70%; }
}

/* Меню выбора иконок */
.brc-badge-popover {
    position: absolute;
    top: calc(100% + 15px);
    left: 50%;
    transform: translateX(-50%) translateY(-10px) scale(0.95);
    background: var(--yz-surface);
    border: 1px solid var(--yz-border);
    border-radius: 16px;
    padding: 12px;
    width: max-content;
    box-shadow: 0 15px 40px rgba(0,0,0,0.8);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 9999;
    cursor: default;
    transform-origin: top center;
}

.brc-badge-popover.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0) scale(1);
}

.brc-badge-popover .popover-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--badge-color, #d4af37);
    text-align: center;
    margin-bottom: 10px;
    padding: 0 5px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

.brc-badge-popover .popover-arrow {
    position: absolute;
    top: -6px;
    left: 50%;
    transform: translateX(-50%) rotate(45deg);
    width: 12px;
    height: 12px;
    background: var(--yz-surface);
    border-left: 1px solid var(--yz-border);
    border-top: 1px solid var(--yz-border);
    z-index: 1;
}

.brc-badge-popover .icon-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    position: relative;
    z-index: 2;
}

.brc-badge-popover .icon-grid i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    font-size: 16px;
    color: var(--yz-dim);
    background: var(--yz-surface-2);
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.brc-badge-popover .icon-grid i:hover {
    color: var(--badge-color, #d4af37);
    background: var(--yz-border-strong);
    border-color: var(--badge-color, #d4af37);
    transform: scale(1.1);
    box-shadow: 0 0 15px rgba(0,0,0,0.5), inset 0 0 8px rgba(255,255,255,0.05);
    filter: drop-shadow(0 0 4px var(--badge-color, #d4af37));
}

/* Адаптация меню под телефоны */
@media (max-width: 480px) {
    .brc-badge-popover {
        left: auto;
        right: -40px;
        transform: translateY(-10px) scale(0.95);
        transform-origin: top right;
        padding: 10px;
    }
    
    .brc-badge-popover.active {
        transform: translateY(0) scale(1);
    }
    
    .brc-badge-popover .popover-arrow {
        left: auto;
        right: 47px;
        transform: rotate(45deg);
    }
    
    .brc-badge-popover .icon-grid {
        gap: 6px;
    }
    
    .brc-badge-popover .icon-grid i {
        width: 34px;
        height: 34px;
        font-size: 15px;
    }
}

/* === ГЛОБАЛЬНЫЕ ЭЛЕМЕНТЫ ПРОФИЛЯ (INPUT, SELECT, DATE) === */

/* Кастомный инпут для модалок */
.custom-input {
    width: 100%;
    background: var(--yz-surface-2);
    border: 2px solid var(--yz-border);
    padding: 14px 16px;
    border-radius: 16px;
    color: var(--yz-text);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    box-sizing: border-box;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
}

.custom-input:focus {
    border-color: var(--yz-accent);
    background: var(--yz-surface-2);
    box-shadow: 0 0 0 4px var(--yz-accent-soft);
}

.custom-input::placeholder {
    color: var(--yz-muted);
}

/* Стилизация select (выпадающий список) */
select.custom-input {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%239a9384' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
    padding-right: 45px;
}

select.custom-input option {
    background: var(--yz-surface);
    color: var(--yz-text);
    padding: 10px;
}

/* Красивый календарь (input type="date") */
input[type="date"].custom-input {
    position: relative;
    cursor: text;
}

input[type="date"].custom-input::-webkit-calendar-picker-indicator {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    background-color: transparent;
    color: transparent;
    cursor: pointer;
    filter: invert(0.8) sepia(1) hue-rotate(180deg) saturate(0%);
    opacity: 0.6;
    transition: all 0.2s ease;
    padding: 5px;
    border-radius: 8px;
}

input[type="date"].custom-input::-webkit-calendar-picker-indicator:hover {
    opacity: 1;
    background-color: var(--yz-border-strong);
}

input[type="date"].custom-input:focus::-webkit-calendar-picker-indicator {
    opacity: 1;
    filter: invert(0.5) sepia(1) saturate(5) hue-rotate(175deg);
}

/* === ИНВЕНТАРЬ И ВИТРИНА === */

/* Подсветка активного слота в модалке */
.edit-slot {
    cursor: pointer;
    transition: 0.3s;
}
.edit-slot.active {
    border-color: var(--yz-accent) !important;
    background: var(--yz-accent-soft) !important;
    box-shadow: 0 0 15px var(--yz-accent-line), inset 0 0 10px var(--yz-accent-soft);
    transform: scale(1.05);
}

/* Рамки редкости для инвентаря */
.inv-item[data-rarity="common"] { border-color: #4b6584; } /* Ширпотреб (Синий) */
.inv-item[data-rarity="rare"] { border-color: #8854d0; } /* Засекреченное (Фиолетовый) */
.inv-item[data-rarity="epic"] { border-color: #eb3b5a; } /* Тайное (Розовый) */
.inv-item[data-rarity="legendary"] { 
    border-color: #f7b731; /* Легендарное (Золотой) */
    box-shadow: 0 0 8px rgba(247, 183, 49, 0.3);
    animation: legendaryPulse 3s infinite alternate;
}

@keyframes legendaryPulse {
    0% { box-shadow: 0 0 5px rgba(247, 183, 49, 0.2); }
    100% { box-shadow: 0 0 15px rgba(247, 183, 49, 0.6); }
}

.inv-item.selected {
    outline: 3px solid var(--yz-accent);
    outline-offset: 2px;
}

/* === АДАПТИВНЫЙ БЕЙДЖ ПОДПИСКИ В ОБЕРТКЕ ИМЕНИ (ДЛЯ МОБИЛЬНЫХ) === */
@media (max-width: 480px) {
    .name-with-badge .brc-badge {
        width: 22px;
        height: 22px;
    }
    .name-with-badge .brc-badge > i {
        font-size: 11px;
    }
}

/* === УНИВЕРСАЛЬНАЯ ОБЕРТКА ДЛЯ ИМЕНИ С БЕЙДЖЕМ === */
.name-with-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-wrap: nowrap;
    max-width: 100%;
    overflow: hidden;
    vertical-align: middle;
    line-height: 1;
}

.name-with-badge .name-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.name-with-badge .brc-badge {
    flex-shrink: 0;
}

/* Компактный бейдж в тесных местах (списки друзей, запросы) */
.req-user-info .brc-badge,
.friend-item .brc-badge {
    width: 22px;
    height: 22px;
}
.req-user-info .brc-badge > i,
.friend-item .brc-badge > i {
    font-size: 11px;
}
.req-user-info .brc-badge-tooltip,
.friend-item .brc-badge-tooltip {
    font-size: 9px;
    padding: 4px 8px;
}