/* Локальные шрифты для офлайн работы */
@font-face {
    font-family: 'Montserrat';
    src: url('./fonts/Montserrat-Regular.woff2') format('woff2');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Montserrat';
    src: url('./fonts/Montserrat-SemiBold.woff2') format('woff2');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Montserrat';
    src: url('./fonts/Montserrat-Bold.woff2') format('woff2');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Montserrat';
    src: url('./fonts/Montserrat-ExtraBold.woff2') format('woff2');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

@font-face {
    font-family: 'Montserrat';
    src: url('./fonts/Montserrat-Black.woff2') format('woff2');
    font-weight: 900;
    font-style: normal;
    font-display: swap;
}

/* Предотвращение горизонтального скролла и зума */
* {
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    touch-action: pan-y pinch-zoom;
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    overflow-y: hidden;
    position: fixed;
    width: 100%;
    height: 100%;
    height: 100dvh;
}

html,
body {
    margin: 0;
    padding: 0;
    height: 100%;
    /* dvh учитывает панели браузера и не оставляет пустой полосы внизу. */
    height: 100dvh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: linear-gradient(135deg, #eada66 0%, #b0d12c 100%);
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Раскладка прибита к краям окна: высоту задаёт само окно, а не расчёт из
   dvh или visualViewport. Так под приложением не остаётся полосы фона —
   ни в браузере с панелями, ни в установленном приложении. */
body {
    position: fixed;
    inset: 0;
    width: auto;
    height: auto;
}

#inputContainer {
    display: flex;
    padding: 20px 20px calc(20px + env(safe-area-inset-bottom, 0px)) 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    gap: 15px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1);
    border-radius: 20px 20px 0 0;
}

#inputWrapper {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

#wordInput {
    width: 100%;
    font-size: 18px;
    padding: 15px 50px 15px 20px;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 400;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    background: white;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

#wordInput:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
    transform: translateY(-2px);
}

#wordInput::placeholder {
    color: #999;
    font-style: italic;
}

#clearBtn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.1);
    border: none;
    font-size: 28px;
    color: #666;
    cursor: pointer;
    padding: 1px;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1;
    font-weight: 600;
}

#clearBtn:hover {
    background: rgba(0, 0, 0, 0.2);
    color: #333;
}

#clearBtn:active {
    transform: translateY(-50%) scale(0.95);
}

#sendBtn {
    padding: 15px 25px;
    font-size: 18px;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    background: linear-gradient(171deg, #8BC34A 0% 0%, #5f9600 100%);
    color: white;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    white-space: nowrap;
    min-width: 120px;
}

#sendBtn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

#sendBtn:active {
    transform: translateY(0);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.3);
}

/* Кнопка поделиться */
.share-btn {
    position: absolute;
    top: calc(35px + env(safe-area-inset-top, 0px));
    left: calc(35px + env(safe-area-inset-left, 0px));
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 12px;
    padding: 8px 12px;
    font-size: 12px;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    color: #667eea;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 10;
    white-space: nowrap;
}

.share-btn:hover {
    background: white;
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Кнопка информации */
.info-btn {
    position: absolute;
    top: calc(35px + env(safe-area-inset-top, 0px));
    right: calc(35px + env(safe-area-inset-right, 0px));
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    z-index: 10;
}

.info-btn:hover {
    background: white;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Кнопка случайного слова */
.random-btn {
    position: absolute;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    left: calc(20px + env(safe-area-inset-left, 0px));
    background: linear-gradient(135deg, #ff6b6b 0%, #ee5a24 100%);
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.4);
    transition: all 0.3s ease;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.random-btn:hover {
    transform: scale(1.1) rotate(180deg);
    box-shadow: 0 6px 25px rgba(255, 107, 107, 0.6);
}

.random-btn:active {
    transform: scale(0.95);
}

/* Кнопка показа картинки */
.picture-btn {
    position: absolute;
    top: calc(35px + env(safe-area-inset-top, 0px));
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, #ff48df 0%, #0fffee 100%);
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(193, 50, 191, 0.4);
    transition: all 0.3s ease;
    z-index: 10;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.picture-btn:hover {
    transform: translateX(-50%) scale(1.1);
    box-shadow: 0 6px 25px rgba(201, 107, 255, 0.6);
}

.picture-btn:active {
    transform: translateX(-50%) scale(0.95);
}

.picture-btn.inactive {
    background: rgba(200, 200, 200, 0.5);
    cursor: not-allowed;
    opacity: 0.5;
}

.picture-btn.inactive:hover {
    transform: translateX(-50%);
    box-shadow: 0 4px 20px rgba(200, 200, 200, 0.2);
}

.picture-btn img {
    width: 32px;
    height: 32px;
    pointer-events: none;
}

.picture-btn.inactive img {
    pointer-events: none;
}

/* Блок версии и обновления */
/* Когда вышла новая версия, блок подсвечивается, а кнопка становится зелёной. */
.version-block.has-update {
    background: #eafbef;
    box-shadow: 0 4px 18px rgba(22, 163, 74, 0.45);
    animation: versionPulse 2.4s ease-in-out infinite;
}

.version-block.has-update .update-btn {
    background: linear-gradient(135deg, #34d399 0%, #16a34a 100%);
    color: #fff;
}

/* Пульсирует только свечение: блок не должен «уезжать» из-под пальца. */
@keyframes versionPulse {

    0%,
    100% {
        box-shadow: 0 4px 18px rgba(22, 163, 74, 0.35);
    }

    50% {
        box-shadow: 0 4px 26px rgba(22, 163, 74, 0.75);
    }
}

@media (prefers-reduced-motion: reduce) {
    .version-block.has-update {
        animation: none;
    }
}

.version-block {
    position: absolute;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: calc(20px + env(safe-area-inset-right, 0px));
    background: rgba(255, 255, 255, 0.9);
    border-radius: 12px;
    padding: 8px 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    z-index: 10;
    text-align: center;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
}

.version-text {
    font-size: 11px;
    color: #666;
    font-weight: 600;
    margin-bottom: 4px;
}

.update-btn {
    background: linear-gradient(135deg, #667eea 0%, #dd1065 100%);
    border: none;
    border-radius: 8px;
    padding: 4px 8px;
    font-size: 10px;
    color: white;
    cursor: pointer;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.update-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 10px rgba(102, 126, 234, 0.4);
}

.update-btn:active {
    transform: scale(0.95);
}

.update-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}


/* === СТИЛИ МОДАЛЬНЫХ ОКОН === */


/* Общий фон для всех модальных окон */
.modal,
.qr-modal,
.picture-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
    /* Добавляем внутренний отступ для центрирования и адаптивности */
    padding: 20px;
    box-sizing: border-box;
}

.picture-modal {
    background-color: rgba(0, 0, 0, 0.7);
}

/* Общие стили для контентных блоков (теперь это только позиционирование) */
.modal-content,
.qr-content,
.picture-content {
    background-color: white;
    margin: auto;
    /* Автоматическое центрирование */
    border-radius: 20px;
    width: 100%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
    box-sizing: border-box;
}

.qr-content {
    padding: 40px 20px 20px 20px;
    max-width: 400px;
    text-align: center;
}

.picture-content {
    padding: 0;
    /* Отступы теперь в обертке */
    max-width: 500px;
}


/* Новые обертки для контента с прокруткой */
.info-scroll-wrapper,
.picture-scroll-wrapper {
    max-height: 90vh;
    /* Ограничение высоты */
    overflow-y: auto;
    /* Вертикальный скролл */
    overflow-x: hidden;
    /* Прячем горизонтальный скролл */
    padding: 25px;
    /* Внутренний отступ, который решает проблему со скруглением! */
}

.info-scroll-wrapper::-webkit-scrollbar {
    width: 8px;
    /* ширина полосы */
}

.info-scroll-wrapper::-webkit-scrollbar-track {
    background: transparent;
    /* фон под скроллом прозрачный */
    margin-bottom: 20px;
}

.info-scroll-wrapper::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.17);
    /* сам ползунок */
    border-radius: 5px;
    border: 1px solid transparent;
    /* можно задать отступ */
}

.info-scroll-wrapper {
    padding-top: 30px;
    /* Дополнительный отступ сверху, чтобы текст не лез под кнопку */
}

.picture-scroll-wrapper {
    /* padding: 30px; */
    text-align: center;
}

/* Анимация появления */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* УНИФИЦИРОВАННЫЕ СТИЛИ ДЛЯ ВСЕХ КНОПОК ЗАКРЫТИЯ */
.close,
.qr-close,
.picture-close {
    position: absolute;
    top: -15px;
    /* Теперь все кнопки снаружи */
    right: -15px;
    /* Теперь все кнопки снаружи */
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
    color: #999;
    font-size: 32px;
    font-weight: bold;
    z-index: 1010;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}

.close:hover,
.qr-close:hover {
    color: #333;
    background: #f0f0f0;
    transform: scale(1.1);
}

.picture-close:hover {
    color: white;
    background: #d02ebd;
    transform: scale(1.1);
}

/* Остальные стили для контента модальных окон */
.qr-image,
.picture-img {
    max-width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.21);

}



.qr-image {

    margin-bottom: 15px;
}

.qr-title,
.picture-title {
    margin-bottom: 20px;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    font-weight: 600;
    color: #667eea;
    font-size: 18px;
}

.picture-title {
    margin-bottom: 20px;
    font-size: 30px;
    font-weight: 800;
    text-transform: uppercase;
}

#infoText {
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
    line-height: 1.6;
    color: #333;
    -webkit-user-select: text;
    -moz-user-select: text;
    -ms-user-select: text;
    user-select: text;
}

#infoText h1,
#infoText h2,
#infoText h3 {
    color: #667eea;
    margin-top: 0;
    line-height: 1.13;
}

#infoText h1 {
    font-weight: 900;
}

#infoText h2,
#infoText h3 {
    font-weight: 800;
}

#infoText p {
    margin-bottom: 15px;
}

#infoText ul {
    padding-left: 20px;
}

#infoText li {
    margin-bottom: 8px;
}

/* Стили для изображений в инструкции по установке */
.install-images {
    margin: 15px 0;
    text-align: center;
}

.browser-step {
    margin-bottom: 20px;
}

.browser-step p {
    margin-bottom: 10px;
    font-size: 16px;
    color: #667eea;
    font-weight: 600;
}

.install-img {
    max-width: 100%;
    width: 100%;
    max-width: 295px;
    height: auto;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    border: 2px solid #e0e0e0;
}

.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 15px 25px;
    border-radius: 25px;
    font-family: 'Montserrat', sans-serif;
    font-weight: 600;
    z-index: 2000;
    display: none;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

/* Контейнер единственной картинки (заглушка затем заменяется оригиналом). */
.picture-img-container {
    width: 100%;
    display: block;
}

/* Один элемент используется и для заглушки, и для основной картинки. */
.picture-img {
    display: block;
    width: 100%;
    height: auto;
    opacity: 1;
    margin: 0;
    transition: opacity 0.2s ease-in-out;
}
