body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: Arial, sans-serif;
  user-select: none;
  -webkit-user-select: none; /* Safari */
  -moz-user-select: none; /* Firefox */
  -ms-user-select: none; /* IE/Edge */
  touch-action: manipulation;
  -webkit-touch-callout: none; /* iOS Safari */
}

#game-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.online-users {
  position: fixed;
  top: 20px;
  right: 20px;
  background-color: rgba(0, 0, 0, 0.2);
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 14px;
  color: #fff;
  z-index: 10;
  font-family: monospace;
}

.player-coords {
  position: fixed;
  top: 20px;
  left: 20px;
  background-color: rgba(0, 0, 0, 0.2); /* Semi-transparent background */
  padding: 10px 15px;
  border-radius: 8px;
  font-size: 14px;
  color: #fff;
  z-index: 10;
  font-family: monospace;
  transition: background-color 0.3s ease;
}

.player-coords:hover {
  background-color: rgba(0, 0, 0, 0.4); /* Slightly darker on hover */
}

.instructions {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.7);
  padding: 20px;
  border-radius: 8px;
  font-size: 18px;
  color: #fff;
  z-index: 100;
  max-width: 400px;
  text-align: center;
}

.crosshair {
  position: fixed;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 1000;
}

.crosshair::before,
.crosshair::after {
  content: "";
  position: absolute;
  background-color: white;
}

.crosshair::before {
  top: 9px;
  left: 0;
  width: 20px;
  height: 2px;
}

.crosshair::after {
  top: 0;
  left: 9px;
  width: 2px;
  height: 20px;
}

#move-instruction {
  position: fixed;
  bottom: 150px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 15px;
  border-radius: 8px;
  z-index: 1500;
  text-align: center;
  pointer-events: none;
  max-width: 90%;
}

#joystick-container {
  position: fixed;
  bottom: 50px;
  left: 50px;
  width: 120px;
  height: 120px;
  z-index: 1000;
  display: none; 
  touch-action: none;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 50%;
}

#jump-button {
  position: fixed;
  bottom: 50px;
  right: 20px;
  width: 80px;
  height: 80px;
  background-color: rgba(255, 255, 255, 0.5);
  border-radius: 50%;
  display: none; 
  z-index: 1000;
  touch-action: none;
  text-align: center;
  line-height: 80px;
  font-weight: bold;
  color: #333;
  user-select: none;
}

#action-buttons {
  position: fixed;
  top: 50%;
  right: 20px;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 15px;
  z-index: 1000;
}

.action-btn {
  width: 60px;
  height: 60px;
  background-color: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  -webkit-tap-highlight-color: transparent; /* Remove blue highlight on tap */
}

.action-btn:hover {
  background-color: rgba(255, 255, 255, 1);
  transform: scale(1.1);
}

.action-btn.danger-btn {
    background-color: rgba(244, 67, 54, 0.8);
}
.action-btn.danger-btn:hover {
    background-color: rgba(218, 25, 11, 1);
}

.place-book-btn {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 60px;
  background-color: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(0, 0, 0, 0.3);
  border-radius: 50%;
  font-size: 24px;
  cursor: pointer;
  z-index: 1000;
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.place-book-btn:hover {
  background-color: rgba(255, 255, 255, 1);
  transform: translateX(-50%) scale(1.1);
}

.shelf-modal, .book-modal, .computer-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 30px;
  border-radius: 10px;
  z-index: 2000;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.book-modal h2 {
  margin-top: 0;
  color: #4CAF50;
}

.book-modal input,
.book-modal textarea {
  width: 100%;
  padding: 12px;
  margin: 8px 0;
  border: 1px solid #444;
  border-radius: 5px;
  font-size: 16px;
  box-sizing: border-box;
  background-color: rgba(255,255,255,0.1);
  color: white;
}

.book-modal input::placeholder,
.book-modal textarea::placeholder {
  color: #aaa;
}

.book-modal textarea {
  resize: vertical;
  min-height: 80px;
}

.book-modal input[type="file"] {
  padding: 5px;
  background: rgba(255,255,255,0.1);
  color: white;
}

.shelf-modal button, .book-modal button, .computer-modal button {
  margin: 5px;
  padding: 12px 24px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  background-color: #4CAF50;
  color: white;
  font-size: 16px;
  transition: background-color 0.3s;
}

.shelf-modal button:hover, .book-modal button:hover, .computer-modal button:hover {
  background-color: #45a049;
}

.shelf-modal .danger-btn {
    background-color: #f44336;
}
.shelf-modal .danger-btn:hover {
    background-color: #da190b;
}

.shelf-modal .close-btn, .book-modal .close-btn {
  background-color: #f44336;
}
.shelf-modal .close-btn:hover, .book-modal .close-btn:hover {
  background-color: #da190b;
}

.shelf-actions {
    margin-top: 15px;
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
}

.book-list {
    max-height: 40vh;
    overflow-y: auto;
    border: 1px solid #444;
    border-radius: 5px;
    padding: 10px;
    margin-top: 15px;
}

.book-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #333;
    cursor: grab;
    transition: background-color 0.2s, opacity 0.2s;
}

.book-list-item[draggable="true"]:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.book-list-item:last-child {
    border-bottom: none;
}

.remove-from-shelf-btn {
    background: #f44336;
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    font-size: 16px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    margin-left: 10px;
    transition: background-color 0.2s;
}

.remove-from-shelf-btn:hover {
    background: #c0392b;
}

.book-iframe {
  width: 100%;
  height: 80vh;
  border: none;
  border-radius: 10px;
}

.computer-book-list {
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid #444;
    border-radius: 5px;
    padding: 10px;
    margin-top: 15px;
    text-align: left;
}

.computer-book-item {
    padding: 8px;
    border-bottom: 1px solid #333;
}

.computer-book-item:last-child {
    border-bottom: none;
}

.computer-book-item p {
    margin: 2px 0;
    font-size: 12px;
    color: #ccc;
}
.computer-book-item strong {
    color: white;
    font-size: 14px;
}

#book-preview {
  position: fixed;
  transform: translate(-50%, -110%);
  background-color: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 15px;
  border-radius: 8px;
  z-index: 3000;
  max-width: 300px;
  pointer-events: none;
  text-align: left;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 4px 15px rgba(0,0,0,0.5);
  transition: opacity 0.2s ease-in-out;
  opacity: 0;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

#book-preview.visible {
    opacity: 1;
}

#book-preview h3 {
  margin-top: 0;
  margin-bottom: 10px;
  color: #a5d6a7;
  font-size: 16px;
  border-bottom: 1px solid #444;
  padding-bottom: 8px;
  font-weight: 600;
}

#book-preview p {
  margin: 0;
  font-size: 14px;
  max-height: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;  
  color: #f0f0f0;
  line-height: 1.4;
}

#cabinet-preview p {
  margin: 5px 0;
  font-size: 14px;
  color: #f0f0f0;
  line-height: 1.4;
}

@media (max-width: 768px) {
  #joystick-container {
    display: block;
  }
  
  #jump-button {
    display: block;
  }
  
  .instructions {
    display: none !important; 
  }
  
  .place-book-btn {
    bottom: 120px;
  }

  #action-buttons {
    bottom: 120px;
  }
  
  #move-instruction {
      bottom: 200px;
  }
}