html {
    box-sizing: border-box;
}
*, *:before, *:after {
    box-sizing: inherit;
}
html, body {
    height: 100%;
    width: 100%;

    align-items: center;
    justify-content: center;
    display: flex;
}
canvas {
    display: block;
}
body {
    margin: 0;
}
#unity-container {
    width: 100%;
    height: 100%;
}

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

    display: block;
    background: #231F20;
}
#loading-cover {
  position: fixed;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: url('loading-background.png');
  background-repeat: no-repeat;
  background-size: cover;
  padding: 0;
  z-index: 1000;
}
@media (min-aspect-ratio: 16/9) {
    #loading-cover {
        width: auto;
        height: 100%;
    }
}


#unity-loading-bar {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}
#unity-logo {
    text-align: center;
    position: relative;
    width: 100%;
    height: 100%;
    margin-bottom: 2em;
}
.loading-logo-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 550px;
  height: 550px;
  transform: translate(-50%, -50%);
  z-index: 1;
}
.loading-logo {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 336px;
  height: 336px;
  transform: translate(-50%, -50%);
  z-index: 2;
}

#unity-fullscreen-button {
    position: absolute;
    left: 10px;
    bottom: 10px;
    width: 38px;
    height: 38px;
    background: url('fullscreen-button.png') no-repeat center;
    background-size: contain;
}

.loading-bottom-right {
  position: fixed;
  bottom: 50px;
  right: 120px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
}
.spinner-wrapper {
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.spinner {
  width: 100px;
  height: 100px;
  animation: spinner-spin 5s infinite linear;
}
.loading-text {
  color: white;
  font-size: clamp(28px, 6vw, 60px);
  font-family: 'Poetsen One', sans-serif;
  font-weight: 400;
}
.loading-text .dots span {
  animation: dot-fade 1.5s infinite;
  opacity: 0;
}
.loading-text .dots span:nth-child(1) {
  animation-delay: 0s;
}
.loading-text .dots span:nth-child(2) {
  animation-delay: 0.3s;
}
.loading-text .dots span:nth-child(3) {
  animation-delay: 0.6s;
}
@keyframes dot-fade {
  0%, 20% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}
@keyframes spinner-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Stato di loading: nasconde canvas per evitare 16:9 visibile dietro */
body.loading-active #unity-container, body.loading-active #unity-canvas {
  visibility: hidden;
}
body.loading-active #loading-cover {
  display: flex;
}

/* Portrait / schermi stretti: adatta dimensioni mantenendo proporzioni */
@media (max-aspect-ratio: 16/9) {
  #unity-logo {
    height: 100%;
  }
  .loading-logo-glow {
    width: min(90vw, 550px);
    height: min(90vw, 550px);
  }
  .loading-logo {
    width: calc(min(90vw, 550px) * 336 / 550);
    height: calc(min(90vw, 550px) * 336 / 550);
  }
  .spinner-wrapper, .spinner {
    width: clamp(60px, 18vw, 100px);
    height: clamp(60px, 18vw, 100px);
  }
  .loading-bottom-right {
    bottom: 30px;
    right: 30px;
    gap: clamp(12px, 4vw, 20px);
  }
}
