:root {
    --button-orange: hsl(20, 100%, 45%);
    --button-skyblue: hsl(196, 88%, 45%);
    --button-green: hsl(120, 100%, 25%);
    --theme-black: hsl(0, 0%, 10%);
    --selected-border-white: hsl(0, 0%, 85%);
    --degree: 0deg;
    --space-hue1: 0;
    --space-hue2: 0;
}

* {
    user-select: none;
}

/* 
html {
    filter: contrast(110%) saturate(120%);
} */

html, body {
    margin: 0;
    padding: 0;
    overflow: hidden;
    background-color: black;
}

#canvas, #effectsCanvas, #gameStatsCanvas {
    position: absolute;
    top: 50%;
    left: 50%;
    translate: -50% -50%;
}

#canvas, #loadingScreen {
    /* background-image: url("./geometry/noise.png"); */
    /* background-image: url("./geometry/noise_tomato.png"); */
    /* background-image: url("./geometry/noise_cyan.png"); */
    /* background-image: url("./geometry/noise_black.png"); */
    background-attachment: fixed;
    background-position: center;
    background-repeat: no-repeat;
    background-size: cover;
    background-clip: border-box;
    background-origin: border-box;
    background-blend-mode: luminosity;
}

.normal {
    background-image: url(); /* It solves a glitch for some reason */
    background-color: var(--theme-black);
}

.clouds-default {
    background-image: url("./geometry/noise_purple.png");
    background-color: transparent;
}

.clouds-original {
    background-image: url("./geometry/noise_purple.png");
    background-color: hsl(214, 50%, 78%);
}

.clouds-skyblue {
    background-image: url("./geometry/noise_purple.png");
    background-color: skyblue;
}

.clouds-wheat {
    background-image: url("./geometry/noise_purple.png");
    background-color: wheat;
}

.water {
    background-image: url("./geometry/noise_gray.png");
    background-color: skyblue;
}

.space {
    background-image: url("./geometry/noise_black.png"), linear-gradient(var(--degree), rgba(255, 0, 0, 0.75), rgba(0, 0, 255, 0.75));
}

.colors {
    background-image: url("./geometry/noise_black.png"), 
    linear-gradient(var(--degree), 
                    hsl(var(--space-hue1), 75%, 75%),  
                    hsl(var(--space-hue2), 75%, 75%));
}

#effectsCanvas {
    filter: blur(5px);
}

#options {
    position: absolute;
    bottom: 0;
    right: 10px;
    opacity: 0.5;
    padding: 20px 0px;
    display: flex;
    flex-direction: column;
    transform: translateY(70%);
    transition: opacity, transform 500ms;
}

#options:has(button:hover), #options:has(button:focus), #options:hover {
    transform: translateY(0);
    opacity: 1;
}

#options button:nth-child(1) {
    text-align: center;
    font-size: 35px;
    margin-bottom: 5px;
    background-color: transparent;
    border: none;
    text-shadow: 0 0 5px black;
}

.option {
    font-size: 30px;
    margin: 10px;
    background-color: hsl(from gray h s l / 0.25);
    border: 2px solid hsl(from whitesmoke h s l / 0.5);
    border-radius: 50%;
    padding: 10px;
    cursor: pointer;
}

.option:hover {
    text-shadow: 0 0 5px gray;
}

.option:active {
    background-color: var(--theme-black);
}

/* Customisation Panel Designing */
.customTab, .customTab[open] {
    width: 650px;
    border-radius: 5px;
    padding: 20px;
    color: white;
    background-color: rgba(128, 128, 128, 0.1);
    font-family: Arial, Helvetica, sans-serif;
    font-size: 20px;
    flex-direction: column;
    border: 2px solid gray;
    overflow: scroll;
    scrollbar-width: none;
    max-height: 90%;
}

.customTab[open] {
    display: flex;
}

dialog {
    display: none;
    opacity: 0;
    animation: vanish 500ms;
}

dialog[open] {
    display: block;
    opacity: 1;
    animation: appear 750ms;
}

dialog::backdrop {
    background-color: hsl(0, 0%, 0%);
    opacity: 0;
}

dialog[open]::backdrop {
    opacity: 0.5;
}

.closeBtn {
    position: absolute;
    top: 0;
    right: 0;
    background-color: transparent;
    border: none;
    cursor: pointer;
    font-size: 15px;
    font-family: monospace;
}

.customTab .closeBtn {
    margin: 30px;
}

#panel {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin: 10px;
}

.prop {
    position: relative;
    display: flex;
    flex-direction: column;
    animation: fade-in ease-in-out 0.5s;
}

@keyframes fade-in {
    from {
        translate: 0 200%;
        opacity: 0;
    }
    to {
        translate: 0 0;
        opacity: 1;
    }
}

.prop input {
    margin: 5px 0 ;
}

.label {
    font-family: monospace;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
}

#preview {
    position: relative;
    margin-top: 10px;
}

#previewCanvas {
    border: 5px ridge hsl(0, 0%, 70%);
    border-radius: 5px;
    transform: translateX(-5px);
    background-color: hsl(0, 0%, 10%, 0.5);
}

#previewEffects {
    position: absolute;
    top: 0;
    left: 0;
    filter: blur(5px);
}

.headings {
    font-family: monospace;
    text-align: center;
    margin: 10px;
    margin-bottom: 20px;
    font-size: 25px;
    color: whitesmoke;
}

.refresh {
    cursor: pointer;
    font-size: 1.1em;
    user-select: none;
    background-color: transparent;
    border: none;
    color: whitesmoke;
}

.customChoice {
    height: 50px;
    width: 50px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: var(--theme-black);
    border: 2px solid gray;
    border-radius: 2px;
    font-size: 25px;
    margin: 0 5px;
    cursor: pointer;
}

.customChoice:hover {
    background-color: hsl(from var(--theme-black) h s calc(l + 5));
}

.customChoice:active {
    background-color: var(--theme-black);
}

.customChoice input {
    opacity: 0;
    position: absolute;
}

.customChoice:has(input:checked) {
    border: 2px solid var(--selected-border-white);
}

#typeCustomisation {
    display: flex;
    flex-direction: column;
}

.typeCustomisationSection {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    margin: 10px;
}

.options {
    display: flex;
    flex-direction: row;
}

/* Customisation Tab Actions */
#customisationControls {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

#customisationControls button {
    /* --button-color: var(--theme-black); */
    --_button-color: var(--button-color, black);

    width: 100%;
    border: none;
    padding: 15px;
    margin: 10px auto;
    font-family: monospace;
    border-radius: 5px;
    font-size: 20px;
    cursor: pointer;

    background-color: transparent;
    border: 2px solid hsl(0, 0%, 75%);
    color: hsl(0, 0%, 95%);
}

#customisationControls button:hover {
    border: none;
    background-color: hsl(from var(--_button-color) h s calc(l + 5));
}

#customisationControls button:active {
    background-color: var(--_button-color);
}

#startGame {
    --button-color: var(--button-green);
}

#saveSetup {
    --button-color: var(--button-skyblue);
}

#playDefault {
    --button-color: var(--button-orange);
}

@media (width < 500px) {
    .customTab, .customTab[open] {
        width: 80%;
        height: 75%;
    }

    .customTab > .headings {
        font-size: 1.1em;
    }

    .customTab > .closeBtn {
        top: -20px;
        right: -25px;
    }

    #panel {
        grid-template-columns: 1fr;
        font-size: 0.9em;
        min-height: 165px;
        overflow: scroll;
    }

    #typeCustomisation {
        font-size: 0.8em;
    }

    .customChoice {
        width: 40px;
        height: 40px;
        font-size: 1.25em;
    }

    #previewCanvas, #previewEffects {
        width: 100%;
    }

    #customisationControls {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: repeat(3, 1fr);
        gap: 10px;
        margin: 10px 0;
    }
    
    #customisationControls > button {
        font-size: 0.9em;
        height: fit-content;
        margin: 0;
    }

    #customisationControls > button:last-child {
        grid-column: span 2;
    }
}

/* Show Stats */
#showStats {
    position: absolute;
    top: 0;
    right: 0;
    margin: 20px;
    font-size: 1.5em;
    border: none;
    background-color: transparent;
    opacity: 0.75;
    cursor: pointer;
    transition: opacity 0.5s;
}

#showStats:hover {
    opacity: 1;
}

#stats {
    font-family: monospace;
    font-size: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: 2px solid hsl(from white h s l / 0.5);
    width: 400px;
}

#stats ul {
    list-style-type: none;    
    margin: 10px;
    padding: 0;
}

#stats li {
    margin: 10px;
}

#stats .closeBtn {
    margin: 10px;
}

#stats::backdrop {
    background-color: hsl(0, 0%, 10%);
    opacity: 0;
}

#stats[open]::backdrop {
    opacity: 0.5;
}

@media (width < 500px) {
    #showStats {
        right: -10px;
    }

    #options {
        right: -1px;
    }

    #stats {
        width: 80%;
        font-size: 1.3em;
    }

    .headings {
        font-size: 1.5em;
    }
}

/* Buy Popup */
#buyPopup, #notice {
    font-family: monospace;
    font-size: 20px;
    background-color: rgba(0, 0, 0, 0.5);
    color: white;
    border: 2px solid hsl(from white h s l / 0.5);
    width: 400px;
}

#notice {
    width: max-content;
    padding: 20px 50px;
}

#notice > button {
    border: 1.5px solid whitesmoke;
    border-radius: 50px;
    background-color: transparent;
    color: white;
    padding: 10px 15px;
    text-align: center;
    margin: auto;
    display: block;
    cursor: pointer;
}

#notice > button:hover, #notice > button:focus {
    background-color: rgb(0, 148, 197);
    color: white;
}