:root {
    --primary: #6C63FF;
    --bg: #F0F4F8;
    --text: #2D3748;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    text-align: center;
}

header {
    display: flex;
    justify-content: space-between;
    padding: 15px 20px;
    background: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

.logo { font-weight: 900; font-size: 1.2rem; color: var(--primary); }
.parent-btn { background: none; border: 1px solid #ccc; padding: 5px 15px; border-radius: 15px; cursor: pointer; }

main { max-width: 600px; margin: 0 auto; padding: 20px; }

/* Управление экранами */
.hidden-view { display: none; }
.active-view { display: block; animation: fadeIn 0.4s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* СЕТКА */
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Всегда 2 колонки для крупных монстров */
    gap: 15px;
    margin-top: 20px;
}

/* КАРТОЧКИ МОНСТРОВ */
.card {
    background: white;
    padding: 15px;
    border-radius: 20px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
    border: 3px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
}
.card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.1); }

/* Картинки монстров */
.monster-img { width: 100px; height: 100px; margin-bottom: 10px; }
.label { font-weight: 800; font-size: 1.1rem; }

/* ШКАЛА СИЛЫ (Слайдер) */
.intensity-preview {
    margin-bottom: 30px;
}
#selected-monster-img {
    width: 120px;
    height: 120px;
}
.score-display {
    font-size: 2.5rem;
    font-weight: 900;
    color: var(--primary);
}

/* Сам ползунок */
input[type=range] {
    -webkit-appearance: none;
    width: 100%;
    height: 15px;
    border-radius: 10px;
    background: #d3d3d3;
    outline: none;
    margin: 20px 0;
}
input[type=range]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 4px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-weight: bold;
    color: #888;
    margin-bottom: 30px;
}

/* ДЫХАНИЕ */
.circle-container { height: 250px; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.breathe-circle { width: 120px; height: 120px; background: #A2D2FF; border-radius: 50%; animation: breathe 4s infinite ease-in-out; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.6); } }
#breathe-text { font-size: 1.5rem; margin-top: 20px; font-weight: bold; }

/* BUTTONS */
button { font-family: inherit; cursor: pointer; border: none; }
.primary-btn { background: var(--primary); color: white; padding: 15px 40px; font-size: 1.2rem; border-radius: 30px; width: 100%; margin-top: 10px; }
.back-btn { background: #CBD5E0; padding: 10px 20px; border-radius: 20px; margin-top: 15px; }
.danger-btn { background: #FF6B6B; color: white; padding: 10px 20px; border-radius: 20px; }

/* DASHBOARD */
.history-item { 
    background: white; padding: 15px; margin-bottom: 10px; border-radius: 15px; 
    text-align: left; border-left: 5px solid #ccc; 
}
.intensity-badge {
    background: #333; color: white; padding: 2px 8px; border-radius: 10px; font-size: 0.8rem; margin-left: 5px;
}
.success-img { width: 150px; }

/* СТИЛИ ДЛЯ ПЕЧАТИ (PDF) */
@media print {
    /* Скрываем всё лишнее */
    header, .dash-controls, .back-btn, #view-home, #view-intensity, #view-context, #view-breathe, #view-success {
        display: none !important;
    }
    /* Показываем только дашборд */
    main, #view-dashboard, .history-list, .stats-summary {
        display: block !important;
        visibility: visible !important;
    }
    /* Делаем список красивым для бумаги */
    .history-item {
        border: 1px solid #ddd;
        page-break-inside: avoid; /* Чтобы запись не рвалась между страницами */
        color: black;
    }
    body { background: white; }
}

@media print {
    /* Скрываем ВСЕ кнопки при печати */
    button {
        display: none !important;
    }
}

* АНАЛИТИКА И ГРАФИКИ */
.analytics-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
    margin-bottom: 30px;
}

.chart-box {
    background: white;
    border-radius: 20px;
    padding: 15px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
    flex: 1;
    min-width: 300px;
    
    /* --- ВОТ ЛЕКАРСТВО ОТ "ПОЛЗАНИЯ": --- */
    position: relative; /* Обязательно для Chart.js */
    height: 300px;      /* Фиксируем высоту намертво */
    overflow: hidden;   /* Если что-то вылезет - обрезаем */
    /* ------------------------------------- */
}
.chart-box h4 {
    margin-top: 0;
    color: #888;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Улучшаем печать графиков */
@media print {
    .analytics-container {
        display: block !important;
        page-break-inside: avoid;
    }
    .chart-box {
        box-shadow: none;
        border: 1px solid #eee;
        margin-bottom: 20px;
        page-break-inside: avoid;
    }
}


/* ПУПЫРКА (POP-IT) */
.popit-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr); /* 4 в ряд */
    gap: 15px;
    max-width: 350px;
    margin: 0 auto;
    padding: 20px;
    background: #FF6B6B; /* Цвет корпуса игрушки */
    border-radius: 30px;
    box-shadow: 0 10px 0 #D63031; /* Объем корпуса снизу */
}

.pop-bubble {
    width: 60px;
    height: 60px;
    background: radial-gradient(circle at 30% 30%, #54a0ff, #2e86de);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 5px 0 #1e3799, inset 0 5px 10px rgba(255,255,255,0.4);
    transition: all 0.1s;
    border: none;
    -webkit-tap-highlight-color: transparent; /* Убираем синюю подсветку на Андроиде */
}

/* Состояние "Лопнул" */
.pop-bubble.popped {
    background: #2e86de;
    transform: translateY(5px); /* Вдавливается */
    box-shadow: inset 0 5px 10px rgba(0,0,0,0.3); /* Тень внутри */
}


/* СОВЕТ ДНЯ */
.advice-card {
    background: #FFF3CD; /* Нежно-желтый */
    border-left: 5px solid #FFC107; /* Яркая полоска слева */
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 30px;
    text-align: left;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}
.advice-card h4 {
    margin: 0 0 10px 0;
    color: #856404; /* Темно-желтый текст */
    font-size: 1.1rem;
}
.advice-card p {
    margin: 0;
    color: #555;
    line-height: 1.5;
    font-style: italic;
}




/* Кнопка помощи в шапке */
.header-controls {
    display: flex;
    gap: 10px;
}
.help-btn {
    background: #E2E8F0;
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* МОДАЛЬНОЕ ОКНО (Фон) */
.modal {
    position: fixed;
    z-index: 1000; /* Поверх всего */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5); /* Полупрозрачный черный */
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 1;
    transition: opacity 0.3s;
}

/* Скрытое состояние */
.hidden-modal {
    display: none;
    opacity: 0;
}

/* Белая карточка внутри */
.modal-content {
    background-color: white;
    padding: 25px;
    border-radius: 20px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh; /* Чтобы не вылезало за экран на маленьких телефонах */
    overflow-y: auto; /* Прокрутка, если текст длинный */
    position: relative;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    text-align: left;
}

/* Крестик закрытия */
.close-btn {
    position: absolute;
    top: 10px;
    right: 20px;
    color: #aaa;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}
.close-btn:hover { color: black; }

/* Списки внутри помощи */
.install-guide ol { padding-left: 20px; margin-bottom: 20px; }
.install-guide li { margin-bottom: 10px; color: #444; }
.feature-list p { margin: 5px 0; }
hr { border: 0; border-top: 1px solid #eee; margin: 20px 0; }



/* Стили для модального окна */
.modal {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; justify-content: center; align-items: center;
}
.modal-content {
    background: white; padding: 30px; border-radius: 20px;
    width: 90%; max-width: 500px; position: relative;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.close-btn {
    position: absolute; top: 15px; right: 20px;
    font-size: 2rem; cursor: pointer; color: #aaa;
}
/* Для RTL (иврита) крестик должен быть слева */
body[dir="rtl"] .close-btn { right: auto; left: 20px; }
