* {
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: white;
    --primary-label: black;
    --secondary-label: white;
    --white-ball: white;
    --black-ball: black;
}

body {
    background: var(--primary-color);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

#switch {
    width: 0;
    height: 0;
    visibility: hidden;
}

label {
    display: block;
    width: 120px;
    height: 60px;
    background: var(--primary-label);
    border-radius: 100px;
    cursor: pointer;
    transition: 0.5s;
    position: relative;
}

label::after {
    content: "";
    width: 50px;
    height: 50px;
    border-radius: 80px;
    background: var(--white-ball);
    position: absolute;
    top: 5px;
    left: 5px;
    transition: 0.5s;
}

#switch:checked+label::after {
    background-color: var(--black-ball);
    left: calc(100% - 5px);
    transform: translateX(-100%);
}

#switch:checked+label {
    background: var(--secondary-label);
}

label:active::after {
    width: 60px;
}