body,
html {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  /* height: 100dvh; Dynamic viewport height for mobile browsers */
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  background-color: #12226c;
}

body {
  box-sizing: border-box;
}
body::after {
  content: "";
  position: absolute;
  top: env(safe-area-inset-top);
  left: env(safe-area-inset-left);
  right: env(safe-area-inset-right);
  bottom: env(safe-area-inset-bottom);
  background: linear-gradient(135deg, #6b6b6b 0%, #2c2c2c 50%, #1a1a1a 100%);
  z-index: -1;
}

header {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 20px;
  padding-top: calc(20px + env(safe-area-inset-top));
  z-index: 10;
}

.logo {
  max-width: 20vw;
  height: auto;
  opacity: 0.8;
}
/* This keeps child nodes hidden while the element loads */
:not(:defined) > * {
  display: none;
}

model-viewer {
  flex-grow: 1;
  width: 100%;
  height: 100%;
  --ar-button-display: block; /* Show by default, JS will hide on desktop */
  --progress-bar-color: white; /* Make loading bar white */
  background: transparent; /* Make model-viewer transparent to show background */
  position: relative;
  z-index: 2;
}

model-viewer::part(default-ar-button) {
  bottom: auto;
  top: 100px;
  right: 20px;
}
.screen-controls {
  position: absolute;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
  z-index: 15;
  transition: left 0.3s ease-out;
}

footer {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 20px;
  z-index: 4;
  padding-bottom: calc(20px + env(safe-area-inset-bottom));
}
button {
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 25px;
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1),
    0 1px 3px rgba(255, 255, 255, 0.3) inset;
  transition: all 0.3s ease;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  min-height: 44px;
}
button:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.5);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15),
    0 2px 5px rgba(255, 255, 255, 0.4) inset;
  transform: translateY(-1px);
}
button.active {
  background: rgba(0, 123, 255, 0.3);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 1);
  border-color: rgba(0, 123, 255, 0.6);
  box-shadow: 0 4px 15px rgba(0, 123, 255, 0.2),
    0 1px 3px rgba(255, 255, 255, 0.3) inset;
}

button.hotspot {
  content: "";
  padding: 0 !important;
  margin: 0;
  width: 12px !important;
  height: 12px !important;
  min-width: 12px !important;
  min-height: 12px !important;
  background: #5f5f5f;
  border: none !important;
  border-radius: 50% !important;
  border: 1px solid white !important;
  position: absolute;
  cursor: pointer;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
  text-shadow: none !important;
  font-size: 0 !important;
  line-height: 1 !important;
  /* --min-hotspot-opacity: 0; */

  overflow: visible !important;
  /* Start hidden to avoid top-left glitch */

  pointer-events: auto;
  transition: opacity 0.4s ease-in-out;
}

.annotations {
  position: absolute;
  transform: translate(10px, 10px);
  padding: 10px 16px;
  font-size: 14px !important; /* Force font size to override parent */
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1),
    0 1px 3px rgba(255, 255, 255, 0.3) inset;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  white-space: nowrap;
  pointer-events: none;
  display: inline-block !important; /* Force display to override parent */
  min-width: fit-content;
  z-index: 10;
  line-height: 1.2 !important; /* Override parent line-height */
}

/* Mobile responsive styles */
@media (max-width: 768px) {
  header {
    top: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    text-align: center;
  }

  .logo {
    max-width: 80vw;
    height: auto;
    opacity: 0.8;
  }

  footer {
    bottom: 0;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    padding: 0 10px;
    padding-bottom: calc(15px + env(safe-area-inset-bottom));
    width: 100%;
    box-sizing: border-box;
  }

  .screen-controls {
    bottom: calc(85px + env(safe-area-inset-bottom));
    gap: 10px;
    width: max-content;
  }

  button {
    padding: 6px 8px;
    font-size: 10px;
    min-width: 60px;
    flex: 1;
    max-width: calc(50% - 3px);
    min-height: 36px;
    line-height: 1.1;
  }

  button.hotspot {
    width: 16px !important;
    height: 16px !important;
    min-width: 16px !important;
    min-height: 16px !important;
  }

  .annotations {
    transform: translate(12px, 12px);
    padding: 6px 10px;
    font-size: 13px !important;
    line-height: 1.2 !important;
  }
}

/* iPhone specific optimizations */
@media (max-width: 414px) {
  header {
    top: 10px;
  }

  .logo {
    max-width: 80vw;
    height: auto;
  }

  footer {
    bottom: 0;
    gap: 4px;
    padding: 0 5px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .screen-controls {
    bottom: calc(75px + env(safe-area-inset-bottom));
    gap: 4px;
  }

  button {
    padding: 4px 6px;
    font-size: 12px;
    min-width: 50px;
    border-radius: 15px;
    flex: 1;
    max-width: calc(50% - 2px);
    min-height: 32px;
    line-height: 1;
  }

  button.hotspot {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
  }

  .annotations {
    transform: translate(14px, 14px);
    padding: 5px 8px;
    font-size: 12px !important;
    line-height: 1.2 !important;
  }
}

/* iPhone SE and smaller screens */
@media (max-width: 375px) {
  button {
    padding: 3px 4px;
    font-size: 12px;
    min-width: 45px;
    border-radius: 12px;
    min-height: 28px;
    line-height: 0.9;
  }

  button.hotspot {
    width: 20px !important;
    height: 20px !important;
    min-width: 20px !important;
    min-height: 20px !important;
  }

  .annotations {
    transform: translate(16px, 16px);
    padding: 4px 6px;
    font-size: 11px !important;
    line-height: 1.2 !important;
  }
}
