body {
    margin: 0;
    box-sizing: border-box;
    font-family: 'Courier New', Courier, monospace;
    display: flex;
    flex-direction: column;
    height: 100vh;
    --bg-dark: #222;
    --button-color: #63B8FF;
    --button-hover: #328ce6;
    counter-reset: levels; /*Counter for levels*/
}

*, *::before, *::after {
    box-sizing: inherit;
    font-family: inherit;
}

header {
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    width: 100%;
    height: 10%;
    padding: 5px;
    background-color: var(--bg-dark);
    color: white;
    text-align: center;
    font-size: 1.2em;
    z-index: 1;
}

.modal {
    visibility: visible;
    display: flex;
    justify-content: center;
    align-items: center;
    position: fixed;
    top: 10%;     
    left: 0;
    width: 100%;
    height: 90%; 
    padding: 16px;
    backdrop-filter: blur(5px) grayscale(0.5);
    transition: backdrop-filter 4s ease-out;
    -moz-transition: backdrop-filter 4s ease-out;
    overflow: auto;
}

.modal-content {
    background-color: rgb(28, 116, 216);
    color: white;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
    padding: 20px;
    margin: 0 auto;
    max-width: 600px;
    margin-top: auto; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.modal-content button[id^="level"] {
    background-color: var(--button-color);
    place-items: center;
    align-self: center;
    color: white;
    border: 2px rgb(6, 56, 6);
    padding: 10px;
    margin: 5px 0;
    width: 50%;
    cursor: pointer;
    font-size: 1.2em;
    transition: background-color 0.3s ease;
    --moz-transition: background-color 0.3s ease;
    counter-increment:levels;
}

.modal button[id^="level"]:nth-child(even) {
    background-color:var(--button-color);
  }
  
.modal-content button[id^="level"]:hover {
    background-color:var(--button-hover);
    transform: scale(1.05);
}
.modal-content button[id^="level"]::before {
    content:counter(levels)"."
}


form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 15px 20px;
    margin: 0 auto;
    max-width: 400px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  }
input[type="text"] {
    padding: 10px;
    border: 2px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
    width: 100%;
    transition: border-color 0.3s ease;
}
input[type="text"]:focus {
    border-color:var(--button-color);
    outline: none;
}
input[type="text"]::placeholder {
    color: #aaa;
    font-style: italic; 
}
input[type="text"]:not(:placeholder-shown) {
    color: #0c0233
}
label {
    font-size: 1.2em;
    color: #fff;
    transition: color 0.3s ease;
    margin-bottom: 5px;
}
form button {
    background-color:var(--button-color);
    color: white;
    border: none;
    padding: 12px;
    font-size: 1.2em;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.3s ease;
  }
form button:hover {
    background-color:var(--button-hover);
    transform: scale(1.05);
}


canvas {
    display: block;
    border: 2px solid white;
    background-color: #333;
    margin: 10px 0;
}

.hud {
    display: flex;
    flex-direction: column;
    color: white;
    text-align: center;
    align-items: center;
    font-size: 1.2em;
    border: 2px solid white;
    background-color: #333;
    margin: 20px;
    padding: 10px;
    height: 90%;
    width: 15%;

}

.hud button {
    background-color:var(--button-color);
    color: white;
    border: none;
    padding: 10px;
    margin: 5px 0;
    cursor: pointer;
    font-size: 1.2em;
    transition: background-color 0.3s ease;
    width: 100%;
    height: 64px;  
    display: flex;
    justify-content: center;
    align-items: center;
}


/* color of money */
.hud button ~ p {
    color: rgb(9, 192, 73);
    text-align: center;
    font-size: 1.5em;
    font-weight: bold;
    text-align: center;
}

.hud img {
    width: 64px;
    height: 64px;
    margin-right: 10px;
}
.hud img + p {
    color: rgb(233, 215, 18);
    font-size: 1.5em;
    font-weight: bold;
    text-align: center;
}


.hud button:hover {
    background-color:var(--button-hover);
}


#game {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 0;
    background-color: rgb(87, 154, 248);
    flex-grow: 1; 
    padding: 5% 0;
}

.menu {
    position: fixed;
    padding: 20px;
    left: 100%;
    top: 20%;
    color: white;
    font-size: 1.2em;
    height: 60%;
    width: 220px;
    transition: transform 0.5s ease-out;
    --moz-transition: transform 0.5s ease-out;
    background-color: rgb(123, 182, 250);
    z-index: 1;
}
#musicVolume {
    height: 8px;
    background: #252cff;
    border-radius: 5px;
    margin-top: 10px;
    cursor: pointer;
}

.menu h2 + li {
    color: rgb(255, 255, 255);
    font-size: 1em;
    margin: 10px 0;
    list-style: none;
}

body.menu-visible .menu {
    transform: translateX(-100%);
}

article .menu-button {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--button-color);
    color: white;
    border: 2px rgb(6, 56, 6);
    padding: 10px;
    margin: 5px 0;
    width: 50%;
    cursor: pointer;
    font-size: 1.2em;
    transition: background-color 0.3s ease;
}

article .menu-button:hover {
    background-color: var(--button-hover);

}
.menu-button img {
    width: 20px;
    height: 20px;
    margin-right: 10px;
}

#volumeIcon {
    position: relative;
    top: 42px;
    width: 50px;
    transform: rotate(-10deg);
}

#hintIcon {
    width: 50px;
}

#towerIcon {
    width: 64px; 
    cursor: grab;
}

.towerIcon:hover {
    transform: scale(1.1) rotate(-5deg);
}

body.modal-visible .modal {
    visibility: hidden;
}

.level_buttons{
    display: flex;
    flex-direction: column;
    margin: auto;
    justify-content: center;
    align-items: center;
    padding: 10px;
    gap: 10px;
}

.hint-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

body.modal-visible .modal-content {
    background: rgb(186, 2, 2);
}

#custom-checkbox {
    display: inline-block;
    width: 60px;
    height: 30px;
    background-color: rgb(12, 1, 37);
    border-radius: 30px;
    margin-right: 10px;
    cursor: pointer;
}

#custom-checkbox::before {
    display: block;
    content: "";
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background-color: red;
    left: 0;
    position: relative;
    transition: all 0.5s ease;
}

#custom-checkbox-input:checked + #custom-checkbox::before {
    background-color: green;
    left: 100%;
    transform: translateX(-100%);
}

#timer {
    color: #e6db13;
    font-size: 1.5em;
    font-weight: bold;
    text-align: center;
}


#money::before {
    content: "💰";
    margin-right: 5px;
}

#lives {
    color: #d9300a;
    font-size: 1.5em;
    font-weight: bold;
    text-align: center;
} 
#lives::before {
    content: "❤️";
    margin-right: 5px;
}

#custom-checkbox-input {
    display: none;
}

/*Footer*/
footer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    bottom: 0;
    left: 0;
    height:5%;
    width: 100%;
    background-color: var(--bg-dark);
    color: white;
    text-align: center;
    padding: 10px;
    font-size: 0.8em;
    z-index: 1;
}

#githubLink {
    color: white;
    font-size: 1.2em;
}
#JS_logo {
    width: 32px;
}
#JS_logo:hover {
    transform: scale(1.2) rotate(5deg);
    transition: transform 0.3s ease;
}

@media screen and (max-width: 900px) {

    #game {
        flex-direction: column;
        padding: 10px;
        width: 100%;
    }

    .hud {
        width: 100%;
        margin: 10px 0;
        height: auto;
    }

    canvas {
        margin: 5px 0;
        width: 100%;
    }

    footer {
        font-size: 0.7em;
        padding: 5px;
    }

    #custom-checkbox {
        width: 50px;
        height: 25px;
    }

    #custom-checkbox::before {
        width: 25px;
        height: 25px;
    }
}
