
:root {
    --system-font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Oxygen", "Ubuntu", "Noto Sans UI", "Roboto", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
}

templates {
    display: none;
}


body {
    font-family: var(--system-font);
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    box-shadow: inset 0 0 20px 0px black;
    background-color: #3f3f3f;
    color: #eee;
    overflow: hidden;

    /* Nothing is implicitly selectable */
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;

    min-width: fit-content;
    min-width: -moz-fit-content;
}

body.busy {
    cursor: wait !important;
}
body.no-cursor {
    cursor: none !important;
}

body > menu,
body > game {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
}

body > menu {
    opacity: 1;
    transition: opacity 1s ease-in-out;
    z-index: 1;

    display: grid;
    grid-template-rows: 10vh 75vh 15vh;
    text-align: center;
}

body > menu > h1 {
    margin: 0;
    font-size: 6vh;
    white-space: nowrap;
}

#level-list {
    overflow: auto;
    text-align: left;
    list-style-position: inside;
    font-size: 6vw;
}

@media screen and (min-aspect-ratio: 4/3) {
    #level-list {
        font-size: 8vh;
    }
}

#level-list li:not([disabled]) {
    cursor: pointer;
}

#level-list li[disabled] {
    cursor: not-allowed;
    color: grey;
}

body > menu > #fullscreen-button {
    padding: 2vh 3vw;
    width: fit-content;
    height: fit-content;
    width: -moz-fit-content;
    height: -moz-fit-content;
    margin-bottom: 1vh;
    margin-left: 1vw;
    margin-top: 1vh;
}

.big-button {
    font-family: var(--system-font);
    background-color: floralwhite;
    color: black;
    border-width: 4px;
    border-style: outset;
    font-size: 4vh;
}

body > game > aside > section:last-child .big-button {
    padding: 4% 10%;
}

.big-button:active {
    background-color: silver;
    color: black;
    border-style: inset;
}

body > game {
    opacity: 0;
    transition: opacity 1s ease-in-out;
    z-index: 0;
    display: flex;
    flex-direction: row;
}

body > game > aside {
    min-width: fit-content;
    min-width: -moz-fit-content;
    width: 20vw;
    max-width: 30vh;
    display: flex;
    flex-direction: column;
    padding-right: 1%;
    padding-left: 1vh;
    flex-shrink: 0;
}

body > game > aside h2,
dialog h2 {
    text-align: center;
    margin: 0;
    font-size: 6vh;
}

body > game > aside h2:not(:first-child) {
    margin-top: 4vh;
}

body > game > aside > section:last-child {
    flex-grow: 1;
    display: flex;
    flex-direction: row;
    justify-content: space-around;
    align-items: flex-end;
    margin-bottom: 2vh;
}


#goal, #focus {
    text-align: center;
    vertical-align: middle;
    height: 30vh;
}

#goal *, #focus * {
    display: block;
}

#goal img, #focus img, #map img {
    -webkit-filter: invert(1);
    filter: invert(1);
}

#goal img, #focus img, #map img, dialog img {
    object-fit: contain;
    max-width: 100%;
/*    height: calc(100% - 3vh);*/
    height: 100%;
}

#map td {
    height: 25vh;
}

#map td img {
    height: calc(25vh - 4vh);
}

#goal label, #focus label, #map label, dialog label {
/*    display: block;*/
/*    font-size: 3vh;*/
    display: none;
}

body > game > main {
    height: 100vh;
    flex-grow: 1;
}

#map  {
    min-width: fit-content;
    min-width: -moz-fit-content;
    width: 100%;
    height: 100vh;
    border-collapse: collapse;
    table-layout: fixed;
}

#map td.item,
#map td.item *
{
    cursor: pointer;
    cursor: grab;
    cursor: -webkit-grab;
}

#map td.item.focusing,
#map td.item.focusing *,
#map td.npc.focusing,
#map td.npc.focusing *
{
    cursor: pointer;
    cursor: grabbing;
    cursor: -webkit-grabbing;
}

#map td.npc,
#map td.npc *
{
    cursor: help;
}

#map td.npc.asking,
#map td.npc.asking *,
dialog::backdrop,
dialog,
dialog :not(button)
{
    cursor: crosshair;
}

dialog button {
    cursor: pointer;
}

#win-menu {
    float: left;
}
#win-next {
    float: right;
}

#level-list, #map, #goal, #focus {
    border-style: inset;
    border-color: #eee;
    border-width: 2px;
    box-shadow: inset 0 0 10px 0px black;
}

#map td {
    position: relative;
    text-align: center;
    vertical-align: middle;
}

dialog::backdrop { /* native */
    background-color: rgba(0,0,0,0.6);
}

dialog + .backdrop { /* polyfill */
    background-color: rgba(0,0,0,0.6);
}

dialog {
    z-index: 9000;
    position: fixed;
    top: 50%;
    transform: translate(0, -50%);
    max-height: 75vh;
    overflow: hidden;
    text-align: center;
    display: grid;
    grid-template-rows: 8vh 50vh 8vh;
}
dialog footer {
    display: flex;
    flex-direction: row;
    width: 100%;
    justify-content: space-around;
}
dialog footer > * {
    flex-grow: 1;
}
items {
    display: flex;
    flex-direction: row;
    width: fit-content;
    width: -moz-fit-content;
}

items > item {
    flex-shrink: 1;
    flex-grow: 1;
}

#map progress[max=''],
#map progress[max='0'],
#map progress[max='1'] {
    display: none;
}

#map [type='hidden'] * {
    display: none;
}
