body {
  margin: 0;
  overflow: hidden;
}

#instructions {
  position: absolute;
  top: 20px;
  left: 20px;
  font-family: 'Courier New', monospace;
  font-size: 14px;
  color: white;
  background: rgba(0, 0, 0, 0.5);
  padding: 15px;
  border-radius: 5px;
  pointer-events: none;
  z-index: 100;
  line-height: 1.6;
  max-width: 300px;
  backdrop-filter: blur(5px);
  white-space: pre-line;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#instructions.hidden {
  opacity: 0;
  transform: translateX(-20px);
  pointer-events: none;
}

/* Instructions toggle button */
#instructions-toggle {
  display: none;
  position: absolute;
  top: 20px;
  left: 20px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  border: none;
  color: white;
  font-size: 20px;
  cursor: pointer;
  z-index: 101;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

#instructions-toggle:hover {
  background: rgba(0, 0, 0, 0.8);
}

#instructions-toggle.active {
  background: rgba(60, 60, 60, 0.8);
}

/* Controls toggle button */
#controls-toggle {
  display: none;
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(40, 40, 40, 0.9);
  backdrop-filter: blur(5px);
  border: 2px solid rgba(255, 255, 255, 0.2);
  color: white;
  font-size: 24px;
  cursor: pointer;
  z-index: 1001;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s ease, background 0.2s ease;
}

#controls-toggle:hover {
  transform: scale(1.1);
  background: rgba(60, 60, 60, 0.95);
}

#controls-toggle.active {
  background: rgba(80, 80, 80, 0.95);
}

/* Controls overlay for mobile */
#controls-overlay {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 60vh;
  background: rgba(30, 30, 30, 0.95);
  backdrop-filter: blur(10px);
  border-top-left-radius: 16px;
  border-top-right-radius: 16px;
  z-index: 1000;
  overflow-y: auto;
  transform: translateY(100%);
  transition: transform 0.3s ease;
  padding-bottom: env(safe-area-inset-bottom, 20px);
}

#controls-overlay.visible {
  transform: translateY(0);
}

#controls-overlay .drag-handle {
  width: 40px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin: 12px auto;
}

/* Mobile Tweakpane wrapper */
#mobile-pane-container {
  padding: 0 8px 80px 8px;
}

/* Mobile styles */
@media (max-width: 768px) {
  #instructions {
    display: none;
  }

  #instructions.visible {
    display: block;
    opacity: 1;
    transform: translateX(0);
    top: 70px;
    max-width: calc(100vw - 40px);
    font-size: 12px;
    padding: 12px;
  }

  #instructions-toggle {
    display: flex;
  }

  #controls-toggle {
    display: flex;
  }

  #controls-overlay {
    display: block;
  }

  /* Hide default Tweakpane on mobile */
  .tp-dfwv {
    display: none !important;
  }

  /* Show Tweakpane inside mobile container */
  #mobile-pane-container .tp-dfwv {
    display: block !important;
    position: static !important;
    width: 100% !important;
    max-width: none !important;
  }

  #mobile-pane-container .tp-rotv {
    width: 100% !important;
  }
}

/* Tablet styles */
@media (min-width: 769px) and (max-width: 1024px) {
  #instructions {
    max-width: 250px;
    font-size: 13px;
  }
}