.unity-container-wrapper {
  width: 100%;
  max-width: 100%;
  margin-top: 0.7rem;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  color: yellow;
  align-items: center;
  position: relative;
}

#unity-container {
  width: 100%;
  height: auto;
  max-width: 960px; /* Limit maximum size */
  position: relative;
}

#unity-canvas {
  width: 100% !important;
  height: auto !important;
  max-width: 960px; /* Limit maximum size */
  aspect-ratio: 16/10; /* Maintain aspect ratio */
  display: block;
  margin: auto;
  background-color: black;
}

#unity-warning {
  position: absolute;
  left: 50%;
  top: 5%;
  transform: translate(-50%);
  background: white;
  padding: 1rem;
  display: none;
}

#unity-footer {
  position: relative;
}
.unity-mobile #unity-footer {
  display: none;
}

#unity-logo-title-footer {
  float: left;
  width: 102px;
  height: 38px;
  background: url("../assets/unity-logo-title-footer.png") no-repeat center;
  filter: invert(1);
}

#unity-build-title {
  float: right;
  margin-right: 10px;
  line-height: 38px;
  font-family: arial;
  font-size: 18px;
  color: white;
  font-weight: bold;
}

#unity-fullscreen-button {
  cursor: pointer;
  float: right;
  width: 38px;
  height: 38px;
  background: url("../assets/fullscreen-button.png") no-repeat center;
}

#game-description {
  padding: 1rem;
  background: rgba(0, 0, 0, 0.5);
  border-radius: 5px;
  margin-top: 5rem;
  text-align: left;
}

/* Desktop styles (1200px and above) */
@media (min-width: 1200px) {
  .unity-container-wrapper {
    max-width: 100%;
    min-height: 100%;
  }

  #unity-container {
    width: 960px;
    height: 600px;
  }

  #unity-canvas {
    width: 960px !important;
    height: 600px !important;
  }
}

/* Large tablets and small desktops (992px to 1199px) */
@media (min-width: 992px) and (max-width: 1199px) {
  .unity-container-wrapper {
    max-width: 100%;
    padding: 1rem;
    min-height: 600px;
  }

  #unity-container {
    width: 90%;
    max-width: 800px;
    height: auto;
  }

  #unity-canvas {
    width: 100% !important;
    height: auto !important;
    max-width: 800px;
    aspect-ratio: 16/10;
  }
}

/* Tablets (768px to 991px) */
@media (min-width: 768px) and (max-width: 991px) {
  .unity-container-wrapper {
    padding: 1rem;
    min-height: 500px;
  }

  #unity-container {
    width: 95%;
    max-width: 700px;
    height: auto;
  }

  #unity-canvas {
    width: 100% !important;
    height: auto !important;
    max-width: 700px;
    aspect-ratio: 16/10;
  }
}

/* Small tablets and large phones (576px to 767px) */
@media (min-width: 576px) and (max-width: 767px) {
  .unity-container-wrapper {
    padding: 0.8rem;
    min-height: 400px;
  }

  #unity-container {
    width: 98%;
    height: auto;
  }

  #unity-canvas {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16/10;
    max-height: 60vh;
  }
}

/* Mobile phones (575px and below) */
@media (max-width: 575px) {
  .unity-container-wrapper {
    padding: 0.5rem;
    min-height: 300px;
    border: 1px dotted white; /* Thinner border for mobile */
  }

  #unity-container {
    width: 100%;
    height: auto;
  }

  #unity-canvas {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 16/10;
    max-height: 50vh;
    min-height: 250px;
  }

  /* Unity UI elements adjustments for mobile */
  #unity-footer {
    flex-direction: column;
    gap: 0.5rem;
  }

  #unity-fullscreen-button {
    padding: 0.5rem;
    font-size: 0.9rem;
  }
}

/* Extra small devices (phones in portrait, 320px and below) */
@media (max-width: 320px) {
  .unity-container-wrapper {
    min-height: 250px;
  }

  #unity-canvas {
    min-height: 200px;
    max-height: 45vh;
  }
}

/* Landscape orientation on mobile */
@media (max-width: 950px) and (orientation: landscape) {
  .unity-container-wrapper {
    min-height: 250px;
  }

  #unity-canvas {
    max-height: 70vh;
    aspect-ratio: 16/9; /* Better for landscape */
  }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  #unity-canvas {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
  }
}

/* Very small phones (480px and below) */
@media (max-width: 480px) {
  .unity-container-wrapper {
    padding: 3rem !important;
    min-height: 280px;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
    box-sizing: border-box !important;
    position: relative !important;
    transform: none !important;
  }

  #unity-container {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 auto !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    position: relative !important;
    left: 0 !important;
    right: 0 !important;
  }

  #unity-canvas {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 4/3 !important; /* Better ratio for very small screens */
    max-height: 45vh !important;
    min-height: 220px !important;
    margin: 0 auto !important;
    display: block !important;
    border-radius: 6px;
    position: relative !important;
    left: 0 !important;
    right: 0 !important;
    transform: none !important;
  }

  /* Force center all elements */
  #unity-footer {
    width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    text-align: center !important;
    margin: 0 auto !important;
    gap: 0.3rem;
  }

  #unity-fullscreen-button {
    margin: 0 auto !important;
    padding: 0.4rem;
    font-size: 0.8rem;
  }

  #unity-loading-bar {
    width: 95% !important;
    margin: 0.5rem auto !important;
    text-align: center !important;
  }

  #game-description {
    width: 100% !important;
    max-width: 100% !important;
    margin: 1rem auto !important;
    padding: 0.8rem !important;
    box-sizing: border-box !important;
    text-align: center !important;
    font-size: 0.9rem;
  }

  /* Remove any absolute positioning */
  .unity-container-wrapper * {
    position: relative !important;
    float: none !important;
    clear: both !important;
  }

  /* Ensure no elements extend beyond container */
  .unity-container-wrapper *,
  #unity-container *,
  #unity-canvas * {
    max-width: 100% !important;
    box-sizing: border-box !important;
  }
}
