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

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background:#667eea;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 1200px;
    width: 100%;
    transition: all 0.3s ease;
}

h1 {
    color: #333;
    margin-bottom: 20px;
    font-size: 24px;
    transition: font-size 0.3s ease;
}

.controls {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
    align-items: center;
}

select,
button {
    padding: 10px 20px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
    white-space: nowrap;
}

select {
    background:  white;
    color: black;
    border: 1px solid #0b7dda;
    background-position: right 12px center;
    padding-right: 35px;
}

select:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-action {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    min-width: 140px;
    font-weight: bold;
}

.btn-action:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-action.sorting {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    animation: pulse 1s infinite;
}

.btn-action.sorting:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(244, 67, 54, 0.4);
}

.btn-generate {
    background: #2196f3;
    color: white;
    border: none;
}

.btn-generate:hover:not(:disabled) {
    background: #0b7dda;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(33, 150, 243, 0.3);
}

.control-element:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.speed-control {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 15px;
    background: #f5f5f5;
    border-radius: 8px;
}

.speed-control label {
    font-weight: 500;
    color: #333;
    white-space: nowrap;
}

.speed-control input[type="range"] {
    -webkit-appearance: none;
    width: 150px;
    height: 6px;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.speed-control input[type="range"]:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.speed-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    border: 2px solid #667eea;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.speed-control input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    background: #667eea;
    border-color: white;
}

.speed-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    border: 2px solid #667eea;
    cursor: pointer;
    transition: all 0.3s;
}

.speed-control input[type="range"]::-moz-range-thumb:hover {
    transform: scale(1.2);
    background: #667eea;
    border-color: white;
}

#speedValue {
    font-weight: bold;
    color: #667eea;
    min-width: 35px;
    background: white;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 14px;
}

canvas {
    border: 2px solid #ddd;
    border-radius: 8px;
    background: #f7f7f7;
    margin: 20px 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    height: auto;
    display: block;
}

.info {
    color: #666;
    font-size: 14px;
    margin-top: 10px;
}

.status {
    margin-top: 10px;
    font-weight: bold;
    padding: 8px;
    border-radius: 6px;
    background: #f5f5f5;
    display: inline-block;
    transition: all 0.3s;
}

.status.sorting {
    background: #fff3cd;
    color: #856404;
}

.status.completed {
    background: #d4edda;
    color: #155724;
}

.status.stopped {
    background: #f8d7da;
    color: #721c24;
}

@keyframes pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.7);
    }
    70% {
        transform: scale(1.02);
        box-shadow: 0 0 0 10px rgba(244, 67, 54, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0);
    }
}

@media screen and (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        padding: 20px;
    }

    h1 {
        font-size: 20px;
        margin-bottom: 15px;
    }

    .controls {
        gap: 8px;
    }

    select,
    button {
        padding: 8px 12px;
        font-size: 14px;
    }

    .btn-action {
        min-width: 110px;
    }

    .speed-control {
        padding: 5px 10px;
        gap: 8px;
    }

    .speed-control label {
        font-size: 12px;
    }

    .speed-control input[type="range"] {
        width: 100px;
    }

    #speedValue {
        font-size: 12px;
        padding: 2px 6px;
        min-width: 30px;
    }

    .status {
        font-size: 12px;
        padding: 6px 12px;
    }

    .info {
        font-size: 12px;
    }
}

@media screen and (max-width: 600px) {
    .container {
        padding: 15px;
    }

    h1 {
        font-size: 18px;
    }

    .controls {
        gap: 6px;
    }

    select,
    button {
        padding: 6px 10px;
        font-size: 12px;
    }

    select {
        padding-right: 28px;
        background-size: 12px;
    }

    .btn-action {
        min-width: 90px;
    }

    .speed-control {
        width: 100%;
        justify-content: center;
        margin-top: 5px;
    }

    .speed-control input[type="range"] {
        width: 120px;
    }

    canvas {
        margin: 15px 0;
    }
}

@media screen and (max-width: 480px) {
    body {
        padding: 5px;
    }

    .container {
        padding: 12px;
    }

    h1 {
        font-size: 16px;
        margin-bottom: 12px;
    }

    .controls {
        gap: 5px;
    }

    select,
    button {
        padding: 5px 8px;
        font-size: 11px;
    }

    .btn-action {
        min-width: 80px;
    }

    .speed-control {
        padding: 4px 8px;
    }

    .speed-control label {
        font-size: 10px;
    }

    .speed-control input[type="range"] {
        width: 90px;
    }

    #speedValue {
        font-size: 10px;
        padding: 2px 4px;
        min-width: 25px;
    }

    .status {
        font-size: 11px;
        padding: 4px 10px;
    }

    .info {
        font-size: 10px;
    }
}

@media screen and (max-width: 380px) {
    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    select,
    button {
        width: 100%;
        justify-content: center;
    }

    .speed-control {
        width: auto;
    }

    .btn-action {
        min-width: auto;
    }
}
