body, html {
  margin: 0; padding: 0; width: 100%; height: 100%;
  overflow: hidden; background: #000;
  font-family: "Noto Sans", system-ui, sans-serif;
}
* {
  user-select: none;
  -webkit-user-select: none;
}
#webgl {
  width: 100vw; height: 100vh;
  display: block;
  position: fixed;
  top: 0; left: 0;
}
#ui { position: fixed; inset: 0; pointer-events: none; }
#crosshair {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: 14px; height: 14px; border-radius: 50%; border: 2px solid #000; opacity: 0.7;
}
#hint {
  position: absolute; left: 50%; bottom: 12%; transform: translateX(-50%);
  color: #000; font-size: 14px; opacity: 0.6; user-select: none;
}
#click-to-play {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  color: rgba(255, 255, 255, 0.9);
  font-size: 32px;
  font-weight: 600;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
  pointer-events: none;
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}
#throw-gauge {
  position: absolute; left: 50%; top: calc(50% + 32px); transform: translateX(-50%);
  width: 280px; height: 10px; background: rgba(0,0,0,0.1);
  border-radius: 12px; backdrop-filter: blur(8px);
  border: 1px solid rgba(0,0,0,0.15); pointer-events: none;
  display: none;
}
#throw-gauge.show { display: block; }
#throw-bar {
  height: 100%; width: 0%; background: #000; border-radius: 12px;
  transition: width 80ms ease;
}
#throw-gauge #throw-value {
  position: absolute; top: -22px; left: 0; width: 100%; text-align: center;
  font-size: 12px; color: #000; opacity: 0.7;
}
#debug-ui {
  position: fixed; top: 10px; left: 10px;
  background: rgba(0, 0, 0, 0.9); color: #fff;
  padding: 15px; border-radius: 8px;
  font-size: 14px; pointer-events: auto;
  z-index: 10000;
  max-width: 300px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
#debug-ui h3 { margin: 0 0 10px 0; font-size: 16px; }
#debug-ui label { display: block; margin: 5px 0; cursor: pointer; }
#debug-ui input[type="checkbox"] { margin-right: 8px; cursor: pointer; }
#debug-ui button {
  margin-top: 10px; padding: 5px 10px;
  background: #444; color: #fff; border: 1px solid #666;
  border-radius: 4px; cursor: pointer;
}
#debug-ui button:hover { background: #555; }
#debug-ui.hidden { display: none; }

#level-complete.hidden { display: none; }
#level-complete {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: auto; background: rgba(0,0,0,0.5);
}
#level-complete .panel {
  background: rgba(255,255,255,0.6);
  color: #000; padding: 24px 28px; border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25), inset 0 1px 0 rgba(255,255,255,0.6);
  backdrop-filter: blur(20px) saturate(120%); -webkit-backdrop-filter: blur(20px) saturate(120%);
  border: 1px solid rgba(0,0,0,0.08); min-width: 260px; text-align: center;
}
#level-complete .panel button {
  margin-top: 12px; padding: 10px 14px; border-radius: 10px;
  background: rgba(0,0,0,0.85); color: #fff; border: 1px solid rgba(0,0,0,0.9);
  transition: transform 120ms ease, opacity 120ms ease;
}

#mobile-controls { display: none; }
@media (pointer: coarse) {
  #mobile-controls { display: block; position: fixed; inset: 0; pointer-events: none; }
  #left-joystick, #right-joystick {
    position: absolute; width: 160px; height: 160px; pointer-events: auto;
    bottom: 24px; background: rgba(0,0,0,0.06); border-radius: 12px;
  }
  #left-joystick { left: 24px; }
  #right-joystick { right: 24px; }
  #mobile-buttons {
    position: absolute; bottom: 24px; left: 50%; transform: translateX(-50%);
    display: flex; gap: 10px; pointer-events: auto;
  }
  #mobile-buttons button {
    width: 56px; height: 56px; border-radius: 50%;
    font-size: 24px; line-height: 1; display: grid; place-items: center;
    border: 1px solid #222;
  }
  #btn-blue { background: #2a7fff; color: #fff; }
  #btn-orange { background: #ff7a00; color: #fff; }
  #btn-grab { background: #000; color: #fff; }
  #hint { display: none; }
  #click-to-play { display: none; }
}

#render-scale-control {
  position: fixed; left: 56px; top: 12px; pointer-events: auto;
  background: rgba(255,255,255,0.6); color: #000; border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px; padding: 8px 10px; backdrop-filter: blur(16px) saturate(120%);
  font-size: 12px; display: flex; align-items: center; gap: 8px;
}
#render-scale-control input[type="range"] { width: 140px; }
#render-scale-control label { opacity: 0.7; }
#render-scale-control span { min-width: 42px; text-align: right; opacity: 0.8; }

#menu-toggle {
  position: fixed; right: 12px; top: 12px; z-index: 1000;
  background: #000; color: #fff; border: 1px solid #222;
  border-radius: 8px; padding: 8px 10px; cursor: pointer;
  pointer-events: auto;
}
#back-to-menu {
  position: fixed; left: 12px; top: 12px; z-index: 1000;
  background: #000; color: #fff; border: 1px solid #222;
  border-radius: 8px; padding: 8px 10px; cursor: pointer;
  pointer-events: auto;
  font-size: 18px;
}
#back-to-menu:hover {
  background: #222;
}
/* Start Menu */
.menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  pointer-events: auto;
}

.menu-panel {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 16px;
  padding: 40px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  text-align: center;
}

.menu-panel h1 {
  margin: 0 0 10px 0;
  font-size: 36px;
  color: #000;
  font-weight: 700;
}

.menu-panel .subtitle {
  margin: 0 0 30px 0;
  font-size: 16px;
  color: #666;
}

.menu-buttons {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.menu-btn {
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.menu-btn:hover {
  background: rgba(255, 255, 255, 1);
  border-color: rgba(0, 0, 0, 0.3);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.menu-btn.primary {
  background: rgba(0, 100, 255, 0.9);
  border-color: rgba(0, 100, 255, 1);
  color: #fff;
}

.menu-btn.primary:hover {
  background: rgba(0, 100, 255, 1);
}

.menu-btn .btn-icon {
  font-size: 24px;
}

.menu-btn .btn-text {
  font-size: 20px;
  font-weight: 600;
}

.menu-btn .btn-desc {
  font-size: 14px;
  opacity: 0.8;
}

.menu-btn.primary .btn-desc {
  opacity: 0.9;
}

/* Edit Mode UI */
#edit-ui {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 280px;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  padding: 20px;
  pointer-events: auto;
  z-index: 1000;
  overflow-y: auto;
}

#edit-ui.hidden {
  display: none;
}

.edit-toolbar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.toolbar-section {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 8px;
  padding: 4px;
}

.toolbar-section h3 {
  margin: 0 0 15px 0;
  font-size: 18px;
}

.toolbar-section h4 {
  margin: 0 0 10px 0;
  font-size: 14px;
  opacity: 0.8;
}

.toolbar-section p {
  margin: 5px 0;
  font-size: 12px;
  opacity: 0.7;
}

.toolbar-btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 8px;
  font-size: 14px;
}

.toolbar-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

.toolbar-btn:active, .toolbar-btn.active {
  background: rgba(100, 150, 255, 0.4);
  border-color: rgba(100, 150, 255, 0.6);
}

.hidden {
  display: none !important;
}

/* Hide desktop-only elements on mobile */
@media (max-width: 768px), (pointer: coarse) {
  .desktop-only {
    display: none !important;
  }
}

.toolbar-checkbox {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 0px;
  padding: 4px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
}

.toolbar-checkbox input[type="checkbox"] {
  cursor: pointer;
}

.toolbar-checkbox:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Icon buttons for transform modes */
.icon-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.icon-btn {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-2px);
}

.icon-btn:active, .icon-btn.active {
  background: rgba(100, 150, 255, 0.4);
  border-color: rgba(100, 150, 255, 0.6);
}

.icon-btn.danger {
  background: rgba(255, 50, 50, 0.2);
  border-color: rgba(255, 50, 50, 0.4);
}

.icon-btn.danger:hover {
  background: rgba(255, 50, 50, 0.4);
  border-color: rgba(255, 50, 50, 0.6);
}

.toolbar-btn.danger {
  background: rgba(255, 50, 50, 0.2);
  border-color: rgba(255, 50, 50, 0.4);
}

.toolbar-btn.danger:hover {
  background: rgba(255, 50, 50, 0.4);
  border-color: rgba(255, 50, 50, 0.6);
}

/* Object group styling */
.object-group {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
