* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    touch-action: none;
    overscroll-behavior: none;
    user-select: none; /* Prevent text selection globally */
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE/Edge */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    overflow: hidden;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    background: #000;
    margin: 0;
    padding: 0;
    position: fixed;
    width: 100%;
    box-sizing: border-box;
    touch-action: none;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: none;
}

.stories-container {
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    position: relative;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
    overscroll-behavior: none;
}

/* Progress Bar Container */
.progress-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 4px;
    padding: 10px 10px;
    z-index: 1000;
}

.progress-bar {
    flex: 1;
    height: 3px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    width: 0%;
    background: white;
    border-radius: 2px;
    transition: width 0.05s linear;
}

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

.progress-bar.active .progress-fill {
    transition: width 0.05s linear;
}

.progress-bar.paused .progress-fill {
    transition: width 0.05s linear;
}

.controls {
    position: absolute;
    top: 60px;
    right: 20px;
    z-index: 1001;
    display: flex;
    gap: 8px;
    align-items: center;
}

.toggle-btn {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    user-select: none; /* Prevent text selection */
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE/Edge */
    touch-action: manipulation; /* Prevent double-tap zoom on mobile */
}

.toggle-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.toggle-btn.active {
    background: rgba(255, 255, 255, 0.9);
    color: #000;
}

/* Autoplay Toggle Icons */
.autoplay-toggle {
    position: relative;
    user-select: none; /* Prevent text selection during long press */
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE/Edge */
    touch-action: manipulation; /* Prevent double-tap zoom on mobile */
}

.autoplay-toggle .play-icon,
.autoplay-toggle .pause-icon {
    position: absolute;
    font-size: 16px;
    line-height: 1;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.autoplay-toggle .play-icon {
    opacity: 0;
    transform: scale(0.8);
}

.autoplay-toggle .pause-icon {
    opacity: 1;
    transform: scale(1);
}

.autoplay-toggle.paused .play-icon {
    opacity: 1;
    transform: scale(1);
}

.autoplay-toggle.paused .pause-icon {
    opacity: 0;
    transform: scale(0.8);
}

/* Language Toggle */
.language-toggle {
    padding: 0;
    display: flex;
    align-items: center;
    position: relative;
    width: 80px;
    height: 40px;
    border-radius: 20px;
    overflow: hidden;
}

.language-toggle-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 25px;
    transition: transform 0.3s ease;
    z-index: 1;
}

.language-toggle.hebrew .language-toggle-bg {
    transform: translateX(100%);
}

.language-toggle .flag {
    font-size: 18px;
    position: relative;
    z-index: 2;
    width: 40px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.language-toggle.english .flag-us {
    opacity: 1;
}

.language-toggle.english .flag-il {
    opacity: 0.6;
}

.language-toggle.hebrew .flag-us {
    opacity: 0.6;
}

.language-toggle.hebrew .flag-il {
    opacity: 1;
}

.stories-swiper {
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    position: relative;
    overflow: hidden;
    touch-action: pan-y pinch-zoom;
}

.stories-swiper .swiper-wrapper {
    overflow: hidden;
}

.stories-swiper .swiper-slide {
    overflow: hidden;
}

.story-slide {
    width: 100%;
    height: 100%;
    height: 100dvh; /* Dynamic viewport height for mobile */
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    background-color: #000;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-sizing: border-box;
    padding: 0;
    margin: 0;
    user-select: none; /* Prevent text selection on long press */
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE/Edge */
    -webkit-touch-callout: none; /* Disable iOS callout */
}

/* Overlay for better text readability */
.story-slide::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        to bottom,
        rgba(0, 0, 0, 0.6) 0%,
        rgba(0, 0, 0, 0.4) 30%,
        rgba(0, 0, 0, 0.4) 70%,
        rgba(0, 0, 0, 0.7) 100%
    );
    z-index: 1;
}

.story-content {
    position: relative;
    z-index: 2;
    text-align: center;
    color: white;
    padding: 40px;
    max-width: 600px;
    max-height: calc(100vh - 120px - 80px); /* Viewport height minus top UI (120px) and bottom safe area (80px) */
    max-height: calc(100dvh - 120px - 80px); /* Dynamic viewport height for mobile */
    overflow: hidden; /* Clip content that exceeds bounds */
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    box-sizing: border-box;
    transition: opacity 0.3s ease; /* Smooth fade for modal interactions */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center content vertically */
    align-items: center;
    user-select: none; /* Prevent text selection on long press */
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE/Edge */
    -webkit-touch-callout: none; /* Disable iOS callout */
}

.story-content.welcome-content {
    max-width: 800px;
    max-height: calc(100vh - 120px - 80px); /* Viewport height minus top UI and bottom safe area */
    max-height: calc(100dvh - 120px - 80px); /* Dynamic viewport height for mobile */
    box-sizing: border-box;
    overflow: hidden; /* Clip content that exceeds bounds */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center content vertically */
    align-items: center;
}

.story-content.welcome-content .story-text {
    /* Allow truncation with read more for welcome text */
}

/* Hide scrollbar for story content but allow scrolling */
.story-content::-webkit-scrollbar {
    width: 0;
    background: transparent;
}

/* Hebrew text support */
.story-content[dir="rtl"],
.story-text[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

.story-title {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 20px;
    animation: fadeInUp 0.6s ease;
}

.story-text {
    font-size: 1.5rem;
    font-weight: 400;
    line-height: 1.6;
    animation: fadeInUp 0.8s ease;
    white-space: pre-line;
    overflow: visible; /* Allow "read more" link to be visible */
    word-wrap: break-word;
    overflow-wrap: break-word;
    width: 100%; /* Ensure it respects parent width */
    max-width: 100%; /* Don't exceed parent */
    user-select: none; /* Prevent text selection on long press */
    -webkit-user-select: none; /* Safari */
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE/Edge */
    -webkit-touch-callout: none; /* Disable iOS callout */
}

.read-more-link {
    color: rgba(255, 255, 255, 0.9);
    font-weight: 600;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
    user-select: none; /* Prevent text selection */
    -webkit-user-select: none; /* Safari */
    -webkit-touch-callout: none; /* Disable iOS callout */
    cursor: pointer;
}

.read-more-link:hover {
    opacity: 0.8;
}

.story-author {
    font-size: 1.2rem;
    font-weight: 600;
    font-style: italic;
    margin-bottom: 20px;
    opacity: 0.9;
    animation: fadeInUp 0.6s ease;
}

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

/* Edge Navigation Zones */
.nav-edge {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 20%; /* Reduced from 30% for smaller margins */
    z-index: 10;
    cursor: pointer;
}

.nav-edge-left {
    left: 0;
}

.nav-edge-right {
    right: 0;
}

/* Hide navigation buttons */
.swiper-button-next,
.swiper-button-prev {
    display: none;
}

/* Loading Indicator */
.loading-indicator {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    color: white;
    text-align: center;
}

.loading-indicator p {
    font-size: 1.2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Share Story Button */
.share-btn {
    font-size: 18px;
}

/* Browse Stories Button */
.browse-btn {
    font-size: 18px;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Read More Modal - Transparent to show background image */
.modal-overlay.read-more-modal {
    background: rgba(0, 0, 0, 0.3) !important; /* More transparent to show background image */
    backdrop-filter: blur(2px) !important;
}

.modal-overlay.read-more-modal .modal-content {
    max-width: 800px;
    max-height: 85vh;
    background: rgba(26, 26, 26, 0.85); /* More transparent content background */
    backdrop-filter: blur(8px);
    padding-top: 20px; /* Extra padding at top to accommodate close button */
}

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

.modal-content {
    background: #1a1a1a;
    border-radius: 20px;
    padding: 30px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
    z-index: 10000;
    pointer-events: auto;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

.modal-close:active {
    background: rgba(255, 255, 255, 0.2);
}

.modal-title {
    color: white;
    font-size: 2rem;
    margin-bottom: 25px;
    text-align: center;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: white;
    margin-bottom: 8px;
    font-size: 0.95rem;
    font-weight: 500;
}

.form-group .required {
    color: #ff6b6b;
}

.form-group input[type="text"],
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.5);
    background: rgba(255, 255, 255, 0.08);
}

.form-group textarea {
    resize: vertical;
    min-height: 120px;
}

.form-group input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 1px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: white;
    cursor: pointer;
}

.form-group input[type="file"]::file-selector-button {
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    cursor: pointer;
    margin-right: 10px;
    transition: background 0.3s ease;
}

.form-group input[type="file"]::file-selector-button:hover {
    background: rgba(255, 255, 255, 0.2);
}

.char-count {
    text-align: right;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.85rem;
    margin-top: 5px;
}

.image-preview {
    margin-top: 15px;
    display: none;
}

.image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.image-preview.active {
    display: block;
}

.remove-image-btn {
    margin-top: 10px;
    padding: 8px 16px;
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.remove-image-btn:hover {
    background: rgba(255, 107, 107, 0.3);
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 25px;
}

.btn {
    flex: 1;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: rgba(255, 255, 255, 0.9);
    color: #000;
}

.btn-primary:hover {
    background: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 255, 255, 0.3);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.form-error {
    margin-top: 15px;
    padding: 12px;
    background: rgba(255, 107, 107, 0.2);
    border: 1px solid rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
    border-radius: 8px;
    text-align: center;
}

.form-success {
    margin-top: 15px;
    padding: 12px;
    background: rgba(76, 175, 80, 0.2);
    border: 1px solid rgba(76, 175, 80, 0.3);
    color: #4caf50;
    border-radius: 8px;
    text-align: center;
}


.read-more-author {
    font-size: 1.3rem;
    font-weight: 600;
    font-style: italic;
    color: white;
    margin-bottom: 20px;
    margin-top: 0;
    padding-top: 40px; /* Space for close button */
    padding-right: 50px; /* Space for close button on the right */
    text-align: center;
    opacity: 0.9;
}

.read-more-text {
    font-size: 1.2rem;
    line-height: 1.8;
    color: white;
    text-align: left;
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    max-height: 60vh;
    overflow-y: auto;
}

.read-more-text[dir="rtl"] {
    text-align: right;
    direction: rtl;
}

/* Scrollbar styling for read more text */
.read-more-text::-webkit-scrollbar {
    width: 8px;
}

.read-more-text::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.read-more-text::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.read-more-text::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Browse Stories Modal */
.browse-stories-content {
    max-width: 500px;
    max-height: 80vh;
}

.stories-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 10px 0;
}

.story-list-item {
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1rem;
    text-align: left;
}

.story-list-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateX(5px);
}

.story-list-item:active {
    background: rgba(255, 255, 255, 0.15);
    transform: translateX(2px);
}

.stories-list .no-stories {
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    padding: 40px 20px;
    font-size: 1.1rem;
}

/* Scrollbar styling for stories list */
.stories-list::-webkit-scrollbar {
    width: 8px;
}

.stories-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.stories-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 4px;
}

.stories-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    html {
        height: 100%;
        height: 100dvh;
        overflow: hidden;
        position: fixed;
        width: 100%;
        touch-action: none;
        overscroll-behavior: none;
    }

    body {
        overflow: hidden;
        position: fixed;
        width: 100%;
        height: 100%;
        height: 100dvh;
        overscroll-behavior: none;
        -webkit-overflow-scrolling: none;
        touch-action: none;
    }

    .stories-container {
        height: 100dvh;
        height: -webkit-fill-available; /* iOS Safari fix */
        overflow: hidden;
    }

    .stories-swiper {
        height: 100dvh;
        height: -webkit-fill-available; /* iOS Safari fix */
        overflow: hidden;
    }

    .story-slide {
        height: 100dvh;
        height: -webkit-fill-available; /* iOS Safari fix */
        overflow: hidden;
    }

    .story-title {
        font-size: 2rem;
    }

    .story-text {
        font-size: 1.2rem;
    }

    .story-author {
        font-size: 1rem;
    }

    .story-content {
        padding: 15px 10px;
        max-width: 95%;
        width: 95%;
        max-height: calc(100dvh - 100px - 60px); /* Viewport height minus top UI (100px) and bottom safe area (60px) */
        max-height: calc(100vh - 100px - 60px); /* Fallback for older browsers */
        overflow: hidden; /* Clip content that exceeds bounds */
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        flex-shrink: 0;
    }

    .story-content.welcome-content {
        max-width: 95%;
        width: 95%;
        max-height: calc(100dvh - 100px - 60px); /* Viewport height minus top UI and bottom safe area */
        max-height: calc(100vh - 100px - 60px); /* Fallback */
        overflow: visible;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        flex-shrink: 0;
    }

    .story-text {
        font-size: 1.1rem;
        line-height: 1.5;
        max-width: 100%;
    }

    .progress-container {
        padding: 8px 8px;
        gap: 3px;
    }

    .progress-bar {
        height: 2px;
    }

    .controls {
        top: 50px;
        right: 10px;
        gap: 6px;
    }

    .toggle-btn {
        width: 36px;
        height: 36px;
    }

    .autoplay-toggle .play-icon,
    .autoplay-toggle .pause-icon {
        font-size: 14px;
    }

    .language-toggle {
        width: 70px;
        height: 36px;
    }

    .language-toggle .flag {
        font-size: 16px;
        width: 35px;
    }

    .modal-content {
        padding: 20px;
        max-height: 95vh;
    }

    .modal-title {
        font-size: 1.5rem;
        margin-bottom: 20px;
    }

    .form-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }
}

