* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: #fff; }
#f-container {
    position: fixed;
    left: 50%; top: 50%;
    width: 100vw; height: 100vh;
    width: 100dvw; height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    transform: translate(-50%, -50%);
    background: #fff;
}
.game-area { display: grid; place-items: center; min-width: 0; min-height: 0; }
#unity-container {
    position: relative;
    display: grid;
    grid-template-rows: minmax(0, 1fr);
    width: min(100%, 960px);
    height: min(100%, 600px);
    min-width: 0; min-height: 0;
}
#unity-canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%; height: 100%;
    min-width: 0; min-height: 0;
    background: #231f20;
}
#unity-loading-bar {
    display: none;
    position: absolute;
    left: 50%; top: 50%;
    transform: translate(-50%, -50%);
    width: min(80%, 154px);
    pointer-events: none;
}
#unity-logo { display: block; width: 100%; height: 130px; max-height: 30dvh; object-fit: contain; }
#unity-progress-bar-empty { width: 100%; height: 18px; margin-top: 10px; border: 1px solid #fff; }
#unity-progress-bar-full { width: 0; height: 100%; background: #fff; }
#unity-warning { position: absolute; top: 0; left: 0; right: 0; z-index: 20; font: 14px/1.5 Arial, sans-serif; overflow-wrap: anywhere; }
#orientation-hint { display: none; }

@media (max-width: 600px), (max-height: 450px), (orientation: landscape) and (pointer: coarse) {
    #unity-container { width: 100%; height: 100%; }
}

@media (orientation: portrait) {
    #f-container:not(.is-fullscreen) {
        grid-template-rows: auto auto;
        align-content: center;
    }

    #f-container:not(.is-fullscreen) #unity-container {
        width: 100%;
        height: auto;
        aspect-ratio: 16 / 9;
    }

    #orientation-hint {
        display: block;
        margin: 0;
        padding: 16px 20px 20px;
        color: #292524;
        font: 400 clamp(16px, 4vw, 18px)/1.7 system-ui, -apple-system, "Segoe UI", sans-serif;
        text-align: center;
        text-wrap: pretty;
    }
}

#fullscreen-hint {
    display: inline-block;
    padding: 4px 6px;
    color: #842f22;
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 4px;
}
#fullscreen-hint:focus-visible { outline: 2px solid #784b31; outline-offset: 3px; }
#f-container.is-fullscreen #unity-container { width: 100%; height: 100%; }
#f-container.is-fullscreen #orientation-hint { display: none; }
@media (orientation: portrait) {
    #f-container.is-fullscreen {
        width: 100vh; height: 100vw;
        width: 100dvh; height: 100dvw;
        transform: translate(-50%, -50%) rotate(90deg);
    }
}
