@import url('https://fonts.googleapis.com/css2?family=Creepster&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Comfortaa&display=swap');

:root {
    --globalSat: 1;

    --hue: 180;
    --backgroundLight: 50%;
    --appleHue: 0;


    --eyePosX: column;
    --eyePosY: flex-start;
    --eyeSize: 8px;
    --eyeMargin: .2vh;
    --eyeBorder: .25vh;

    --tongueTop: 0vh;
    --tongueBottom: 0vh;
    --tongueLeft: 3vh;
    --tongueRight: 0vh;
    --tongueWidth: 2.5vh;
    --tongueHeight: 1vh;

    --healthbarHeight: 79vh;
    --healthHue: 100;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    margin: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between; 
    align-items: center;
    height: 100vh;
    width: 100vw;
    background-color: hsl(165, calc(60% * var(--globalSat)), 70%);
    font-family: 'Comfortaa', sans-serif;
}

.hidden { display: none; }

#username-modal {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    background: rgba(0, 0, 0, 0.4); 
    justify-content: center; 
    align-items: center;
    z-index: 10;
}

.modal-content {
    position: absolute;
    background: hsl(270, calc(50% * var(--globalSat)), 70%); 
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50vw;
    height: 25vh;
    padding: 5vh; 
    border-radius: 5px; 
    border: 1vh double  hsl(0, 0%, 0%);
    text-align: center;
    display: flex;
    flex-direction: column;
}

.modal-content h2 {
    transform: translateY(-60%);
}

.modal-content #username-cancel {
    font-family: monospace;
    position: absolute;
    top: 0%;
    right: 0%;
    background-color: hsl(270, calc(50% * var(--globalSat)), 70%); 
    border: none;
    margin: 1vh;
    margin-top: 0;
    cursor: pointer;
}

.modal-content #username-cancel:hover {
    font-weight: bold;
}

.modal-content #username-confirm,
.modal-content #my-username {
    position: relative;
    cursor: pointer;
    border: .1rem solid hsl(0, 0%, 0%);
    border-radius: .25rem;
    background-color: hsl(165, calc(60% * var(--globalSat)), 80%);
    width:  5vw;
    height: 1.8vw;
    left: 50%;
    transform: translateX(-50%);
    margin: .5vh;
    font-family: 'Comfortaa';
    padding: .2vw;
}

.modal-content #my-username {
    height: 2vw;
    width: 14vw;
}

.modal-content #username-confirm:hover,
.modal-content #my-username:hover {
    background-color: hsl(165, calc(60% * var(--globalSat)), 75%);
    transform: translateX(-50%) scale(1.05);
}

.modal-content #username-warning {
    position: relative;
    color: hsl(10, calc(100% * var(--globalSat)), 30%);
    font-weight: bold;
    margin: .5vh;
}

#username-input {
    position: relative;
    width: 20vw;
    height: 4.5vh;
    left: 50%;
    font-size: 1rem;
    transform: translateX(-50%);
    padding: 1vh;
    border: .1rem solid hsl(0, 0%, 0%);
    border-radius: .25rem;
    background-color: hsl(165, calc(60% * var(--globalSat)), 60%);
    font-family: 'Comfortaa';
    margin: .5vh;
}

#username-input::placeholder {
    color: hsl(0, 0%, 0%, .7);
    font-style: italic;
}

#username-input:hover {
    background-color: hsl(165, calc(60% * var(--globalSat)), 65%);
}

#username-input:-webkit-autofill,
#username-input:-webkit-autofill:hover, 
#username-input:-webkit-autofill:focus {
    -webkit-text-fill-color: hsl(0, 0%, 0%);
    -webkit-box-shadow: 0 0 0 1000px hsl(165, calc(60% * var(--globalSat)), 60%) inset;
    font-family: 'Comfortaa';
    font-size: 1rem;
    transition: background-color 5000s ease-in-out 0s;
}

.top-bar {
    width: 100vw;
    height: 7vw;
    margin-bottom: 3vh;
    display: flex;
    flex-direction: row;
    justify-content: space-between;  
    align-items: center; 
    background-color: hsl(270, calc(50% * var(--globalSat)), 70%);
    padding: 1vw;  
    overflow: hidden;
}

.top-bar .score {
    font-size: 1.75rem;
    font-weight: bold;
    padding: 1vh;
    margin-right: .5rem;
    margin-left: .5rem;
}

.top-bar .time {
    position: absolute;
    right: 12vw;
    font-size: 1.75rem;
    font-weight: bold;
    width: 18vw;
    padding: 1vh;
    text-align: left;
    margin-right: .5rem;
}

.top-bar button {
    font-size: 1.5vw;  
    width: 4vw;  
    height: 4vw; 
    justify-content: flex-start;  
    align-items: center; 
    padding: 0;  
    margin-right: .7vw;
    margin-left: .7vw;
    cursor: pointer;
    border: .1rem solid hsl(0, 0%, 0%);
    border-radius: .5rem;
    background-color: hsl(165, calc(60% * var(--globalSat)), 80%);
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.username-cont button {
    position: absolute;
    font-size: 1.2vw;
    font-weight: bold;
    top: 1.17vw;
    left: 23.8vw;
    width: 8vw;
    border-radius: .6rem;
    font-family: 'Comfortaa', sans-serif;
}


.top-bar button:hover {
    background-color: hsl(165, calc(60% * var(--globalSat)), 70%);
    transform: scale(1.1);
}

#main-menu {
    font-size: 1.2rem;
    font-weight: bold;
}

#restart i {
    transition: transform .3s ease-out;
}

#restart:hover i {
    transform: rotate(360deg);
}

#settings i {
    transition: transform .3s ease-out;
}


#settings:hover i {
    transform: rotate(90deg);
}

#gameMessage {
    position: absolute;
    text-align: center;
    justify-content: center;
    font-size: 3rem;
    left: 50%;
    transform: translateX(-50%);
}

.goodLuck {
    font-family: 'Comfortaa', sans-serif;
    font-size: 5rem;
    color: hsl(165, calc(100% * var(--globalSat)), 50%);
    background-color: hsl(270, calc(50% * var(--globalSat)), 70%);
    width: 100vw;
    z-index: 5;
}

.gameOver {
    font-family: 'Creepster', sans-serif;
    font-size: 5rem;
    color: hsl(0, calc(80% * var(--globalSat)), 40%);
    opacity: 1;
}

.tooLong {
    font-family: 'Creepster', sans-serif;
    font-size: 4rem;
    margin-right: 5vw;
    color: hsl(10, calc(80% * var(--globalSat)), 40%);
    opacity: 1;
}

.winGame {
    font-family: 'Comfortaa', sans-serif;
    font-size: 5rem;
    color:  hsl(165, calc(100% * var(--globalSat)), 50%);
}

.game-wrapper {
    display: flex;
    align-items: flex-start;
    position: relative;
    justify-content: flex-end;
    height: 100vh;
    width: 100vw;
    gap: 2rem;
}

.set-cont {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: .5vw;
    justify-content: center;
    align-items: left;
    margin-top: 9vh;
    margin-left: 2vw;
    margin-bottom: 2vh;
    border: .2rem solid hsl(0, 0%, 0%);
    border-radius: 0.5rem;
    padding: .5vw;
}

.set-cont p,
.set-cont span {
    font-size: 2vw;
}

.set-title  {
    text-align: center;
    text-decoration: underline;
    margin-bottom: 1vw;
}

.info-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 1.5rem;
}

#heading {
    max-width: 17rem;
    font-size: 5.4vw;
    font-weight: bold;
    text-align: center;
    margin-right: 1vw;
    margin-left: 2vw;
}

.paragraph {
    font-size: 1.1vw;
    line-height: 1.5;
    max-width: 17rem; 
    margin-bottom: 12rem;
    text-align: center;
    padding: 1vh;
    border: .4vh solid hsl(0, 0%, 0%);
    border-radius: 2vh;
}

.grid-health-cont {
    display: flex;
}

.healthbar-cont {
    position: relative;
    right: -2px;
    border: .5vh solid hsl(var(--hue), calc(50% * var(--globalSat)), 25%);
    border-radius: 5px;
    box-sizing: content-box;
    width: 4vh;
    height: 79vh;
    margin: 0;
    z-index: 1;
}

.healthbar-cont #healthbar {
    position: absolute;
    bottom: 0;
    height: var(--healthbarHeight);
    width: 4vh;
    z-index: 0;
    background-color: hsl(var(--healthHue), calc(100% * var(--globalSat)), 50%);
    border-top: .5vh solid hsl(var(--hue), calc(50% * var(--globalSat)), 25%);
    box-sizing: border-box;
    text-align: center;
    align-content: end;
}

.healthbar-cont p {
    position: absolute;
    bottom: 0;
    width: 4vh;
    z-index: 1;
    text-align: center;
    align-content: end;
}

.grid-container  {
    border: .5rem solid hsl(var(--hue), calc(100% * var(--globalSat)), 30%);
    display: grid;
    justify-content: center;
    margin-bottom: 1rem;
    margin-right: 1rem;
    margin-left: 0;
    width: 80vh;
    height: 80vh;
    background-color: hsl(var(--hue), calc(75% * var(--globalSat)), var(--backgroundLight));
    z-index: 2;
}

.controls {
    position: absolute;
    right: 2.5%;
    bottom: 1.7rem;
    display: flex;
    align-items: center;
    flex-direction: column;
    align-items: center;
    gap: .25rem; 
}

.controls button {
    font-size: 9vh;
    align-content: center;
    height: 13vh;
    width: 15vh;
    border: .2rem solid hsl(0, 0%, 0%);
    border-radius: 25%; 
    background-color: hsl(165, calc(60% * var(--globalSat)), 80%);
    cursor: pointer;
    transition: transform .3s ease-out;
}


.controls button:hover {
    background-color: hsl(165, calc(60% * var(--globalSat)), 85%);
    transform: scale(1.05);
}




/* GAMEBOARD */
.squareT1:not(.snake) {
    background-color: hsl(var(--hue), calc(75% * var(--globalSat)), 55%);
    border: 1px solid hsl(var(--hue), calc(100% * var(--globalSat)), 20%);
    box-sizing: border-box;
    
}

.squareT2:not(.snake) {
    background-color: hsl(var(--hue), calc(75% * var(--globalSat)), 40%);
    border: 1px solid hsl(var(--hue), calc(100% * var(--globalSat)), 35%);
    box-sizing: border-box;

}

.snake-head {
    display: flex;
    justify-content: center;
    flex-direction: var(--eyePosX);
    align-items: var(--eyePosY);
    gap: var(--eyeMargin);
    background-color: hsl(var(--hue), calc(100% * var(--globalSat)), 25%) !important;
}

.snake-head .eye1,
.snake-head .eye2 {
    margin: var(--eyeMargin);
    height: var(--eyeSize);
    width: var(--eyeSize);
    background-color: hsl(0, 0%, 0%);
    box-sizing: border-box;
    border: var(--eyeBorder) solid hsl(0, 0%, 100%);
    border-radius: 50%;
}

.snake-head .tongue {
    position: absolute;
    margin-top: var(--tongueTop);
    margin-bottom: var(--tongueBottom);
    margin-left: var(--tongueLeft);
    margin-right: var(--tongueRight);
    width: var(--tongueWidth);
    height: var(--tongueHeight);
    background-color: hsl(var(--appleHue), calc(80% * var(--globalSat)), 70%);
}

.apple {
    border-radius: 50%;
    background-color: hsl(var(--appleHue), calc(100% * var(--globalSat)), 45%) !important;
    border: 1px solid hsl(var(--appleHue), calc(100% * var(--globalSat)), 10%);
    box-sizing: border-box;
}