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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #000;
    overflow: hidden;
    -webkit-user-select: none;
    user-select: none;
}

/* ===== ТЕМОВИ ПРОМЕНЛИВИ ===== */
:root {
    /* Тъмна тема (по подразбиране) */
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --bg-surface: rgba(0, 0, 0, 0.3);
    --bg-surface-hover: rgba(0, 0, 0, 0.5);
    --text-primary: #ffffff;
    --text-secondary: rgba(255, 255, 255, 0.8);
    --accent-color: #667eea;
    --border-color: rgba(255, 255, 255, 0.1);
    --card-bg: rgba(255, 255, 255, 0.1);
    --gradient-overlay: linear-gradient(to bottom, 
        rgba(0,0,0,0.8) 0%,
        rgba(0,0,0,0.4) 20%,
        rgba(0,0,0,0.2) 40%,
        rgba(0,0,0,0.3) 60%,
        rgba(0,0,0,0.5) 80%,
        rgba(0,0,0,0.9) 100%);
}

.light-theme {
    /* Светла тема */
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-surface: rgba(255, 255, 255, 0.7);
    --bg-surface-hover: rgba(255, 255, 255, 0.9);
    --text-primary: #000000;
    --text-secondary: rgba(0, 0, 0, 0.7);
    --accent-color: #4f46e5;
    --border-color: rgba(0, 0, 0, 0.1);
    --card-bg: rgba(0, 0, 0, 0.05);
    --gradient-overlay: linear-gradient(to bottom, 
        rgba(255,255,255,0.8) 0%,
        rgba(255,255,255,0.4) 20%,
        rgba(255,255,255,0.2) 40%,
        rgba(255,255,255,0.3) 60%,
        rgba(255,255,255,0.5) 80%,
        rgba(255,255,255,0.9) 100%);
}

/* ===== ПРИЛАГАНЕ НА ПРОМЕНЛИВИТЕ ===== */
body {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.container {
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
}

.phone-frame {
    width: min(430px, 100vw);
    height: min(932px, 100vh);
    max-height: 100vh;
    background: var(--bg-secondary);
    border-radius: 40px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Меню стилове */
.menu-container {
    position: absolute;
    top: 13px;
    left: 110px;
    z-index: 100;
}

.menu-btn {
    width: 40px;
    height: 40px;
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 101;
}

.menu-btn:hover {
    background: var(--bg-surface-hover);
    transform: scale(1.1);
}

.dropdown-menu {
    position: absolute;
    top: 50px;
    left: 0;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 20px;
    width: 300px;
    max-height: 500px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.dropdown-menu.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.menu-header h3 {
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.close-menu {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    padding: 5px;
    transition: all 0.3s ease;
}

.close-menu:hover {
    transform: scale(1.2);
}

.categories-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.category-item {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 15px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 12px;
}

.category-item:hover {
    background: var(--bg-surface);
    transform: translateX(5px);
}

.category-item.active {
    background: rgba(255, 193, 7, 0.3);
    border-color: rgba(255, 193, 7, 0.5);
}

.category-icon {
    font-size: 20px;
}

.category-name {
    font-size: 16px;
    font-weight: 500;
}

.category-count {
    margin-left: auto;
    background: var(--card-bg);
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 12px;
}

/* Останалите стилове */
.story-container {
    flex: 1;
    width: 100%;
    position: relative;
    overflow-y: scroll;
    scroll-snap-type: y proximity;
    scrollbar-width: none;
    display: flex;
    flex-direction: column;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    scroll-behavior: smooth;
}

.story-container::-webkit-scrollbar {
    display: none;
}

.story {
    width: 100%;
    min-height: 100%;
    height: auto;
    flex: 0 0 100%;
    position: relative;
    background-size: cover;
    background-position: center;
    display: flex;
    flex-direction: column;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    will-change: transform;
}

/* Скриваме скролбара за Webkit браузъри */
.story-text::-webkit-scrollbar {
    display: none;
}

.image-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 0;
    overflow: hidden;
    will-change: transform;
}

.story-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.85;
    will-change: transform, opacity;
}

video.story-image {
    background-color: var(--bg-primary);
}

.gradient-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-overlay);
    z-index: 1;
}

.top-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    z-index: 99;
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border-color);
}

.left-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

.app-title {
    color: var(--text-primary);
    font-weight: bold;
    font-size: 18px;
    margin-left: 0px;
}

.right-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Стилове за тема бутон */
.theme-toggle {
    display: flex;
    align-items: center;
}

.theme-btn {
    width: 40px;
    height: 40px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    margin-left: 8px;
}

.theme-btn:hover {
    background: var(--bg-surface);
    transform: scale(1.05);
}

.stats-display {
    display: flex;
    gap: 15px;
    color: var(--text-primary);
    font-size: 14px;
}

.stat-item {
    background: var(--card-bg);
    padding: 5px 10px;
    border-radius: 10px;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 20px 16px 70px;
    position: relative;
    z-index: 2;
    color: var(--text-primary);
    min-height: 100%;
}

.category-badge {
    display: inline-block;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 12px;
    align-self: flex-start;
    text-transform: uppercase;
    letter-spacing: 1px;
    border: 1px solid var(--border-color);
}

.difficulty-badge {
    display: inline-block;
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid var(--border-color);
}

.difficulty-easy {
    background: rgba(46, 213, 115, 0.7) !important;
    color: #000;
}

.difficulty-medium {
    background: rgba(255, 193, 7, 0.7) !important;
    color: #000;
}

.difficulty-hard {
    background: rgba(255, 71, 87, 0.7) !important;
    color: #fff;
}

.title {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 16px;
    line-height: 1.2;
    text-shadow: 0 2px 8px rgba(0,0,0,0.7);
    background: rgba(0,0,0,0.4);
    padding: 8px 12px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
}

.text {
    font-size: 17px;
    line-height: 1.5;
    margin-bottom: 12px;
    overflow-y: auto;
    text-shadow: 0 1px 4px rgba(0,0,0,0.8);
    background: rgba(0,0,0,0.5);
    padding: 12px 16px;
    border-radius: 10px;
    backdrop-filter: blur(5px);
    transition: all 0.5s ease;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
    max-height: 210px; /* Увеличено от 180px */
}

.text.hidden {
    max-height: 0;
    opacity: 0;
    padding: 0 16px;
    margin-bottom: 0;
    overflow: hidden;
}

.text::-webkit-scrollbar {
    width: 4px;
}

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

.question-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 16px;
    margin-bottom: 10px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: all 0.5s ease;
}

.question-card.visible {
    max-height: 500px;
    opacity: 1;
    overflow: visible;
}

.question-text {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--text-primary);
    text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.answer-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.answer-btn {
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 15px;
    padding: 14px 20px;
    color: var(--text-primary);
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: left;
    width: 100%;
    min-height: 50px;
}

.answer-btn:hover {
    background: var(--bg-surface-hover);
    transform: translateX(5px);
}

.answer-btn.correct {
    background: rgba(46, 213, 115, 0.95) !important;
    color: #000 !important;
    border-color: rgba(46, 213, 115, 0.4);
}

.answer-btn.wrong {
    background: rgba(255, 71, 87, 0.95) !important;
    color: #fff !important;
    border-color: rgba(255, 71, 87, 0.4);
}

.action-buttons {
    display: flex;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.action-btn {
    flex: 1;
    min-width: 140px;
    background: var(--accent-color);
    color: #fff;
    border: none;
    border-radius: 15px;
    padding: 7px 10px;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 600;
}

.action-btn:hover {
    transform: scale(1.05);
    opacity: 0.9;
}

.action-btn.quiz {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.action-btn.text {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

.side-controls {
    position: absolute;
    right: 20px;
    bottom: 160px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    z-index: 20;
}

.side-btn {
    width: 50px;
    height: 50px;
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.side-btn:hover {
    background: var(--bg-surface-hover);
    transform: scale(1.1);
}

.side-btn-label {
    font-size: 10px;
    margin-top: 4px;
    font-weight: 600;
}

.swipe-hint {
    position: absolute;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-primary);
    font-size: 14px;
    opacity: 0;
    z-index: 5;
    animation: fadeInOut 3s ease-in-out;
    text-align: center;
    background: var(--bg-surface);
    padding: 10px 20px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
}

@keyframes fadeInOut {
    0%, 100% { opacity: 0; }
    50% { opacity: 0.8; }
}

.nav-arrows {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    gap: 20px;
    z-index: 3;
    opacity: 0.3;
    transition: opacity 0.3s ease;
}

.nav-arrows:hover {
    opacity: 0.8;
}

.arrow-btn {
    width: 48px;
    height: 48px;
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.arrow-btn:hover {
    background: var(--bg-surface-hover);
    transform: scale(1.1);
}

.controls-hidden {
    opacity: 0 !important;
    pointer-events: none !important;
}

.memory-hint {
    color: var(--text-secondary);
    font-size: 13px;
    text-align: center;
    background: var(--bg-surface);
    padding: 10px 16px;
    border-radius: 15px;
    backdrop-filter: blur(5px);
    margin: 8px 0 12px 0;
    border: 1px solid var(--border-color);
    max-width: 90%;
    align-self: center;
    transition: all 0.5s ease;
    position: relative;
    z-index: 4;
}

.memory-hint.hidden {
    opacity: 0;
    max-height: 0;
    padding: 0;
    margin: 0;
    overflow: hidden;
}

/* Текстове класове с увеличена височина */
.text-tall {
    max-height: 210px; /* Увеличено от 180px */
}

.text-medium {
    max-height: 180px; /* Увеличено от 150px */
}

.text-short {
    max-height: 150px; /* Увеличено от 120px */
}

/* Lazy loading стилове */
.loading-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--bg-surface);
    color: var(--text-primary);
    font-size: 14px;
    text-align: center;
    padding: 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: var(--text-primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 10px;
}

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

.placeholder-text {
    font-size: 14px;
    opacity: 0.8;
}

.story.loading {
    opacity: 0.7;
}

.story.loaded .loading-placeholder {
    display: none;
}

/* Video play button */
.video-play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background: var(--bg-surface);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    transition: all 0.3s ease;
}

.video-play-btn:hover {
    background: var(--bg-surface-hover);
    transform: translate(-50%, -50%) scale(1.1);
}

/* Progressive loading animation */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.lazy-content {
    animation: fadeIn 0.5s ease;
}

/* Мета информация за историите */
.story-meta-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    display: flex;
    gap: 10px;
    background: var(--bg-surface);
    backdrop-filter: blur(10px);
    padding: 8px 12px;
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 12px;
    z-index: 10;
    flex-wrap: wrap;
    max-width: calc(100% - 40px);
    border: 1px solid var(--border-color);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.meta-item i {
    font-size: 10px;
}

/* NOTIFICATION STYLES */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: 16px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 15px;
    animation: slideIn 0.4s ease;
    max-width: 350px;
    box-shadow: 0 15px 40px rgba(0,0,0,0.7);
    font-size: 15px;
    font-weight: 600;
    border: 1px solid var(--border-color);
}

.notification.success {
    background: linear-gradient(135deg, rgba(46, 213, 115, 0.95), rgba(39, 174, 96, 0.95));
    border-color: rgba(46, 213, 115, 0.4);
    box-shadow: 0 15px 40px rgba(46, 213, 115, 0.3);
    color: #000;
}

.notification.error {
    background: linear-gradient(135deg, rgba(255, 71, 87, 0.95), rgba(214, 48, 49, 0.95));
    border-color: rgba(255, 71, 87, 0.4);
    box-shadow: 0 15px 40px rgba(255, 71, 87, 0.3);
    color: #fff;
}

.notification-icon {
    font-size: 22px;
    width: 30px;
    text-align: center;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.notification-text {
    flex: 1;
    text-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

@keyframes slideIn {
    from { transform: translateX(400px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(400px); opacity: 0; }
}

/* Специални за светла тема */
.light-theme .story-image {
    opacity: 0.7;
}

.light-theme .answer-btn.correct {
    background: rgba(46, 213, 115, 0.9);
}

.light-theme .answer-btn.wrong {
    background: rgba(255, 71, 87, 0.9);
}

.light-theme .difficulty-easy {
    background: rgba(46, 213, 115, 0.9) !important;
}

.light-theme .difficulty-medium {
    background: rgba(255, 193, 7, 0.9) !important;
}

.light-theme .difficulty-hard {
    background: rgba(255, 71, 87, 0.9) !important;
}

.light-theme .title,
.light-theme .text {
    text-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.light-theme .title {
    background: rgba(255, 255, 255, 0.7);
}

.light-theme .text {
    background: rgba(255, 255, 255, 0.8);
}

/* Анимация за харесване */
@keyframes heartBeat {
    0% { transform: scale(1); }
    25% { transform: scale(1.3); }
    50% { transform: scale(1); }
    75% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.side-btn.like i.fa-heart {
    transition: all 0.3s ease;
}

.side-btn.like i.fas.fa-heart {
    color: #ff4757 !important;
    animation: heartBeat 0.5s ease;
}

.side-btn.like:hover i.far.fa-heart {
    color: #ff4757;
}

/* Стил за активен бутон за харесване */
.side-btn.like.active {
    background: rgba(255, 71, 87, 0.2);
    border: 1px solid rgba(255, 71, 87, 0.5);
}

/* Анимация за популярност в мета информацията */
@keyframes pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.5); }
    100% { transform: scale(1); }
}

.meta-item .fa-fire {
    transition: all 0.3s ease;
}

/* Стилове за мобилни устройства */
@media (max-width: 480px) {
    .phone-frame {
        border-radius: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
    }

    .title {
        font-size: 24px;
    }

    .text {
        font-size: 16px;
        max-height: 170px; /* Увеличено от 140px */
    }

    .action-buttons {
        flex-direction: column;
    }

    .action-btn {
        min-width: 100%;
        max-width: 100%;
        padding: 12px 16px;
        font-size: 15px;
        min-height: 48px;
    }

    .memory-hint {
        font-size: 12px;
        padding: 8px 12px;
        margin: 6px 0 10px 0;
    }

    .dropdown-menu {
        width: 280px;
        left: -20px;
    }
    
    .text-tall {
        max-height: 170px; /* Увеличено от 140px */
    }
    
    .text-medium {
        max-height: 150px; /* Увеличено от 120px */
    }
    
    .text-short {
        max-height: 130px; /* Увеличено от 100px */
    }
    
    .loading-placeholder {
        font-size: 12px;
        padding: 15px;
    }
    
    .spinner {
        width: 30px;
        height: 30px;
    }
    
    .video-play-btn {
        width: 50px;
        height: 50px;
        font-size: 20px;
    }
    
    .story-meta-info {
        font-size: 11px;
        padding: 6px 10px;
        gap: 8px;
        bottom: 12px;
        left: 15px;
    }
    
    .theme-btn {
        width: 36px;
        height: 36px;
        font-size: 16px;
    }
    
    .stats-display {
        gap: 8px;
    }
    
    .stat-item {
        font-size: 12px;
        padding: 4px 8px;
    }
    
    .content {
        padding: 16px 12px 60px;
    }
    
    .question-card {
        padding: 14px;
        margin-bottom: 8px;
    }
    
    .question-card.visible {
        max-height: 300px;
    }
    
    .answer-btn {
        padding: 10px 12px;
        font-size: 15px;
        min-height: 44px;
    }
    
    .side-controls {
        right: 12px;
        bottom: 140px;
    }
    
    .side-btn {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
    
    .swipe-hint {
        bottom: 90px;
        font-size: 13px;
        padding: 8px 16px;
    }
    
    .nav-arrows {
        opacity: 0.2;
    }
}