* { margin: 0; padding: 0; box-sizing: border-box; }
body { font-family: 'Segoe UI', Arial, sans-serif; overflow: hidden; background: #000; color: #fff; }
canvas { display: block; position: fixed; top: 0; left: 0; z-index: 0; }

#blocker {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.7); cursor: pointer;
}
#blocker.hidden { display: none; }
#instructions { text-align: center; max-width: 420px; }
#instructions h1 { font-size: 4rem; font-weight: 900; letter-spacing: 8px;
  background: linear-gradient(135deg, #00d4ff, #7b2ff7);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent; margin-bottom: 20px; }
#instructions > p { font-size: 1rem; color: #aaa; margin-bottom: 25px; }
.controls-hint { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.controls-hint span { background: rgba(255,255,255,0.08); padding: 6px 12px; border-radius: 6px;
  font-size: 0.75rem; color: #888; }

#hud { position: fixed; inset: 0; pointer-events: none; z-index: 100; }
#chat-container {
  position: absolute; bottom: 70px; left: 20px; width: 350px;
  background: rgba(0,0,0,0.6); border-radius: 12px; backdrop-filter: blur(10px);
  pointer-events: auto; overflow: hidden; transition: opacity 0.3s, transform 0.3s;
  transform-origin: bottom left;
}
#chat-container.hidden { opacity: 0; transform: scale(0.8) translateY(20px); pointer-events: none; }
#chat-messages { height: 200px; overflow-y: auto; padding: 12px; font-size: 0.85rem; }
#chat-messages::-webkit-scrollbar { width: 4px; }
#chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }
.chat-msg { margin-bottom: 6px; line-height: 1.4; word-wrap: break-word; }
.chat-name { color: #7bff7b; font-weight: 600; }
.chat-body { color: #ddd; }
#chat-input-area { display: flex; border-top: 1px solid rgba(255,255,255,0.1); }
#chat-input { flex: 1; background: transparent; border: none; padding: 10px 12px;
  color: #fff; font-size: 0.85rem; outline: none; }
#chat-input::placeholder { color: #666; }
#chat-send { background: transparent; border: none; color: #7bff7b; padding: 10px 16px;
  cursor: pointer; font-weight: 600; }
#chat-send:hover { background: rgba(255,255,255,0.05); }

#chat-toggle {
  position: absolute; bottom: 20px; left: 20px; width: 44px; height: 44px;
  background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%; color: #fff; font-size: 1.3rem; cursor: pointer;
  backdrop-filter: blur(8px); transition: background 0.2s, transform 0.2s;
  display: flex; align-items: center; justify-content: center; z-index: 10;
  pointer-events: auto;
}
#chat-toggle:hover { background: rgba(123,255,123,0.2); transform: scale(1.1); }
#chat-toggle.active { background: rgba(123,255,123,0.3); border-color: rgba(123,255,123,0.4); }

#obj-editor {
  position: absolute; top: 80px; right: 20px; width: 280px;
  background: rgba(15,15,30,0.92); backdrop-filter: blur(16px);
  border: 1px solid rgba(130,80,220,0.3); border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5), 0 0 0 1px rgba(130,80,220,0.15);
  pointer-events: auto; transition: opacity 0.25s, transform 0.25s; z-index: 10;
  overflow: hidden;
}
#obj-editor.hidden { opacity: 0; transform: scale(0.92) translateY(-8px); pointer-events: none; }
.editor-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; background: linear-gradient(135deg, rgba(80,40,160,0.4), rgba(40,20,80,0.3));
  border-bottom: 1px solid rgba(130,80,220,0.2);
}
.editor-title { color: #ccc; font-size: 0.85rem; }
.editor-title .obj-name { color: #fff; font-weight: 600; }
.editor-close { background: transparent; border: none; color: #888; font-size: 1.1rem; cursor: pointer; padding: 2px 8px; border-radius: 4px; }
.editor-close:hover { color: #fff; background: rgba(255,255,255,0.1); }
.editor-tabs { display: flex; gap: 0; border-bottom: 1px solid rgba(255,255,255,0.06); }
.editor-tab { flex: 1; background: transparent; border: none; color: #888; padding: 8px; cursor: pointer; font-size: 0.8rem; transition: all 0.2s; border-bottom: 2px solid transparent; }
.editor-tab:hover { color: #ccc; background: rgba(255,255,255,0.03); }
.editor-tab.active { color: #b388ff; border-bottom-color: #b388ff; }
.transform-modes { display: flex; border-bottom: 1px solid rgba(255,255,255,0.06); }
.tmode-btn { flex: 1; background: transparent; border: none; color: #888; padding: 6px; cursor: pointer; font-size: 1rem; transition: all 0.2s; border-bottom: 2px solid transparent; }
.tmode-btn:hover { color: #ccc; background: rgba(255,255,255,0.03); }
.tmode-btn.active { color: #b388ff; border-bottom-color: #b388ff; }
.edit-scope { display: flex; gap: 6px; padding: 8px 10px; border-bottom: 1px solid rgba(255,255,255,0.06); }
.escope-btn { flex: 1; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); color: #999; padding: 5px 4px; cursor: pointer; font-size: 0.78rem; border-radius: 6px; transition: all 0.2s; }
.escope-btn:hover { color: #ccc; background: rgba(255,255,255,0.08); }
.escope-btn.active { color: #fff; background: rgba(123,47,247,0.35); border-color: #b388ff; }
.escope-btn[data-scope="part"].active { background: rgba(255,149,0,0.35); border-color: #ff9500; }
.editor-body { padding: 12px 14px 14px; }
.opacity-row { align-items: center; gap: 8px; }
.opacity-row input[type=range] { flex: 1; accent-color: #b388ff; }
.opacity-row #obj-opacity-val { min-width: 42px; text-align: right; font-size: 0.8rem; color: #bbb; }
.btn-tex { width: 100%; background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: #ddd; padding: 7px; border-radius: 6px; cursor: pointer; font-size: 0.82rem; transition: all 0.2s; }
.btn-tex:hover { background: rgba(179,136,255,0.2); border-color: #b388ff; color: #fff; }
.edit-tab-content { display: none; }
.edit-tab-content.active { display: block; }
.editor-section { margin-bottom: 14px; }
.section-label { display: block; font-size: 0.7rem; color: #8877aa; letter-spacing: 1px; margin-bottom: 6px; }
.num-row { display: flex; align-items: center; gap: 4px; margin-bottom: 5px; }
.num-row > span { color: #999; font-size: 0.75rem; width: 16px; text-align: right; font-weight: 600; }
.num-row input[type="number"] { flex: 1; min-width: 0; background: rgba(0,0,0,0.4); border: 1px solid rgba(130,80,220,0.2); border-radius: 6px; padding: 5px 6px; color: #fff; font-size: 0.85rem; outline: none; font-family: monospace; }
.num-row input[type="number"]:focus { border-color: rgba(130,80,220,0.6); box-shadow: 0 0 0 2px rgba(130,80,220,0.1); }
.scale-btn { background: rgba(130,80,220,0.1); border: 1px solid rgba(130,80,220,0.2); color: #8877aa; border-radius: 6px; padding: 2px 6px; cursor: pointer; font-size: 0.8rem; transition: all 0.2s; }
.scale-btn:hover { background: rgba(130,80,220,0.25); color: #b388ff; }
.scale-btn.active { background: rgba(130,80,220,0.3); border-color: #b388ff; color: #b388ff; }
.btn-danger { width: 100%; padding: 8px; border-radius: 8px; border: none; cursor: pointer; font-size: 0.85rem; transition: all 0.2s; background: rgba(255,50,50,0.15); border: 1px solid rgba(255,50,50,0.2); color: #ff6666; margin-top: 8px; }
.btn-danger:hover { background: rgba(255,50,50,0.3); }
.toggle-row { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: #999; cursor: pointer; }
.toggle-row input { accent-color: #b388ff; }

#fps-counter { position: absolute; top: 20px; left: 20px; color: #888; font-size: 0.75rem; font-family: monospace; }

#menu-btn {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: rgba(0,0,0,0.5); color: #fff; border: 1px solid rgba(255,255,255,0.2);
  width: 44px; height: 44px; border-radius: 50%; font-size: 1.3rem;
  cursor: pointer; z-index: 200; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(5px); transition: background 0.2s; pointer-events: auto;
}
#menu-btn:hover { background: rgba(0,0,0,0.8); }

#menu-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  z-index: 300; display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px); transition: opacity 0.3s;
}
#menu-overlay.hidden { display: none; }
#menu-panel {
  background: #1a1a2e; border-radius: 16px; width: 90%; max-width: 600px;
  max-height: 85vh; overflow-y: auto; padding: 24px; border: 1px solid rgba(255,255,255,0.1);
}
#menu-panel::-webkit-scrollbar { width: 6px; }
#menu-panel::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
#menu-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
#menu-header h2 { font-size: 1.5rem; }
#menu-close { background: transparent; border: none; color: #888; font-size: 1.2rem; cursor: pointer; padding: 4px 8px; border-radius: 4px; }
#menu-close:hover { color: #fff; background: rgba(255,255,255,0.1); }
#menu-tabs { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; }
.tab { background: transparent; border: none; color: #888; padding: 8px 16px;
  border-radius: 8px; cursor: pointer; font-size: 0.85rem; transition: all 0.2s; }
.tab:hover { color: #fff; background: rgba(255,255,255,0.05); }
.tab.active { color: #fff; background: rgba(123,47,247,0.3); }

.tab-content { display: none; }
.tab-content.active { display: block; }
.tab-content h3 { font-size: 1.2rem; margin-bottom: 8px; }
.formats { font-size: 0.8rem; color: #888; margin-bottom: 12px; }

#drop-zone {
  border: 2px dashed rgba(255,255,255,0.2); border-radius: 12px;
  padding: 40px 20px; text-align: center; cursor: pointer;
  transition: all 0.2s; position: relative;
}
#drop-zone:hover, #drop-zone.dragover { border-color: #7b2ff7; background: rgba(123,47,247,0.05); }
#drop-zone p { color: #888; }
#drop-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

#avatar-drop {
  border: 2px dashed rgba(255,255,255,0.2); border-radius: 12px;
  padding: 22px 16px; text-align: center; cursor: pointer; color: #999;
  transition: all 0.2s; position: relative; margin-bottom: 14px; font-size: 0.85rem;
}
#avatar-drop:hover, #avatar-drop.dragover { border-color: #7b2ff7; background: rgba(123,47,247,0.05); color: #ccc; }
#avatar-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

#upload-progress { margin-top: 16px; }
.progress-bar { height: 4px; background: rgba(255,255,255,0.1); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, #7b2ff7, #00d4ff);
  border-radius: 2px; transition: width 0.3s; }
.progress-text { font-size: 0.8rem; color: #888; margin-top: 6px; }

#model-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
#model-list li {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.03); padding: 8px 12px; border-radius: 8px;
  font-size: 0.85rem; gap: 8px;
}
.model-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-size { color: #666; font-size: 0.75rem; white-space: nowrap; }
.btn-spawn { background: rgba(123,47,247,0.3); border: none; color: #fff; padding: 4px 12px;
  border-radius: 6px; cursor: pointer; font-size: 0.8rem; white-space: nowrap; }
.btn-spawn:hover { background: rgba(123,47,247,0.5); }
.btn-delete-model {
  background: rgba(255,60,60,0.2); border: none; color: #ff6b6b; cursor: pointer;
  border-radius: 6px; width: 28px; height: 28px; font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center; transition: background 0.2s;
}
.btn-delete-model:hover { background: rgba(255,60,60,0.4); }

#avatar-list { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 16px; }
.avatar-option {
  position: relative;
  width: 80px; height: 100px; border: 2px solid transparent; border-radius: 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; cursor: pointer; transition: all 0.2s; background: rgba(255,255,255,0.03);
}
.avatar-del {
  position: absolute; top: 3px; right: 3px; width: 20px; height: 20px; padding: 0;
  border: none; border-radius: 50%; background: rgba(0,0,0,0.45); color: #ff8080;
  font-size: 12px; line-height: 20px; cursor: pointer; opacity: 0; transition: opacity 0.15s;
}
.avatar-option:hover .avatar-del { opacity: 1; }
.avatar-del:hover { background: #c0392b; color: #fff; }
.avatar-option:hover { background: rgba(255,255,255,0.08); }
.avatar-option.selected { border-color: #7b2ff7; background: rgba(123,47,247,0.1); }
.avatar-icon { width: 50px; height: 50px; border-radius: 50%; }
.default-avatar { background: linear-gradient(135deg, #00d4ff, #7b2ff7); }
.avatar-option span { font-size: 0.75rem; color: #aaa; }
.hint { font-size: 0.8rem; color: #666; margin-top: 8px; }

#objects-list { max-height: 300px; overflow-y: auto; }
.object-entry {
  display: flex; align-items: center; justify-content: space-between;
  background: rgba(255,255,255,0.03); padding: 8px 12px; border-radius: 8px;
  margin-bottom: 6px; font-size: 0.85rem;
}
.object-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.obj-delete-btn {
  background: rgba(255,60,60,0.2); border: none; color: #ff6b6b; cursor: pointer;
  border-radius: 6px; width: 28px; height: 28px; font-size: 0.8rem;
  display: flex; align-items: center; justify-content: center; transition: background 0.2s;
}
.obj-delete-btn:hover { background: rgba(255,60,60,0.4); }

#tab-settings label { display: block; margin: 10px 0; font-size: 0.9rem; cursor: pointer; }
#tab-settings input[type="checkbox"] { margin-right: 8px; }
#tab-settings input[type="range"] { width: 200px; margin-right: 10px; vertical-align: middle; }

#terrain-options { display: flex; flex-wrap: wrap; gap: 10px; }
.terrain-option {
  padding: 10px 16px; border: 2px solid transparent; border-radius: 10px;
  cursor: pointer; transition: all 0.2s; background: rgba(255,255,255,0.03);
  font-size: 0.9rem; flex: 1; min-width: 100px; text-align: center;
}
.terrain-option:hover { background: rgba(255,255,255,0.08); }
.terrain-option.selected { border-color: #7b2ff7; background: rgba(123,47,247,0.1); }

#crosshair { position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); pointer-events: none; z-index: 50; opacity: 0.6; }

#time-indicator {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 12px; z-index: 90; pointer-events: auto;
  background: rgba(0,0,0,0.3); padding: 6px 14px; border-radius: 20px;
  backdrop-filter: blur(6px);
}
.time-icon {
  font-size: 1.2rem; opacity: 0.25; transition: all 0.3s;
  filter: grayscale(1); cursor: pointer;
}
.time-icon:hover { opacity: 0.6; transform: scale(1.1); }
.time-icon.active { opacity: 1; filter: grayscale(0); transform: scale(1.2); }
.time-icon.active:hover { transform: scale(1.25); }
.time-icon[data-phase="auto"] { font-size: 1rem; }

#toast-container {
  position: fixed; bottom: 240px; left: 20px; z-index: 150;
  display: flex; flex-direction: column; gap: 6px;
}
.toast {
  background: rgba(0,0,0,0.7); backdrop-filter: blur(8px); border-radius: 8px;
  padding: 10px 16px; font-size: 0.85rem; animation: toastIn 0.3s ease;
  border-left: 3px solid #7b2ff7;
}
.toast.error { border-left-color: #ff4444; }
.toast.success { border-left-color: #44ff44; }
@keyframes toastIn { from { opacity: 0; transform: translateX(-20px); } to { opacity: 1; transform: translateX(0); } }

@media (max-width: 768px) {
  #blocker h1 { font-size: 2.5rem; }
  .controls-hint span { font-size: 0.75rem; padding: 4px 10px; }
  #chat-container { width: 280px; }
  #chat-messages { height: 150px; }
  #menu-panel { width: 95%; padding: 16px; }
}

/* Botón Avaturn (crear avatar realista) */
#avaturn-btn {
  width: 100%; margin-bottom: 12px; padding: 11px; cursor: pointer;
  border: 0; border-radius: 10px; color: #fff; font-size: 0.9rem; font-weight: 600;
  background: linear-gradient(135deg, #7b2ff7, #00d4ff); transition: filter 0.2s;
}
#avaturn-btn:hover { filter: brightness(1.12); }
