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

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&display=swap');

body {
    font-family: 'Orbitron', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    color: #ffffff;
    background: #000;
    /* Safe area для Telegram Mini App */
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    min-height: 100vh;
    min-height: 100dvh; /* Динамическая высота viewport */
    min-height: -webkit-fill-available;
    /* Предотвращение смещения при открытии клавиатуры */
    position: fixed;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Космический фон */
.cosmic-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    height: -webkit-fill-available;
    height: 100dvh; /* Динамическая высота viewport для предотвращения смещения */
    z-index: 0;
    /* Космический градиент: от темно-синего через фиолетовый к черному */
    background: 
        radial-gradient(ellipse at top, #1a0a2e 0%, #16213e 25%, #0f3460 50%, #000000 100%),
        radial-gradient(ellipse at bottom right, #2d1b4e 0%, transparent 50%),
        radial-gradient(ellipse at bottom left, #1a1a3e 0%, transparent 50%),
        linear-gradient(180deg, #000000 0%, #0a0a1a 50%, #000000 100%);
    background-size: 100% 100%, 80% 80%, 70% 70%, 100% 100%;
    background-position: center, top right, bottom left, center;
    background-attachment: fixed;
    /* Оптимизация для производительности */
    will-change: auto;
    transform: translateZ(0);
    /* Отключаем композитные слои для лучшей производительности */
    contain: layout style paint;
    /* Предотвращение смещения при открытии клавиатуры */
    overscroll-behavior: none;
    overflow: hidden;
}

/* Космические туманности */
.nebula {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.4;
    animation: nebulaFloat 20s infinite ease-in-out;
    pointer-events: none;
}

.nebula-1 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(147, 51, 234, 0.6) 0%, rgba(147, 51, 234, 0.2) 50%, transparent 100%);
    top: 10%;
    left: 10%;
    animation-duration: 25s;
    animation-delay: 0s;
}

.nebula-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.5) 0%, rgba(59, 130, 246, 0.15) 50%, transparent 100%);
    top: 60%;
    right: 15%;
    animation-duration: 30s;
    animation-delay: -5s;
}

.nebula-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(236, 72, 153, 0.4) 0%, rgba(236, 72, 153, 0.1) 50%, transparent 100%);
    bottom: 20%;
    left: 20%;
    animation-duration: 35s;
    animation-delay: -10s;
}

.nebula-4 {
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.45) 0%, rgba(168, 85, 247, 0.12) 50%, transparent 100%);
    top: 30%;
    right: 30%;
    animation-duration: 28s;
    animation-delay: -15s;
}

@keyframes nebulaFloat {
    0%, 100% {
        transform: translate(0, 0) scale(1);
    }
    25% {
        transform: translate(30px, -30px) scale(1.1);
    }
    50% {
        transform: translate(-20px, 20px) scale(0.9);
    }
    75% {
        transform: translate(20px, 30px) scale(1.05);
    }
}

.stars {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
    pointer-events: none;
    /* Оптимизация: убираем will-change для лучшей производительности */
    transform: translateZ(0);
    contain: layout style paint;
}

.star {
    position: absolute;
    border-radius: 50%;
    /* Оптимизация: убираем will-change, используем только для анимируемых */
    transform: translateZ(0);
    /* Базовый стиль - будет переопределен через inline стили */
    contain: layout style paint;
}

/* Уровни яркости - оптимизированные (упрощенные box-shadow, увеличенная яркость) */
.star[data-brightness="1"],
.star[data-brightness="2"] {
    width: 1.5px;
    height: 1.5px;
    /* Увеличенный box-shadow для большей яркости */
    box-shadow: 0 0 4px currentColor, 0 0 6px currentColor;
}

.star[data-brightness="3"],
.star[data-brightness="4"] {
    width: 2px;
    height: 2px;
    box-shadow: 0 0 5px currentColor, 0 0 8px currentColor;
}

.star[data-brightness="5"],
.star[data-brightness="6"] {
    width: 2.5px;
    height: 2.5px;
    box-shadow: 0 0 6px currentColor, 0 0 10px currentColor;
}

.star[data-brightness="7"],
.star[data-brightness="8"] {
    width: 3px;
    height: 3px;
    box-shadow: 0 0 8px currentColor, 0 0 12px currentColor;
}

.star[data-brightness="9"],
.star[data-brightness="10"] {
    width: 3.5px;
    height: 3.5px;
    box-shadow: 0 0 10px currentColor, 0 0 15px currentColor;
}

/* Оптимизированные анимации - только для самых ярких звезд */
/* Большинство звезд без анимации для лучшей производительности */
.star[data-brightness="1"],
.star[data-brightness="2"],
.star[data-brightness="3"],
.star[data-brightness="4"],
.star[data-brightness="5"],
.star[data-brightness="6"] {
    /* Анимации отключены для оптимизации */
    animation: none;
}

/* Только пульсары (яркие звезды) имеют анимацию */
.star.pulsar {
    animation: pulsar var(--pulsar-duration, 3s) infinite ease-in-out;
    will-change: opacity, transform;
}

@keyframes twinkleSlow {
    0%, 100% {
        opacity: 0.2;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(1.1);
    }
}

@keyframes twinkle {
    0%, 100% {
        opacity: 0.4;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.2);
    }
}

@keyframes twinkleFast {
    0%, 100% {
        opacity: 0.5;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.3);
    }
}

@keyframes pulsar {
    0%, 100% {
        opacity: 0.6;
        transform: scale(1);
        filter: brightness(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.4);
        filter: brightness(1.5);
    }
}

/* Дополнительный слой звездной пыли с цветными акцентами */
.star-field-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(2px 2px at 20% 30%, rgba(147, 51, 234, 0.4), transparent),
        radial-gradient(1px 1px at 50% 50%, rgba(59, 130, 246, 0.3), transparent),
        radial-gradient(2px 2px at 80% 70%, rgba(236, 72, 153, 0.35), transparent),
        radial-gradient(1px 1px at 30% 80%, rgba(168, 85, 247, 0.3), transparent),
        radial-gradient(1px 1px at 70% 20%, rgba(34, 197, 94, 0.25), transparent);
    background-size: 200% 200%, 150% 150%, 180% 180%, 170% 170%, 160% 160%;
    background-position: 0% 0%, 50% 50%, 100% 100%, 25% 75%, 75% 25%;
    animation: starFieldDrift 60s infinite linear;
    pointer-events: none;
    opacity: 0.5;
    z-index: 1;
}

@keyframes starFieldDrift {
    0% {
        background-position: 0% 0%, 50% 50%, 100% 100%, 25% 75%, 75% 25%;
    }
    100% {
        background-position: 100% 100%, 150% 150%, 200% 200%, 125% 175%, 175% 125%;
    }
}

/* Контейнер */
.container {
    position: relative;
    z-index: 1;
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 15px 20px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    min-height: 100vh;
    min-height: -webkit-fill-available;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    /* Оптимизация для Telegram Mini App */
    box-sizing: border-box;
}

/* Заголовок */
.cosmic-header {
    text-align: center;
    margin-bottom: 20px;
    width: 100%;
    padding-top: env(safe-area-inset-top, 0);
}

.cosmic-header h1 {
    font-size: clamp(1.5rem, 5vw, 2.5rem);
    font-weight: 700;
    margin-bottom: 8px;
    color: #ffffff;
    /* Упрощенный text-shadow */
    text-shadow: 0 0 10px rgba(0, 255, 255, 0.5);
    line-height: 1.2;
}

.cosmic-header .subtitle {
    font-size: clamp(0.85rem, 3vw, 1rem);
    opacity: 0.7;
    color: #cccccc;
    line-height: 1.4;
}

/* Убраны анимации glow для упрощения */

/* Кнопки (упрощенные) */
.cosmic-button {
    background: rgba(0, 100, 200, 0.8);
    border: 1px solid rgba(0, 255, 255, 0.5);
    border-radius: 8px;
    padding: 14px 24px;
    pointer-events: auto;
    color: #ffffff;
    font-size: clamp(0.95rem, 3.5vw, 1.1rem);
    font-weight: 600;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: background 0.2s ease, border-color 0.2s ease;
    /* Упрощенный box-shadow */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    text-transform: none;
    letter-spacing: 0.3px;
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 8px 0;
    display: block;
    /* Минимальный размер для touch-целей (44x44px) */
    min-height: 44px;
    box-sizing: border-box;
}

.cosmic-button:hover,
.cosmic-button:active {
    background: rgba(0, 120, 240, 0.9);
    border-color: rgba(0, 255, 255, 0.7);
}

.cosmic-button:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

@media (hover: hover) {
    .cosmic-button:hover {
        background: rgba(0, 120, 240, 0.9);
        border-color: rgba(0, 255, 255, 0.8);
    }
}

.cosmic-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(50, 50, 50, 0.8);
    border-color: rgba(100, 100, 100, 0.5);
}

.cosmic-button .button-text {
    position: relative;
    z-index: 1;
}

/* Ввод сообщения */
.message-input-container {
    width: 100%;
    max-width: 100%;
    margin: 15px 0;
    position: relative;
    box-sizing: border-box;
}

#messageInput {
    width: 100%;
    padding: 14px;
    border: 1px solid rgba(0, 255, 255, 0.4);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    font-size: clamp(0.95rem, 3.5vw, 1rem);
    font-family: 'Orbitron', monospace;
    resize: vertical;
    min-height: 100px;
    max-height: 200px;
    /* Упрощенный box-shadow */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    /* Убраны transition для предотвращения дергания */
    transition: none;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
    touch-action: manipulation;
    /* Исправление курсора */
    caret-color: #00ffff;
    cursor: text;
    /* Оптимизация производительности - убраны will-change и contain для стабильности */
    /* Предотвращение смещения при открытии клавиатуры */
    position: relative;
    z-index: 1;
}

#messageInput:focus {
    outline: none;
    border-color: rgba(0, 255, 255, 0.7);
    /* Упрощенный box-shadow */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.char-counter {
    position: absolute;
    bottom: 10px;
    right: 15px;
    font-size: clamp(0.75rem, 3vw, 0.85rem);
    color: #cccccc;
    opacity: 0.6;
    pointer-events: none;
}

/* Бинарная визуализация (упрощенная) */
.binary-viz-container {
    width: 100%;
    max-width: 100%;
    margin: 15px 0;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 8px;
    min-height: 80px;
    max-height: 180px;
    overflow-y: auto;
    box-sizing: border-box;
    /* Оптимизация скролла для мобильных */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.binary-visualization {
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    line-height: 1.8;
    color: #00ffff;
    word-break: break-all;
    letter-spacing: 0.5px;
    /* Оптимизация производительности */
    will-change: contents;
    contain: layout style;
}

/* Красивые строки бинарного кода */
.binary-line {
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-size: clamp(0.75rem, 2.5vw, 0.85rem);
    line-height: 1.8;
    word-break: break-all;
    margin: 4px 0;
    padding: 2px 0;
    letter-spacing: 0.5px;
    /* Минимальные стили для лучшей производительности */
    contain: layout style;
    /* Убрана анимация появления для предотвращения дергания */
    animation: none;
}

/* Стили для отдельных битов */
.binary-bit {
    display: inline-block;
    padding: 2px 3px;
    margin: 0 1px;
    border-radius: 3px;
    font-weight: 600;
    /* Убраны transition для предотвращения дергания */
    transition: none;
    /* Оптимизация */
    contain: layout style;
}

/* Бит 0 - темный/серый (упрощенный) */
.binary-bit-0 {
    color: #888;
    background: rgba(102, 102, 102, 0.1);
    text-shadow: none;
}

/* Бит 1 - яркий циан (упрощенный) */
.binary-bit-1 {
    color: #00ccff;
    background: rgba(0, 255, 255, 0.15);
    text-shadow: 0 0 4px rgba(0, 255, 255, 0.5);
    box-shadow: none;
}

/* Упрощенные эффекты при наведении (только для десктопа) */
@media (hover: hover) {
    .binary-bit-1:hover {
        background: rgba(0, 255, 255, 0.2);
    }
    
    .binary-bit-0:hover {
        background: rgba(102, 102, 102, 0.15);
    }
}

/* Медиа-запросы для оптимизации под Telegram Mini App */
@media (max-width: 480px) {
    .container {
        padding: 12px 15px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
    }
    
    .cosmic-header {
        margin-bottom: 15px;
    }
    
    .message-input-container {
        margin: 12px 0;
    }
    
    .cosmic-button {
        margin: 6px 0;
        padding: 12px 20px;
    }
}

/* Оптимизация производительности анимаций */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.binary-bit {
    display: inline-block;
    padding: 2px 4px;
    margin: 2px;
    border-radius: 3px;
    transition: all 0.2s ease;
}

.binary-bit.active {
    background: #00ffff;
    color: #000;
    box-shadow: 0 0 10px #00ffff;
    transform: scale(1.2);
}

.binary-bit.bit-0 {
    color: #666;
}

.binary-bit.bit-1 {
    color: #00ffff;
    text-shadow: 0 0 5px #00ffff;
}

.hint {
    color: #666;
    font-style: italic;
    text-align: center;
    padding: 20px;
}

/* Страницы */
.page {
    display: none;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Динамическая высота viewport */
    height: -webkit-fill-available;
    /* Предотвращение смещения при открытии клавиатуры */
    position: relative;
    overflow-y: auto;
    overflow-x: hidden;
    /* Оптимизация скролла для мобильных */
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.page.active {
    display: flex;
    flex-direction: column;
}

/* Камера */
.camera-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow: hidden;
}

#cameraView {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    z-index: 1;
}

.camera-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 20px;
    z-index: 10;
    pointer-events: none;
}

.cosmic-instruction {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: transparent;
    border: none;
}

.cosmic-instruction h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
    text-shadow: 0 0 20px #00ffff;
}

.cosmic-instruction p {
    font-size: 1.1rem;
    color: #00ffff;
    opacity: 0.9;
}


.flashlight {
    position: absolute;
    width: 100%;
    height: 100%;
    background: #ffffff;
    opacity: 0;
    transition: opacity 0.1s ease;
    pointer-events: none;
    z-index: 20;
}

.flashlight.active {
    opacity: 1;
}

.flashlight.hidden {
    display: none;
}

.back-button {
    position: absolute;
    top: calc(20px + env(safe-area-inset-top, 0));
    left: calc(20px + env(safe-area-inset-left, 0));
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #00ffff;
    border-radius: 10px;
    padding: 12px 18px;
    color: #00ffff;
    font-size: clamp(0.9rem, 3vw, 1rem);
    min-height: 44px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    z-index: 100;
    cursor: pointer;
    transition: all 0.2s ease;
    box-sizing: border-box;
    pointer-events: auto;
}

.back-button:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

/* Отчет */
.report-content {
    text-align: center;
    padding: 20px;
}

.success-icon {
    margin: 0 0 20px 0;
}

.pulsing-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0066ff, #00ffff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    color: #ffffff;
    margin: 0 auto;
    animation: pulse 2s infinite;
    box-shadow: 0 0 40px rgba(0, 255, 255, 0.8);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 40px rgba(0, 255, 255, 0.8);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 60px rgba(0, 255, 255, 1);
    }
}

.report-title {
    font-size: 2rem;
    margin: 0 0 20px 0;
    text-shadow: 0 0 20px #00ffff;
}

.report-card {
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #00ffff;
    border-radius: 15px;
    padding: 30px 20px;
    margin: 20px 0;
}

.report-enhanced {
    border: 3px solid #ffd700 !important;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6), inset 0 0 20px rgba(255, 215, 0, 0.1) !important;
    background: rgba(0, 0, 0, 0.8) !important;
    text-align: center;
}

.report-section {
    margin: 15px 0;
    padding: 15px;
    background: rgba(0, 255, 255, 0.1);
    border-radius: 10px;
    border-left: 4px solid #00ffff;
    text-align: left;
}

.report-section h3 {
    color: #00ffff;
    margin-bottom: 10px;
    font-size: 1.2rem;
}

.report-text {
    color: #ffffff;
    font-size: 1rem;
    line-height: 1.6;
}

.cosmic-message {
    margin: 30px 0;
    padding: 20px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 15px;
    border: 2px solid #00ffff;
}

.message-main {
    font-size: 1.5rem;
    margin: 0 0 20px 0;
    font-weight: bold;
    color: #ffffff;
}


@keyframes fade-in-glow {
    from {
        opacity: 0;
        transform: translateX(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.message-sub {
    font-size: 1.2rem;
    opacity: 0.8;
    font-style: italic;
}

.galaxy-choice-container {
    margin-top: 30px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 15px;
    border: 2px solid #00ffff;
}

.galaxy-choice-btn {
    margin: 10px 0;
}

.restart-btn {
    background: linear-gradient(135deg, #666 0%, #444 100%);
}

/* Галактика */
.galaxy-container {
    position: relative;
    width: 100%;
    height: 100vh;
    height: 100dvh; /* Динамическая высота для мобильных */
    overflow: hidden;
    /* Космический фон для галактики */
    background: 
        radial-gradient(ellipse at center, #0a0a1a 0%, #000000 50%, #000000 100%),
        radial-gradient(ellipse at top left, rgba(147, 51, 234, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at bottom right, rgba(59, 130, 246, 0.12) 0%, transparent 50%);
    background-size: 100% 100%, 60% 60%, 50% 50%;
    background-attachment: fixed;
}

.galaxy-header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 15px;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
}

.galaxy-back-btn {
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #00ffff;
    border-radius: 10px;
    padding: 10px 20px;
    color: #00ffff;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.galaxy-back-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

.galaxy-menu-btn {
    background: linear-gradient(135deg, #0066ff 0%, #0044cc 100%);
    border: 2px solid #00ffff;
    border-radius: 10px;
    padding: 10px 20px;
    color: #ffffff;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.galaxy-menu-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.6);
}

.galaxy-music-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.music-toggle-btn {
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #00ffff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
}

.music-toggle-btn:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
}

/* Визуализация передачи */

/* Визуализация бинарных битов в квадратиках */
.camera-binary-display {
    position: absolute;
    top: 10%;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 500px;
    max-height: 60vh;
    background: rgba(0, 0, 0, 0.9);
    border: 2px solid #00ffff;
    border-radius: 10px;
    padding: 15px;
    z-index: 200;
    display: none;
    overflow: hidden;
    box-shadow: 0 0 30px rgba(0, 255, 255, 0.5);
    box-sizing: border-box;
}

.binary-bits-container {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-height: calc(25vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
    margin-bottom: 15px;
}

.camera-binary-bit {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-family: 'Courier New', monospace;
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.5);
    color: #666;
    transition: all 0.2s ease;
}

.camera-binary-bit.bit-1 {
    color: #00ffff;
    text-shadow: 0 0 5px #00ffff;
}

.camera-binary-bit.active {
    background: #00ffff;
    color: #000;
    box-shadow: 0 0 15px #00ffff;
    transform: scale(1.2);
    border-color: #00ffff;
}

.binary-bits-container::-webkit-scrollbar {
    width: 6px;
}

.binary-bits-container::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 255, 0.5);
    border-radius: 3px;
}

.binary-bits-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

/* Контейнер для текста сообщения */
.message-text-container {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    max-height: calc(25vh - 60px);
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    margin-top: 20px;
    padding: 8px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    border: 1px solid rgba(0, 255, 255, 0.2);
    align-items: flex-start;
    align-content: flex-start;
    width: 100%;
    box-sizing: border-box;
}

.message-text-char {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 6px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    color: #666;
    border: 1px solid rgba(0, 255, 255, 0.2);
    border-radius: 4px;
    background: rgba(0, 0, 0, 0.4);
    transition: all 0.2s ease;
    min-width: 22px;
    min-height: 28px;
    max-width: 100%;
    text-align: center;
    box-sizing: border-box;
    flex-shrink: 0;
    line-height: 1.2;
    word-break: break-all;
    overflow: hidden;
}

.message-text-char.active {
    background: #00ffff;
    color: #000;
    box-shadow: 0 0 15px #00ffff;
    transform: scale(1.15);
    border-color: #00ffff;
    font-weight: bold;
}

.message-text-char.completed {
    color: #00ffff;
    text-shadow: 0 0 5px #00ffff;
    border-color: rgba(0, 255, 255, 0.5);
}

.message-text-container::-webkit-scrollbar {
    width: 6px;
}

.message-text-container::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 255, 0.5);
    border-radius: 3px;
}

.message-text-container::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

/* Модальное окно магазина */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    overflow: hidden;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-overlay {
    display: flex;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: linear-gradient(135deg, #0a0a2a 0%, #000000 100%);
    border: 2px solid #00ffff;
    border-radius: 20px;
    padding: 20px;
    max-width: 90%;
    max-height: 90vh;
    width: 600px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 0 50px rgba(0, 255, 255, 0.5);
    position: relative;
    overflow: hidden;
    overflow-y: auto;
    pointer-events: auto;
    z-index: 10001;
    box-sizing: border-box;
}

/* Специальные стили для модального окна усиления намерения */
#enhanceIntentionModal .modal-content {
    background: rgba(10, 10, 15, 0.95);
    border: 2px solid #ffd700;
    border-radius: 15px;
    padding: 20px;
    max-width: calc(100% - 30px);
    width: 100%;
    max-width: 400px;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

#enhanceIntentionModal .modal-content h2 {
    color: #ffd700;
    margin-bottom: 15px;
    margin-top: 0;
    text-align: center;
    font-size: clamp(1.2rem, 4vw, 1.5rem);
    line-height: 1.3;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#enhanceIntentionModal .modal-content p {
    color: #cccccc;
    margin-bottom: 15px;
    margin-top: 0;
    text-align: center;
    font-size: clamp(0.85rem, 3vw, 0.9rem);
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
    padding: 0 5px;
}

#enhanceIntentionModal .modal-content > div {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: nowrap;
}

#enhanceIntentionModal .modal-content input[type="number"] {
    flex: 1;
    min-width: 0;
    padding: 12px;
    border: 2px solid rgba(255, 215, 0, 0.5);
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.5);
    color: #ffd700;
    font-size: clamp(1rem, 4vw, 1.2rem);
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
    pointer-events: auto;
    touch-action: manipulation;
    box-sizing: border-box;
    width: 100%;
}

#enhanceIntentionModal .modal-content > div > span {
    color: #ffd700;
    font-weight: bold;
    flex-shrink: 0;
    font-size: clamp(1.2rem, 4vw, 1.5rem);
}

#enhanceIntentionModal .modal-content button.cosmic-button {
    width: 100%;
    margin-top: 0;
    box-sizing: border-box;
}

#enhanceIntentionModal #closeModalBtn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    border: none;
    color: #ffd700;
    font-size: 24px;
    cursor: pointer;
    padding: 5px 10px;
    z-index: 10002;
    line-height: 1;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content input {
    pointer-events: auto !important;
    touch-action: manipulation !important;
    -webkit-user-select: text !important;
    user-select: text !important;
    z-index: 10002 !important;
}

.modal-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(0, 255, 255, 0.1) 0%, transparent 70%);
    animation: rotate 20s linear infinite;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid rgba(0, 255, 255, 0.3);
    position: relative;
    z-index: 1;
}

.modal-header h2 {
    font-size: 1.8rem;
    color: #00ffff;
    text-shadow: 0 0 20px #00ffff;
}

.modal-close {
    background: transparent;
    border: 2px solid #00ffff;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: #00ffff;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.modal-close:hover {
    background: rgba(0, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(0, 255, 255, 0.5);
    transform: rotate(90deg);
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    position: relative;
    z-index: 1;
}

.modal-footer {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 2px solid rgba(0, 255, 255, 0.3);
    position: relative;
    z-index: 1;
}

.shop-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.shop-3d-preview {
    width: 100%;
    height: 300px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(0, 255, 255, 0.3);
    border-radius: 15px;
    overflow: hidden;
    position: relative;
}

#starPreviewCanvas {
    width: 100%;
    height: 100%;
    display: block;
}

.shop-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.shop-levels {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.shop-level {
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(0, 255, 255, 0.3);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.shop-level:hover {
    border-color: #00ffff;
    box-shadow: 0 0 20px rgba(0, 255, 255, 0.5);
    transform: translateY(-3px);
}

.shop-level.selected {
    border-color: #ffd700;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.8);
    background: rgba(255, 215, 0, 0.1);
}

.level-emoji {
    font-size: 2rem;
    margin-bottom: 8px;
}

.level-name {
    font-size: 0.9rem;
    color: #00ffff;
    margin-bottom: 5px;
    font-weight: bold;
}

.level-price {
    font-size: 0.85rem;
    color: #ffd700;
    font-weight: bold;
}

.shop-custom {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid rgba(0, 255, 255, 0.3);
    border-radius: 10px;
}

.shop-custom label {
    font-size: 0.9rem;
    color: #00ffff;
    white-space: nowrap;
}

#shopCustomInput {
    flex: 1;
    padding: 10px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.5);
    color: #00ffff;
    font-size: 1rem;
}

.shop-selected {
    padding: 15px;
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid #00ffff;
    border-radius: 10px;
    text-align: center;
}

.selected-name {
    font-size: 1.2rem;
    color: #ffd700;
    font-weight: bold;
    margin-bottom: 5px;
}

.selected-price {
    font-size: 1rem;
    color: #00ffff;
}

/* Донат секция */
.donation-section {
    width: 100%;
    max-width: 400px;
    margin: 20px 0;
}

.donation-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.custom-donation {
    display: flex;
    align-items: center;
    gap: 10px;
}

.custom-donation label {
    font-size: 0.9rem;
    color: #00ffff;
    white-space: nowrap;
}

.custom-donation input {
    padding: 8px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.5);
    color: #00ffff;
    font-size: 1rem;
}

/* Поле ввода суммы доната - улучшенная видимость при открытии клавиатуры */
#donationAmountInput {
    padding: 10px;
    border: 1px solid rgba(0, 255, 255, 0.3);
    border-radius: 5px;
    background: rgba(0, 0, 0, 0.5);
    color: #00ffff;
    font-size: 1rem;
    position: relative;
    z-index: 10;
}

/* Форма доната - улучшенное позиционирование */
.donation-form {
    position: relative;
    z-index: 5;
    scroll-margin-top: 20px;
    scroll-margin-bottom: 20px;
}

.currency {
    color: #ffd700;
    font-weight: bold;
}

.selected-star-preview {
    padding: 15px;
    background: rgba(0, 255, 255, 0.1);
    border: 2px solid #00ffff;
    border-radius: 10px;
}

.star-preview-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.star-preview-emoji {
    font-size: 2.5rem;
}

.star-preview-info {
    flex: 1;
}

.star-preview-name {
    font-size: 1.2rem;
    color: #ffd700;
    font-weight: bold;
    margin-bottom: 5px;
}

.star-preview-desc {
    font-size: 0.9rem;
    color: #00ffff;
}

/* Эзотерические сообщения */
.esoteric-message {
    text-align: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 15px;
    border: 1px solid rgba(0, 255, 255, 0.3);
}

.mystical-symbol {
    font-size: 3rem;
    margin-bottom: 15px;
    animation: rotate 10s linear infinite;
}

.mystical-quote {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #00ffff;
    margin: 10px 0;
    font-style: italic;
}

/* Улучшенные анимации для метеоров и комет */
@keyframes meteorFall {
    0% {
        transform: translate(0, 0) rotate(var(--meteor-angle, 45deg));
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translate(calc(100vw + 200px), calc(100vh + 200px)) rotate(var(--meteor-angle, 45deg));
        opacity: 0;
    }
}

@keyframes cometFly {
    0% {
        transform: translate(0, 0) rotate(var(--comet-angle, 20deg));
        opacity: 0;
    }
    15% {
        opacity: 1;
    }
    85% {
        opacity: 1;
    }
    100% {
        transform: translate(calc(100vw + 300px), calc(100vh + 300px)) rotate(var(--comet-angle, 20deg));
        opacity: 0;
    }
}

/* Стили для метеоров */
.meteor-shower {
    position: absolute;
    pointer-events: none;
    z-index: 5;
    will-change: transform, opacity;
}

.meteor-core {
    position: relative;
    z-index: 2;
    filter: blur(0.5px);
}

.meteor-tail {
    position: absolute;
    filter: blur(1px);
}

/* Стили для комет */
.comet-shower {
    position: absolute;
    pointer-events: none;
    z-index: 5;
    will-change: transform, opacity;
}

.comet-core {
    position: relative;
    z-index: 2;
    filter: blur(1px);
}

.comet-tail {
    position: absolute;
    filter: blur(2px);
}

/* Скроллбар */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.3);
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 255, 255, 0.5);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 255, 255, 0.7);
}

/* Tooltip для сообщений */
.message-tooltip {
    position: fixed;
    background: linear-gradient(135deg, rgba(20, 20, 40, 0.95) 0%, rgba(30, 30, 60, 0.95) 100%);
    border: 2px solid rgba(0, 255, 255, 0.5);
    border-radius: 12px;
    padding: 20px;
    max-width: 90%;
    max-width: min(90%, 500px);
    z-index: 10000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 20px rgba(0, 255, 255, 0.3);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: auto;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.tooltip-message {
    color: #ffffff;
    font-size: 1rem;
    line-height: 1.6;
    margin: 0;
    padding-right: 40px; /* Отступ справа, чтобы крестик не накладывался на текст */
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: break-word;
}

.tooltip-close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    color: #00ffff;
    cursor: pointer;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(0, 255, 255, 0.1);
    transition: all 0.2s ease;
    user-select: none;
    -webkit-user-select: none;
}

.tooltip-close:hover {
    background: rgba(0, 255, 255, 0.3);
    transform: scale(1.1);
}

.tooltip-close:active {
    transform: scale(0.95);
}

/* На мобильных устройствах */
@media (max-width: 768px) {
    .message-tooltip {
        padding: 15px;
        font-size: 0.9rem;
        max-width: 85%;
    }
    
    .tooltip-message {
        font-size: 0.9rem;
    }
    
    .tooltip-close {
        width: 35px;
        height: 35px;
        font-size: 28px;
        top: 5px;
        right: 5px;
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    .cosmic-header h1 {
        font-size: 2rem;
    }
    
    .cosmic-button {
        padding: 12px 20px;
        font-size: 1rem;
    }
    
    .shop-levels {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .modal-content {
        max-width: 95%;
        padding: 15px;
    }
    
    /* Мобильные стили для модального окна усиления намерения */
    #enhanceIntentionModal .modal-content {
        max-width: calc(100% - 20px);
        padding: 15px;
        margin: 10px;
    }
    
    #enhanceIntentionModal .modal-content h2 {
        font-size: 1.2rem;
        margin-bottom: 12px;
        padding: 0;
    }
    
    #enhanceIntentionModal .modal-content p {
        font-size: 0.85rem;
        margin-bottom: 12px;
        padding: 0 3px;
    }
    
    #enhanceIntentionModal .modal-content > div {
        margin-bottom: 12px;
        gap: 8px;
    }
    
    #enhanceIntentionModal .modal-content input[type="number"] {
        padding: 10px;
        font-size: 1rem;
    }
    
    #enhanceIntentionModal #closeModalBtn {
        top: 5px;
        right: 5px;
        font-size: 20px;
        padding: 5px;
        min-width: 35px;
        min-height: 35px;
    }
    
    .shop-3d-preview {
        height: 250px;
    }
}
