/* ===== Стили для обложек (кружочки) ===== */
.stories-covers {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 20px;
}

.story-cover {
    width: 80px;
    cursor: pointer;
    text-align: center;
    transition: transform 0.2s;
}

.story-cover:hover {
    transform: scale(1.05);
}

.story-cover img {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid #667eea;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    display: block;
}

.story-cover {
    display: block;
    font-size: 13px;
    color: #333;
    word-break: break-word;
}

/* ===== Стили для модалки историй ===== */
.stories-modal,
.stories-modal *,
.stories-container,
.stories-container * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.stories-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.stories-modal.active {
    display: flex;
}

.stories-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.stories-container {
    position: relative;
    width: 100%;
    max-width: 400px;
    height: 100dvh;
    max-height: 800px;
    background: #000;
    z-index: 1001;
    box-shadow: 0 20px 40px rgba(0,0,0,0.3);
    overflow: hidden;
    border-radius: 20px;
}

.stories-modal-close {
    position: absolute;
    top: 50px; /* Отступ 50px от верха слайда */
    right: 15px; /* Отступ справа */
    width: 40px;
    height: 40px;
    color: white;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1003;
    text-shadow: 2px -1px 5px black;
}

/* ===== Прогресс бары ===== */
.progress-bars {
    position: absolute;
    top: max(15px, env(safe-area-inset-top));
    left: max(15px, env(safe-area-inset-left));
    right: max(15px, env(safe-area-inset-right));
    z-index: 30;
    display: flex;
    gap: 5px;
    padding: 5px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
    pointer-events: none;
}

.progress-item {
    flex: 1;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: white;
    transition: width 0.1s linear;
    box-shadow: 0 0 5px rgba(255,255,255,0.5);
}

.progress-fill.completed {
    width: 100%;
    background: white;
}

/* ===== Слайды ===== */
.slides-container {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

.slide.active {
    opacity: 1;
    visibility: visible;
}

/* Затемнение для текста */
.slide::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30%;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    pointer-events: none;
}

/* Контент слайда */
.slide-content {
    position: absolute;
    bottom: max(30px, env(safe-area-inset-bottom));
    left: max(20px, env(safe-area-inset-left));
    right: max(20px, env(safe-area-inset-right));
    color: white;
    z-index: 20;
    text-shadow: 0 2px 8px rgba(0,0,0,0.8);
    pointer-events: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.slide-text {
    font-size: 20px;
    line-height: 1.4;
    font-weight: 500;
}

.slide-button {
    display: inline-block;
    padding: 12px 24px;
    background: white;
    color: #333;
    text-decoration: none;
    border-radius: 30px;
    font-weight: 600;
    font-size: 16px;
    text-align: center;
    pointer-events: auto;
    cursor: pointer;
    border: none;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: transform 0.2s;
    max-width: fit-content;
}

.slide-button:hover {
    transform: scale(1.05);
}

/* ===== Навигационные области (для тапа) ===== */
.nav-areas {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    z-index: 100;
    pointer-events: none;
}

.nav-area {
    height: 100%;
    pointer-events: auto;
    background: transparent;
    -webkit-tap-highlight-color: transparent;
}

.nav-area.left {
    width: 20%;
    cursor: pointer;
}

.nav-area.right {
    width: 20%;
    margin-left: auto;
    cursor: pointer;
}

.nav-area.center {
    width: 60%;
    pointer-events: none;
}

.nav-area.left:active,
.nav-area.right:active {
    background: rgba(255, 255, 255, 0.15);
    transition: background 0.1s;
}

/* ===== Индикатор (отладка) ===== */
.debug-info {
    position: absolute;
    bottom: max(10px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    color: white;
    font-size: 12px;
    z-index: 40;
    background: rgba(0,0,0,0.6);
    padding: 6px 12px;
    border-radius: 20px;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255,255,255,0.2);
    pointer-events: none;
}


@media (max-width: 767px) {
    .stories-container {
        max-width: 100%;
        height: 100dvh;
        border-radius: 0;
    }
}

@supports (padding: max(0px)) {
    .progress-bars {
        top: max(20px, env(safe-area-inset-top));
        left: max(20px, env(safe-area-inset-left));
        right: max(20px, env(safe-area-inset-right));
    }
}