/* === 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: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(5px);
    /* Адаптация под мобильные экраны (чтобы не заезжало за челку) */
    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: rgba(24, 24, 27, 0.95);
    backdrop-filter: blur(20px);
    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: rgba(255, 255, 255, 0.03);
    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: rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.06);
}

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

.auth-btn, .profile-btn {
    background: var(--text-primary);
    color: #000;
    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: #fff;
}

/* === УПРАВЛЕНИЕ ДРУЗЬЯМИ (МОДАЛКА) === */
.friends-container {
    background: rgba(24, 24, 27, 0.95);
    backdrop-filter: blur(20px);
    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: rgba(255,255,255,0.03);
    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: rgba(255,255,255,0.03);
    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: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}

/* === ОБНОВЛЕННЫЙ STORY RING (ADVANCED) === */
.story-ring-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    padding: 3px;
    background: transparent;
    z-index: 1;
    --ring-color: transparent; 
}

/* Стандартное свечение для Plus и Premium */
.story-ring-wrapper::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--ring-color), transparent 80%);
    z-index: -1;
    box-shadow: 0 0 10px var(--ring-color);
    transition: all 0.3s ease;
    animation: ringPulse 2.5s infinite alternate ease-in-out;
}

/* Анимированное неоновое свечение для ULTRA (если цвет #f43f5e) */
.story-ring-wrapper[style*="#f43f5e"]::before {
    background: conic-gradient(from 0deg, #f43f5e, #fb7185, #f43f5e);
    animation: ultraSpin 3s linear infinite, ringPulse 1.5s infinite alternate ease-in-out;
}

.story-ring-wrapper img {
    border-radius: 50%;
    border: 2px solid var(--surface, #0a0a0c);
    background: var(--surface, #0a0a0c);
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: relative;
    z-index: 2;
}

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

@keyframes ringPulse {
    0% { filter: brightness(0.8); box-shadow: 0 0 5px var(--ring-color); transform: scale(1); }
    100% { filter: brightness(1.3); box-shadow: 0 0 20px var(--ring-color); transform: scale(1.02); }
}

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

/* Кастомный инпут для модалок */
.custom-input {
    width: 100%;
    background: #0e1621;
    border: 2px solid #242f3d;
    padding: 14px 16px;
    border-radius: 16px;
    color: white;
    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: #5288c1;
    background: #131d29;
    box-shadow: 0 0 0 4px rgba(82, 136, 193, 0.1);
}

.custom-input::placeholder {
    color: #708499;
}

/* Стилизация 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='%23708499' 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: #17212b;
    color: #fff;
    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: rgba(255, 255, 255, 0.1);
}

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: #5288c1 !important;
    background: rgba(82, 136, 193, 0.1) !important;
    box-shadow: 0 0 15px rgba(82, 136, 193, 0.4), inset 0 0 10px rgba(82, 136, 193, 0.2);
    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 #5288c1;
    outline-offset: 2px;
}