:root{
    --grey: #53616a;
    --yellow: #f7f6cf;
    --green: #a9d8b5;
    --pink: #f7c6c6;
    --blue: #5784ba;
    --red: #c54b6c;
    --purple: #f0d9ff;
    --orange: #f7d59c;
}

.buttonContainer {
    display: flex;
    justify-content: space-around;
    margin-top: 2em;
    max-width: 1200px;
    margin-inline: auto;
    margin-bottom: 1em;
}

.button {
    border: 3px solid #ff99b1;
    background: none;
    color: #ff99b1;
    padding: .5em 1em;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-weight: bold;
    font-size: 1.2em;
    margin: 4px 2px;
    cursor: pointer;
    border-radius: 5px;
    position: relative;
    transition: background .2s, color .2s, border .2s;
}

.button:not(.active):hover {
    border: 3px solid var(--red);
    color: var(--red);
}

.button.active {
    background-color: #ff99b1;
    color: white;
}

button#reset {
    position: absolute;
    top: 0;
    left: 0;
    margin: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: 0;
    border-top-left-radius: 0;
    border-bottom-right-radius: 16px;
    border: 6px solid #ff99b1;
    border-top: none;
    border-left: none;
}

button#back {
    position: absolute;
    top: 0;
    right: 0;
    margin: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: 16px;
    border-top-left-radius: 0;
    border-bottom-right-radius: 0;
    border: 6px solid #ff99b1;
    border-top: none;
    border-right: none;
}

button#reset:not([disabled]):hover {
    border: 6px solid #ff99b1;
    background: #ff99b1;
    color: white;
    border-top: none;
    border-left: none;
}

button#back:not([disabled]):hover {
    border: 6px solid #ff99b1;
    background: #ff99b1;
    color: white;
    border-top: none;
    border-right: none;
}

button#reset[disabled] {
    border: 3px solid #bebebe;
    color: #bebebe;
    border-top: none;
    border-left: none;
}

button#back[disabled] {
    border: 3px solid #bebebe;
    color: #bebebe;
    border-top: none;
    border-right: none;
}

button#new {
    position: absolute;
    top: 0;
    left: 50%;
    margin: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: 16px;
    border-top-left-radius: 0;
    border-bottom-right-radius: 16px;
    border: 3px solid #ff99b1;
    border-top: none;
    transform: translateX(-50%);
    transition: all 0.2s;
    width: 150px;
    height: 48px;
    -webkit-tap-highlight-color: transparent;
}

.button[disabled] {
    cursor: not-allowed;
}

#game {
    border: 6px solid #ff99b1;
    border-radius: 16px;
    padding: 5em 2em;
    max-width: 1200px;
    margin-left: auto;
    min-height: 400px;
    margin-right: auto;
    position: relative;
}

#game.stop #new{
    width: 100%;
    height: 100%;
    z-index: 10;
    border-width: 0;
    background: #fadcdc8c;
    border-radius: 10px;
    font-size: 2em;
    color: var(--red);
    transition: all 0.5s;
}
#tube-container {
    display: grid;
    justify-items: center;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 80px 20px;
}

.tube {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 60px;
    height: 220px;
    border: 4px solid var(--grey);
    align-items: center;
    border-end-start-radius: 100vw;
    border-end-end-radius: 100vw;
    transition: transform 0.2s;
    justify-content: end;
    position: relative;
    cursor: pointer;
}

.tube:not(.selected):hover {
    transform: translateY(-1%);
}

.ball.red {
    background-color: var(--red);
}

.ball.blue {
    background-color: var(--blue);
}

.ball.green {
    background-color: var(--green);
}

.ball.pink {
    background-color: var(--pink);
}

.ball.yellow {
    background-color: var(--yellow);
}

.ball.purple {
    background-color: var(--purple);
}

.ball.orange {
    background-color: var(--orange);
}

.ball {
    aspect-ratio: 1;
    border-radius: 100vw;
    border: 3px solid var(--grey);
    width: 50px;
    transition: transform 0.2s;
}

.tube.selected .ball:first-of-type {
    position: absolute;
    top: -70px;
    transform: translateY(calc(-100% - 15px));
    -webkit-animation: pulsate-fwd 2s ease-in-out infinite both;
    animation: pulsate-fwd 2s ease-in-out infinite both;
}

.tube.selected.shake .ball:first-of-type {
    -webkit-animation: shake-horizontal 0.8s cubic-bezier(0.455, 0.03, 0.515, 0.955) both;
    animation: shake-horizontal 0.8s cubic-bezier(0.455, 0.03, 0.515, 0.955) both;
}
@media (max-width: 767px){
    button#new {
        top: revert;
        bottom:0;
        border-top-right-radius: 16px;
        border-bottom-left-radius: 0;
        border-top-left-radius: 16px;
        border-bottom-right-radius: 0;
        border-top: 3px solid #ff99b1;
        border-bottom: none;
    }
    #tube-container{
        gap: 80px 0;
    }
}
@-webkit-keyframes shake-horizontal {

    0%,
    100% {
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70% {
        -webkit-transform: translateX(-10px);
        transform: translateX(-10px);
    }

    20%,
    40%,
    60% {
        -webkit-transform: translateX(10px);
        transform: translateX(10px);
    }

    80% {
        -webkit-transform: translateX(8px);
        transform: translateX(8px);
    }

    90% {
        -webkit-transform: translateX(-8px);
        transform: translateX(-8px);
    }
}

@keyframes shake-horizontal {

    0%,
    100% {
        -webkit-transform: translateX(0);
        transform: translateX(0);
    }

    10%,
    30%,
    50%,
    70% {
        -webkit-transform: translateX(-10px);
        transform: translateX(-10px);
    }

    20%,
    40%,
    60% {
        -webkit-transform: translateX(10px);
        transform: translateX(10px);
    }

    80% {
        -webkit-transform: translateX(8px);
        transform: translateX(8px);
    }

    90% {
        -webkit-transform: translateX(-8px);
        transform: translateX(-8px);
    }
}

@-webkit-keyframes pulsate-fwd {
    0% {
        -webkit-transform: scale(1);
        transform: scale(1);
    }

    50% {
        -webkit-transform: scale(1.1);
        transform: scale(1.1);
    }

    100% {
        -webkit-transform: scale(1);
        transform: scale(1);
    }
}

@keyframes pulsate-fwd {
    0% {
        -webkit-transform: scale(1);
        transform: scale(1);
    }

    50% {
        -webkit-transform: scale(1.1);
        transform: scale(1.1);
    }

    100% {
        -webkit-transform: scale(1);
        transform: scale(1);
    }
}