canvas#mapCanvas {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 0;
    width: 100%;
    height: 100%;
}

.selected {
    border: 0.2rem solid #0f0;
    box-shadow: 0 0 1rem #0f0;
}
#tileContainer {
    user-select: none;
    grid-area: sidebar;
    border: 0.2rem solid #fff;
    background: #00000033;
    z-index: 1;
    color: #676767;
    border-color: #676767;
    margin-top: 0.4rem;
    margin-left: 1rem;
    margin-right: 1rem;
}
* {
    touch-action: pan-x pan-y;
}
body {
    margin: 0;
    display: grid;
    grid-template-columns: 4fr 1fr 8fr 27rem;
    grid-template-rows: 1fr 8fr 0.5fr;
    grid-template-areas: 
    "sidebar sidebar toolbar notes"
    "instructions content content notes"
    "buttons buttons buttons notes";
    height: var(--viewport-height, 100dvh);
    width: 100%;
    padding: 0;
    position: fixed;
    overscroll-behavior: none;
}
html {
    height: var(--viewport-height, 100%);
    overscroll-behavior: none;
    position: fixed;
}
#buttonContainer {
    display: flex;
    grid-area: buttons;
    bottom: 1rem;
    left: 1rem;
    gap: 1rem;
    padding: 1rem;
    z-index: 1;
    overflow-x: scroll;
    height: 3rem;
}
#saveButton {
    z-index: 2;
    
}
#saveMapButton {
    z-index: 2;
    
}
#saveJSONButton {
    z-index: 2;
}
#loadJSONButton {
    z-index: 2;
}
button {
    background: #ffffff;
    border: 0.2rem solid #676767;
    color: #676767;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: transform 0.1s ease-in-out, background 0.1s ease-in-out, color 0.1s ease-in-out;
}
button:hover {
    background: #676767;
    color: #ffffff;
    transform: scale(1.02);
}
button:active {
    background: #000000;
    color: #ffffff;
    transform: scale(0.98);
    cursor: grabbing;
}
.tile{
    transition: transform 0.1s ease-in-out, box-shadow 0.1s ease-in-out, border 0.1s ease-in-out;
}
.tile:hover {
    transform: scale(1.05);
}
.tile:active {
    transform: scale(0.95);
}
#instructions {
    grid-area: instructions;
    z-index: 1;
    font-family: Arial, Helvetica, sans-serif;
    text-align: start;
    color: #ffffff;
    background: #2b2b2bBB;
    border: 0.2rem solid #676767;
    margin: 1rem 1rem 0rem 1rem;
    padding: 0.5rem;
    overflow-y: scroll;
    height: calc(100% - 7rem);
}
#close-instructions {
    grid-area: instructions;
    pointer-events: all;
    z-index: 2;
    width: calc(100% - 2rem);
    height: 3rem;
    align-self: end;
    justify-self: center;
    margin: 0 1rem 0rem 1rem;
}
details summary{
    pointer-events: all;
    user-select: none;
    background: #181922;

    touch-action: pan-y;
    overscroll-behavior: scroll;
}
details {
    pointer-events: all;
    user-select: none;
    background: #181922;
    outline: 0.2rem solid #3d3d3d;
    margin: 0.5rem 0;
    padding: 0.5rem;
}
ul {
    padding: 0.2rem 0.2rem 0.2rem 1rem;
    border-top: 2px solid #62d4d4;
    border-bottom: 2px solid #62d4d4;
    margin-top: 0;
}

.hide {
    display: none !important;
}
#overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 2;
}
#conformation {
    grid-area: content;
    z-index: 3;
    background: #99866e;
    border: 0.5rem solid #664c2e;
    padding: 0.5rem;
    pointer-events: all;
    display: grid;
    height: 10rem;
    width: 15rem;
    justify-self: center;
    justify-content: center;
    align-content: center;
    gap: 1rem;
    align-self: center;
    color: #43301a;
}
#conformation h2 {
    margin: 0;
    padding: 0;
}
#conformation button {
    padding: 0.5rem 1rem;
    border: 0.15rem solid #664c2e;
    border-radius: 0.25rem;
    background: #c7ad8a;
    color: #332416;
    cursor: pointer;
}
#conformation button:hover {
    background: #dbc09a;
}
#colorSlider{
    width: 5rem;
    height: 1.5rem;
}

#toolbar {
    grid-area: toolbar;
    display: flex;
    justify-content: start;
    align-items: center;
    background: #181922;
    border: 0.2rem solid #bdbdbd;
    margin: 0.5rem 1rem 0rem 1rem;
    padding: 0.5rem;
    z-index: 1;
    gap: 0.5rem;
    padding-top: 0rem;
}
#toolbar legend {
    color: #d1d1d1;
}
#toolbar button {
    flex: 1;
    height: 100%;
    margin: 0rem;
    background: #232641;
    border: 0.2rem solid #677d97;
    border-radius: 0.25rem;
    color: #b9b9b9;
    cursor: pointer;
    pointer-events: all;
}
#toolbar button:active {
    cursor: grabbing;
}
#toolbar button.toggled {
    background: #194b4b;
    border: 0.2rem solid #478683;
    color: #9dd4d4;
}
span {
    user-select: none;
}

.mobile-only {
    display: none;
}

@media (max-width: 600px) {
    body {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 3.5rem 1fr 4.5rem;
        grid-template-areas:
            "notes info"
            "content content"
            "toolbar toolbar";
    }

    #buttonContainer,
    #tileContainer {
        display: none;
    }

    #notes {
        grid-area: notes;
        position: relative;
        width: 100%;
        height: 3.5rem !important;
        margin: 0;
        border: none;
        overflow: visible;
    }

    #notes main {
        display: none;
    }

    #notes main:not(.hidden) {
        display: flex;
    }

    #notes:has(main:not(.hidden)) {
        z-index: 4;
    }

    #notes main:not(.hidden) {
        position: fixed;
        top: 3.5rem;
        right: 0;
        left: 0;
        height: calc(var(--viewport-height, 100dvh) - 8rem);
        box-sizing: border-box;
        display: flex;
        min-height: 0;
        margin: 0;
        overflow: auto;
        background: #99866e;
        z-index: 4;
    }

    #notes header {
        box-sizing: border-box;
        width: 100%;
        height: 3.5rem;
        margin: 0;
        padding: 0.5rem 1rem;
        border: none;
        background: #664c2e;
        color: #f5ead7;
        font-weight: bold;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    #notes header:hover,
    #notes header:active {
        padding: 0.5rem 1rem;
        font-size: 1rem;
        background: #7a5d3d;
        color: #fcf8f1;
    }

    #instructions {
        position: fixed;
        top: 3.5rem;
        right: 0;
        bottom: 4.5rem;
        left: 0;
        width: 100%;
        height: auto;
        box-sizing: border-box;
        margin: 0;
        overflow-y: auto;
        z-index: 4;
    }

    #close-instructions {
        grid-area: info;
        position: relative;
        width: 100%;
        height: 3.5rem;
        margin: 0;
        justify-self: end;
        z-index: 5;
    }

    #toolbar {
        grid-area: toolbar;
        box-sizing: border-box;
        min-width: 0;
        min-height: 0;
        margin: 0;
        padding: 0.35rem;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
    }

    #toolbar legend {
        display: none;
    }

    #toolbar button {
        flex: 0 0 auto;
        min-width: 5rem;
        height: 3.5rem;
    }

    #toolbar button.mobile-only {
        display: block;
    }

    html.keyboard-open body {
        grid-template-rows: 0 1fr 0;
    }

    html.keyboard-open #notes {
        height: 0 !important;
    }

    html.keyboard-open #notes header,
    html.keyboard-open #close-instructions,
    html.keyboard-open #toolbar {
        display: none;
    }

    html.keyboard-open #notes main:not(.hidden) {
        top: 0;
        height: var(--viewport-height, 100dvh);
    }
}