* {
            box-sizing: border-box;
        }

        body {
            margin: 0;
            padding: 0;
            font-family: Arial, sans-serif;
            background: #f1f3f6;
            color: #222;
        }

        /* Затемнение фона */
        .modal {
            display: none;
            position: fixed;
            z-index: 1000;
            left: 0;
            top: 0;
            width: 100%;
            height: 100%;
            background: rgba(0, 0, 0, 0.65);

            align-items: center;
            justify-content: center;
            padding: 20px;
        }

        .modal.active {
            display: flex;
        }

        /* Окно */
        .modal-content {
            position: relative;

            width: 100%;
            max-width: 1600px;
            max-height: 90vh;

            background: white;
            border-radius: 20px;

            overflow: hidden;

            display: flex;

            box-shadow: 0 15px 50px rgba(0, 0, 0, 0.25);
        }

        /* Левая часть с картинкой */
        .question-image {
            width: 350px;
            flex-shrink: 0;

            display: flex;
            align-items: center;
            justify-content: center;

            padding: 20px;
            background: #f7f7f7;

            overflow: auto;
        }

        /*
            Картинка сохраняет свой исходный размер.
            Если она больше доступного места,
            max-width/max-height не дадут ей выйти
            за пределы блока.
        */
        .question-image img {
            width: auto;
            height: auto;

            max-width: 100%;
            max-height: 100%;

            display: block;
        }

        /* Правая часть */
        .question-body {
            flex: 1;

            padding: 35px 40px;

            overflow-y: auto;
        }

        /* Заголовок-вопрос */
        .question-title {
            display: inline-flex;
            align-items: center;
            gap: 10px;

            margin: 0 0 25px 0;
            padding: 13px 22px;

            border-radius: 12px;

            background: #222;
            color: white;

            font-size: 24px;
            font-weight: bold;
        }

        .question-title .icon {
            font-size: 26px;
        }

        .question-text {
            font-size: 18px;
            line-height: 1.5;
            margin-bottom: 12px;
        }

        .hint {
            font-size: 16px;
            font-style: italic;
            color: #666;
            margin-bottom: 15px;
        }

        /* Поля */
        textarea,
        input[type="text"] {
            width: 100%;

            border: 1px solid #ccc;
            border-radius: 10px;

            padding: 14px;

            font-family: inherit;
            font-size: 16px;

            outline: none;

            transition: 0.2s;
        }

        textarea {
            min-height: 120px;
            resize: vertical;
        }

        textarea:focus,
        input[type="text"]:focus {
            border-color: #555;
            box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.07);
        }

        .form-row {
            margin-bottom: 18px;
        }

        .form-row label {
            display: block;
            margin-bottom: 7px;

            font-size: 16px;
            font-weight: 600;
        }

        /* Кнопки навигации */
        .navigation {
            display: flex;
            justify-content: space-between;
            gap: 15px;

            margin-top: 30px;
        }

        .btn {
            border: none;
            border-radius: 10px;

            padding: 13px 25px;

            font-size: 16px;
            font-weight: bold;

            cursor: pointer;

            transition: 0.2s;
        }

        .btn:hover {
            transform: translateY(-1px);
        }

        .btn-back {
            background: #e5e5e5;
            color: #222;
        }

        .btn-next {
            background: #222;
            color: white;
            margin-left: auto;
        }

        .btn-finish {
            background: #2d7d46;
            color: white;
            margin-left: auto;
        }

        /* Прогресс */
        .progress-container {
            width: 100%;
            height: 8px;

            background: #e4e4e4;

            border-radius: 10px;

            margin-bottom: 25px;

            overflow: hidden;
        }

        .progress-bar {
            height: 100%;
            width: 10%;

            background: #222;

            transition: width 0.3s;
        }

        .progress-text {
            text-align: right;
            color: #777;
            font-size: 14px;
            margin-top: -18px;
            margin-bottom: 15px;
        }

        /* ==============================
           КАРУСЕЛЬ
           ============================== */

        .carousel-wrapper {
            position: relative;

            width: 100%;

            margin: 20px 0;
        }

        .carousel {
            display: flex;

            gap: 15px;

            overflow-x: auto;

            scroll-behavior: smooth;

            padding: 10px 5px 15px;

            scrollbar-width: thin;
        }

        .carousel::-webkit-scrollbar {
            height: 8px;
        }

        .carousel::-webkit-scrollbar-thumb {
            background: #aaa;
            border-radius: 10px;
        }

        .carousel-item {
            flex: 0 0 auto;

            height: 300px;

            border: 4px solid transparent;

            border-radius: 12px;

            overflow: hidden;

            cursor: pointer;

            transition: 0.2s;

            background: #eee;
        }

        .carousel-item img {
            display: block;

            height: 300px;
            width: auto;

            object-fit: contain;
        }

        .carousel-item:hover {
            transform: scale(1.02);
        }

        .carousel-item.selected {
            

            box-shadow:
                0 0 0 0px white,
                0 0 0 3px #39834b;
        }

        /* Стрелки карусели */
        .carousel-arrow {
            position: absolute;

            top: 50%;

            transform: translateY(-50%);

            width: 42px;
            height: 42px;

            border: none;

            border-radius: 50%;

            background: rgba(0, 0, 0, 0.75);

            color: white;

            font-size: 25px;

            cursor: pointer;

            z-index: 5;
        }

        .carousel-arrow.left {
            left: -5px;
        }

        .carousel-arrow.right {
            right: -5px;
        }

        /* ==============================
           РИСОВАНИЕ
           ============================== */

        .drawing-section {
            margin-top: 20px;
        }

        #drawingCanvas {
            display: block;

            width: 400px;
            height: 400px;

            max-width: 100%;

            background: white;

            border: 2px solid #222;

            border-radius: 5px;

            touch-action: none;

            cursor: crosshair;
        }

        .drawing-controls {
            display: flex;

            flex-wrap: wrap;

            gap: 8px;

            margin: 15px 0;
        }

        .color-button {
            width: 34px;
            height: 34px;

            border-radius: 50%;

            border: 2px solid #ccc;

            cursor: pointer;

            padding: 0;
        }

        .color-button.active {
            outline: 3px solid #222;
            outline-offset: 2px;
        }

        .color-black { background: black; }
        .color-red { background: red; }
        .color-blue { background: blue; }
        .color-green { background: green; }
        .color-yellow { background: yellow; }
        .color-purple { background: purple; }
        .color-orange { background: orange; }
        .color-pink { background: pink; }
        .color-white { background: white; }

        .clear-button {
            padding: 8px 15px;

            border: 1px solid #bbb;
            border-radius: 8px;

            background: #eee;

            cursor: pointer;
        }

        /* Финальное окно */
        .finish-screen {
            text-align: center;
            padding: 30px 10px;
        }

        .finish-screen h2 {
            font-size: 32px;
            margin-bottom: 15px;
        }

        .finish-screen p {
            font-size: 18px;
            color: #555;
        }

        /* ==============================
           АДАПТАЦИЯ ДЛЯ ТЕЛЕФОНА
           ============================== */

        @media (max-width: 800px) {

            .modal {
                padding: 10px;
            }

            .modal-content {
                max-height: 95vh;

                flex-direction: column;
            }

            .question-image {
                width: 100%;
                height: 220px;

                padding: 10px;
            }

            .question-image img {
                max-width: 100%;
                max-height: 200px;
            }

            .question-body {
                padding: 25px 20px;
            }

            .question-title {
                font-size: 20px;
            }

            .carousel-item,
            .carousel-item img {
                height: 300px;
            }

            .navigation {
                position: sticky;
                bottom: 0;

                background: white;

                padding-top: 15px;
            }
        }

        @media (max-width: 450px) {

            .question-image {
                height: 170px;
            }

            .question-image img {
                max-height: 150px;
            }

            .question-title {
                font-size: 18px;
                padding: 11px 16px;
            }

            .carousel-item,
            .carousel-item img {
                height: 250px;
            }

            #drawingCanvas {
                width: 400px;
                height: 400px;
            }
        }


/* Итоговое окно со всеми ответами */
.answers-summary {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin: 22px 0;
    text-align: left;
}

.answer-result {
    padding: 14px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
    overflow-wrap: anywhere;
}

.answer-result h3,
.logo-result h3 {
    margin: 0 0 7px;
    font-size: 1rem;
    color: #334155;
}

.answer-result p {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.55;
    color: #0f172a;
}

.logo-result {
    margin: 18px 0;
    text-align: left;
}

.logo-result img {
    display: block;
    max-width: 100%;
    width: 400px;
    height: auto;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: white;
}

.finish-navigation {
    flex-wrap: wrap;
    gap: 10px;
}

@media print {
    body {
        background: white !important;
    }

    #finishModal {
        display: block !important;
        position: static !important;
        overflow: visible !important;
    }

    #finishModal .modal-content {
        box-shadow: none !important;
        max-height: none !important;
        overflow: visible !important;
    }

    .finish-navigation {
        display: none !important;
    }

    .answer-result {
        break-inside: avoid;
    }
}


/* Картинки выбранных ответов в итоговом окне */
.answer-result-image {
    display: block;
    width: min(100%, 420px);
    max-height: 320px;
    height: auto;
    object-fit: contain;
    object-position: left center;
    margin-top: 8px;
    border-radius: 10px;
    background: #fff;
}


/* =====================================================
   КАРУСЕЛЬ -> СЕТКА image-grid (все картинки без прокрутки)
   ===================================================== */

.image-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    overflow: visible;
    padding: 5px;
}

.image-grid .carousel-item {
    flex: none;
    height: auto;
    aspect-ratio: 3 / 4;
}

.image-grid .carousel-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-grid ~ .carousel-arrow,
.carousel-wrapper .carousel-arrow {
    display: none;
}
/* Подписи под изображениями в вопросах 2, 7 и 9 */
.image-grid .carousel-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    height: auto;
    aspect-ratio: auto;
    padding: 6px;
}

.image-grid .carousel-item img {
    display: block;
    width: 100%;
    height: 240px;
    object-fit: contain;
    flex: 1 1 auto;
}

.image-caption {
    display: block;
    width: 100%;
    padding: 8px 4px 3px;
    text-align: center;
    font-size: 14px;
    line-height: 1.3;
    color: #222;
    overflow-wrap: anywhere;
}

@media (max-width: 800px) {
    .image-grid .carousel-item img {
        height: 200px;
    }
}

@media (max-width: 450px) {
    .image-grid .carousel-item img {
        height: 150px;
    }
    .image-caption {
        font-size: 12px;
    }
}


/* Вопрос 7: четыре направления с независимым выбором 4 из 6 */
.lifestyle-directions {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin: 18px 0;
}
.lifestyle-direction {
    border: 1px solid #d9e2d8;
    border-radius: 14px;
    padding: 14px;
    background: #fbfdfb;
}
.direction-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
}
.direction-heading h3 {
    margin: 0;
    font-size: 18px;
}
.direction-heading p {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
}
.direction-heading.direction-complete p {
    color: #237a42;
}
.lifestyle-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}
.lifestyle-grid .carousel-item {
    cursor: pointer;
    min-width: 0;
    border: 2px solid transparent;
    border-radius: 10px;
    background: #fff;
}
.lifestyle-grid .carousel-item.selected {
    border-color: #39834b;
    box-shadow: 0 0 0 2px rgba(57, 131, 75, .14);
}
.lifestyle-grid .carousel-item:focus-visible {
    outline: 3px solid #39834b;
    outline-offset: 2px;
}
.lifestyle-grid .carousel-item img.image-missing {
    min-height: 150px;
    border: 1px dashed #b66;
    background: #fff5f5;
    object-fit: contain;
}
.selection-feedback {
    padding: 12px 14px;
    border-radius: 8px;
    background: #f3f5f3;
    font-size: 14px;
}
.selection-feedback.selection-complete {
    color: #216b37;
    background: #eef8f0;
}
.answer-result-images {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 14px;
}
.answer-result-images .answer-result-image {
    width: 100%;
    max-width: none;
    margin: 0;
}
@media (max-width: 800px) {
    .lifestyle-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .answer-result-images { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 450px) {
    .lifestyle-direction { padding: 9px; }
    .direction-heading { align-items: flex-start; flex-direction: column; }
    .lifestyle-grid .carousel-item img { height: 150px; }
}


/* Инструменты рисования: ластик и заливка */
.drawing-tool {
    min-height: 34px;
    padding: 6px 11px;
    border: 2px solid #ccc;
    border-radius: 8px;
    background: #f5f5f5;
    color: #222;
    font-size: 14px;
    cursor: pointer;
}

.drawing-tool.active {
    border-color: #222;
    outline: 2px solid #222;
    outline-offset: 1px;
    background: #e2e8f0;
}

.drawing-tool:focus-visible {
    outline: 3px solid #2563eb;
    outline-offset: 2px;
}

/* Скрытая карточка C0 в направлении «Семья» */
.lifestyle-hidden { display: none !important; }
