html {
    box-sizing: border-box;
    background-color: #0f0f1a;
}

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

html, body {
    padding: 0;
    margin: 0;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
}

html {
    overflow-x: hidden;
    overflow-y: hidden;
    overscroll-behavior-y: none;
}

body {
    background-color: #0f0f1a;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100vw;
    min-height: 100dvh;
}

#page-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Without this the column defaults to flex-start, so whenever the container is
       shorter than the viewport ALL the slack piles up as a single bar under the game
       instead of splitting evenly above and below it. */
    justify-content: center;
    width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    position: relative;
    isolation: isolate;
    overflow: hidden;
}

#page-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100dvh;
    background: url(Images/background.jpg) center center / cover no-repeat;
    z-index: -1;
}

canvas {
    display: block;
}

canvas:focus {
    outline: none;
}

#unity-canvas {
    width: 100%;
    height: 100%;
}

#unity-container {
    display: flex;
    position: relative;
    z-index: 1;

    /* DEFAULT (LANDSCAPE) BEHAVIOR:
      Lock to 9/16 and fit to the screen height.
      This creates "pillarboxes" (bars on the sides).
    */
    aspect-ratio: 55/100;  /* 0.7 */
    height: 100dvh;
    width: auto;
    max-width: 100vw; /* Safety catch */
}

/* CASE 1: "MEDIUM" PORTRAIT (THE "FILL" ZONE)
  (e.g., 9:18 phone, 0.43 <= AR <= 0.7)
*/
@media (min-aspect-ratio: 43/100) and (max-aspect-ratio: 55/100) {
    #unity-container {
        /* This is the ideal zone. FILL the screen. */
        aspect-ratio: auto;
        width: 100vw;
        height: 100dvh;
    }
}

/* CASE 2: "SKINNY" PORTRAIT
  (e.g., 9:22 phone, AR < 0.43)
*/
@media (max-aspect-ratio: 43/100) {
    #unity-container {
        /* Lock to your MINIMUM AR and fit to width. */
        /* This creates "letterboxes" (bars top/bottom). */
        aspect-ratio: 43/100;
        width: 100vw;
        height: auto;
        max-height: 100dvh;
    }
}

/* TOUCH DEVICES: always fill the viewport, no bars.

  The rules above are a DESKTOP presentation - a portrait-shaped game centred in a
  decorative frame over a background image. On a phone or tablet the game is the whole
  page and any bar reads as a bug (CrazyGames QA flagged exactly this).

  The 0.43-0.55 "fill" window is too narrow in practice: a portal embeds the game in an
  iframe whose height is cut by the portal's own chrome (and, on a phone browser, by the
  address bar), so a 19.5:9 handset that is 0.46 on paper lands nearer 0.58 in the frame
  and falls out of the window into the pillarbox branch. An iPad is ~0.70 in portrait and
  never had a chance. `#unity-container.unity-mobile` is (1,1,0) so it outranks the
  `#unity-container` rules inside the media queries above regardless of source order, and
  desktop behaviour is untouched.

  The ::after frame needs no handling here: it is drawn on negative offsets outside the
  container, so once the container is full-bleed the frame is clipped away by
  #page-wrapper's overflow:hidden. */
#unity-container.unity-mobile {
    aspect-ratio: auto;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
}

/* ...except in true landscape on a tablet. The UI canvases are built around 1125x2436
  with ScreenMatchMode=MatchWidthOrHeight, so filling a ~1.4 AR viewport compresses the
  layout to roughly 57% of its design height and anchored top/bottom elements start to
  collide. Keep the portrait presentation there - a rotate-your-device case, not the
  full-screen-phone case the review is about. */
@media (min-aspect-ratio: 80/100) {
    #unity-container.unity-mobile {
        aspect-ratio: 55/100;
        width: auto;
        height: 100dvh;
        max-width: 100vw;
    }
}


#unity-container::after {
    content: '';
    position: absolute;
    top: -110px;
    left: -161px;
    right: -159px;
    bottom: -115px;
    border-style: solid;
    border-top-width: 110px;
    border-left-width: 161px;
    border-right-width: 159px;
    border-bottom-width: 115px;

    border-image-source: url('Images/container_border.png');
    border-image-slice: 110 159 115 161;
    border-image-repeat: stretch;
    /* Send the frame *behind* the content container */
    z-index: -1;
}

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

#unity-loading-bar {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

#unity-logo {
    text-align: center;
    pointer-events: none;
}

#unity-logo img {
    max-width: 80%;
    max-height: 80%;
    pointer-events: none;
}


#unity-progress-bar-empty {
    width: 30%;
    height: 24px;
    margin: 10px 20px 20px 10px;
    text-align: left;
    border: 1px solid white;
    padding: 2px;
}

#unity-progress-bar-full {
    width: 0%;
    height: 100%;
    background: white;
    transition: width 0.5s ease;
}

.light #unity-progress-bar-empty {
    border-color: black;
}

.light #unity-progress-bar-full {
    background: black;
}

.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);
    }
}

.spinner {
    border-top: 1.1em solid rgba(255, 211, 37, 0.2);
    border-right: 1.1em solid rgba(255, 211, 37, 0.2);
    border-bottom: 1.1em solid rgba(255, 211, 37, 0.2);
    border-left: 1.1em solid rgba(63, 162, 255, 1);
}

#unity-progress-bar-empty {
    border-color: rgba(255, 211, 37, 0.7);
    width: 30%;
}

#unity-progress-bar-full {
    background: rgba(63, 162, 255, 1);
}

.light #unity-progress-bar-empty {
    border-color: rgba(255, 211, 37, 0.7);
}

.light #unity-progress-bar-full {
    background: rgba(63, 162, 255, 1);
}

#unity-progress-bar-empty {
    height: 24px;
}


#unity-progress-bar-empty {
    border-radius: 12px;
}

#unity-progress-bar-full {
    border-radius: 10px;
    transition: width 0.5s ease;
}



body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
  overflow: hidden;
}

#unity-container {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  aspect-ratio: 9/16;
  width: min(calc(100dvh*(9/16)), 100vw);
  height: auto;
}


body {
    background: linear-gradient(140deg, rgba(4, 4, 4, 1) 0%, rgba(5, 5, 5, 1) 100%);
}



.spinner {
    border-top: 1.1em solid rgba(255, 211, 37, 0.2);
    border-right: 1.1em solid rgba(255, 211, 37, 0.2);
    border-bottom: 1.1em solid rgba(255, 211, 37, 0.2);
    border-left: 1.1em solid rgba(63, 162, 255, 1);
}

#unity-progress-bar-empty {
    border-color: rgba(255, 211, 37, 0.7);
    width: 30%;
}

#unity-progress-bar-full {
    background: rgba(63, 162, 255, 1);
}

.light #unity-progress-bar-empty {
    border-color: rgba(255, 211, 37, 0.7);
}

.light #unity-progress-bar-full {
    background: rgba(63, 162, 255, 1);
}



#unity-progress-bar-empty {
    height: 24px;
}


#unity-progress-bar-empty {
    border-radius: 12px;
}

#unity-progress-bar-full {
    border-radius: 10px;
    transition: width 0.5s ease;
}
