:root {
    /*--correct: #e20000;*/
    --red: #e20000;
    --lightRed: #d65b5b;
    --absent: #FFFFFF;
    --present: #DCDDDF;
    --black: #000000;
    --darkRed: #aa0000;
    --extraLightRed: #d68585;
}

#gameboard {
    max-width: 400px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    margin-left: 17%;
    margin-top: 2em;
}

#gameboard .modal {
    box-shadow: 0 0 20px #b3b3b3;
    background-color: white;
    width: 100%;
    max-width: 400px;
    flex-direction: column;
    padding: 2em 1em;
    border-radius: 8px;
    justify-content: center;
    align-items: center;
    position: absolute;
    gap: 10px;
    display: none;
    z-index: 11;
    max-height: 85%;
    top: 5%;
}

#gameboard .modal .modal--end__close-button,
.modal__close {
    background: none;
    border: none;
    color: var(--black);
    font-weight: 700;
    font-size: 1.8em;
    width: 40px;
    height: 40px;
    aspect-ratio: 1;
    border-radius: 100vw;
    line-height: 0;
    transition: box-shadow 0.25s;
    cursor: pointer;
    position: absolute;
    top: 15px;
    right: 15px;
}

#gameboard .modal .modal--end__close-button:hover,
.modal__close:hover {
    box-shadow: 0 0 18px 0px #191919;
}

#gameboard .modal p {
    text-align: center;
    margin: 0;
}

#gameboard .modal .modal__title {
    font-weight: 600;
    font-size: 1.3em;
    margin-bottom: 0.5em;
}

#gameboard .modal .rule__title {
    align-self: center;
    width: 70%;
    text-align: right;
    margin-right: 1.2em;
}

#gameboard .modal.show {
    display: flex;
}

#gameboard .modal.show~.words-container,
#gameboard .modal.show~.keyboard {
    filter: opacity(0.5) grayscale(0.5);
    user-select: none;
    pointer-events: none;
}

#gameboard .modal .modal__button,
#gameboard .modal a .modal__button,
#ruleButton,
.backToGames {
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    border: none;
    justify-content: center;
    padding: 0.7em 1.7em;
    font-size: 1em;
    line-height: 1;
    cursor: pointer;
    transition: background 0.2s;
}

.backToGames {
    background: white;
    color: var(--red);
    border: 1px solid var(--red);
    margin-top: 1em;
}

#gameboard .modal .modal__button,
#gameboard .modal a .modal__button,
#ruleButton {
    background: var(--red);
    color: white;
}

.modal__header {
    display: flex;
    width: 100%;
}

.headerContainer {
    width: 250px;
}

.description {
    max-width: 250px;
    text-align: left;
    margin-bottom: 1.3em;
    font-size: 0.9em;
}

#gameboard .modal .modal__button:hover,
#ruleButton:hover {
    background: var(--darkRed);
}

#gameboard .modal--end .win,
#gameboard .modal--end .lose {
    display: none;
}

#gameboard .modal--end .modal__title {
    margin-bottom: 2em;
}

#gameboard .modal--end .modal__button {
    margin-top: 2em;
}

#gameboard .modal--end.modal--end-lose .win {
    display: none;
}

#gameboard .modal--end.modal--end-lose .lose {
    display: block;
}

#gameboard .modal--end.modal--end-win .win {
    display: block;
}

#gameboard .modal--end.modal--end-win .lose {
    display: none;
}

#gameboard .wrongAnswer {
    width: 100%;
    max-width: 350px;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    padding: 1em;
    background: #ff4b4bc2;
    position: absolute;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10;
    backdrop-filter: blur(10px);
}

#gameboard .words-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

#gameboard .words-container .word.active .word__letter {
    border: 3px solid var(--red);
}

#gameboard .word {
    display: flex;
    gap: 5px;
    width: 100%;
    justify-content: center;
}

#gameboard .word .word__letter {
    border: 2px solid var(--lightRed);
    aspect-ratio: 1;
    max-width: 50px;
    width: 100%;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 600;
    font-size: 1.5em;
    text-transform: uppercase;
    transition: background 0.25s 0s, border 0.2s;
    box-sizing: border-box;
}

#gameboard .keyboard {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 5px;
    align-items: center;
    width: 100%;
}

#gameboard .keyboard .keyboard__row {
    display: flex;
    gap: 5px;
    justify-content: center;
    width: 100%;
}

#gameboard .keyboard .keyboard__row button {
    border-radius: 4px;
    background: var(--lightRed);
    color: white;
    border: none;
    transition: background 0.2s;
    cursor: pointer;
    font-size: 1.1em;
    width: 100%;
    height: 45px;
    padding: 0 0.5em;
    line-height: 0;
    text-transform: uppercase;
    -webkit-tap-highlight-color: #353b4a;
}

#gameboard .keyboard .keyboard__row button[data-key="Backspace"] {
    min-width: 40px;
}

#gameboard .keyboard .keyboard__row button:hover {
    background: var(--extraLightRed);
}

#gameboard .keyboard .keyboard__row.double-letters button {
    font-size: 0.8em;
    font-weight: 700;
}

#gameboard .word__letter--absent,
#gameboard .btn--absent {
    background: var(--absent) !important;
    color: var(--red) !important;
    border: 2px solid var(--lightRed) !important;
    transition: background 0.25s 0.5s !important;
}

#gameboard .word__letter--present,
#gameboard .btn--present {
    background: var(--present) !important;
    color: var(--black) !important;
    border-color: transparent;
    transition: background 0.25s 0.5s !important;
}

#gameboard .word__letter--correct,
#gameboard .btn--correct {
    background: var(--red) !important;
    border-color: transparent;
    color: white !important;
    transition: background 0.25s 0.5s !important;
}

.shake-horizontal {
    -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;
}

@-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);
    }
}

.rotate-hor-center {
    -webkit-animation: rotate-hor-center 1s cubic-bezier(0.455, 0.03, 0.515, 0.955) both;
    animation: rotate-hor-center 1s cubic-bezier(0.455, 0.03, 0.515, 0.955) both;
}

@-webkit-keyframes rotate-hor-center {
    0% {
        -webkit-transform: rotateX(0);
        transform: rotateX(0);
    }

    100% {
        -webkit-transform: rotateX(-360deg);
        transform: rotateX(-360deg);
    }
}

@keyframes rotate-hor-center {
    0% {
        -webkit-transform: rotateX(0);
        transform: rotateX(0);
    }

    100% {
        -webkit-transform: rotateX(-360deg);
        transform: rotateX(-360deg);
    }
}

.jello-horizontal {
    -webkit-animation: jello-horizontal 0.9s both;
    animation: jello-horizontal 0.9s both;
}

@-webkit-keyframes jello-horizontal {
    0% {
        -webkit-transform: scale3d(1, 1, 1);
        transform: scale3d(1, 1, 1);
    }

    30% {
        -webkit-transform: scale3d(1.25, 0.75, 1);
        transform: scale3d(1.25, 0.75, 1);
    }

    40% {
        -webkit-transform: scale3d(0.75, 1.25, 1);
        transform: scale3d(0.75, 1.25, 1);
    }

    50% {
        -webkit-transform: scale3d(1.15, 0.85, 1);
        transform: scale3d(1.15, 0.85, 1);
    }

    65% {
        -webkit-transform: scale3d(0.95, 1.05, 1);
        transform: scale3d(0.95, 1.05, 1);
    }

    75% {
        -webkit-transform: scale3d(1.05, 0.95, 1);
        transform: scale3d(1.05, 0.95, 1);
    }

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

@keyframes jello-horizontal {
  0% {
    -webkit-transform: scale3d(1, 1, 1);
    transform: scale3d(1, 1, 1);
  }

  30% {
    -webkit-transform: scale3d(1.25, 0.75, 1);
    transform: scale3d(1.25, 0.75, 1);
  }

  40% {
    -webkit-transform: scale3d(0.75, 1.25, 1);
    transform: scale3d(0.75, 1.25, 1);
  }

  50% {
    -webkit-transform: scale3d(1.15, 0.85, 1);
    transform: scale3d(1.15, 0.85, 1);
  }

  65% {
    -webkit-transform: scale3d(0.95, 1.05, 1);
    transform: scale3d(0.95, 1.05, 1);
  }

  75% {
    -webkit-transform: scale3d(1.05, 0.95, 1);
    transform: scale3d(1.05, 0.95, 1);
  }

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

@media (max-width: 360px) {
    #gameboard .keyboard .keyboard__row button {
        padding: 0 0.3em;
    }
}

@media (max-width: 767px) {
    #ruleButton {
        margin: auto;
        margin-bottom: 1em;
    }

    #gameboard .word .word__letter {
        max-width: 40px;
        font-size: 1.3em;
    }

    #gameboard .modal--info .word .word__letter {
        font-size: 1.2em;
        max-width: 60px;
        height: 40px;
    }

    #gameboard .keyboard .keyboard__row button {
        height: 35px;
        font-size: 0.9em;
    }

    .modal.modal--info {
        top: 1% !important;
        max-height: 95% !important;
    }

    .description {
        text-align: center;
        margin-left: auto;
        margin-right: auto;
        margin-bottom: 1em;
    }
}

@media (max-width: 1024px) {
    #gameboard {
        margin-left: 0;
        margin-top: 0;
        margin-inline: auto;
    }

    .headerContainer {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-inline: auto;
    }

    .headerContainer .description {
        text-align: center;
        margin-bottom: 0.8em;
    }

    #ruleButton, .backToGames {
        padding: 0.6em 1.6em;
        font-size: 0.8em;
    }

    #ruleButton {
        margin-bottom: 0.5em;
    }

    .backToGames {
        margin-bottom: 1.2em;
    }
}