html {
    box-sizing: border-box;
}
*, *:before, *:after {
    box-sizing: inherit;
}
html, body {
    height: 100%;
}
/* The page never scrolls or zooms: the canvas is the whole page. */
html, body {
    overflow: hidden;
    overscroll-behavior: none;
}
canvas {
    display: block;
}
body {
    margin: 0;
    background: #000;
}
#unity-container {
    width: 100%;
    height: 100%;
}
#unity-canvas {
    width: 100%;
    height: 100%;
    background: #000;
}

#loading-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: calc(6px * var(--scale, 3));
}

/* Pixel-art sprite sheet animation: frames laid out in a single horizontal row.
   The sheet url, the concrete pixel sizes and the @keyframes rule are injected
   at runtime by index.html, once the sheet's natural size is known. */
#loading-sprite {
    background-repeat: no-repeat;
    background-position: 0 0;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

#unity-progress-bar-empty {
    width: calc(var(--frame-width, 64px) * var(--scale, 3));
    height: calc(6px * var(--scale, 3));
    padding: calc(1px * var(--scale, 3));
    border: calc(1px * var(--scale, 3)) solid #fff;
    text-align: left;
}
#unity-progress-bar-full {
    width: 0%;
    height: 100%;
    background: #fff;
}

#unity-fullscreen-button {
    position: absolute;
    right: 10px;
    bottom: 10px;
    width: 38px;
    height: 38px;
    background-size: contain;
}

/* ---------- Mobile shell (web-shell.js), shared by all templates ---------- */

/* The canvas takes the whole viewport including the notch area (viewport-fit=cover);
   the game keeps its UI inside the safe area it reads through WebShell.jslib. */
.shell-mobile body {
    position: fixed;
    inset: 0;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
.shell-mobile #unity-container {
    position: fixed;
    inset: 0;
}
/* The canvas renders below the device pixel ratio (an integer fraction of it, see renderPixelRatio):
   the browser upscales it by whole device pixels, pixelated keeps the pixel art sharp. */
.shell-mobile #unity-canvas {
    touch-action: none;
    image-rendering: pixelated;
}

/* Measures env(safe-area-inset-*): the shell reads its computed padding. */
#safe-area-probe {
    position: fixed;
    left: 0;
    top: 0;
    width: 0;
    height: 0;
    visibility: hidden;
    pointer-events: none;
    padding-top: env(safe-area-inset-top, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
}

/* Shown over everything (the loading screen too) while a mobile screen is portrait. */
#rotate-cover {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: #000;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 28px;
    font-family: monospace;
    font-size: 20px;
    letter-spacing: 1px;
    text-transform: uppercase;
    touch-action: none;
}
/* A phone outline that tips over to landscape and back. */
#rotate-cover .rotate-phone {
    width: 44px;
    height: 76px;
    border: 4px solid #fff;
    border-radius: 6px;
    position: relative;
    animation: rotate-phone 2.4s ease-in-out infinite;
}
#rotate-cover .rotate-phone::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 4px;
    width: 8px;
    height: 4px;
    margin-left: -4px;
    background: #fff;
}
@keyframes rotate-phone {
    0%, 20% { transform: rotate(0deg); }
    45%, 75% { transform: rotate(-90deg); }
    100% { transform: rotate(0deg); }
}
