:root {
  --canvas-opacity: 1;
}

* {
  margin: 0;
  padding: 0;
  touch-action: none;
}

body {
  overflow: hidden;
  font-family: "Roboto", system-ui, sans-serif;
  -moz-user-select: none;
       user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #AFBABB;
}
::-webkit-scrollbar-thumb:hover {
  background: #5B696B;
}

canvas {
  opacity: var(--canvas-opacity);
}

button {
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
}

.hidden {
  display: none !important;
}

.spacer {
  flex-grow: 1;
}

#ui {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#ui * {
  pointer-events: auto;
}

/* poster */
#poster {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: var(--poster-url);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* loadingWrap */
#loadingWrap {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translate(-50%, 0);
  width: 380px;
  display: flex;
  flex-direction: column;
  padding: 16px;
}
#loadingWrap > #loadingText {
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  text-align: center;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
#loadingWrap > #loadingBar {
  width: 100%;
  height: 4px;
  margin-top: 12px;
  overflow: hidden;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* controlsWrap */
#controlsWrap {
  position: absolute;
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}
#controlsWrap.faded-in {
  visibility: visible;
  opacity: 1;
  transition: opacity 0.5s ease-out;
}
#controlsWrap.faded-out {
  visibility: hidden;
  opacity: 0;
  transition: visibility 0s 0.5s, opacity 0.5s ease-out;
}
#controlsWrap > #timelineContainer {
  height: 30px;
  cursor: pointer;
}
#controlsWrap > #timelineContainer > #line {
  width: 100%;
  height: 50%;
  border-bottom: 4px solid rgba(255, 255, 255, 0.6);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.3));
}
#controlsWrap > #timelineContainer > #handle {
  position: absolute;
  top: 16.5px;
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  border: 2px solid #fff;
  border-radius: 50%;
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}
#controlsWrap > #timelineContainer > #time {
  position: absolute;
  top: 0;
  padding: 4px 8px;
  border-radius: 2px;
  transform: translate(-50%, -100%);
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background-color: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}
#controlsWrap > #buttonsContainer {
  display: flex;
  gap: 8px;
  /* controlButton */
}
#controlsWrap > #buttonsContainer .controlButton {
  width: 40px;
  height: 40px;
  padding: 0;
  margin: 0;
  border: 0;
  cursor: pointer;
  color: #fff;
  background-color: transparent;
  transition: color 0.15s ease;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}
#controlsWrap > #buttonsContainer .controlButton:hover {
  color: #fff;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.5));
}
#controlsWrap > #buttonsContainer .controlButton {
  /* icon styling */
}
#controlsWrap > #buttonsContainer .controlButton > svg {
  display: block;
  margin: auto;
}
#controlsWrap > #buttonsContainer .controlButton > svg > g.stroke {
  fill: none;
  stroke: rgba(0, 0, 0, 0.4);
  stroke-width: 2;
  stroke-linejoin: round;
  opacity: 1;
}
#controlsWrap > #buttonsContainer .controlButton > svg > g.fill {
  fill: currentColor;
  stroke: none;
}
#controlsWrap > #buttonsContainer .controlButton {
  /* camera toggle styling */
}
#controlsWrap > #buttonsContainer .controlButton.toggle {
  border-radius: 8px;
  transition: background-color 0.15s ease, color 0.15s ease;
}
#controlsWrap > #buttonsContainer .controlButton.toggle.active {
  background-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}
#controlsWrap > #buttonsContainer .controlButton.toggle.left {
  margin-right: 4px;
}
#controlsWrap > #buttonsContainer .controlButton.toggle.right {
  margin-right: 20px;
}

/* settingsPanel */
#settingsPanel {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 80px);
  padding: 12px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  font-size: 14px;
  color: #0D0D0D;
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(175, 186, 187, 0.5);
}
#settingsPanel > .settingsRow {
  display: flex;
  gap: 6px;
  width: 100%;
}
#settingsPanel > .settingsRow > button {
  flex-grow: 1;
  padding: 10px 20px;
  border: 0;
  border-radius: 2px;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.15s ease;
  color: #5B696B;
  background-color: rgba(175, 186, 187, 0.2);
}
#settingsPanel > .settingsRow > button:hover {
  color: #0D0D0D;
  background-color: rgba(175, 186, 187, 0.4);
}
#settingsPanel > .settingsRow > div {
  padding: 8px;
  cursor: pointer;
  color: #5B696B;
}
#settingsPanel > .settingsRow > div.checkMark {
  width: 16px;
}
#settingsPanel > .settingsRow > div.checkMark:not(.active) {
  color: transparent;
}
#settingsPanel > .settingsRow > div.checkMark.active {
  color: #5B696B;
}
#settingsPanel > .settingsRow > div:hover {
  color: #0D0D0D;
}
#settingsPanel > .settingsRow {
  /* Speed slider styles */
}
#settingsPanel > .settingsRow .sliderLabel {
  width: 90px;
  color: #5B696B;
}
#settingsPanel > .settingsRow .sliderLabel #speedValue {
  color: #0D0D0D;
  font-weight: 600;
}
#settingsPanel > .settingsRow input[type=range] {
  flex-grow: 1;
  height: 4px;
  margin: auto 0;
  border-radius: 2px;
  -webkit-appearance: none;
     -moz-appearance: none;
          appearance: none;
  background: rgba(175, 186, 187, 0.5);
  cursor: pointer;
}
#settingsPanel > .settingsRow input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
          appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #5B696B;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
#settingsPanel > .divider {
  width: 100%;
  height: 1px;
  margin: 8px 0;
  background-color: rgba(175, 186, 187, 0.5);
}

/* infoPanel */
#infoPanel {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(8px);
}
#infoPanel > #infoPanelContent {
  position: absolute;
  top: 40px;
  left: 50%;
  transform: translate(-50%, 0);
  min-height: 280px;
  min-width: 320px;
  padding: 8px;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  color: #0D0D0D;
  background-color: rgba(255, 255, 255, 0.95);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(175, 186, 187, 0.5);
}
#infoPanel > #infoPanelContent > #tabs {
  display: flex;
  gap: 8px;
  padding: 6px;
  border-radius: 2px;
  background-color: rgba(175, 186, 187, 0.2);
}
#infoPanel > #infoPanelContent > #tabs > .tab {
  padding: 10px 16px;
  border-radius: 2px;
  cursor: pointer;
  flex-grow: 1;
  text-align: center;
  font-weight: 500;
  font-size: 14px;
  color: #5B696B;
  transition: all 0.2s ease;
}
#infoPanel > #infoPanelContent > #tabs > .tab:hover {
  color: #0D0D0D;
  background-color: rgba(255, 255, 255, 0.5);
}
#infoPanel > #infoPanelContent > #tabs > .tab.active {
  color: #0D0D0D;
  background-color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
#infoPanel > #infoPanelContent > #infoPanels {
  padding: 20px;
}
#infoPanel > #infoPanelContent > #infoPanels h1 {
  font-size: 13px;
  font-weight: 600;
  padding: 0 0 8px 0;
  color: #0D0D0D;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
#infoPanel > #infoPanelContent > #infoPanels .control-item {
  display: flex;
  justify-content: space-between;
  gap: 32px;
  line-height: 1.6;
  font-size: 14px;
}
#infoPanel > #infoPanelContent > #infoPanels .control-item > .control-action {
  text-align: left;
  color: #5B696B;
}
#infoPanel > #infoPanelContent > #infoPanels .control-item > .control-key {
  text-align: right;
  color: #0D0D0D;
  font-weight: 500;
}
#infoPanel > #infoPanelContent > #infoPanels .control-spacer {
  border-bottom: 1px solid rgba(175, 186, 187, 0.4);
  margin: 12px 0;
}

#joystickBase {
  position: absolute;
  width: 96px;
  height: 96px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  touch-action: none;
  background: radial-gradient(circle at center, rgba(255, 255, 255, 0) 50%, rgba(175, 186, 187, 0.4) 100%);
  background-color: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(175, 186, 187, 0.5);
}
#joystickBase > #joystick {
  position: absolute;
  width: 48px;
  height: 48px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  touch-action: none;
  background-color: rgba(255, 255, 255, 0.9);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  border: 1px solid rgba(175, 186, 187, 0.5);
}

#tooltip {
  display: none;
  position: absolute;
  padding: 6px 10px;
  border-radius: 2px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  background-color: rgba(13, 13, 13, 0.9);
  backdrop-filter: blur(4px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

#annotations {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#annotations * {
  pointer-events: auto;
}

/* Drop Zone Overlay */
#dropZone {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
#dropZone > #dropMessage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 56px;
  border: 2px dashed #AFBABB;
  border-radius: 4px;
  background-color: #fff;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}
#dropZone > #dropMessage > .dropIcon {
  color: #5B696B;
}
#dropZone > #dropMessage > .dropText {
  font-size: 24px;
  font-weight: 600;
  color: #0D0D0D;
}
#dropZone > #dropMessage > .dropHint {
  font-size: 14px;
  color: #5B696B;
  text-align: center;
  line-height: 1.6;
}

/* FPS Overlay */
#fpsOverlay {
  position: fixed;
  top: 16px;
  right: 16px;
  font-size: 13px;
  font-weight: 600;
  font-family: "SF Mono", "Monaco", "Consolas", monospace;
  color: #fff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  z-index: 900;
}

/* ==================== Landing Page ==================== */
#sceneListOverlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;
  display: flex;
  flex-direction: column;
  z-index: 100;
}

#landingHeader {
  padding: 32px 48px;
  display: flex;
  align-items: center;
  gap: 0px;
  background-color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  z-index: 1;
}

#landingLogo {
  height: 200px;
  width: auto;
}

#landingDescription {
  flex: 1;
  text-align: center;
}
#landingDescription h1 {
  font-size: 56px;
  font-weight: 700;
  color: #0D0D0D;
  margin-bottom: 4px;
}
#landingDescription p {
  font-size: 28px;
  color: #5B696B;
}

#landingQR {
  height: 200px;
  width: auto;
}

#landingContent {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 48px;
  overflow: hidden;
  background-color: #fff;
}

#sceneListLoading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 60px 20px;
  color: #5B696B;
  font-size: 14px;
}
#sceneListLoading .loadingSpinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(175, 186, 187, 0.4);
  border-top-color: #5B696B;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
#sceneListError {
  padding: 20px;
  text-align: center;
  color: #dc3545;
  font-size: 14px;
}

#sceneCarousel h2 {
  font-size: 28px;
  font-weight: 600;
  color: #0D0D0D;
  margin-bottom: 24px;
  margin-left: 64px;
  letter-spacing: -0.25px;
}

#carouselContainer {
  display: flex;
  align-items: center;
  gap: 16px;
}

#carouselTrack {
  flex: 1;
  display: flex;
  gap: 24px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding: 8px 4px;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
}
#carouselTrack::-webkit-scrollbar {
  display: none;
}

.carouselNav {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: #5B696B;
  cursor: pointer;
  transition: color 0.15s ease;
}
.carouselNav:hover:not(:disabled) {
  color: #0D0D0D;
}
.carouselNav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.sceneCard {
  flex-shrink: 0;
  width: 280px;
  display: flex;
  flex-direction: column;
  border-radius: 4px;
  background-color: #fff;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(175, 186, 187, 0.3);
}
.sceneCard:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-color: #AFBABB;
}
.sceneCard:active {
  transform: translateY(-2px);
}
.sceneCard .thumbnailWrap {
  position: relative;
  width: 100%;
  padding-top: 56.25%; /* 16:9 aspect ratio */
  background-color: #e8ecec;
  overflow: hidden;
}
.sceneCard .thumbnail {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  -o-object-fit: cover;
     object-fit: cover;
  transition: transform 0.3s ease;
}
.sceneCard:hover .thumbnail {
  transform: scale(1.05);
}
.sceneCard .thumbnailPlaceholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #AFBABB;
}
.sceneCard .sceneInfo {
  padding: 16px;
}
.sceneCard .sceneName {
  font-size: 15px;
  font-weight: 500;
  color: #0D0D0D;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sceneCard .sceneDescription {
  font-size: 13px;
  color: #5B696B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#dropHint {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  color: #AFBABB;
  font-size: 13px;
}
#dropHint svg {
  opacity: 0.8;
}

@media (max-width: 768px) {
  #sceneListOverlay {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
  }
  #landingHeader {
    position: relative;
    padding: 20px;
    flex-direction: row;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
  }
  #landingLogo {
    height: 56px;
    flex-shrink: 0;
  }
  #landingDescription {
    flex: 1;
    text-align: left;
  }
  #landingDescription h1 {
    font-size: 20px;
    margin-bottom: 2px;
  }
  #landingDescription p {
    font-size: 12px;
    line-height: 1.3;
  }
  #landingQR {
    display: none;
  }
  #landingContent {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
  }
  #sceneCarousel h2 {
    font-size: 18px;
    margin-bottom: 16px;
    margin-left: 0;
  }
  .carouselNav {
    display: none;
  }
  #carouselContainer {
    margin: 0 -20px;
  }
  #carouselTrack {
    padding: 8px 20px 16px;
    gap: 12px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
  }
  .sceneCard {
    width: 160px;
    scroll-snap-align: start;
  }
  .sceneCard .thumbnailWrap {
    padding-top: 75%;
  }
  .sceneCard .sceneInfo {
    padding: 12px;
  }
  .sceneCard .sceneName {
    font-size: 14px;
  }
  .sceneCard .sceneDescription {
    font-size: 12px;
  }
  .sceneCard:hover {
    transform: none;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  }
  .sceneCard:active {
    transform: scale(0.98);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  }
  #dropHint {
    position: relative;
    bottom: auto;
    left: auto;
    transform: none;
    margin-top: 24px;
    justify-content: center;
    font-size: 12px;
  }
  #sceneListLoading {
    padding: 40px 20px;
  }
  #sceneListOverlay,
  #landingContent,
  #carouselTrack {
    touch-action: pan-x pan-y;
  }
}
@media (max-width: 480px) {
  #landingHeader {
    padding: 16px;
    gap: 12px;
  }
  #landingLogo {
    height: 48px;
  }
  #landingDescription h1 {
    font-size: 18px;
  }
  #landingDescription p {
    font-size: 11px;
  }
  #landingContent {
    padding: 16px;
  }
  #sceneCarousel h2 {
    font-size: 16px;
    margin-bottom: 12px;
  }
  #carouselContainer {
    margin: 0 -16px;
  }
  #carouselTrack {
    padding: 8px 16px 12px;
    gap: 10px;
  }
  .sceneCard {
    width: 140px;
  }
  .sceneCard .sceneInfo {
    padding: 10px;
  }
  .sceneCard .sceneName {
    font-size: 13px;
  }
  .sceneCard .sceneDescription {
    font-size: 11px;
  }
  #dropHint {
    margin-top: 20px;
    font-size: 11px;
  }
}