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

body {
    font-family: Arial, sans-serif;
    background: #f5f5f5;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

h1 {
    text-align: center;
    color: #333;
    margin-bottom: 10px;
    font-size: clamp(20px, 5vw, 32px);
}

h2 {
    text-align: center;
    color: #666;
    font-size: clamp(14px, 4vw, 18px);
    margin-bottom: 30px;
    font-weight: normal;
}

/* Адаптивная сетка для шкал */
.scales-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 20px;
    margin: 40px 0;
    overflow-x: auto;
    padding: 10px 0;
}

.scale-card {
    background: #f9f9f9;
    border-radius: 10px;
    padding: 20px 10px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 140px;
}

.scale-title {
    text-align: center;
    font-weight: bold;
    margin-bottom: 20px;
    min-height: 50px;
    color: #444;
    font-size: 14px;
    line-height: 1.3;
}

/* Вертикальные слайдеры */
.vertical-scale {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100px;
    height: 220px;
}

.slider-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 40px;
    height: 100%;
    overflow: visible;
    position: relative;
}

.slider-wrapper::before {
    content: "";
    position: absolute;
    right: -1px;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 1px;
    background: #999;
    opacity: 0.7;
    pointer-events: none;
}

/* Слайдеры с динамическим градиентом */
.slider {
    appearance: none;
    -webkit-appearance: none;
    width: 250px;
    height: 8px;
    border-radius: 4px;
    transform: rotate(-90deg) translateY(0px);
    transform-origin: 50% 50%;
    cursor: pointer;
    position: absolute;
    background: linear-gradient(to right, #2196F3 0%, #ccc 0%);
    /* позволяем браузеру обрабатывать жесты, но фокус на взаимодействие */
    touch-action: none;
}

/* Chrome / Safari / Edge Thumb */
.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #fff;
    background-color: currentColor;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    position: relative;
    z-index: 2;
}

/* Firefox Thumb */
.slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid #fff;
    background-color: currentColor;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Firefox Track */
.slider::-moz-range-track {
    height: 8px;
    border-radius: 4px;
    background: #ccc;
}

/* Firefox Progress */
.slider::-moz-range-progress {
    height: 8px;
    border-radius: 4px;
    background: currentColor;
}

/* Цвета ползунков */
.now-slider {
    accent-color: #2196F3;
    color: #2196F3;
}

.ideal-slider {
    accent-color: #FF1493;
    color: #FF1493;
}

/* Кнопки */
.actions {
    text-align: center;
    margin: 40px 0 20px;
}

.btn {
    display: inline-block;
    padding: 14px 40px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
    text-decoration: none;
    box-shadow: 0 4px 6px rgba(76, 175, 80, 0.3);
    margin: 5px;
}

.btn:hover {
    background: #45a049;
    transform: translateY(-2px);
    box-shadow: 0 6px 8px rgba(76, 175, 80, 0.4);
}

.btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.error-message {
    color: #f44336;
    margin-top: 10px;
    min-height: 20px;
    font-weight: bold;
}

/* Таблица результатов */
.results-table {
    width: 100%;
    border-collapse: collapse;
    margin: 30px 0;
    font-size: 14px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    overflow-x: auto;
}

.results-table th {
    background: #2c3e50;
    color: white;
    padding: 15px 10px;
    font-weight: bold;
    white-space: nowrap;
}

.results-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #eee;
    text-align: center;
    white-space: nowrap;
    color: #333;
}

.results-table tbody tr:hover {
    background: #f8f9fa;
}

.results-table tfoot {
    background: #e3f2fd;
    font-weight: bold;
}

.results-table tfoot td {
    border-top: 2px solid #1976D2;
    padding: 15px 10px;
    white-space: nowrap;
    color: #333;
}

.diff-positive {
    color: #2e7d32;
    font-weight: bold;
}

.diff-negative {
    color: #c62828;
    font-weight: bold;
}

/* Интерпретация */
.interpretation-box {
    background: #f0f7ff;
    border-left: 6px solid #2196F3;
    padding: 25px;
    margin: 30px 0;
    border-radius: 0 10px 10px 0;
    font-size: 15px;
    line-height: 1.6;
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

.interpretation-box h3 {
    margin-top: 0;
    margin-bottom: 20px;
    color: #1565C0;
}

.interpretation-box p {
    margin-bottom: 10px;
    font-size: clamp(14px, 3vw, 15px);
    color: #333;
}

/* Адаптив для планшетов */
@media (max-width: 1024px) {
    .scales-container {
        grid-template-columns: repeat(4, 1fr);
        gap: 15px;
    }
    
    .container {
        padding: 20px;
    }
}

@media (max-width: 768px) {
    body {
        padding: 10px;
    }
    
    .container {
        padding: 15px;
    }
    
    .scales-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .scale-card {
        min-width: auto;
    }
    
    .vertical-scale {
        width: 90px;
        height: 200px;
    }
    
    .slider-wrapper {
        width: 35px;
    }
    
    .slider {
        width: 220px;
    }
    
    .btn {
        padding: 12px 30px;
        font-size: 16px;
        width: 100%;
        max-width: 300px;
    }
    
    .actions {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 10px;
    }
    
    .interpretation-box {
        padding: 15px;
    }
    
    .results-table {
        display: table;
        width: 100%;
        font-size: 12px;
    }
    
    .results-table th,
    .results-table td,
    .results-table tfoot td {
        padding: 8px 5px;
        white-space: normal;
    }
    
    .table-wrapper {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        margin: 20px 0;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 20px;
    }
    
    h2 {
        font-size: 14px;
        margin-bottom: 20px;
    }
    
    .scales-container {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .scale-card {
        padding: 15px 10px;
    }
    
    .scale-title {
        font-size: 16px;
        min-height: auto;
        margin-bottom: 15px;
    }
    
    .vertical-scale {
        width: 100%;
        height: 180px;
        justify-content: space-around;
    }
    
    .slider-wrapper {
        width: 45px;
    }
    
    .slider {
        width: 200px;
    }
    
    .slider-wrapper::before {
        display: none;
    }
    
    .btn {
        padding: 10px 20px;
        font-size: 14px;
    }
    
    .interpretation-box {
        padding: 10px;
        font-size: 13px;
    }
    
    .interpretation-box h3 {
        font-size: 16px;
        margin-bottom: 10px;
    }
    
    .results-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .results-table th,
    .results-table td,
    .results-table tfoot td {
        font-size: 11px;
        padding: 6px 3px;
    }
}

/* Поддержка сенсорных экранов */
@media (hover: none) and (pointer: coarse) {
    .slider {
        transform: rotate(-90deg) translateY(0px) scale(1);
    }
    
    .slider::-webkit-slider-thumb {
        width: 20px;
        height: 20px;
    }
    
    .btn {
        -webkit-tap-highlight-color: transparent;
    }
    
    .btn:active {
        transform: scale(0.98);
    }
}

/* Улучшения для accessibility */
@media (prefers-reduced-motion: reduce) {
    .btn {
        transition: none;
    }
    
    .btn:hover {
        transform: none;
    }
}

@media (orientation: landscape) and (max-width: 1024px) {
    body {
        overscroll-behavior: contain;
        padding: 10px;
    }
    
    .container {
        max-height: calc(100vh - 20px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 15px;
    }
    
    .scales-container {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 15px;
        padding: 10px 0;
    }
    
    .vertical-scale {
        height: 150px;
    }
}

/* Для телефонов в альбомной ориентации (маленькая высота) */
@media (orientation: landscape) and (max-width: 1024px) and (max-height: 500px) {
    .vertical-scale {
        height: 100px;
    }
    
    .slider {
        width: 140px;
    }
    
    .scale-title {
        font-size: 11px;
        min-height: 30px;
        margin-bottom: 10px;
    }
    
    .scale-card {
        padding: 10px 5px;
    }
    
    .slider::-webkit-slider-thumb {
        width: 20px !important;
        height: 20px !important;
    }
}

/* Для планшетов в альбомной ориентации */
@media (orientation: landscape) and (min-width: 769px) and (max-width: 1024px) {
    .scales-container {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .vertical-scale {
        height: 180px;
    }
    
    .slider {
        width: 200px;
    }
}

/* Для узких экранов в альбомной ориентации */
@media (orientation: landscape) and (max-width: 700px) {
    .scales-container {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* МЕТКА 50% ДЛЯ МАЛЕНЬКИХ УСТРОЙСТВ */
@media (max-width: 450px) {
    .slider-wrapper::before {
        content: "";
        position: absolute;
        right: -1px;
        top: 50%;
        transform: translateY(-50%);
        width: 6px;
        height: 1px;
        background: #999;
        opacity: 0.7;
        pointer-events: none;
        z-index: 5;
        display: block !important;
    }
    
    .slider-wrapper::after {
        display: none;
    }
}

/* Для совсем крошечных устройств */
@media (max-width: 350px) {
    .slider-wrapper::before {
        width: 5px;
        right: -2px;
    }
}
