html {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    padding: 0;
    position: absolute;
    overflow: hidden;
    display: block;
    height: 100%;
    width: 100%;
    background: #222133;
}

#app_container {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    /* padding: 40px; */
    display: flex;
    justify-content: center;
    align-items: center;
}

#app_container[data-game="moleminers"] #game {
    justify-content: flex-start;
    width: fit-content;
}

#app_container[data-game="moleminers"] canvas {
    max-height: unset;
}

#app_container[data-type="pixi"] #game {
    grid-template-rows: calc((90vmax) * 0.5625);
    grid-template-columns: calc(90vmax);
}

#game {
    /* width: calc(100vw * 0.975);  */
    /* height:width ratio = 9/16 = .5625  */
    /* height: calc((100vw * 0.975) * 0.5625);  */
    /* border: solid 2px red; */
    height: fit-content;
    width: fit-content;
    /* height: 100%; */
    /* height: 100%; */
    /* max-height: 100vh; */
    /* max-height: calc(100% - 50px - 10px); */
    max-height: calc(100vh - 20px);
    max-width: 177.78vh; /* 16/9 = 1.778 */
    margin: auto;
    position: relative;
    top:0;bottom:0;
    left:0;right:0; 
    overflow: hidden;
    /* display: flex;
    justify-content: center; 
    align-items: center; 
    flex-direction: column; */
    display: grid;

    /* grid-template-rows: calc(56.25vw * 0.75) 50px;
    grid-template-columns: 75vw; */
    grid-template-rows: calc((75vmax - 50px - 10px) * 0.5625) 50px;
    grid-template-columns: calc(75vmax);

    justify-content: center;
    align-items: center;
    /* grid-template-rows: auto 50px; */
    gap: 10px;
    border-radius: 8px;
}

#game[data-expand-canvas="true"]{
    /* grid-template-rows: calc(56.25vmax - 100px) 50px; */
    grid-template-rows: 90vh calc(10vh - 30px);
    grid-template-columns: calc(100vmax - 50px);
}

canvas {
    width: 90vw; /* 90% of viewport vidth */
    height: 50.625vw; /* ratio = 9/16 * 90 = 50.625 */
    /* max-height: 90vh; */
    max-height: 110%;
    max-width: 160vh; 
    /* 16/9 * 90 = 160 */
    max-width: 100%;
    margin: auto;
    position: relative;
    display:block;
    border-radius: 20px;
}

/* try to handle mobile dialog */
canvas + * {
    z-index: 2;
}

.logo {
    display: block;
    max-width: 70vw;
    max-height: 70vh;
}

#logo {
    width: 300px;
    margin-bottom: 40px;
}

.progress {
    margin: 1.5em;
    border: 1px solid white;
    width: 50vw;
    display: none;
}

.progress .full {
    margin: 2px;
    background: white;
    height: 1em;
    transform-origin: top left;
}

#loader {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.spinner,
.spinner:after {
    border-radius: 50%;
    width: 5em;
    height: 5em;
}

.spinner {
    margin: 10px;
    font-size: 10px;
    position: relative;
    text-indent: -9999em;
    border-top: 1.1em solid rgba(255, 255, 255, 0.2);
    border-right: 1.1em solid rgba(255, 255, 255, 0.2);
    border-bottom: 1.1em solid rgba(255, 255, 255, 0.2);
    border-left: 1.1em solid #ffffff;
    transform: translateZ(0);
    animation: spinner-spin 1.1s infinite linear;
}

@keyframes spinner-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

#canvas-button-wrapper {
    width: 100%;
    height: 100%;
}

#canvas-buttons {
    display: none;
    width: 300px;
    margin: auto;
}

#canvas-buttons a img {
    width: 40px;
    padding: 5px;
    padding-left: 10px;
}

#footer {
    background-color: #0f1e29;
    background: linear-gradient(to bottom, #000000 1%, #0f1e29 62%);
    width: 100%;
    height: 20px;
    padding-top: 5px;
    position: absolute;
    bottom: 0;
    text-align: center;
    font-family: "Lato", "proxima-nova", "Helvetica Neue", Arial, sans-serif;
    color: #167a7a;
    font-size: 10px
}

#footer a {
    color: #167a7a
}

button:focus {
    background: pink;
    border-bottom-color: pink;
    border-bottom-style: dotted;
}