@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Crimson+Text:ital,wght@0,400;0,600;1,400&display=swap');

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

body {
    font-family: 'Crimson Text', serif;
    background: linear-gradient(135deg, #0a0a0a 0%, #1a0d2e 30%, #16213e 60%, #0a0a0a 100%);
    color: #e8e3d3;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow-x: hidden;
}

/* Мистические частицы на фоне */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 20% 30%, rgba(187, 134, 252, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 70%, rgba(255, 215, 0, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 40% 80%, rgba(138, 43, 226, 0.04) 0%, transparent 50%);
    animation: mysticalFloat 20s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: -1;
}

@keyframes mysticalFloat {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(-10px, -10px) rotate(1deg); }
}

/* Звездное небо */
.stars {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.star {
    position: absolute;
    background: #fff;
    border-radius: 50%;
    animation: twinkle 3s ease-in-out infinite alternate;
}

.star:nth-child(1) { top: 20%; left: 20%; width: 1px; height: 1px; animation-delay: 0s; }
.star:nth-child(2) { top: 30%; left: 80%; width: 2px; height: 2px; animation-delay: 1s; }
.star:nth-child(3) { top: 70%; left: 30%; width: 1px; height: 1px; animation-delay: 2s; }
.star:nth-child(4) { top: 10%; left: 60%; width: 1.5px; height: 1.5px; animation-delay: 0.5s; }
.star:nth-child(5) { top: 80%; left: 70%; width: 1px; height: 1px; animation-delay: 1.5s; }

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

/* Заголовки */
h1 {
    font-family: 'Cinzel', serif;
    font-size: 3.5rem;
    font-weight: 700;
    background: linear-gradient(45deg, #bb86fc, #ffd700, #9c5dfc);
    background-size: 200% 200%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: mysticalGlow 3s ease-in-out infinite alternate;
    text-shadow: 0 0 30px rgba(187, 134, 252, 0.3);
    margin-bottom: 1rem;
    text-align: center;
    letter-spacing: 0.1em;
}

@keyframes mysticalGlow {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

h2 {
    font-family: 'Cinzel', serif;
    font-size: 2.2rem;
    font-weight: 600;
    color: #e8e3d3;
    margin-bottom: 1.5rem;
    text-align: center;
    text-shadow: 0 0 20px rgba(232, 227, 211, 0.3);
}

/* Основной контент */
.container {
    text-align: center;
    max-width: 600px;
    margin: 0 auto;
    padding: 2rem;
    position: relative;
}

p {
    font-size: 1.3rem;
    line-height: 1.6;
    margin-bottom: 2.5rem;
    opacity: 0.9;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

em {
    color: #bb86fc;
    font-style: italic;
    font-weight: 600;
}

/* Кнопки */
.button {
    display: inline-block;
    background: linear-gradient(45deg, #bb86fc, #9c5dfc);
    color: #0a0a0a;
    padding: 1.2em 2.5em;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    font-family: 'Cinzel', serif;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    box-shadow: 
        0 8px 25px rgba(187, 134, 252, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.button:hover::before {
    left: 100%;
}

.button:hover {
    background: linear-gradient(45deg, #9c5dfc, #8b4cf9);
    transform: translateY(-2px);
    box-shadow: 
        0 12px 35px rgba(187, 134, 252, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.button:active {
    transform: translateY(0);
    box-shadow: 
        0 5px 15px rgba(187, 134, 252, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

/* Отладочная информация */
#debugInfo {
    position: fixed;
    bottom: 20px;
    left: 20px;
    font-size: 0.9rem;
    opacity: 0.6;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: 1px solid rgba(187, 134, 252, 0.2);
}

/* Анимация появления */
.fade-in {
    animation: fadeIn 1s ease-in-out;
}

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

/* Мистические эффекты для контента */
.mystical-card {
    background: rgba(16, 21, 46, 0.3);
    border: 1px solid rgba(187, 134, 252, 0.2);
    border-radius: 20px;
    padding: 2rem;
    backdrop-filter: blur(10px);
    box-shadow: 
        0 8px 32px rgba(0, 0, 0, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.mystical-card::before {
    content: '';
    position: absolute;
    top: -2px;
    left: -2px;
    right: -2px;
    bottom: -2px;
    background: linear-gradient(45deg, #bb86fc, #ffd700, #9c5dfc, #bb86fc);
    background-size: 400% 400%;
    border-radius: 20px;
    z-index: -1;
    animation: mysticalBorder 8s ease-in-out infinite;
    opacity: 0.3;
}

@keyframes mysticalBorder {
    0%, 100% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
}

/* Адаптивность */
@media (max-width: 768px) {
    h1 {
        font-size: 2.5rem;
    }
    
    h2 {
        font-size: 1.8rem;
    }
    
    p {
        font-size: 1.1rem;
    }
    
    .container {
        padding: 1rem;
    }
    
    .button {
        padding: 1em 2em;
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 2rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    p {
        font-size: 1rem;
    }
    
    .button {
        padding: 0.8em 1.8em;
        font-size: 0.9rem;
    }
}

/* ===== TMA СТИЛИ ===== */

/* Контейнер TMA */
.tma-container {
    max-width: 600px;
    margin: 0 auto;
    padding: 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Приветствие */
.greeting {
    font-family: 'Cinzel', serif;
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: 2rem;
    text-align: center;
    color: #e8e3d3;
    background: linear-gradient(45deg, #bb86fc, #ffd700);
    background-size: 200% 200%;
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    animation: mysticalGlow 3s ease-in-out infinite alternate;
}

.greeting-subtitle {
    font-size: 1rem;
    color: #a0aec0;
    text-align: center;
    margin-bottom: 3rem;
    font-style: italic;
}

/* Выбор формата */
.format-selection {
    margin-bottom: 3rem;
}

.format-selection h3 {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: #e8e3d3;
    margin-bottom: 1.5rem;
    text-align: center;
}

.format-chips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 15px;
    margin-bottom: 2rem;
}

.format-chip {
    padding: 15px 20px;
    border: 2px solid #6b46c1;
    border-radius: 12px;
    background: rgba(107, 70, 193, 0.1);
    color: #e8e3d3;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    text-align: center;
    backdrop-filter: blur(10px);
}

.format-chip.selected {
    background: linear-gradient(135deg, #6b46c1, #9f7aea);
    color: white;
    box-shadow: 0 8px 25px rgba(107, 70, 193, 0.3);
    transform: translateY(-2px);
}

.format-chip:hover:not(.selected) {
    background: rgba(107, 70, 193, 0.2);
    border-color: #9f7aea;
    transform: translateY(-1px);
}

/* Селект периода */
.period-select {
    display: none;
    margin-top: 1.5rem;
    text-align: center;
}

.period-select.show {
    display: block;
}

.period-select select {
    width: 100%;
    max-width: 300px;
    padding: 12px 15px;
    border: 2px solid #6b46c1;
    border-radius: 8px;
    background: rgba(45, 55, 72, 0.8);
    color: #e8e3d3;
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    backdrop-filter: blur(10px);
}

.period-select select:focus {
    outline: none;
    border-color: #9f7aea;
    box-shadow: 0 0 0 3px rgba(107, 70, 193, 0.1);
}

/* Секция вопроса */
.question-section {
    margin-bottom: 3rem;
}

.question-section h3 {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: #e8e3d3;
    margin-bottom: 1.5rem;
    text-align: center;
}

.question-input {
    width: 100%;
    min-height: 120px;
    padding: 20px;
    border: 2px solid #6b46c1;
    border-radius: 12px;
    background: rgba(45, 55, 72, 0.8);
    color: #e8e3d3;
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    resize: vertical;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
}

.question-input:focus {
    outline: none;
    border-color: #9f7aea;
    box-shadow: 0 0 0 3px rgba(107, 70, 193, 0.1);
}

.question-input::placeholder {
    color: #a0aec0;
    font-style: italic;
}

/* Подсказки */
.question-hints {
    margin-top: 1.5rem;
}

.question-hints p {
    color: #a0aec0;
    margin-bottom: 1rem;
    text-align: center;
    font-style: italic;
}

.hint-chips {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.hint-chip {
    padding: 8px 16px;
    border: 1px solid #6b46c1;
    border-radius: 20px;
    background: transparent;
    color: #a0aec0;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    font-family: 'Crimson Text', serif;
}

.hint-chip:hover {
    background: rgba(107, 70, 193, 0.2);
    color: #e8e3d3;
    border-color: #9f7aea;
}

/* CTA кнопка */
.cta-button {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, #6b46c1, #9f7aea);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Cinzel', serif;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    box-shadow: 0 4px 15px rgba(107, 70, 193, 0.3);
}

.cta-button:disabled {
    background: #4a5568;
    cursor: not-allowed;
    opacity: 0.6;
    box-shadow: none;
}

.cta-button:not(:disabled):hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(107, 70, 193, 0.4);
}

/* Капсула с параметрами */
.capsule {
    display: none;
    background: rgba(107, 70, 193, 0.1);
    border: 1px solid #6b46c1;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 2rem;
    backdrop-filter: blur(10px);
}

.capsule.show {
    display: block;
    animation: fadeInUp 0.5s ease;
}

.capsule-content {
    color: #e8e3d3;
    font-size: 1rem;
    line-height: 1.6;
}

/* Состояние печатания духа */
.spirit-typing {
    display: none;
    text-align: center;
    padding: 40px 20px;
    color: #a0aec0;
    font-style: italic;
    font-size: 1.1rem;
}

.spirit-typing.show {
    display: block;
    animation: fadeIn 0.5s ease;
}

/* Сообщения об ошибках */
.error-message {
    color: #fc8181;
    margin-top: 1rem;
    font-size: 0.9rem;
    text-align: center;
    padding: 10px;
    background: rgba(252, 129, 129, 0.1);
    border-radius: 8px;
    border: 1px solid rgba(252, 129, 129, 0.3);
}

/* Состояние загрузки */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Анимации */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    .tma-container {
        padding: 15px;
    }
    
    .greeting {
        font-size: 2rem;
    }
    
    .format-chips {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    
    .format-chip {
        padding: 12px 15px;
        font-size: 0.9rem;
    }
    
    .hint-chips {
        flex-direction: column;
        align-items: center;
    }
    
    .hint-chip {
        width: 100%;
        max-width: 300px;
        text-align: center;
    }
}

/* Скелетные плейсхолдеры */
.skeleton {
    background: linear-gradient(90deg, #2d3748 25%, #4a5568 50%, #2d3748 75%);
    background-size: 200% 100%;
    animation: skeletonLoading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 1rem;
    margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
    width: 60%;
}

@keyframes skeletonLoading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ===== ЭКРАН 2 - ЧТЕНИЕ ===== */

/* Форматы карт */
.format-chips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 20px;
    margin-bottom: 2rem;
}

.format-chip {
    padding: 20px;
    border: 2px solid #6b46c1;
    border-radius: 16px;
    background: rgba(107, 70, 193, 0.1);
    color: #e8e3d3;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: 'Crimson Text', serif;
    text-align: center;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.format-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.format-name {
    font-family: 'Cinzel', serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: #e8e3d3;
}

.format-desc {
    font-size: 0.85rem;
    color: #a0aec0;
    line-height: 1.3;
}

.format-chip.selected {
    background: linear-gradient(135deg, #6b46c1, #9f7aea);
    color: white;
    box-shadow: 0 8px 25px rgba(107, 70, 193, 0.3);
    transform: translateY(-2px);
}

.format-chip.selected .format-desc {
    color: rgba(255, 255, 255, 0.8);
}

.format-chip:hover:not(.selected) {
    background: rgba(107, 70, 193, 0.2);
    border-color: #9f7aea;
    transform: translateY(-1px);
}

/* Переключатель тона */
.tone-chips {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.tone-chip {
    padding: 8px 16px;
    border: 1px solid #6b46c1;
    border-radius: 20px;
    background: transparent;
    color: #a0aec0;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    font-family: 'Crimson Text', serif;
}

.tone-chip.selected {
    background: rgba(107, 70, 193, 0.3);
    color: #e8e3d3;
    border-color: #9f7aea;
}

.tone-chip:hover:not(.selected) {
    background: rgba(107, 70, 193, 0.1);
    color: #e8e3d3;
}

/* Счётчик символов */
.char-counter {
    text-align: right;
    color: #a0aec0;
    font-size: 0.8rem;
    margin-top: 0.5rem;
    transition: color 0.3s ease;
}

.char-counter.warning {
    color: #f6ad55;
}

.char-counter.danger {
    color: #fc8181;
}

/* Адаптивность для экрана 2 */
@media (max-width: 768px) {
    .format-chips {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .format-chip {
        padding: 15px;
    }
    
    .format-icon {
        font-size: 1.5rem;
    }
    
    .format-name {
        font-size: 1rem;
    }
    
    .format-desc {
        font-size: 0.8rem;
    }
    
    .tone-chips {
        flex-direction: column;
        align-items: center;
    }
    
    .tone-chip {
        width: 100%;
        max-width: 200px;
        text-align: center;
    }
}
